fix: Code Quality improvements to response record endpoint and added 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 <[email protected]> * 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 <[email protected]> * 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: [email protected] <[email protected]> --------- Co-authored-by: Claude <[email protected]> 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>
This commit is contained in:
9 files changed
+477
-51
No files matched your search
@@ -17,6 +17,13 @@ export type GetSlotsInput_2024_09_04 =
|
||||
| ByTeamSlugAndEventTypeSlug_2024_09_04
|
||||
| ByUsernames_2024_09_04;
|
||||
|
||||
export type GetSlotsInputWithRouting_2024_09_04 = GetSlotsInput_2024_09_04 & {
|
||||
teamMemberEmail?: string;
|
||||
routingFormResponseId?: number;
|
||||
routedTeamMemberIds?: number[];
|
||||
skipContactOwner?: boolean;
|
||||
};
|
||||
|
||||
@Injectable()
|
||||
export class GetSlotsInputPipe implements PipeTransform {
|
||||
// note(Lauris): we need empty constructor otherwise v2 can't be started due to error:
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { ApiProperty, ApiPropertyOptional, ApiHideProperty } from "@nestjs/swagger";
|
||||
import { ApiProperty, ApiPropertyOptional } from "@nestjs/swagger";
|
||||
import { Transform } from "class-transformer";
|
||||
import {
|
||||
IsDateString,
|
||||
@@ -9,7 +9,6 @@ import {
|
||||
IsArray,
|
||||
ArrayMinSize,
|
||||
IsEnum,
|
||||
IsBoolean,
|
||||
} from "class-validator";
|
||||
|
||||
import { SlotFormat } from "@calcom/platform-enums";
|
||||
@@ -89,26 +88,6 @@ export class GetAvailableSlotsInput_2024_09_04 {
|
||||
example: "abc123def456",
|
||||
})
|
||||
bookingUidToReschedule?: string;
|
||||
|
||||
@IsString()
|
||||
@IsOptional()
|
||||
@ApiHideProperty()
|
||||
teamMemberEmail?: string;
|
||||
|
||||
@IsNumber()
|
||||
@IsOptional()
|
||||
@ApiHideProperty()
|
||||
routingFormResponseId?: number;
|
||||
|
||||
@IsArray()
|
||||
@IsOptional()
|
||||
@ApiHideProperty()
|
||||
routedTeamMemberIds?: number[];
|
||||
|
||||
@IsBoolean()
|
||||
@IsOptional()
|
||||
@ApiHideProperty()
|
||||
skipContactOwner?: boolean;
|
||||
}
|
||||
|
||||
export const ById_2024_09_04_type = "byEventTypeId";
|
||||
|
||||
Reference in new issue
Block a user