File tree Expand file tree Collapse file tree 2 files changed +5
-9
lines changed Expand file tree Collapse file tree 2 files changed +5
-9
lines changed Original file line number Diff line number Diff line change @@ -19,8 +19,8 @@ export function usePagination(
19
19
) : UsePaginationResult {
20
20
const { searchParams, onSearchParamsChange } = options ;
21
21
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 ;
24
24
25
25
return {
26
26
page,
Original file line number Diff line number Diff line change 1
1
import { screen , waitFor , within } from "@testing-library/react" ;
2
2
import userEvent from "@testing-library/user-event" ;
3
3
import { API } from "api/api" ;
4
- import type { Workspace } from "api/typesGenerated" ;
4
+ import type { Template , WorkspacesResponse , Workspace } from "api/typesGenerated" ;
5
5
import { http , HttpResponse } from "msw" ;
6
6
import {
7
7
MockDormantOutdatedWorkspace ,
@@ -28,18 +28,14 @@ describe("WorkspacesPage", () => {
28
28
} ) ;
29
29
30
30
it ( "renders an empty workspaces page" , async ( ) => {
31
- // Given
32
31
server . use (
33
32
http . get ( "/api/v2/workspaces" , async ( ) => {
34
- return HttpResponse . json ( { workspaces : [ ] , count : 0 } ) ;
33
+ return HttpResponse . json < WorkspacesResponse > ( { workspaces : [ ] , count : 0 } ) ;
35
34
} ) ,
36
35
) ;
37
36
38
- // When
39
37
renderWithAuth ( < WorkspacesPage /> ) ;
40
-
41
- // Then
42
- await screen . findByText ( "Create a workspace" ) ;
38
+ await screen . findByRole ( "heading" , { name : / C r e a t e a w o r k s p a c e / } ) ;
43
39
} ) ;
44
40
45
41
it ( "renders a filled workspaces page" , async ( ) => {
You can’t perform that action at this time.
0 commit comments