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:
@@ -29,7 +29,7 @@
|
||||
"@axiomhq/winston": "^1.2.0",
|
||||
"@calcom/platform-constants": "*",
|
||||
"@calcom/platform-enums": "*",
|
||||
"@calcom/platform-libraries": "npm:@calcom/platform-libraries@0.0.85",
|
||||
"@calcom/platform-libraries": "npm:@calcom/platform-libraries@0.0.86",
|
||||
"@calcom/platform-libraries-0.0.2": "npm:@calcom/platform-libraries@0.0.2",
|
||||
"@calcom/platform-types": "*",
|
||||
"@calcom/platform-utils": "*",
|
||||
|
||||
+6
@@ -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 } });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -346,20 +346,24 @@ export async function createNewUsersConnectToOrgIfExists({
|
||||
accepted: autoAccept, // If the user is invited to a child team, they are automatically accepted
|
||||
},
|
||||
},
|
||||
schedules: {
|
||||
create: {
|
||||
name: t("default_schedule_name"),
|
||||
availability: {
|
||||
createMany: {
|
||||
data: defaultAvailability.map((schedule) => ({
|
||||
days: schedule.days,
|
||||
startTime: schedule.startTime,
|
||||
endTime: schedule.endTime,
|
||||
})),
|
||||
...(!isPlatformManaged
|
||||
? {
|
||||
schedules: {
|
||||
create: {
|
||||
name: t("default_schedule_name"),
|
||||
availability: {
|
||||
createMany: {
|
||||
data: defaultAvailability.map((schedule) => ({
|
||||
days: schedule.days,
|
||||
startTime: schedule.startTime,
|
||||
endTime: schedule.endTime,
|
||||
})),
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
: {}),
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user