Skip to content

Commit d5930df

Browse files
Refactor goToShop function
1 parent 710834b commit d5930df

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

tests/e2e-pw/utils/shopper-navigation.ts

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,21 @@ import { Page } from 'playwright/test';
88
*/
99
import { isUIUnblocked } from './helpers';
1010

11-
export const goToShop = async ( page: Page, pageNumber?: number ) => {
11+
export const goToShop = async (
12+
page: Page,
13+
{ pageNumber, currency }: { pageNumber?: number; currency?: string } = {}
14+
) => {
15+
let url = '/shop/';
16+
1217
if ( pageNumber ) {
13-
await page.goto( `/shop/page/` + pageNumber, { waitUntil: 'load' } );
14-
} else {
15-
await page.goto( `/shop/`, { waitUntil: 'load' } );
18+
url += `page/${ pageNumber }/`;
19+
}
20+
21+
if ( currency ) {
22+
url += `?currency=${ currency }`;
1623
}
17-
};
1824

19-
export const goToShopWithCurrency = async ( page: Page, currency: string ) => {
20-
await page.goto( `/shop/?currency=${ currency }`, { waitUntil: 'load' } );
25+
await page.goto( url, { waitUntil: 'load' } );
2126
};
2227

2328
export const goToProductPageBySlug = async (

0 commit comments

Comments
 (0)