Skip to content

feat: Add user menu #887

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Apr 7, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
refactor: Use Language in tests
  • Loading branch information
BrunoQuaresma committed Apr 7, 2022
commit d17a808dc3914d3f288b7e20d83bed1bbef73552
14 changes: 7 additions & 7 deletions site/src/components/Navbar/UserDropdown.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 { render } from "../../test_helpers"
import { MockUser } from "../../test_helpers/entities"
import { UserDropdown, UserDropdownProps } from "./UserDropdown"
import { Language, UserDropdown, UserDropdownProps } from "./UserDropdown"

const renderAndClick = async (props: Partial<UserDropdownProps> = {}) => {
render(<UserDropdown user={props.user ?? MockUser} onSignOut={props.onSignOut ?? jest.fn()} />)
Expand All @@ -14,9 +14,9 @@ describe("UserDropdown", () => {
describe("when the trigger is clicked", () => {
it("opens the menu", async () => {
await renderAndClick()
expect(screen.getByText(/account/i)).toBeDefined()
expect(screen.getByText(/documentation/i)).toBeDefined()
expect(screen.getByText(/sign out/i)).toBeDefined()
expect(screen.getByText(Language.accountLabel)).toBeDefined()
expect(screen.getByText(Language.docsLabel)).toBeDefined()
expect(screen.getByText(Language.signOutLabel)).toBeDefined()
})
})

Expand All @@ -25,7 +25,7 @@ describe("UserDropdown", () => {
it("calls the onSignOut function", async () => {
const onSignOut = jest.fn()
await renderAndClick({ onSignOut })
screen.getByText(/sign out/i).click()
screen.getByText(Language.signOutLabel).click()
expect(onSignOut).toBeCalledTimes(1)
})
})
Expand All @@ -34,7 +34,7 @@ describe("UserDropdown", () => {
it("has the correct link for the documentation item", async () => {
await renderAndClick()

const link = screen.getByText(/documentation/i).closest("a")
const link = screen.getByText(Language.docsLabel).closest("a")
if (!link) {
throw new Error("Anchor tag not found for the documentation menu item")
}
Expand All @@ -45,7 +45,7 @@ describe("UserDropdown", () => {
it("has the correct link for the account item", async () => {
await renderAndClick()

const link = screen.getByText(/account/i).closest("a")
const link = screen.getByText(Language.accountLabel).closest("a")
if (!link) {
throw new Error("Anchor tag not found for the account menu item")
}
Expand Down