fix: Offer seats events invites everyone regardless their availability schedule (#15171)
* fix: Offer seats events invites everyone regardless their availibility schedule * chore: add test * uncomment * remove timeout * only check when first seat --------- Co-authored-by: Peer Richelsen <peeroke@gmail.com> Co-authored-by: Joe Au-Yeung <65426560+joeauyeung@users.noreply.github.com>
This commit is contained in:
3 files changed
+29
-2
No files matched your search
@@ -484,13 +484,17 @@ testBothFutureAndLegacyRoutes.describe("Booking round robin event", () => {
|
||||
schedulingType: SchedulingType.ROUND_ROBIN,
|
||||
teamEventLength: 120,
|
||||
teammates: teamMatesObj,
|
||||
seatsPerTimeSlot: 5,
|
||||
}
|
||||
);
|
||||
const team = await testUser.getFirstTeamMembership();
|
||||
await page.goto(`/team/${team.team.slug}`);
|
||||
});
|
||||
|
||||
test("Does not book round robin host outside availability with date override", async ({ page, users }) => {
|
||||
test("Does not book seated round robin host outside availability with date override", async ({
|
||||
page,
|
||||
users,
|
||||
}) => {
|
||||
const [testUser] = users.get();
|
||||
await testUser.apiLogin();
|
||||
|
||||
|
||||
@@ -91,6 +91,7 @@ const createTeamEventType = async (
|
||||
teamEventTitle?: string;
|
||||
teamEventSlug?: string;
|
||||
teamEventLength?: number;
|
||||
seatsPerTimeSlot?: number;
|
||||
}
|
||||
) => {
|
||||
return await prisma.eventType.create({
|
||||
@@ -120,6 +121,7 @@ const createTeamEventType = async (
|
||||
title: scenario?.teamEventTitle ?? `${teamEventTitle}-team-id-${team.id}`,
|
||||
slug: scenario?.teamEventSlug ?? `${teamEventSlug}-team-id-${team.id}`,
|
||||
length: scenario?.teamEventLength ?? 30,
|
||||
seatsPerTimeSlot: scenario?.seatsPerTimeSlot,
|
||||
},
|
||||
});
|
||||
};
|
||||
@@ -253,6 +255,7 @@ export const createUsersFixture = (
|
||||
isDnsSetup?: boolean;
|
||||
hasSubteam?: true;
|
||||
isUnpublished?: true;
|
||||
seatsPerTimeSlot?: number;
|
||||
} = {}
|
||||
) => {
|
||||
const _user = await prisma.user.create({
|
||||
|
||||
@@ -1258,9 +1258,29 @@ async function handler(
|
||||
}
|
||||
|
||||
let luckyUserResponse;
|
||||
let isFirstSeat = true;
|
||||
|
||||
if (eventType.seatsPerTimeSlot) {
|
||||
const booking = await prisma.booking.findFirst({
|
||||
where: {
|
||||
OR: [
|
||||
{
|
||||
uid: rescheduleUid || reqBody.bookingUid,
|
||||
},
|
||||
{
|
||||
eventTypeId: eventType.id,
|
||||
startTime: new Date(dayjs(reqBody.start).utc().format()),
|
||||
},
|
||||
],
|
||||
status: BookingStatus.ACCEPTED,
|
||||
},
|
||||
});
|
||||
|
||||
if (booking) isFirstSeat = false;
|
||||
}
|
||||
|
||||
//checks what users are available
|
||||
if (!eventType.seatsPerTimeSlot) {
|
||||
if (isFirstSeat) {
|
||||
const eventTypeWithUsers: Awaited<ReturnType<typeof getEventTypesFromDB>> & {
|
||||
users: IsFixedAwareUser[];
|
||||
} = {
|
||||
|
||||
Reference in new issue
Block a user