Skip to content

Commit

Permalink
fix: cleanup all schedules in tests (#27)
Browse files Browse the repository at this point in the history
  • Loading branch information
BaDo2001 authored Nov 20, 2023
1 parent a1d4f90 commit 876bd43
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 11 deletions.
10 changes: 5 additions & 5 deletions tests/integration/askPresentIdeas.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { constructPresentIdeaSavedMessage } from "@/services/slack/constructPres
import { timeout } from "@/testUtils/constants";
import { deleteLastDm } from "@/testUtils/integration/deleteLastDm";
import {
cleanUpSchedule,
cleanUpSchedules,
getSchedule,
} from "@/testUtils/integration/scheduler";
import { sendCronEvent } from "@/testUtils/integration/sendCronEvent";
Expand Down Expand Up @@ -87,7 +87,7 @@ describe("Present ideas", () => {
"Block doesn't contain save button",
).toBe(presentIdeasSaveButtonActionId);

await cleanUpSchedule(`${eventId}_askPresentAndSquadJoinFromTeam`);
await cleanUpSchedules(eventId);
},
timeout,
);
Expand Down Expand Up @@ -205,7 +205,7 @@ describe("Present ideas", () => {
"After completion should be DELETE",
).toEqual("DELETE");

await cleanUpSchedule(`${eventId}_askPresentAndSquadJoinFromTeam`);
await cleanUpSchedules(eventId);
},
timeout,
);
Expand Down Expand Up @@ -249,7 +249,7 @@ describe("Present ideas", () => {
"After completion should be DELETE",
).toEqual("DELETE");

await cleanUpSchedule(`${eventId}_createBirthdaySquad`);
await cleanUpSchedules(eventId);
},
timeout,
);
Expand Down Expand Up @@ -293,7 +293,7 @@ describe("Present ideas", () => {
"After completion should be DELETE",
).toEqual("DELETE");

await cleanUpSchedule(`${eventId}_birthdayCleanup`);
await cleanUpSchedules(eventId);
},
timeout,
);
Expand Down
24 changes: 18 additions & 6 deletions tests/utils/integration/scheduler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,21 @@ export const getSchedule = async (name: string) =>
}),
);

export const cleanUpSchedule = async (name: string) =>
schedulerClient.send(
new DeleteScheduleCommand({
Name: name,
}),
);
export const cleanUpSchedules = async (eventId: string) =>
Promise.all([
schedulerClient.send(
new DeleteScheduleCommand({
Name: `${eventId}_askPresentAndSquadJoinFromTeam`,
}),
),
schedulerClient.send(
new DeleteScheduleCommand({
Name: `${eventId}_createBirthdaySquad`,
}),
),
schedulerClient.send(
new DeleteScheduleCommand({
Name: `${eventId}_birthdayCleanup`,
}),
),
]);

0 comments on commit 876bd43

Please sign in to comment.