@@ -15,6 +15,7 @@ import { server } from "testHelpers/server"
15
15
16
16
import * as CreateDayString from "utils/createDayString"
17
17
import AuditPage from "./AuditPage"
18
+ import { DEFAULT_RECORDS_PER_PAGE } from "components/PaginationWidget/utils"
18
19
19
20
interface RenderPageOptions {
20
21
filter ?: string
@@ -67,6 +68,27 @@ describe("AuditPage", () => {
67
68
screen . getByTestId ( `audit-log-row-${ MockAuditLog2 . id } ` )
68
69
} )
69
70
71
+ it ( "renders page 5" , async ( ) => {
72
+ // Given
73
+ const page = 5
74
+ const getAuditLogsSpy = jest . spyOn ( API , "getAuditLogs" ) . mockResolvedValue ( {
75
+ audit_logs : [ MockAuditLog , MockAuditLog2 ] ,
76
+ count : 2 ,
77
+ } )
78
+
79
+ // When
80
+ await renderPage ( { page : page } )
81
+
82
+ // Then
83
+ expect ( getAuditLogsSpy ) . toBeCalledWith ( {
84
+ limit : DEFAULT_RECORDS_PER_PAGE ,
85
+ offset : DEFAULT_RECORDS_PER_PAGE * ( page - 1 ) ,
86
+ q : "" ,
87
+ } )
88
+ screen . getByTestId ( `audit-log-row-${ MockAuditLog . id } ` )
89
+ screen . getByTestId ( `audit-log-row-${ MockAuditLog2 . id } ` )
90
+ } )
91
+
70
92
describe ( "Filtering" , ( ) => {
71
93
it ( "filters by URL" , async ( ) => {
72
94
const getAuditLogsSpy = jest
@@ -76,7 +98,11 @@ describe("AuditPage", () => {
76
98
const query = "resource_type:workspace action:create"
77
99
await renderPage ( { filter : query } )
78
100
79
- expect ( getAuditLogsSpy ) . toBeCalledWith ( { limit : 25 , offset : 1 , q : query } )
101
+ expect ( getAuditLogsSpy ) . toBeCalledWith ( {
102
+ limit : DEFAULT_RECORDS_PER_PAGE ,
103
+ offset : 0 ,
104
+ q : query ,
105
+ } )
80
106
} )
81
107
82
108
it ( "resets page to 1 when filter is changed" , async ( ) => {
@@ -91,8 +117,8 @@ describe("AuditPage", () => {
91
117
92
118
await waitFor ( ( ) =>
93
119
expect ( getAuditLogsSpy ) . toBeCalledWith ( {
94
- limit : 25 ,
95
- offset : 1 ,
120
+ limit : DEFAULT_RECORDS_PER_PAGE ,
121
+ offset : 0 ,
96
122
q : query ,
97
123
} ) ,
98
124
)
0 commit comments