Skip to content

Commit 56873b8

Browse files
committed
chore: add hard cutoff for waitFor calls
1 parent 3191ddb commit 56873b8

File tree

1 file changed

+27
-10
lines changed

1 file changed

+27
-10
lines changed

site/src/pages/TemplateSettingsPage/TemplateSchedulePage/TemplateSchedulePage.test.tsx

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { screen, waitFor } from "@testing-library/react";
1+
import { screen, waitFor, type waitForOptions } from "@testing-library/react";
22
import userEvent from "@testing-library/user-event";
33
import * as API from "api/api";
44
import { Language as FooterFormLanguage } from "components/FormFooter/FormFooter";
@@ -103,6 +103,12 @@ const fillAndSubmitForm = async ({
103103
await user.click(confirmButton);
104104
};
105105

106+
const waitForConfig = {
107+
// Test averages about 13 seconds to complete; adding an extra three to
108+
// account for spikes before definitely failing a test
109+
timeout: 16_000,
110+
} as const satisfies waitForOptions;
111+
106112
describe("TemplateSchedulePage", () => {
107113
beforeEach(() => {
108114
jest
@@ -121,7 +127,10 @@ describe("TemplateSchedulePage", () => {
121127
});
122128

123129
await fillAndSubmitForm(validFormValues);
124-
await waitFor(() => expect(API.updateTemplateMeta).toBeCalledTimes(1));
130+
await waitFor(
131+
() => expect(API.updateTemplateMeta).toBeCalledTimes(1),
132+
waitForConfig,
133+
);
125134
});
126135

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

135144
await fillAndSubmitForm(validFormValues);
136-
await waitFor(() => expect(API.updateTemplateMeta).toBeCalledTimes(1));
137-
await waitFor(() =>
145+
await waitFor(
146+
() => expect(API.updateTemplateMeta).toBeCalledTimes(1),
147+
waitForConfig,
148+
);
149+
150+
await waitFor(() => {
138151
expect(API.updateTemplateMeta).toBeCalledWith(
139152
"test-template",
140153
expect.objectContaining({
141154
default_ttl_ms: (validFormValues.default_ttl_ms || 0) * 3600000,
142155
max_ttl_ms: (validFormValues.max_ttl_ms || 0) * 3600000,
143156
}),
144-
),
145-
);
157+
);
158+
}, waitForConfig);
146159
});
147160

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

156169
await fillAndSubmitForm(validFormValues);
157-
await waitFor(() => expect(API.updateTemplateMeta).toBeCalledTimes(1));
158-
await waitFor(() =>
170+
await waitFor(
171+
() => expect(API.updateTemplateMeta).toBeCalledTimes(1),
172+
waitForConfig,
173+
);
174+
175+
await waitFor(() => {
159176
expect(API.updateTemplateMeta).toBeCalledWith(
160177
"test-template",
161178
expect.objectContaining({
@@ -165,8 +182,8 @@ describe("TemplateSchedulePage", () => {
165182
time_til_dormant_autodelete_ms:
166183
(validFormValues.time_til_dormant_autodelete_ms || 0) * 86400000,
167184
}),
168-
),
169-
);
185+
);
186+
}, waitForConfig);
170187
});
171188

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

0 commit comments

Comments
 (0)