@@ -13,7 +13,7 @@ import { Role } from "api/typesGenerated";
13
13
import { Language as ResetPasswordDialogLanguage } from "./ResetPasswordDialog" ;
14
14
import { renderWithAuth } from "testHelpers/renderHelpers" ;
15
15
import { server } from "testHelpers/server" ;
16
- import { Language as UsersPageLanguage , UsersPage } from "./UsersPage" ;
16
+ import { UsersPage } from "./UsersPage" ;
17
17
18
18
const renderPage = ( ) => {
19
19
return renderWithAuth ( < UsersPage /> ) ;
@@ -34,17 +34,14 @@ const suspendUser = async (setupActionSpies: () => void) => {
34
34
35
35
// Check if the confirm message is displayed
36
36
const confirmDialog = await screen . findByRole ( "dialog" ) ;
37
- expect ( confirmDialog ) . toHaveTextContent (
38
- `${ UsersPageLanguage . suspendDialogMessagePrefix } ${ MockUser . username } ?` ,
39
- ) ;
40
37
41
38
// Setup spies to check the actions after
42
39
setupActionSpies ( ) ;
43
40
44
41
// Click on the "Confirm" button
45
- const confirmButton = await within ( confirmDialog ) . findByText (
46
- UsersPageLanguage . suspendDialogAction ,
47
- ) ;
42
+ const confirmButton = await within ( confirmDialog ) . findByText ( "suspend" , {
43
+ exact : false ,
44
+ } ) ;
48
45
await user . click ( confirmButton ) ;
49
46
} ;
50
47
@@ -93,17 +90,14 @@ const activateUser = async (setupActionSpies: () => void) => {
93
90
94
91
// Check if the confirm message is displayed
95
92
const confirmDialog = screen . getByRole ( "dialog" ) ;
96
- expect ( confirmDialog ) . toHaveTextContent (
97
- `${ UsersPageLanguage . activateDialogMessagePrefix } ${ SuspendedMockUser . username } ?` ,
98
- ) ;
99
93
100
94
// Setup spies to check the actions after
101
95
setupActionSpies ( ) ;
102
96
103
97
// Click on the "Confirm" button
104
- const confirmButton = within ( confirmDialog ) . getByText (
105
- UsersPageLanguage . activateDialogAction ,
106
- ) ;
98
+ const confirmButton = within ( confirmDialog ) . getByText ( "activate" , {
99
+ exact : false ,
100
+ } ) ;
107
101
fireEvent . click ( confirmButton ) ;
108
102
} ;
109
103
@@ -175,7 +169,7 @@ describe("UsersPage", () => {
175
169
} ) ;
176
170
177
171
// Check if the success message is displayed
178
- await screen . findByText ( "User suspended" ) ;
172
+ await screen . findByText ( "Successfully suspended the user. " ) ;
179
173
180
174
// Check if the API was called correctly
181
175
expect ( API . suspendUser ) . toBeCalledTimes ( 1 ) ;
@@ -194,7 +188,7 @@ describe("UsersPage", () => {
194
188
} ) ;
195
189
196
190
// Check if the error message is displayed
197
- await screen . findByText ( "Error suspending user" ) ;
191
+ await screen . findByText ( "Error suspending user. " ) ;
198
192
199
193
// Check if the API was called correctly
200
194
expect ( API . suspendUser ) . toBeCalledTimes ( 1 ) ;
@@ -251,7 +245,7 @@ describe("UsersPage", () => {
251
245
} ) ;
252
246
253
247
// Check if the success message is displayed
254
- await screen . findByText ( "User deleted" ) ;
248
+ await screen . findByText ( "Successfully deleted the user. " ) ;
255
249
256
250
// Check if the API was called correctly
257
251
expect ( API . deleteUser ) . toBeCalledTimes ( 1 ) ;
@@ -273,7 +267,7 @@ describe("UsersPage", () => {
273
267
} ) ;
274
268
275
269
// Check if the error message is displayed
276
- await screen . findByText ( "Error deleting user" ) ;
270
+ await screen . findByText ( "Error deleting user. " ) ;
277
271
278
272
// Check if the API was called correctly
279
273
expect ( API . deleteUser ) . toBeCalledTimes ( 1 ) ;
@@ -300,7 +294,7 @@ describe("UsersPage", () => {
300
294
} ) ;
301
295
302
296
// Check if the success message is displayed
303
- await screen . findByText ( "User activated" ) ;
297
+ await screen . findByText ( "Successfully activated the user. " ) ;
304
298
305
299
// Check if the API was called correctly
306
300
expect ( API . activateUser ) . toBeCalledTimes ( 1 ) ;
@@ -316,7 +310,7 @@ describe("UsersPage", () => {
316
310
} ) ;
317
311
318
312
// Check if the error message is displayed
319
- await screen . findByText ( "Error activating user" ) ;
313
+ await screen . findByText ( "Error activating user. " ) ;
320
314
321
315
// Check if the API was called correctly
322
316
expect ( API . activateUser ) . toBeCalledTimes ( 1 ) ;
@@ -337,7 +331,7 @@ describe("UsersPage", () => {
337
331
} ) ;
338
332
339
333
// Check if the success message is displayed
340
- await screen . findByText ( "Password reset " ) ;
334
+ await screen . findByText ( "Successfully updated the user password. " ) ;
341
335
342
336
// Check if the API was called correctly
343
337
expect ( API . updateUserPassword ) . toBeCalledTimes ( 1 ) ;
@@ -356,7 +350,7 @@ describe("UsersPage", () => {
356
350
} ) ;
357
351
358
352
// Check if the error message is displayed
359
- await screen . findByText ( "Error resetting password" ) ;
353
+ await screen . findByText ( "Error on resetting the user password. " ) ;
360
354
361
355
// Check if the API was called correctly
362
356
expect ( API . updateUserPassword ) . toBeCalledTimes ( 1 ) ;
@@ -405,7 +399,9 @@ describe("UsersPage", () => {
405
399
} , MockAuditorRole ) ;
406
400
407
401
// Check if the error message is displayed
408
- await waitFor ( ( ) => expect ( "Error updating user roles" ) . toBeDefined ( ) ) ;
402
+ await waitFor ( ( ) =>
403
+ expect ( "Error on updating the user roles." ) . toBeDefined ( ) ,
404
+ ) ;
409
405
410
406
// Check if the API was called correctly
411
407
const currentRoles = MockUser . roles . map ( ( r ) => r . name ) ;
0 commit comments