@@ -5,6 +5,11 @@ import { QuotaPage } from '../utils/quota-page';
55
66const DEFAULT_PAGE_SIZE = 50 ;
77
8+ // Regex patterns for pagination tests
9+ const ENTITY_TYPE_REGEX = / c l i e n t - i d | u s e r | i p / ;
10+ const PAGE_0_REGEX = / p a g e = 0 / ;
11+ const PAGE_1_REGEX = / p a g e = 1 / ;
12+
813test . describe ( 'Quotas - Pagination' , ( ) => {
914 test ( 'should not show pagination controls when quotas count is less than page size' , async ( { page } ) => {
1015 await test . step ( 'Navigate to quotas page' , async ( ) => {
@@ -13,10 +18,7 @@ test.describe('Quotas - Pagination', () => {
1318
1419 await test . step ( 'Verify pagination is not visible for small datasets' , async ( ) => {
1520 // Check if table has rows but pagination is not present
16- const rowCount = await page
17- . locator ( 'tr' )
18- . filter ( { hasText : / c l i e n t - i d | u s e r | i p / } )
19- . count ( ) ;
21+ const rowCount = await page . locator ( 'tr' ) . filter ( { hasText : ENTITY_TYPE_REGEX } ) . count ( ) ;
2022
2123 // If there are less than 50 items, pagination should not be visible
2224 if ( rowCount < DEFAULT_PAGE_SIZE ) {
@@ -77,7 +79,7 @@ test.describe('Quotas - Pagination', () => {
7779 await quotaPage . clickNextPage ( ) ;
7880
7981 // Wait for page navigation to complete
80- await page . waitForURL ( / p a g e = 1 / , { timeout : 5000 } ) ;
82+ await page . waitForURL ( PAGE_1_REGEX , { timeout : 5000 } ) ;
8183 } ) ;
8284
8385 await test . step ( 'Verify page 1 quotas are no longer visible on page 2' , async ( ) => {
@@ -149,7 +151,7 @@ test.describe('Quotas - Pagination', () => {
149151
150152 await test . step ( 'Navigate to page 2' , async ( ) => {
151153 await quotaPage . clickNextPage ( ) ;
152- await page . waitForURL ( / p a g e = 1 / , { timeout : 5000 } ) ;
154+ await page . waitForURL ( PAGE_1_REGEX , { timeout : 5000 } ) ;
153155 } ) ;
154156
155157 await test . step ( 'Capture page 2 quotas' , async ( ) => {
@@ -171,7 +173,7 @@ test.describe('Quotas - Pagination', () => {
171173
172174 await test . step ( 'Navigate back to page 1' , async ( ) => {
173175 await quotaPage . clickPreviousPage ( ) ;
174- await page . waitForURL ( / p a g e = 0 / , { timeout : 5000 } ) ;
176+ await page . waitForURL ( PAGE_0_REGEX , { timeout : 5000 } ) ;
175177 } ) ;
176178
177179 await test . step ( 'Verify page 1 quotas are visible again' , async ( ) => {
@@ -239,10 +241,10 @@ test.describe('Quotas - Pagination', () => {
239241
240242 await test . step ( 'Navigate to page 2' , async ( ) => {
241243 await quotaPage . clickNextPage ( ) ;
242- await page . waitForURL ( / p a g e = 1 / , { timeout : 5000 } ) ;
244+ await page . waitForURL ( PAGE_1_REGEX , { timeout : 5000 } ) ;
243245 } ) ;
244246
245- await test . step ( 'Verify URL contains pagination state' , async ( ) => {
247+ await test . step ( 'Verify URL contains pagination state' , ( ) => {
246248 const url = page . url ( ) ;
247249 expect ( url ) . toContain ( 'page=1' ) ;
248250 expect ( url ) . toContain ( `pageSize=${ PAGE_SIZE } ` ) ;
0 commit comments