@@ -112,17 +112,28 @@ describe("WorkspacesPage", () => {
112
112
expect ( stopWorkspace ) . toHaveBeenCalledWith ( workspaces [ 1 ] . id ) ;
113
113
} ) ;
114
114
115
- describe ( "batch update" , ( ) => {
116
- it ( "ignores up-to-date workspaces" , async ( ) => {
117
- const workspaces = [
118
- { ...MockWorkspace , id : "1" } , // running, not outdated. no warning.
119
- { ...MockDormantWorkspace , id : "2" } , // dormant, not outdated. no warning.
115
+ describe ( "batch updates" , ( ) => {
116
+ it ( "skips up-to-date workspaces after confirming update" , async ( ) => {
117
+ const workspaces : readonly Workspace [ ] = [
118
+ // Not outdated but running; should have no warning
119
+ { ...MockWorkspace , id : "1" } ,
120
+ // Dormant; no warning
121
+ { ...MockDormantWorkspace , id : "2" } ,
122
+ // Out of date but not running; no warning
120
123
{ ...MockOutdatedWorkspace , id : "3" } ,
121
- { ...MockOutdatedWorkspace , id : "4" } ,
124
+ // Out of date but running; should issue warning
125
+ {
126
+ ...MockOutdatedWorkspace , id : "4" ,
127
+ latest_build : {
128
+ ...MockOutdatedWorkspace . latest_build ,
129
+ status : "running"
130
+ } ,
131
+ } ,
122
132
] ;
123
133
jest
124
134
. spyOn ( API , "getWorkspaces" )
125
135
. mockResolvedValue ( { workspaces, count : workspaces . length } ) ;
136
+
126
137
const updateWorkspace = jest . spyOn ( API , "updateWorkspace" ) ;
127
138
const user = userEvent . setup ( ) ;
128
139
renderWithAuth ( < WorkspacesPage /> ) ;
@@ -133,22 +144,22 @@ describe("WorkspacesPage", () => {
133
144
}
134
145
135
146
await user . click ( screen . getByRole ( "button" , { name : / b u l k a c t i o n s / i } ) ) ;
136
- const updateButton = await screen . findByTestId ( "bulk-action-update" ) ;
137
- await user . click ( updateButton ) ;
147
+ const dropdownItem = await screen . findByRole ( "menuitem" , {
148
+ name : / U p d a t e / ,
149
+ } ) ;
150
+ await user . click ( dropdownItem ) ;
138
151
139
- // One click: no running workspaces warning, no dormant workspaces warning.
140
- // There is a running workspace and a dormant workspace selected, but they
141
- // are not outdated.
142
- const confirmButton = await screen . findByTestId ( "confirm-button" ) ;
143
- const dialog = await screen . findByRole ( "dialog" ) ;
144
- expect ( dialog ) . toHaveTextContent ( / u s e d b y / i ) ;
145
- await user . click ( confirmButton ) ;
152
+ const modal = await screen . findByRole ( "dialog" , { name : / R e v i e w U p d a t e s / i } ) ;
153
+ const confirmCheckbox = within ( modal ) . getByRole ( "checkbox" , {
154
+ 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
+ } ) ;
156
+ await user . click ( confirmCheckbox ) ;
157
+ const updateModalButton = within ( modal ) . getByRole ( "button" , { name : / U p d a t e / } ) ;
158
+ await user . click ( updateModalButton ) ;
146
159
147
160
// `workspaces[0]` was up-to-date, and running
148
161
// `workspaces[1]` was dormant
149
- await waitFor ( ( ) => {
150
- expect ( updateWorkspace ) . toHaveBeenCalledTimes ( 2 ) ;
151
- } ) ;
162
+ await waitFor ( ( ) => expect ( updateWorkspace ) . toHaveBeenCalledTimes ( 2 ) ) ;
152
163
expect ( updateWorkspace ) . toHaveBeenCalledWith ( workspaces [ 2 ] , [ ] , false ) ;
153
164
expect ( updateWorkspace ) . toHaveBeenCalledWith ( workspaces [ 3 ] , [ ] , false ) ;
154
165
} ) ;
0 commit comments