1
- import { screen , waitFor } from "@testing-library/react" ;
1
+ import { screen , waitFor , type waitForOptions } from "@testing-library/react" ;
2
2
import userEvent from "@testing-library/user-event" ;
3
3
import * as API from "api/api" ;
4
4
import { Language as FooterFormLanguage } from "components/FormFooter/FormFooter" ;
@@ -103,6 +103,12 @@ const fillAndSubmitForm = async ({
103
103
await user . click ( confirmButton ) ;
104
104
} ;
105
105
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
+
106
112
describe ( "TemplateSchedulePage" , ( ) => {
107
113
beforeEach ( ( ) => {
108
114
jest
@@ -121,7 +127,10 @@ describe("TemplateSchedulePage", () => {
121
127
} ) ;
122
128
123
129
await fillAndSubmitForm ( validFormValues ) ;
124
- await waitFor ( ( ) => expect ( API . updateTemplateMeta ) . toBeCalledTimes ( 1 ) ) ;
130
+ await waitFor (
131
+ ( ) => expect ( API . updateTemplateMeta ) . toBeCalledTimes ( 1 ) ,
132
+ waitForConfig ,
133
+ ) ;
125
134
} ) ;
126
135
127
136
test ( "default and max ttl is converted to and from hours" , async ( ) => {
@@ -133,16 +142,20 @@ describe("TemplateSchedulePage", () => {
133
142
} ) ;
134
143
135
144
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 ( ( ) => {
138
151
expect ( API . updateTemplateMeta ) . toBeCalledWith (
139
152
"test-template" ,
140
153
expect . objectContaining ( {
141
154
default_ttl_ms : ( validFormValues . default_ttl_ms || 0 ) * 3600000 ,
142
155
max_ttl_ms : ( validFormValues . max_ttl_ms || 0 ) * 3600000 ,
143
156
} ) ,
144
- ) ,
145
- ) ;
157
+ ) ;
158
+ } , waitForConfig ) ;
146
159
} ) ;
147
160
148
161
test ( "failure, dormancy, and dormancy auto-deletion converted to and from days" , async ( ) => {
@@ -154,8 +167,12 @@ describe("TemplateSchedulePage", () => {
154
167
} ) ;
155
168
156
169
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 ( ( ) => {
159
176
expect ( API . updateTemplateMeta ) . toBeCalledWith (
160
177
"test-template" ,
161
178
expect . objectContaining ( {
@@ -165,8 +182,8 @@ describe("TemplateSchedulePage", () => {
165
182
time_til_dormant_autodelete_ms :
166
183
( validFormValues . time_til_dormant_autodelete_ms || 0 ) * 86400000 ,
167
184
} ) ,
168
- ) ,
169
- ) ;
185
+ ) ;
186
+ } , waitForConfig ) ;
170
187
} ) ;
171
188
172
189
it ( "allows a default ttl of 7 days" , ( ) => {
0 commit comments