fix: ensure platform managed user has 1 schedule by default (#18719)

* fix: ensure managed user has 1 schedule

* chore: bump platform libraries
This commit is contained in:
Lauris Skraucis authored and GitHub committed 2025-01-20 09:11:26 +00:00
1 parent 02ef6dc934
commit bfeafaa21f
5 files changed
+6005 -84

No files matched your search

+1 -1
View File
@@ -29,7 +29,7 @@
"@axiomhq/winston": "^1.2.0",
"@calcom/platform-constants": "*",
"@calcom/platform-enums": "*",
"@calcom/platform-libraries": "npm:@calcom/[email protected]5",
"@calcom/platform-libraries": "npm:@calcom/[email protected]6",
"@calcom/platform-libraries-0.0.2": "npm:@calcom/[email protected]",
"@calcom/platform-types": "*",
"@calcom/platform-utils": "*",
@@ -220,6 +220,7 @@ describe("OAuth Client Users Endpoints", () => {
await userConnectedToOAuth(responseBody.data.user.email);
await userHasDefaultEventTypes(responseBody.data.user.id);
await userHasDefaultSchedule(responseBody.data.user.id, responseBody.data.user.defaultScheduleId);
await userHasOnlyOneSchedule(responseBody.data.user.id);
});
async function userConnectedToOAuth(userEmail: string) {
@@ -260,6 +261,11 @@ describe("OAuth Client Users Endpoints", () => {
expect(schedule?.userId).toEqual(userId);
}
async function userHasOnlyOneSchedule(userId: number) {
const schedules = await schedulesRepositoryFixture.getByUserId(userId);
expect(schedules?.length).toEqual(1);
}
it(`should fail /POST using already used managed user email`, async () => {
const requestBody: CreateManagedUserInput = {
email: userEmail,
@@ -29,4 +29,8 @@ export class SchedulesRepositoryFixture {
async deleteAvailabilities(scheduleId: Schedule["id"]) {
return this.prismaWriteClient.availability.deleteMany({ where: { scheduleId } });
}
async getByUserId(userId: Schedule["userId"]) {
return this.prismaReadClient.schedule.findMany({ where: { userId } });
}
}