Skip to content

feat: add "on this page" to empty table message when you're past page 1 #4886

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 9 commits into from
Nov 8, 2022
Merged
Show file tree
Hide file tree
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
Next Next commit
Fix tests
  • Loading branch information
presleyp committed Nov 8, 2022
commit 1e77742f52808eac333f821b5514d9de81ec0b0d
2 changes: 1 addition & 1 deletion site/src/components/Conditionals/ChooseOne.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export const ChooseOne = ({
}
if (conditionedOptions.some((cond) => cond.props.condition === undefined)) {
throw new Error(
"A non-final Cond in a ChooseOne does not have a condition prop.",
"A non-final Cond in a ChooseOne does not have a condition prop or the prop is undefined.",
)
}
const chosen = conditionedOptions.find((child) => child.props.condition)
Expand Down
1 change: 1 addition & 0 deletions site/src/components/UsersTable/UsersTable.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ describe("AuditPage", () => {
onActivateUser={() => jest.fn()}
onResetUserPassword={() => jest.fn()}
onUpdateUserRoles={() => jest.fn()}
isNonInitialPage={false}
/>,
)

Expand Down
1 change: 1 addition & 0 deletions site/src/components/UsersTable/UsersTableBody.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export const UsersTableBody: FC<
}) => {
const styles = useStyles()
const { t } = useTranslation("usersPage")
console.log(isNonInitialPage)

return (
<ChooseOne>
Expand Down
21 changes: 8 additions & 13 deletions site/src/pages/UsersPage/UsersPage.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { Role } from "../../api/typesGenerated"
import { Language as ResetPasswordDialogLanguage } from "../../components/Dialogs/ResetPasswordDialog/ResetPasswordDialog"
import { GlobalSnackbar } from "../../components/GlobalSnackbar/GlobalSnackbar"
import { Language as RoleSelectLanguage } from "../../components/RoleSelect/RoleSelect"
import { Language as UsersTableBodyLanguage } from "../../components/UsersTable/UsersTableBody"
import {
MockAuditorRole,
MockUser,
Expand Down Expand Up @@ -39,9 +38,8 @@ const suspendUser = async (setupActionSpies: () => void) => {
await user.click(firstMoreButton)

const menu = await screen.findByRole("menu")
const suspendButton = within(menu).getByText(
UsersTableBodyLanguage.suspendMenuItem,
)
const text = t("suspendMenuItem", { ns: "usersPage" })
const suspendButton = within(menu).getByText(text)

await user.click(suspendButton)

Expand Down Expand Up @@ -72,9 +70,8 @@ const deleteUser = async (setupActionSpies: () => void) => {
await user.click(selectedMoreButton)

const menu = await screen.findByRole("menu")
const deleteButton = within(menu).getByText(
UsersTableBodyLanguage.deleteMenuItem,
)
const text = t("deleteMenuItem", { ns: "usersPage" })
const deleteButton = within(menu).getByText(text)

await user.click(deleteButton)

Expand Down Expand Up @@ -107,9 +104,8 @@ const activateUser = async (setupActionSpies: () => void) => {
fireEvent.click(suspendedMoreButton)

const menu = screen.getByRole("menu")
const activateButton = within(menu).getByText(
UsersTableBodyLanguage.activateMenuItem,
)
const text = t("activateMenuItem", { ns: "usersPage" })
const activateButton = within(menu).getByText(text)
fireEvent.click(activateButton)

// Check if the confirm message is displayed
Expand All @@ -135,9 +131,8 @@ const resetUserPassword = async (setupActionSpies: () => void) => {
fireEvent.click(firstMoreButton)

const menu = screen.getByRole("menu")
const resetPasswordButton = within(menu).getByText(
UsersTableBodyLanguage.resetPasswordMenuItem,
)
const text = t("resetPasswordMenuItem", { ns: "usersPage" })
const resetPasswordButton = within(menu).getByText(text)

fireEvent.click(resetPasswordButton)

Expand Down
9 changes: 5 additions & 4 deletions site/src/pages/WorkspacesPage/WorkspacesPage.test.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import { screen, waitFor } from "@testing-library/react"
import { rest } from "msw"
import * as CreateDayString from "util/createDayString"
import { Language as WorkspacesTableBodyLanguage } from "../../components/WorkspacesTable/WorkspacesTableBody"
import { MockWorkspace } from "../../testHelpers/entities"
import { history, render } from "../../testHelpers/renderHelpers"
import { server } from "../../testHelpers/server"
import WorkspacesPage from "./WorkspacesPage"
import { i18n } from "i18n"

const { t } = i18n

describe("WorkspacesPage", () => {
beforeEach(() => {
Expand All @@ -27,9 +29,8 @@ describe("WorkspacesPage", () => {
render(<WorkspacesPage />)

// Then
await screen.findByText(
WorkspacesTableBodyLanguage.emptyCreateWorkspaceMessage,
)
const text = t("emptyCreateWorkspaceMessage", { ns: "workspacesPage" })
await screen.findByText(text)
})

it("renders a filled workspaces page", async () => {
Expand Down