test: Scenario that replicates the crash in production (#19071)

* Add a case that crashes

* Add proper crash test case

---------

Co-authored-by: Hariom Balhara <[email protected]>
Co-authored-by: Alex van Andel <[email protected]>
This commit is contained in:
authored and GitHub committed 2025-02-07 11:20:29 +00:00
1 parent e79af63e6c
commit 6ca76707da
2 files changed
+99 -3

No files matched your search

@@ -166,6 +166,12 @@ type InputUser = Omit<typeof TestData.users.example, "defaultScheduleId"> & {
weekStart?: string;
profiles?: Prisma.ProfileUncheckedCreateWithoutUserInput[];
completedOnboarding?: boolean;
outOfOffice?: {
dateRanges: {
start: string;
end: string;
}[];
};
};
export type InputEventType = {
@@ -652,14 +658,33 @@ export async function addWorkflowReminders(workflowReminders: InputWorkflowRemin
});
}
export async function addUsersToDb(
users: (Prisma.UserCreateInput & { schedules: Prisma.ScheduleCreateInput[]; id?: number })[]
) {
export async function addUsersToDb(users: InputUser[]) {
log.silly("TestData: Creating Users", JSON.stringify(users));
await prismock.user.createMany({
data: users,
});
// Create OutOfOfficeEntry for users with outOfOffice data
for (const user of users) {
if (user.outOfOffice) {
log.debug("Creating OutOfOfficeEntry for user", user.id);
for (const dateRange of user.outOfOffice.dateRanges) {
await prismock.outOfOfficeEntry.create({
data: {
uuid: uuidv4(),
start: new Date(dateRange.start),
end: new Date(dateRange.end),
user: {
connect: {
id: user.id,
},
},
},
});
}
}
}
const allUsers = await prismock.user.findMany({
include: {
credentials: true,