Skip to content

Commit 32bb639

Browse files
committed
Fix tests
1 parent 4fbcfb0 commit 32bb639

File tree

2 files changed

+83
-8
lines changed

2 files changed

+83
-8
lines changed

site/src/components/NavbarView/NavbarView.test.tsx

Lines changed: 82 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,26 +22,54 @@ describe("NavbarView", () => {
2222

2323
it("renders content", async () => {
2424
// When
25-
render(<NavbarView user={MockUser} onSignOut={noop} canViewAuditLog />)
25+
render(
26+
<NavbarView
27+
user={MockUser}
28+
onSignOut={noop}
29+
canViewAuditLog
30+
canViewDeployment
31+
/>,
32+
)
2633

2734
// Then
2835
await screen.findAllByText("Coder", { exact: false })
2936
})
3037

3138
it("workspaces nav link has the correct href", async () => {
32-
render(<NavbarView user={MockUser} onSignOut={noop} canViewAuditLog />)
39+
render(
40+
<NavbarView
41+
user={MockUser}
42+
onSignOut={noop}
43+
canViewAuditLog
44+
canViewDeployment
45+
/>,
46+
)
3347
const workspacesLink = await screen.findByText(navLanguage.workspaces)
3448
expect((workspacesLink as HTMLAnchorElement).href).toContain("/workspaces")
3549
})
3650

3751
it("templates nav link has the correct href", async () => {
38-
render(<NavbarView user={MockUser} onSignOut={noop} canViewAuditLog />)
52+
render(
53+
<NavbarView
54+
user={MockUser}
55+
onSignOut={noop}
56+
canViewAuditLog
57+
canViewDeployment
58+
/>,
59+
)
3960
const templatesLink = await screen.findByText(navLanguage.templates)
4061
expect((templatesLink as HTMLAnchorElement).href).toContain("/templates")
4162
})
4263

4364
it("users nav link has the correct href", async () => {
44-
render(<NavbarView user={MockUser} onSignOut={noop} canViewAuditLog />)
65+
render(
66+
<NavbarView
67+
user={MockUser}
68+
onSignOut={noop}
69+
canViewAuditLog
70+
canViewDeployment
71+
/>,
72+
)
4573
const userLink = await screen.findByText(navLanguage.users)
4674
expect((userLink as HTMLAnchorElement).href).toContain("/users")
4775
})
@@ -55,7 +83,14 @@ describe("NavbarView", () => {
5583
}
5684

5785
// When
58-
render(<NavbarView user={mockUser} onSignOut={noop} canViewAuditLog />)
86+
render(
87+
<NavbarView
88+
user={mockUser}
89+
onSignOut={noop}
90+
canViewAuditLog
91+
canViewDeployment
92+
/>,
93+
)
5994

6095
// Then
6196
// There should be a 'B' avatar!
@@ -64,16 +99,56 @@ describe("NavbarView", () => {
6499
})
65100

66101
it("audit nav link has the correct href", async () => {
67-
render(<NavbarView user={MockUser} onSignOut={noop} canViewAuditLog />)
102+
render(
103+
<NavbarView
104+
user={MockUser}
105+
onSignOut={noop}
106+
canViewAuditLog
107+
canViewDeployment
108+
/>,
109+
)
68110
const auditLink = await screen.findByText(navLanguage.audit)
69111
expect((auditLink as HTMLAnchorElement).href).toContain("/audit")
70112
})
71113

72114
it("audit nav link is hidden for members", async () => {
73115
render(
74-
<NavbarView user={MockUser2} onSignOut={noop} canViewAuditLog={false} />,
116+
<NavbarView
117+
user={MockUser2}
118+
onSignOut={noop}
119+
canViewAuditLog={false}
120+
canViewDeployment
121+
/>,
75122
)
76123
const auditLink = screen.queryByText(navLanguage.audit)
77124
expect(auditLink).not.toBeInTheDocument()
78125
})
126+
127+
it("deployment nav link has the correct href", async () => {
128+
render(
129+
<NavbarView
130+
user={MockUser}
131+
onSignOut={noop}
132+
canViewAuditLog
133+
canViewDeployment
134+
/>,
135+
)
136+
const auditLink = await screen.findByText(navLanguage.deployment)
137+
expect((auditLink as HTMLAnchorElement).href).toContain(
138+
"/settings/deployment/general",
139+
)
140+
})
141+
142+
it("deployment nav link is hidden for members", async () => {
143+
render(
144+
<NavbarView
145+
user={MockUser2}
146+
onSignOut={noop}
147+
canViewAuditLog={false}
148+
canViewDeployment={false}
149+
/>,
150+
)
151+
const auditLink = screen.queryByText(navLanguage.deployment)
152+
expect(auditLink).not.toBeInTheDocument()
153+
})
79154
})

site/src/components/NavbarView/NavbarView.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ const NavItems: React.FC<
7373
)}
7474
{canViewDeployment && (
7575
<ListItem button className={styles.item}>
76-
<NavLink className={styles.link} to="/settings/deployment">
76+
<NavLink className={styles.link} to="/settings/deployment/general">
7777
{Language.deployment}
7878
</NavLink>
7979
</ListItem>

0 commit comments

Comments
 (0)