Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
chore: add hard cutoff for waitFor calls
  • Loading branch information
Parkreiner committed Sep 20, 2023
commit 56873b80d7014374f16733124ba04169f1cdf943
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { screen, waitFor } from "@testing-library/react";
import { screen, waitFor, type waitForOptions } from "@testing-library/react";
import userEvent from "@testing-library/user-event";
import * as API from "api/api";
import { Language as FooterFormLanguage } from "components/FormFooter/FormFooter";
Expand Down Expand Up @@ -103,6 +103,12 @@ const fillAndSubmitForm = async ({
await user.click(confirmButton);
};

const waitForConfig = {
// Test averages about 13 seconds to complete; adding an extra three to
// account for spikes before definitely failing a test
timeout: 16_000,
} as const satisfies waitForOptions;

describe("TemplateSchedulePage", () => {
beforeEach(() => {
jest
Expand All @@ -121,7 +127,10 @@ describe("TemplateSchedulePage", () => {
});

await fillAndSubmitForm(validFormValues);
await waitFor(() => expect(API.updateTemplateMeta).toBeCalledTimes(1));
await waitFor(
() => expect(API.updateTemplateMeta).toBeCalledTimes(1),
waitForConfig,
);
});

test("default and max ttl is converted to and from hours", async () => {
Expand All @@ -133,16 +142,20 @@ describe("TemplateSchedulePage", () => {
});

await fillAndSubmitForm(validFormValues);
await waitFor(() => expect(API.updateTemplateMeta).toBeCalledTimes(1));
await waitFor(() =>
await waitFor(
() => expect(API.updateTemplateMeta).toBeCalledTimes(1),
waitForConfig,
);

await waitFor(() => {
expect(API.updateTemplateMeta).toBeCalledWith(
"test-template",
expect.objectContaining({
default_ttl_ms: (validFormValues.default_ttl_ms || 0) * 3600000,
max_ttl_ms: (validFormValues.max_ttl_ms || 0) * 3600000,
}),
),
);
);
}, waitForConfig);
});

test("failure, dormancy, and dormancy auto-deletion converted to and from days", async () => {
Expand All @@ -154,8 +167,12 @@ describe("TemplateSchedulePage", () => {
});

await fillAndSubmitForm(validFormValues);
await waitFor(() => expect(API.updateTemplateMeta).toBeCalledTimes(1));
await waitFor(() =>
await waitFor(
() => expect(API.updateTemplateMeta).toBeCalledTimes(1),
waitForConfig,
);

await waitFor(() => {
expect(API.updateTemplateMeta).toBeCalledWith(
"test-template",
expect.objectContaining({
Expand All @@ -165,8 +182,8 @@ describe("TemplateSchedulePage", () => {
time_til_dormant_autodelete_ms:
(validFormValues.time_til_dormant_autodelete_ms || 0) * 86400000,
}),
),
);
);
}, waitForConfig);
});

it("allows a default ttl of 7 days", () => {
Expand Down