Fix tests

This commit is contained in:
Presley Pizzo
2022-10-19 16:03:13 +00:00
parent bb2f0f368f
commit 6174b4f10b
4 changed files with 14 additions and 16 deletions
@@ -27,7 +27,7 @@ export type PaginationWidgetProps = {
const range = (start: number, stop: number, step = 1) =>
Array.from({ length: (stop - start) / step + 1 }, (_, i) => start + i * step)
export const DEFAULT_RECORDS_PER_PAGE = 2
export const DEFAULT_RECORDS_PER_PAGE = 25
// Number of pages to the left or right of the current page selection.
const PAGE_NEIGHBORS = 1
// Number of pages displayed for cases where there are multiple ellipsis showing. This can be
@@ -220,7 +220,7 @@ describe("WorkspacePage", () => {
await waitFor(() =>
expect(api.startWorkspace).toBeCalledWith(
"test-workspace",
"test-outdated-workspace",
"test-template-version",
),
)
@@ -1,5 +1,4 @@
import { screen } from "@testing-library/react"
import userEvent from "@testing-library/user-event"
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"
@@ -35,21 +34,19 @@ describe("WorkspacesPage", () => {
it("renders a filled workspaces page", async () => {
// When
render(<WorkspacesPage />)
const { container } = render(<WorkspacesPage />)
// Then
await screen.findByText(MockWorkspace.name)
})
it("navigates to the next page of workspaces", async () => {
const user = userEvent.setup()
const { container } = render(<WorkspacesPage />)
const nextPage = await screen.findByRole("button", { name: "Next page" })
expect(nextPage).toBeEnabled()
await user.click(nextPage)
const pageButtons = await container.querySelectorAll(
`button[name="Page button"]`,
)
expect(pageButtons.length).toBe(2)
await waitFor(async () => {
const prevPage = await screen.findByRole("button", { name: "Previous page" })
expect(prevPage).toBeDisabled()
const pageButtons = await container.querySelectorAll(
`button[name="Page button"]`,
)
expect(pageButtons.length).toBe(2)
}, { timeout: 2000 })
await screen.findByText(MockWorkspace.name)
})
})
@@ -5,6 +5,7 @@ import { createMachine, assign } from "xstate"
export const deploymentFlagsMachine = createMachine(
{
id: "deploymentFlagsMachine",
predictableActionArguments: true,
initial: "idle",
schema: {
context: {} as {