[UI] playwright updates (#13231)

* [UI] playwright updates

- Increased coverage
- various tweaks / fixes

* Additional updates

* Robustify further
This commit is contained in:
Oliver authored and GitHub committed 2026-11-09 22:57:13 +11:00
1 parent 2497dd5425
commit 48ec9d1dd2
18 files changed
+1583 -74

No files matched your search

@@ -1,6 +1,6 @@
import { expect } from '@playwright/test';
import { createApi } from '../api.ts';
import { test } from '../baseFixtures.ts';
import { generateUUID, test } from '../baseFixtures.ts';
import { readeruser, stevenuser } from '../defaults.ts';
import {
activateCalendarView,
@@ -611,6 +611,8 @@ test('Purchase Orders - Receive Items', async ({ browser }) => {
});
test('Purchase Orders - Custom Location', async ({ browser }) => {
// Unique batch code, so that retries do not match items from earlier attempts
const batchCode = `po-custom-location-${generateUUID().slice(0, 8)}`;
const page = await doCachedLogin(browser);
await navigate(page, 'purchasing/purchase-order/14/line-items');
@@ -642,8 +644,20 @@ test('Purchase Orders - Custom Location', async ({ browser }) => {
await row.getByLabel(/row-action-menu-/i).click();
await page.getByRole('menuitem', { name: 'Receive line item' }).click();
await page.getByLabel('tree-field-location').fill('storage room a');
await page.getByText('Storage Room A (purple door)').click();
// Wait for the form to apply its initial data (the order's destination),
// otherwise it can overwrite the location selected below
const locationField = page.getByLabel('tree-field-location');
await expect(locationField).toHaveValue(/Mechanical Lab/);
await expect(async () => {
await locationField.fill('storage room a');
await page
.getByText('Storage Room A (purple door)')
.click({ timeout: 5000 });
await expect(locationField).toHaveValue(/Storage Room A/, {
timeout: 2000
});
}).toPass({ timeout: 30000 });
await page.getByLabel('number-field-quantity').fill('1');
await page.waitForTimeout(500);
@@ -651,11 +665,14 @@ test('Purchase Orders - Custom Location', async ({ browser }) => {
await page.getByLabel('action-button-assign-batch-').click();
await page
.getByLabel('text-field-line_batch_code', { exact: true })
.fill('po-custom-location-test');
.fill(batchCode);
// Short timeout to allow for debouncing
await page.waitForTimeout(200);
// Ensure the selected location has not been reset
await expect(locationField).toHaveValue(/Storage Room A/);
await page.getByRole('button', { name: 'Submit' }).click();
await page.getByText('Items received').waitFor();
@@ -664,11 +681,11 @@ test('Purchase Orders - Custom Location', async ({ browser }) => {
await loadTab(page, 'Received Stock');
await clearTableFilters(page);
await tableSearch(page, 'po-custom-location-test');
await tableSearch(page, batchCode);
const receivedRow = page
.getByRole('row')
.filter({ hasText: 'po-custom-location-test' })
.filter({ hasText: batchCode })
.first();
await expect(receivedRow).toContainText('Storage Room A');
@@ -687,7 +704,7 @@ test('Purchase Orders - Custom Location', async ({ browser }) => {
expect(targetLocation).toBeTruthy();
const items = await api
.get('stock/', { params: { batch: 'po-custom-location-test' } })
.get('stock/', { params: { batch: batchCode } })
.then((res) => res.json());
expect(items.length).toBeGreaterThan(0);