Skip to content

fix: Code Quality improvements to response record endpoint and added unit tests#22264

Merged
hariombalhara merged 8 commits intomainfrom
response-record-fixes-quick-followup
Jul 18, 2025
Merged

fix: Code Quality improvements to response record endpoint and added unit tests#22264
hariombalhara merged 8 commits intomainfrom
response-record-fixes-quick-followup

Conversation

@hariombalhara
Copy link
Copy Markdown
Member

@hariombalhara hariombalhara commented Jul 4, 2025

What does this PR do?

Addresses the followup mentioned at #22239 (comment)

  • Fixes prettier issues
  • Deleted unused log statements in router and related services.
  • Updated slot input and routing types for clearer usage and documentation.
  • Add unit test for SlotService#getAvailableSlotsWithRouting

Mandatory Tasks (DO NOT REMOVE)

  • I have self-reviewed the code (A decent size PR without self-review might be rejected).
  • I have updated the developer docs in /docs if this PR makes changes that would require a documentation change. If N/A, write N/A here and check the checkbox.
  • I confirm automated tests are in place that prove my fix is effective or that my feature works.

@vercel vercel bot temporarily deployed to Preview – api July 4, 2025 12:52 Inactive
@keithwillcode keithwillcode added core area: core, team members only enterprise area: enterprise, audit log, organisation, SAML, SSO labels Jul 4, 2025
Copy link
Copy Markdown
Member Author

hariombalhara commented Jul 4, 2025

@vercel
Copy link
Copy Markdown

vercel bot commented Jul 4, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

2 Skipped Deployments
Name Status Preview Comments Updated (UTC)
cal ⬜️ Ignored (Inspect) Jul 18, 2025 10:35am
cal-eu ⬜️ Ignored (Inspect) Visit Preview Jul 18, 2025 10:35am

@delve-auditor
Copy link
Copy Markdown

delve-auditor bot commented Jul 4, 2025

No security or compliance issues detected. Reviewed everything up to 8067a35.

Security Overview
  • 🔎 Scanned files: 9 changed file(s)
Detected Code Changes
Change Type Relevant files
Enhancement ► create-routing-form-response.output.ts
    Update routing information description
► shared-routing-form-response.service.ts
    Update slots service implementation
► slots-input.service.ts
    Add routing query transformation
► slots.service.spec.ts
    Add comprehensive test suite for slots service
► slots.service.ts
    Implement routing-specific slots functionality
► get-slots-input.pipe.ts
    Add routing input types
► get-slots.input.ts
    Update input validation schema
Documentation ► swagger/documentation.json
    Update API documentation
► docs/api-reference/v2/openapi.json
    Update API reference documentation

Reply to this PR with @delve-auditor followed by a description of what change you want and we'll auto-submit a change to this PR to implement it.

eventTypeId?: number;

@ValidateNested()
@ApiProperty({ type: Routing })
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Type was duplicate

},
})
@ValidateNested()
@Type(() => Routing)
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Duplicate again

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Jul 7, 2025

E2E results are ready!

