fix: Booking Error - cannot be booked at this time (#15288)
Co-authored-by: Joe Au-Yeung <65426560+joeauyeung@users.noreply.github.com>
This commit is contained in:
1 parent
3a22fdb428
commit
765d601ff9
5 files changed
+1345
-89
No files matched your search
@@ -37,7 +37,10 @@ declare global {
|
||||
namespace jest {
|
||||
interface Matchers<R> {
|
||||
toHaveTimeSlots(expectedSlots: string[], date: { dateString: string; doExactMatch?: boolean }): R;
|
||||
toHaveNoTimeSlots(date: { dateString: string }): R;
|
||||
/**
|
||||
* Explicitly checks if the date is disabled and fails if date is marked as OOO
|
||||
*/
|
||||
toHaveDateDisabled(date: { dateString: string }): R;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -55,18 +58,28 @@ expect.extend({
|
||||
};
|
||||
}
|
||||
|
||||
const expectedSlotHasFullTimestamp = expectedSlots[0].split("-").length === 3;
|
||||
|
||||
if (
|
||||
!schedule.slots[`${dateString}`]
|
||||
.map((slot) => slot.time)
|
||||
.every((actualSlotTime, index) => {
|
||||
return `${dateString}T${expectedSlots[index]}` === actualSlotTime;
|
||||
const expectedSlotTime = expectedSlotHasFullTimestamp
|
||||
? expectedSlots[index]
|
||||
: `${dateString}T${expectedSlots[index]}`;
|
||||
return expectedSlotTime === actualSlotTime;
|
||||
})
|
||||
) {
|
||||
return {
|
||||
pass: false,
|
||||
message: () =>
|
||||
`has incorrect timeslots for ${dateString}.\n\r ${diff(
|
||||
expectedSlots.map((expectedSlot) => `${dateString}T${expectedSlot}`),
|
||||
expectedSlots.map((expectedSlot) => {
|
||||
if (expectedSlotHasFullTimestamp) {
|
||||
return expectedSlot;
|
||||
}
|
||||
return `${dateString}T${expectedSlot}`;
|
||||
}),
|
||||
schedule.slots[`${dateString}`].map((slot) => slot.time)
|
||||
)}`,
|
||||
};
|
||||
@@ -88,11 +101,19 @@ expect.extend({
|
||||
};
|
||||
},
|
||||
|
||||
toHaveNoTimeSlots(schedule: { slots: Record<string, Slot[]> }, { dateString }: { dateString: string }) {
|
||||
if (!schedule.slots[`${dateString}`] || schedule.slots[`${dateString}`].length === 0) {
|
||||
toHaveDateDisabled(schedule: { slots: Record<string, Slot[]> }, { dateString }: { dateString: string }) {
|
||||
// Frontend requires that the date must not be set for that date to be shown as disabled.Because weirdly, if an empty array is provided the date itself isn't shown which we don't want
|
||||
if (!schedule.slots[`${dateString}`]) {
|
||||
return {
|
||||
pass: true,
|
||||
message: () => `has no timeslots for ${dateString}`,
|
||||
message: () => `is not disabled for ${dateString}`,
|
||||
};
|
||||
}
|
||||
|
||||
if (schedule.slots[`${dateString}`].length === 0) {
|
||||
return {
|
||||
pass: false,
|
||||
message: () => `is all day OOO for ${dateString}.`,
|
||||
};
|
||||
}
|
||||
return {
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -166,6 +166,7 @@ type InputBooking = Partial<Omit<Booking, keyof WhiteListedBookingProps>> & Whit
|
||||
export const Timezones = {
|
||||
"+5:30": "Asia/Kolkata",
|
||||
"+6:00": "Asia/Dhaka",
|
||||
"-11:00": "Pacific/Pago_Pago",
|
||||
};
|
||||
|
||||
async function addHostsToDb(eventTypes: InputEventType[]) {
|
||||
@@ -928,6 +929,21 @@ export const TestData = {
|
||||
],
|
||||
timeZone: Timezones["+5:30"],
|
||||
}),
|
||||
IstWorkHoursNoWeekends: {
|
||||
id: 1,
|
||||
name: "9:30AM to 6PM in India - 4:00AM to 12:30PM in GMT",
|
||||
availability: [
|
||||
{
|
||||
// userId: null,
|
||||
// eventTypeId: null,
|
||||
days: [/*0*/ 1, 2, 3, 4, 5 /*6*/],
|
||||
startTime: new Date("1970-01-01T09:30:00.000Z"),
|
||||
endTime: new Date("1970-01-01T18:00:00.000Z"),
|
||||
date: null,
|
||||
},
|
||||
],
|
||||
timeZone: Timezones["+5:30"],
|
||||
},
|
||||
},
|
||||
users: {
|
||||
example: {
|
||||
@@ -1669,3 +1685,9 @@ export const getMockFailingAppStatus = ({ slug }: { slug: string }) => {
|
||||
export const getMockPassingAppStatus = ({ slug, overrideName }: { slug: string; overrideName?: string }) => {
|
||||
return getMockAppStatus({ slug, overrideName, failures: 0, success: 1 });
|
||||
};
|
||||
|
||||
export const replaceDates = (dates: string[], replacement: Record<string, string>) => {
|
||||
return dates.map((date) => {
|
||||
return date.replace(/(.*)T/, (_, group1) => `${replacement[group1]}T`);
|
||||
});
|
||||
};
|
||||
Reference in new issue
Block a user