From d5930df7d41e928986cbf28bf1d70a44673ab57e Mon Sep 17 00:00:00 2001 From: Eduardo Umpierre Date: Tue, 4 Feb 2025 15:44:52 -0300 Subject: [PATCH] Refactor goToShop function --- tests/e2e-pw/utils/shopper-navigation.ts | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/tests/e2e-pw/utils/shopper-navigation.ts b/tests/e2e-pw/utils/shopper-navigation.ts index 1d8ebdecc02..6c8b5547414 100644 --- a/tests/e2e-pw/utils/shopper-navigation.ts +++ b/tests/e2e-pw/utils/shopper-navigation.ts @@ -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 (