@hariombalhara hariombalhara force-pushed the response-record-fixes-quick-followup branch from b6c4ef9 to 72991c0 Compare July 7, 2025 10:08
@vercel vercel bot temporarily deployed to Preview – api July 7, 2025 10:08 Inactive
@hariombalhara hariombalhara force-pushed the response-record-fixes-quick-followup branch from 72991c0 to dddbad5 Compare July 7, 2025 10:58
@hariombalhara hariombalhara changed the title chore: remove unnecessary logs and fix documentation fix: Remove unused props from GetAvailableSlotsInput Jul 7, 2025
@vercel vercel bot temporarily deployed to Preview – api July 7, 2025 11:22 Inactive
@vercel vercel bot temporarily deployed to Preview – cal July 7, 2025 11:22 Inactive
export class GetAvailableSlotsInputWithRouting_2024_09_04 extends GetAvailableSlotsInput_2024_09_04 {
@IsString()
@ApiHideProperty()
withRouting = true as const;
Copy link
Copy Markdown
Member Author

@hariombalhara hariombalhara Jul 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It allows us to differentiate b/w the two types GetAvailableSlotsInputWithRouting_2024_09_04 and GetAvailableSlotsInput_2024_09_04

This is similar to what we do using ById_2024_09_04_type to implement Discriminated unions in TS

const availableSlots: TimeSlots = await getAvailableSlots({
input: {
...queryTransformed,
routingFormResponseId: queryTransformed.routingFormResponseId ?? undefined,
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need to handle it here now as queryTransformed will have the correct value

@hariombalhara hariombalhara changed the title fix: Remove unused props from GetAvailableSlotsInput fix: Remove unused props from GetAvailableSlotsInput and add unit test Jul 7, 2025
@hariombalhara hariombalhara force-pushed the response-record-fixes-quick-followup branch from 7163a5b to e702982 Compare July 7, 2025 12:31
@vercel vercel bot temporarily deployed to Preview – api July 7, 2025 12:31 Inactive
@vercel vercel bot temporarily deployed to Preview – cal July 7, 2025 12:31 Inactive
@hariombalhara hariombalhara marked this pull request as ready for review July 7, 2025 12:35
@hariombalhara hariombalhara requested a review from a team July 7, 2025 12:35
@vercel vercel bot temporarily deployed to Preview – api July 17, 2025 11:42 Inactive
Comment on lines -93 to -111
@IsString()
@IsOptional()
@ApiHideProperty()
teamMemberEmail?: string;

@IsNumber()
@IsOptional()
@ApiHideProperty()
routingFormResponseId?: number;

@IsArray()
@IsOptional()
@ApiHideProperty()
routedTeamMemberIds?: number[];

@IsBoolean()
@IsOptional()
@ApiHideProperty()
skipContactOwner?: boolean;
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removing the props that aren't documented and shouldn't be used for the get slots input.

@hariombalhara hariombalhara requested a review from supalarry July 17, 2025 11:46
@hariombalhara
Copy link
Copy Markdown
Member Author

Excellent suggestion @supalarry !! Addressed it

- Remove intermediate variable assignment in getAvailableSlotsWithRouting
- Update test to match simplified routing parameters structure
@hariombalhara hariombalhara marked this pull request as ready for review July 17, 2025 12:22
@dosubot dosubot bot added the 🧹 Improvements Improvements to existing features. Mostly UX/UI label Jul 17, 2025
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (3)
docs/api-reference/v2/openapi.json (1)

23612-23618: Grammar nit – use “as-is” to avoid ambiguity.

Current wording:
"The routing information that could be passed as is to the booking API."

Consider the hyphenated form for clarity:

-            "description": "The routing information that could be passed as is to the booking API.",
+            "description": "The routing information that can be passed as-is to the booking API.",
apps/api/v2/swagger/documentation.json (2)

21607-21611: Duplicate maintenance reminder

Same enumeration appears a second time; if this file is generated, consider de-duplicating the trigger list at the generator level so manual edits aren’t required in multiple blocks.


24803-24808: Keep language codes alphabetically sorted

The newly-added "bn" (Bengali) is appended after "zh-TW", breaking the alphabetical order that the enum followed earlier.
Maintaining a deterministic order eases diff reviews and reduces merge conflicts.

-              "sk",
-              "ta",
-              "uk",
-              "zh-TW",
-              "bn"
+              "bn",
+              "sk",
+              "ta",
+              "uk",
+              "zh-TW"
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e4c4764 and 5d65c63.

📒 Files selected for processing (9)
  • apps/api/v2/src/modules/organizations/routing-forms/outputs/create-routing-form-response.output.ts (1 hunks)
  • apps/api/v2/src/modules/organizations/routing-forms/services/shared-routing-form-response.service.ts (1 hunks)
  • apps/api/v2/src/modules/slots/slots-2024-09-04/services/slots-input.service.ts (3 hunks)
  • apps/api/v2/src/modules/slots/slots-2024-09-04/services/slots.service.spec.ts (1 hunks)
  • apps/api/v2/src/modules/slots/slots-2024-09-04/services/slots.service.ts (5 hunks)
  • apps/api/v2/swagger/documentation.json (4 hunks)
  • docs/api-reference/v2/openapi.json (6 hunks)
  • packages/platform/types/slots/slots-2024-09-04/inputs/get-slots-input.pipe.ts (1 hunks)
  • packages/platform/types/slots/slots-2024-09-04/inputs/get-slots.input.ts (1 hunks)
🧰 Additional context used
🧠 Learnings (8)
📓 Common learnings
Learnt from: eunjae-lee
PR: calcom/cal.com#22106
File: packages/features/insights/components/FailedBookingsByField.tsx:65-71
Timestamp: 2025-07-15T12:59:34.341Z
Learning: In the FailedBookingsByField component (packages/features/insights/components/FailedBookingsByField.tsx), although routingFormId is typed as optional in useInsightsParameters, the system automatically enforces a routing form filter, so routingFormId is always present in practice. This means the data always contains only one entry, making the single-entry destructuring approach safe.
apps/api/v2/src/modules/organizations/routing-forms/outputs/create-routing-form-response.output.ts (2)
Learnt from: eunjae-lee
PR: calcom/cal.com#22106
File: packages/features/insights/components/FailedBookingsByField.tsx:65-71
Timestamp: 2025-07-15T12:59:34.341Z
Learning: In the FailedBookingsByField component (packages/features/insights/components/FailedBookingsByField.tsx), although routingFormId is typed as optional in useInsightsParameters, the system automatically enforces a routing form filter, so routingFormId is always present in practice. This means the data always contains only one entry, making the single-entry destructuring approach safe.
Learnt from: eunjae-lee
PR: calcom/cal.com#22106
File: packages/lib/server/service/insightsRouting.ts:367-368
Timestamp: 2025-07-15T13:02:17.359Z
Learning: In the InsightsRoutingService (packages/lib/server/service/insightsRouting.ts), multi-select filter data is already validated by zod before reaching the buildFormFieldSqlCondition method, so null/undefined values are not present in filterValue.data arrays and don't need to be filtered out.
apps/api/v2/src/modules/organizations/routing-forms/services/shared-routing-form-response.service.ts (2)
Learnt from: eunjae-lee
PR: calcom/cal.com#22106
File: packages/features/insights/components/FailedBookingsByField.tsx:65-71
Timestamp: 2025-07-15T12:59:34.341Z
Learning: In the FailedBookingsByField component (packages/features/insights/components/FailedBookingsByField.tsx), although routingFormId is typed as optional in useInsightsParameters, the system automatically enforces a routing form filter, so routingFormId is always present in practice. This means the data always contains only one entry, making the single-entry destructuring approach safe.
Learnt from: eunjae-lee
PR: calcom/cal.com#22106
File: packages/features/insights/components/RoutingFunnel.tsx:15-17
Timestamp: 2025-07-15T12:58:40.497Z
Learning: In the insights routing funnel component (packages/features/insights/components/RoutingFunnel.tsx), the useColumnFilters exclusions are intentionally different from the general useInsightsParameters exclusions. RoutingFunnel specifically excludes only ["createdAt"] while useInsightsParameters excludes ["bookingUserId", "formId", "createdAt", "eventTypeId"]. This difference is by design.
packages/platform/types/slots/slots-2024-09-04/inputs/get-slots-input.pipe.ts (1)
Learnt from: eunjae-lee
PR: calcom/cal.com#22106
File: packages/features/insights/components/FailedBookingsByField.tsx:65-71
Timestamp: 2025-07-15T12:59:34.341Z
Learning: In the FailedBookingsByField component (packages/features/insights/components/FailedBookingsByField.tsx), although routingFormId is typed as optional in useInsightsParameters, the system automatically enforces a routing form filter, so routingFormId is always present in practice. This means the data always contains only one entry, making the single-entry destructuring approach safe.
packages/platform/types/slots/slots-2024-09-04/inputs/get-slots.input.ts (2)
Learnt from: eunjae-lee
PR: calcom/cal.com#22106
File: packages/features/insights/components/FailedBookingsByField.tsx:65-71
Timestamp: 2025-07-15T12:59:34.341Z
Learning: In the FailedBookingsByField component (packages/features/insights/components/FailedBookingsByField.tsx), although routingFormId is typed as optional in useInsightsParameters, the system automatically enforces a routing form filter, so routingFormId is always present in practice. This means the data always contains only one entry, making the single-entry destructuring approach safe.
Learnt from: eunjae-lee
PR: calcom/cal.com#22106
File: packages/features/insights/components/RoutingFunnel.tsx:15-17
Timestamp: 2025-07-15T12:58:40.497Z
Learning: In the insights routing funnel component (packages/features/insights/components/RoutingFunnel.tsx), the useColumnFilters exclusions are intentionally different from the general useInsightsParameters exclusions. RoutingFunnel specifically excludes only ["createdAt"] while useInsightsParameters excludes ["bookingUserId", "formId", "createdAt", "eventTypeId"]. This difference is by design.
apps/api/v2/swagger/documentation.json (1)

undefined

<retrieved_learning>
Learnt from: eunjae-lee
PR: #22106
File: packages/features/insights/components/FailedBookingsByField.tsx:65-71
Timestamp: 2025-07-15T12:59:34.341Z
Learning: In the FailedBookingsByField component (packages/features/insights/components/FailedBookingsByField.tsx), although routingFormId is typed as optional in useInsightsParameters, the system automatically enforces a routing form filter, so routingFormId is always present in practice. This means the data always contains only one entry, making the single-entry destructuring approach safe.
</retrieved_learning>

docs/api-reference/v2/openapi.json (1)

undefined

<retrieved_learning>
Learnt from: eunjae-lee
PR: #22106
File: packages/features/insights/components/FailedBookingsByField.tsx:65-71
Timestamp: 2025-07-15T12:59:34.341Z
Learning: In the FailedBookingsByField component (packages/features/insights/components/FailedBookingsByField.tsx), although routingFormId is typed as optional in useInsightsParameters, the system automatically enforces a routing form filter, so routingFormId is always present in practice. This means the data always contains only one entry, making the single-entry destructuring approach safe.
</retrieved_learning>

apps/api/v2/src/modules/slots/slots-2024-09-04/services/slots-input.service.ts (1)
Learnt from: eunjae-lee
PR: calcom/cal.com#22106
File: packages/features/insights/components/FailedBookingsByField.tsx:65-71
Timestamp: 2025-07-15T12:59:34.341Z
Learning: In the FailedBookingsByField component (packages/features/insights/components/FailedBookingsByField.tsx), although routingFormId is typed as optional in useInsightsParameters, the system automatically enforces a routing form filter, so routingFormId is always present in practice. This means the data always contains only one entry, making the single-entry destructuring approach safe.
🧬 Code Graph Analysis (3)
apps/api/v2/src/modules/organizations/routing-forms/services/shared-routing-form-response.service.ts (1)
packages/platform/types/slots/slots-2024-09-04/inputs/get-slots.input.ts (1)
  • ById_2024_09_04_type (93-93)
apps/api/v2/src/modules/slots/slots-2024-09-04/services/slots-input.service.ts (1)
packages/platform/types/slots/slots-2024-09-04/inputs/get-slots-input.pipe.ts (2)
  • GetSlotsInput_2024_09_04 (14-18)
  • GetSlotsInputWithRouting_2024_09_04 (20-25)
apps/api/v2/src/modules/slots/slots-2024-09-04/services/slots.service.ts (3)
apps/api/v2/src/modules/slots/slots-2024-09-04/services/slots-input.service.ts (2)
  • TransformedGetSlotsQuery (22-33)
  • TransformedGetSlotsQueryWithRouting (35-40)
apps/api/v2/src/modules/slots/slots-2024-04-15/services/slots-output.service.ts (1)
  • TimeSlots (7-9)
packages/platform/types/slots/slots-2024-09-04/inputs/get-slots-input.pipe.ts (2)
  • GetSlotsInput_2024_09_04 (14-18)
  • GetSlotsInputWithRouting_2024_09_04 (20-25)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: Merge reports / merge-reports
  • GitHub Check: Security Check
🔇 Additional comments (19)
apps/api/v2/src/modules/organizations/routing-forms/outputs/create-routing-form-response.output.ts (1)

92-92: LGTM! Documentation clarification improves API usability.

The updated description clearly indicates that the routing information can be passed directly to the booking API, which provides valuable guidance for API consumers.

docs/api-reference/v2/openapi.json (3)

21530-21534: Double-check enum consistency after dropping RESERVATION_EXPIRED.

"FORM_SUBMITTED_NO_EVENT" is now the last element in two duplicated enum arrays.
Please verify that

  1. Every enum occurrence (input/output DTOs, OAuth client output, etc.) was updated identically, and
  2. No stray "RESERVATION_EXPIRED" values remain anywhere in this file (or the codebase) that could confuse schema-driven clients.

A quick rg RESERVATION_EXPIRED docs/api-reference/v2/openapi.json should confirm.
If any leftover values exist, remove them or regenerate the spec.

Also applies to: 21607-21611


24803-24808: bn (Bengali) added – ensure language lists stay alphabetised & synchronised.

The language enum wasn’t kept in alphabetical order; "bn" was appended after "zh-TW".
While non-breaking, keeping the list ordered improves diff readability and helps avoid accidental duplicates across schemas.
Please sort the array or confirm that other language enums (e.g. attendee output) now also include "bn".


26222-26225: LGTM – multi-line formatting only.

The MarkAbsentAttendee schema still correctly requires "email" and "absent".
No functional changes detected.

apps/api/v2/swagger/documentation.json (2)

21530-21534: Confirm trigger list consistency across all specs

"FORM_SUBMITTED_NO_EVENT" looks good, but please double-check that

  1. the constant list in the source code (WebhookTrigger enum / constants)
  2. every other OpenAPI / Swagger artefact

were updated in the same commit; otherwise consumers may see diverging specs.


23612-23618: Clarified description: 👍

The updated wording (“could be passed as-is…”) is clearer and helps API users understand the field’s purpose.

apps/api/v2/src/modules/organizations/routing-forms/services/shared-routing-form-response.service.ts (1)

58-64: LGTM! Clean refactoring to use routing-specific slot method.

The change from getAvailableSlots to getAvailableSlotsWithRouting with inline parameter merging is a good improvement. This approach is more explicit about routing-specific functionality and eliminates the need for the intermediate paramsForGetAvailableSlots object construction.

packages/platform/types/slots/slots-2024-09-04/inputs/get-slots-input.pipe.ts (1)

20-25: Well-structured type extension for routing parameters.

The new GetSlotsInputWithRouting_2024_09_04 type properly extends the base GetSlotsInput_2024_09_04 with routing-specific optional fields. This separation of concerns improves API clarity and maintainability by distinguishing between standard slot queries and routing-aware queries.

packages/platform/types/slots/slots-2024-09-04/inputs/get-slots.input.ts (1)

1-1: Good separation of base input types from routing extensions.

The updated import reflects the proper architectural separation where routing-specific properties are moved out of the base GetAvailableSlotsInput_2024_09_04 class. This makes the base input type cleaner and more focused on its core responsibility.

apps/api/v2/src/modules/slots/slots-2024-09-04/services/slots.service.spec.ts (1)

1-169: Excellent test coverage for the new routing-aware slot method.

The test suite is well-structured with:

  • Proper dependency mocking and module setup
  • Clear organization of shared test data for reusability
  • Comprehensive verification that getAvailableSlotsWithRouting correctly forwards routing parameters to the underlying availableSlotsService.getAvailableSlots
  • Good assertion that verifies the transformation of start/end to startTime/endTime and inclusion of routing-specific fields

This provides confidence that the new method works as intended and maintains the contract with the underlying service.

apps/api/v2/src/modules/slots/slots-2024-09-04/services/slots-input.service.ts (3)

22-40: Well-designed type separation for base and routing-aware transformations.

The new types TransformedGetSlotsQuery and TransformedGetSlotsQueryWithRouting properly separate concerns. The routing-aware type extends the base type with appropriate routing fields, including proper nullability and default value handling.


54-54: Good explicit typing for the base transformation method.

Making the return type explicit as Promise<TransformedGetSlotsQuery> improves code clarity and type safety by clearly indicating this method handles only base slot queries without routing parameters.


85-100: Excellent implementation of routing-aware transformation using composition.

The new transformRoutingGetSlotsQuery method follows good design principles by:

  • Properly extracting routing-specific fields from the input
  • Delegating base transformation to the existing method (DRY principle)
  • Adding routing fields with appropriate defaults (null/false)
  • Maintaining type safety with the GetSlotsInputWithRouting_2024_09_04 input type

This approach ensures consistency and reduces code duplication while extending functionality.

apps/api/v2/src/modules/slots/slots-2024-09-04/services/slots.service.ts (6)

6-10: LGTM: Import updates support the refactoring.

The imports correctly include the new transformation types (TransformedGetSlotsQuery, TransformedGetSlotsQueryWithRouting) needed for the refactored service methods.


25-31: LGTM: Platform type imports align with the new routing functionality.

The imports correctly include the new routing-aware input type (GetSlotsInputWithRouting_2024_09_04) and the SlotFormat enum needed for the refactored methods.


41-41: LGTM: Type alias improves code readability.

The TransformedSlotsQuery union type clearly expresses that the helper method can handle both regular and routing-aware transformed queries.


55-81: LGTM: Well-designed helper method follows DRY principle.

The fetchAndFormatSlots method effectively consolidates the common slot fetching and formatting logic, reducing code duplication between getAvailableSlots and getAvailableSlotsWithRouting. The error handling is preserved and the method signature is clean.


83-86: LGTM: Refactored method maintains clean separation of concerns.

The getAvailableSlots method is now focused solely on transforming regular slot queries and delegating to the centralized fetchAndFormatSlots helper. This follows the single responsibility principle effectively.


88-91: LGTM: New routing method follows consistent patterns.

The getAvailableSlotsWithRouting method maintains consistency with the existing getAvailableSlots method while properly handling routing-specific transformations. The method signature and implementation are clean and follow the established patterns.

) {}

async getAvailableSlots(query: GetSlotsInput_2024_09_04) {
private async fetchAndFormatSlots(queryTransformed: TransformedSlotsQuery, format?: SlotFormat) {
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Abstracted out for reuse across the two ways to getAvailableSlots

…service

- Add error scenario tests for NotFoundException, invalid time range, and generic errors
- Add edge case tests for null/undefined parameters and empty arrays
- Improve test coverage for getAvailableSlotsWithRouting method
- Mock SlotsInputService properly to enable isolated unit testing
Copy link
Copy Markdown
Contributor

@supalarry supalarry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have small comments:

@supalarry supalarry self-requested a review July 18, 2025 10:08
supalarry
supalarry previously approved these changes Jul 18, 2025
- Fix import path from '@/lib/services/AvailableSlots' to '@/lib/services/available-slots.service'
- Resolves unit test failure due to case sensitivity/naming mismatch
- All API v2 tests now pass (9 test suites, 142 tests)

Co-Authored-By: hariom@cal.com <hariombalhara@gmail.com>
@hariombalhara hariombalhara merged commit 05e1ad0 into main Jul 18, 2025
41 of 42 checks passed
@hariombalhara hariombalhara deleted the response-record-fixes-quick-followup branch July 18, 2025 10:56
zomars pushed a commit that referenced this pull request Jul 22, 2025
…unit tests (#22264)

* chore: remove unnecessary logs and fix documentation

* refactor: extract GetSlotsInputWithRouting type and eliminate code duplication

- Move GetSlotsInputWithRouting_2024_09_04 type to platform-types package for reuse
- Refactor slots service to eliminate duplicate error handling logic
- Fix TypeScript errors in slots service tests by adding missing type property
- Update test expectations to match new implementation

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* refactor: improve type safety in slots service

- Export explicit types from slots-input.service for transformed queries
- Replace 'any' type with proper TransformedSlotsQuery union type
- Re-implement fetchAndFormatSlots abstraction to eliminate code duplication
- Revert unrelated console.log in router.controller.ts

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* refactor: simplify slots service implementation

- Remove intermediate variable assignment in getAvailableSlotsWithRouting
- Update test to match simplified routing parameters structure

* test: add comprehensive error handling and edge case tests for slots service

- Add error scenario tests for NotFoundException, invalid time range, and generic errors
- Add edge case tests for null/undefined parameters and empty arrays
- Improve test coverage for getAvailableSlotsWithRouting method
- Mock SlotsInputService properly to enable isolated unit testing

* 📝 CodeRabbit Chat: Rename TransformedGetSlotsQuery types to InternalGetSlotsQuery in slot services

* fix: correct import path for AvailableSlotsService in slots service test

- Fix import path from '@/lib/services/AvailableSlots' to '@/lib/services/available-slots.service'
- Resolves unit test failure due to case sensitivity/naming mismatch
- All API v2 tests now pass (9 test suites, 142 tests)

Co-Authored-By: hariom@cal.com <hariombalhara@gmail.com>

---------

Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

automated-tests area: unit tests, e2e tests, playwright 🐛 bug Something isn't working core area: core, team members only enterprise area: enterprise, audit log, organisation, SAML, SSO 🧹 Improvements Improvements to existing features. Mostly UX/UI ready-for-e2e

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants