Skip to content

Commit a26786e

Browse files
committed
Add comments and try shorter timeout
1 parent 4d40c30 commit a26786e

File tree

1 file changed

+26
-12
lines changed

1 file changed

+26
-12
lines changed

site/src/components/Navbar/Navbar.test.tsx

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,41 +15,55 @@ import { server } from "testHelpers/server"
1515
*/
1616
describe("Navbar", () => {
1717
it("shows Audit Log link when permitted and entitled", async () => {
18+
// set entitlements to allow audit log
1819
server.use(
1920
rest.get("/api/v2/entitlements", (req, res, ctx) => {
2021
return res(ctx.status(200), ctx.json(MockEntitlementsWithAuditLog))
2122
}),
2223
)
2324
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+
)
2832
})
2933

3034
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
3137
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+
)
3645
})
3746

3847
it("does not show Audit Log link when not permitted via role", async () => {
48+
// set permissions to Member (can't audit)
3949
server.use(
4050
rest.post(`/api/v2/users/${MockUser.id}/authorization`, async (req, res, ctx) => {
4151
return res(ctx.status(200), ctx.json(MockMemberPermissions))
4252
}),
4353
)
54+
// set entitlements to allow audit log
4455
server.use(
4556
rest.get("/api/v2/entitlements", (req, res, ctx) => {
4657
return res(ctx.status(200), ctx.json(MockEntitlementsWithAuditLog))
4758
}),
4859
)
4960
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+
)
5468
})
5569
})

0 commit comments

Comments
 (0)