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:
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,
|
||||
|
||||
Reference in new issue
Block a user