Skip to content

Commit

Permalink
Refactor goToShop function
Browse files Browse the repository at this point in the history
  • Loading branch information
eduardoumpierre committed Feb 4, 2025
1 parent 710834b commit d5930df
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions tests/e2e-pw/utils/shopper-navigation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,21 @@ import { Page } from 'playwright/test';
*/
import { isUIUnblocked } from './helpers';

export const goToShop = async ( page: Page, pageNumber?: number ) => {
export const goToShop = async (
page: Page,
{ pageNumber, currency }: { pageNumber?: number; currency?: string } = {}
) => {
let url = '/shop/';

if ( pageNumber ) {
await page.goto( `/shop/page/` + pageNumber, { waitUntil: 'load' } );
} else {
await page.goto( `/shop/`, { waitUntil: 'load' } );
url += `page/${ pageNumber }/`;
}

if ( currency ) {
url += `?currency=${ currency }`;
}
};

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

export const goToProductPageBySlug = async (
Expand Down

0 comments on commit d5930df

Please sign in to comment.