@@ -15,41 +15,55 @@ import { server } from "testHelpers/server"
15
15
*/
16
16
describe ( "Navbar" , ( ) => {
17
17
it ( "shows Audit Log link when permitted and entitled" , async ( ) => {
18
+ // set entitlements to allow audit log
18
19
server . use (
19
20
rest . get ( "/api/v2/entitlements" , ( req , res , ctx ) => {
20
21
return res ( ctx . status ( 200 ) , ctx . json ( MockEntitlementsWithAuditLog ) )
21
22
} ) ,
22
23
)
23
24
render ( < App /> )
24
- await waitFor ( ( ) => {
25
- const link = screen . getByText ( Language . users ) // TODO change after debugging
26
- expect ( link ) . toBeDefined ( )
27
- } , { timeout : 10000 } )
25
+ await waitFor (
26
+ ( ) => {
27
+ const link = screen . getByText ( Language . audit )
28
+ expect ( link ) . toBeDefined ( )
29
+ } ,
30
+ { timeout : 5000 } ,
31
+ )
28
32
} )
29
33
30
34
it ( "does not show Audit Log link when not entitled" , async ( ) => {
35
+ // by default, user is an Admin with permission to see the audit log,
36
+ // but is unlicensed so not entitled to see the audit log
31
37
render ( < App /> )
32
- await waitFor ( ( ) => {
33
- const link = screen . queryByText ( Language . audit )
34
- expect ( link ) . toBe ( null )
35
- } )
38
+ await waitFor (
39
+ ( ) => {
40
+ const link = screen . queryByText ( Language . audit )
41
+ expect ( link ) . toBe ( null )
42
+ } ,
43
+ { timeout : 5000 } ,
44
+ )
36
45
} )
37
46
38
47
it ( "does not show Audit Log link when not permitted via role" , async ( ) => {
48
+ // set permissions to Member (can't audit)
39
49
server . use (
40
50
rest . post ( `/api/v2/users/${ MockUser . id } /authorization` , async ( req , res , ctx ) => {
41
51
return res ( ctx . status ( 200 ) , ctx . json ( MockMemberPermissions ) )
42
52
} ) ,
43
53
)
54
+ // set entitlements to allow audit log
44
55
server . use (
45
56
rest . get ( "/api/v2/entitlements" , ( req , res , ctx ) => {
46
57
return res ( ctx . status ( 200 ) , ctx . json ( MockEntitlementsWithAuditLog ) )
47
58
} ) ,
48
59
)
49
60
render ( < App /> )
50
- await waitFor ( ( ) => {
51
- const link = screen . queryByText ( Language . audit )
52
- expect ( link ) . toBe ( null )
53
- } )
61
+ await waitFor (
62
+ ( ) => {
63
+ const link = screen . queryByText ( Language . audit )
64
+ expect ( link ) . toBe ( null )
65
+ } ,
66
+ { timeout : 5000 } ,
67
+ )
54
68
} )
55
69
} )
0 commit comments