Skip to content

Commit

Permalink
chore: add users link to nav bar (#1797)
Browse files Browse the repository at this point in the history
* chore: add users link to nav bar

resolves #1746

* fix test names
  • Loading branch information
Kira-Pilot committed May 26, 2022
1 parent 781f3d0 commit b4c41d3
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 3 deletions.
20 changes: 19 additions & 1 deletion site/src/components/NavbarView/NavbarView.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { screen } from "@testing-library/react"
import React from "react"
import { MockUser } from "../../testHelpers/entities"
import { render } from "../../testHelpers/renderHelpers"
import { NavbarView } from "./NavbarView"
import { Language as navLanguage, NavbarView } from "./NavbarView"

describe("NavbarView", () => {
const noop = () => {
Expand All @@ -16,6 +16,24 @@ describe("NavbarView", () => {
await screen.findAllByText("Coder", { exact: false })
})

it("workspaces nav link has the correct href", async () => {
render(<NavbarView user={MockUser} onSignOut={noop} displayAdminDropdown />)
const workspacesLink = await screen.findByText(navLanguage.workspaces)
expect((workspacesLink as HTMLAnchorElement).href).toContain("/workspaces")
})

it("templates nav link has the correct href", async () => {
render(<NavbarView user={MockUser} onSignOut={noop} displayAdminDropdown />)
const templatesLink = await screen.findByText(navLanguage.templates)
expect((templatesLink as HTMLAnchorElement).href).toContain("/templates")
})

it("users nav link has the correct href", async () => {
render(<NavbarView user={MockUser} onSignOut={noop} displayAdminDropdown />)
const userLink = await screen.findByText(navLanguage.users)
expect((userLink as HTMLAnchorElement).href).toContain("/users")
})

it("renders profile picture for user", async () => {
// Given
const mockUser = {
Expand Down
15 changes: 13 additions & 2 deletions site/src/components/NavbarView/NavbarView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ export interface NavbarViewProps {
displayAdminDropdown: boolean
}

export const Language = {
workspaces: "Workspaces",
templates: "Templates",
users: "Users",
}

export const NavbarView: React.FC<NavbarViewProps> = ({ user, onSignOut, displayAdminDropdown }) => {
const styles = useStyles()
return (
Expand All @@ -27,12 +33,17 @@ export const NavbarView: React.FC<NavbarViewProps> = ({ user, onSignOut, display
</ListItem>
<ListItem button className={styles.item}>
<NavLink className={styles.link} to="/workspaces">
Workspaces
{Language.workspaces}
</NavLink>
</ListItem>
<ListItem button className={styles.item}>
<NavLink className={styles.link} to="/templates">
Templates
{Language.templates}
</NavLink>
</ListItem>
<ListItem button className={styles.item}>
<NavLink className={styles.link} to="/users">
{Language.users}
</NavLink>
</ListItem>
</List>
Expand Down

0 comments on commit b4c41d3

Please sign in to comment.