@@ -123,10 +123,11 @@ describe("WorkspacesPage", () => {
123
123
{ ...MockOutdatedWorkspace , id : "3" } ,
124
124
// Out of date but running; should issue warning
125
125
{
126
- ...MockOutdatedWorkspace , id : "4" ,
126
+ ...MockOutdatedWorkspace ,
127
+ id : "4" ,
127
128
latest_build : {
128
129
...MockOutdatedWorkspace . latest_build ,
129
- status : "running"
130
+ status : "running" ,
130
131
} ,
131
132
} ,
132
133
] ;
@@ -149,12 +150,16 @@ describe("WorkspacesPage", () => {
149
150
} ) ;
150
151
await user . click ( dropdownItem ) ;
151
152
152
- const modal = await screen . findByRole ( "dialog" , { name : / R e v i e w U p d a t e s / i } ) ;
153
+ const modal = await screen . findByRole ( "dialog" , {
154
+ name : / R e v i e w U p d a t e s / i,
155
+ } ) ;
153
156
const confirmCheckbox = within ( modal ) . getByRole ( "checkbox" , {
154
157
name : / I a c k n o w l e d g e t h e s e c o n s e q u e n c e s \. / ,
155
158
} ) ;
156
159
await user . click ( confirmCheckbox ) ;
157
- const updateModalButton = within ( modal ) . getByRole ( "button" , { name : / U p d a t e / } ) ;
160
+ const updateModalButton = within ( modal ) . getByRole ( "button" , {
161
+ name : / U p d a t e / ,
162
+ } ) ;
158
163
await user . click ( updateModalButton ) ;
159
164
160
165
// `workspaces[0]` was up-to-date, and running
@@ -164,15 +169,16 @@ describe("WorkspacesPage", () => {
164
169
expect ( updateWorkspace ) . toHaveBeenCalledWith ( workspaces [ 3 ] , [ ] , false ) ;
165
170
} ) ;
166
171
167
- it ( "warns about and updates running workspaces " , async ( ) => {
168
- const workspaces = [
172
+ it ( "lets user update a running workspace (after user goes through warning) " , async ( ) => {
173
+ const workspaces : readonly Workspace [ ] = [
169
174
{ ...MockRunningOutdatedWorkspace , id : "1" } ,
170
175
{ ...MockOutdatedWorkspace , id : "2" } ,
171
176
{ ...MockOutdatedWorkspace , id : "3" } ,
172
177
] ;
173
178
jest
174
179
. spyOn ( API , "getWorkspaces" )
175
180
. mockResolvedValue ( { workspaces, count : workspaces . length } ) ;
181
+
176
182
const updateWorkspace = jest . spyOn ( API , "updateWorkspace" ) ;
177
183
const user = userEvent . setup ( ) ;
178
184
renderWithAuth ( < WorkspacesPage /> ) ;
@@ -183,20 +189,24 @@ describe("WorkspacesPage", () => {
183
189
}
184
190
185
191
await user . click ( screen . getByRole ( "button" , { name : / b u l k a c t i o n s / i } ) ) ;
186
- const updateButton = await screen . findByTestId ( "bulk-action-update" ) ;
187
- await user . click ( updateButton ) ;
188
-
189
- // Two clicks: 1 running workspace, no dormant workspaces warning.
190
- const confirmButton = await screen . findByTestId ( "confirm-button" ) ;
191
- const dialog = await screen . findByRole ( "dialog" ) ;
192
- expect ( dialog ) . toHaveTextContent ( / 1 r u n n i n g w o r k s p a c e / i) ;
193
- await user . click ( confirmButton ) ;
194
- expect ( dialog ) . toHaveTextContent ( / u s e d b y / i) ;
195
- await user . click ( confirmButton ) ;
196
-
197
- await waitFor ( ( ) => {
198
- expect ( updateWorkspace ) . toHaveBeenCalledTimes ( 3 ) ;
192
+ const dropdownItem = await screen . findByRole ( "menuitem" , {
193
+ name : / U p d a t e / ,
194
+ } ) ;
195
+ await user . click ( dropdownItem ) ;
196
+
197
+ const modal = await screen . findByRole ( "dialog" , {
198
+ name : / R e v i e w U p d a t e s / i,
199
+ } ) ;
200
+ const confirmCheckbox = within ( modal ) . getByRole ( "checkbox" , {
201
+ name : / I a c k n o w l e d g e t h e s e c o n s e q u e n c e s \. / ,
202
+ } ) ;
203
+ await user . click ( confirmCheckbox ) ;
204
+ const updateModalButton = within ( modal ) . getByRole ( "button" , {
205
+ name : / U p d a t e / ,
199
206
} ) ;
207
+ await user . click ( updateModalButton ) ;
208
+
209
+ await waitFor ( ( ) => expect ( updateWorkspace ) . toHaveBeenCalledTimes ( 3 ) ) ;
200
210
expect ( updateWorkspace ) . toHaveBeenCalledWith ( workspaces [ 0 ] , [ ] , false ) ;
201
211
expect ( updateWorkspace ) . toHaveBeenCalledWith ( workspaces [ 1 ] , [ ] , false ) ;
202
212
expect ( updateWorkspace ) . toHaveBeenCalledWith ( workspaces [ 2 ] , [ ] , false ) ;
@@ -221,67 +231,24 @@ describe("WorkspacesPage", () => {
221
231
}
222
232
223
233
await user . click ( screen . getByRole ( "button" , { name : / b u l k a c t i o n s / i } ) ) ;
224
- const updateButton = await screen . findByTestId ( "bulk-action-update" ) ;
225
- await user . click ( updateButton ) ;
234
+ const dropdownItem = await screen . findByRole ( "menuitem" , {
235
+ name : / U p d a t e / ,
236
+ } ) ;
237
+ await user . click ( dropdownItem ) ;
226
238
227
- // Two clicks: no running workspaces warning, 1 dormant workspace.
228
- const confirmButton = await screen . findByTestId ( "confirm-button" ) ;
229
- const dialog = await screen . findByRole ( "dialog" ) ;
230
- expect ( dialog ) . toHaveTextContent ( / d o r m a n t / i ) ;
231
- await user . click ( confirmButton ) ;
232
- expect ( dialog ) . toHaveTextContent ( / u s e d b y / i ) ;
233
- await user . click ( confirmButton ) ;
239
+ const modal = await screen . findByRole ( "dialog" , {
240
+ name : / R e v i e w U p d a t e s / i ,
241
+ } ) ;
242
+ const updateModalButton = within ( modal ) . getByRole ( "button" , {
243
+ name : / U p d a t e / ,
244
+ } ) ;
245
+ await user . click ( updateModalButton ) ;
234
246
235
247
// `workspaces[0]` was dormant
236
- await waitFor ( ( ) => {
237
- expect ( updateWorkspace ) . toHaveBeenCalledTimes ( 2 ) ;
238
- } ) ;
248
+ await waitFor ( ( ) => expect ( updateWorkspace ) . toHaveBeenCalledTimes ( 2 ) ) ;
239
249
expect ( updateWorkspace ) . toHaveBeenCalledWith ( workspaces [ 1 ] , [ ] , false ) ;
240
250
expect ( updateWorkspace ) . toHaveBeenCalledWith ( workspaces [ 2 ] , [ ] , false ) ;
241
251
} ) ;
242
-
243
- it ( "warns about running workspaces and then dormant workspaces" , async ( ) => {
244
- const workspaces = [
245
- { ...MockRunningOutdatedWorkspace , id : "1" } ,
246
- { ...MockDormantOutdatedWorkspace , id : "2" } ,
247
- { ...MockOutdatedWorkspace , id : "3" } ,
248
- { ...MockOutdatedWorkspace , id : "4" } ,
249
- { ...MockWorkspace , id : "5" } ,
250
- ] ;
251
- jest
252
- . spyOn ( API , "getWorkspaces" )
253
- . mockResolvedValue ( { workspaces, count : workspaces . length } ) ;
254
- const updateWorkspace = jest . spyOn ( API , "updateWorkspace" ) ;
255
- const user = userEvent . setup ( ) ;
256
- renderWithAuth ( < WorkspacesPage /> ) ;
257
- await waitForLoaderToBeRemoved ( ) ;
258
-
259
- for ( const workspace of workspaces ) {
260
- await user . click ( getWorkspaceCheckbox ( workspace ) ) ;
261
- }
262
-
263
- await user . click ( screen . getByRole ( "button" , { name : / b u l k a c t i o n s / i } ) ) ;
264
- const updateButton = await screen . findByTestId ( "bulk-action-update" ) ;
265
- await user . click ( updateButton ) ;
266
-
267
- // Three clicks: 1 running workspace, 1 dormant workspace.
268
- const confirmButton = await screen . findByTestId ( "confirm-button" ) ;
269
- const dialog = await screen . findByRole ( "dialog" ) ;
270
- expect ( dialog ) . toHaveTextContent ( / 1 r u n n i n g w o r k s p a c e / i) ;
271
- await user . click ( confirmButton ) ;
272
- expect ( dialog ) . toHaveTextContent ( / d o r m a n t / i) ;
273
- await user . click ( confirmButton ) ;
274
- expect ( dialog ) . toHaveTextContent ( / u s e d b y / i) ;
275
- await user . click ( confirmButton ) ;
276
-
277
- // `workspaces[1]` was dormant, and `workspaces[4]` was up-to-date
278
- await waitFor ( ( ) => {
279
- expect ( updateWorkspace ) . toHaveBeenCalledTimes ( 3 ) ;
280
- } ) ;
281
- expect ( updateWorkspace ) . toHaveBeenCalledWith ( workspaces [ 0 ] , [ ] , false ) ;
282
- expect ( updateWorkspace ) . toHaveBeenCalledWith ( workspaces [ 2 ] , [ ] , false ) ;
283
- expect ( updateWorkspace ) . toHaveBeenCalledWith ( workspaces [ 3 ] , [ ] , false ) ;
284
- } ) ;
285
252
} ) ;
286
253
287
254
it ( "starts only the stopped and selected workspaces" , async ( ) => {
0 commit comments