diff --git a/src/frontend/tests/helpers.ts b/src/frontend/tests/helpers.ts index f768625921..c39abded1d 100644 --- a/src/frontend/tests/helpers.ts +++ b/src/frontend/tests/helpers.ts @@ -81,3 +81,13 @@ export const navigate = async (page, url: string) => { await page.goto(url, { waitUntil: 'domcontentloaded' }); }; + +/** + * Perform a 'global search' on the provided page, for the provided query text + */ +export const globalSearch = async (page, query) => { + await page.getByLabel('open-search').click(); + await page.getByLabel('global-search-input').clear(); + await page.getByPlaceholder('Enter search text').fill(query); + await page.waitForTimeout(300); +}; diff --git a/src/frontend/tests/pages/pui_sales_order.spec.ts b/src/frontend/tests/pages/pui_sales_order.spec.ts index 75754b36e4..ab766899b5 100644 --- a/src/frontend/tests/pages/pui_sales_order.spec.ts +++ b/src/frontend/tests/pages/pui_sales_order.spec.ts @@ -1,6 +1,7 @@ import { test } from '../baseFixtures.ts'; import { clearTableFilters, + globalSearch, navigate, setTableChoiceFilter } from '../helpers.ts'; @@ -182,13 +183,7 @@ test('Sales Orders - Shipments', async ({ page }) => { await page.getByRole('button', { name: 'Cancel' }).click(); // Search for shipment by tracking number - await page.getByLabel('open-search').click(); - - await page.getByLabel('global-search-input').clear(); - - await page.waitForTimeout(250); - await page.getByLabel('global-search-input').fill('TRK-002'); - await page.waitForTimeout(250); + await globalSearch(page, 'TRK-002'); await page .getByText(/SO0009/) @@ -196,13 +191,7 @@ test('Sales Orders - Shipments', async ({ page }) => { .click(); // Search for shipment by invoice number - await page.getByLabel('open-search').click(); - - await page.getByLabel('global-search-input').clear(); - - await page.waitForTimeout(250); - await page.getByLabel('global-search-input').fill('INV-123'); - await page.waitForTimeout(250); + await globalSearch(page, 'INV-123'); await page .getByText(/SO0025/)