Skip to content

Commit 330d91d

Browse files
committed
fix: get workspace tests passing
1 parent 86d19b8 commit 330d91d

File tree

2 files changed

+5
-9
lines changed

2 files changed

+5
-9
lines changed

site/src/hooks/usePagination.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ export function usePagination(
1919
): UsePaginationResult {
2020
const { searchParams, onSearchParamsChange } = options;
2121
const limit = DEFAULT_RECORDS_PER_PAGE;
22-
const rawPage = Number.parseInt(searchParams.get(paginationKey) || "0", 10);
23-
const page = Number.isNaN(rawPage) ? 1 : rawPage;
22+
const rawPage = Number.parseInt(searchParams.get(paginationKey) || "1", 10);
23+
const page = Number.isNaN(rawPage) || rawPage <= 0 ? 1 : rawPage;
2424

2525
return {
2626
page,

site/src/pages/WorkspacesPage/WorkspacesPage.test.tsx

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { screen, waitFor, within } from "@testing-library/react";
22
import userEvent from "@testing-library/user-event";
33
import { API } from "api/api";
4-
import type { Workspace } from "api/typesGenerated";
4+
import type { Template, WorkspacesResponse, Workspace } from "api/typesGenerated";
55
import { http, HttpResponse } from "msw";
66
import {
77
MockDormantOutdatedWorkspace,
@@ -28,18 +28,14 @@ describe("WorkspacesPage", () => {
2828
});
2929

3030
it("renders an empty workspaces page", async () => {
31-
// Given
3231
server.use(
3332
http.get("/api/v2/workspaces", async () => {
34-
return HttpResponse.json({ workspaces: [], count: 0 });
33+
return HttpResponse.json<WorkspacesResponse>({ workspaces: [], count: 0 });
3534
}),
3635
);
3736

38-
// When
3937
renderWithAuth(<WorkspacesPage />);
40-
41-
// Then
42-
await screen.findByText("Create a workspace");
38+
await screen.findByRole("heading", { name: /Create a workspace/ });
4339
});
4440

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

0 commit comments

Comments
 (0)