Fix pick list e2e flows

This commit is contained in:
beatz174-bit
2025-11-23 17:11:00 +10:00
parent da58c6ae03
commit 599f44dec8
3 changed files with 78 additions and 7 deletions
+28 -7
View File
@@ -1,25 +1,19 @@
import { expect, test } from '@playwright/test';
const areaName = 'Drinks';
const chocolateProduct = 'Mars Bar';
const chipsProduct = 'Smiths Salt n Vinegar 90g';
const additionalProduct = 'Pump 750';
test.describe('Active pick list', () => {
test('creates a pick list with category-prefilled items and adds more products', async ({ page }) => {
test('creates a pick list and adds products from the search bar', async ({ page }) => {
await page.goto('/');
await expect(page.getByRole('heading', { name: 'StockFill' })).toBeVisible();
await page.getByRole('link', { name: 'Create Pick List' }).click();
await page.getByLabel('Area').click();
await page.getByRole('option', { name: areaName }).first().click();
await page.getByRole('checkbox', { name: 'Chocolates' }).click();
await page.getByRole('checkbox', { name: 'Chips' }).click();
await page.getByRole('button', { name: 'Save Pick List' }).click();
await expect(page.getByRole('heading', { name: `${areaName} List` })).toBeVisible();
await expect(page.getByText(chocolateProduct).first()).toBeVisible();
await expect(page.getByText(chipsProduct).first()).toBeVisible();
const searchInput = page.getByPlaceholder('Search products');
await searchInput.click();
@@ -32,4 +26,31 @@ test.describe('Active pick list', () => {
await expect(page.getByText(additionalProduct).first()).toBeVisible();
await expect(page.getByRole('button', { name: 'Save and Return' })).toBeEnabled();
});
test('allows adding and editing products from the manage products screen', async ({ page }) => {
await page.goto('/');
await page.getByRole('link', { name: 'Manage Products' }).click();
await page.getByLabel('Name').click();
await page.getByLabel('Name').fill('Playwright Cola');
await page.getByLabel('Category').click();
await page.getByRole('option', { name: 'Drinks' }).click();
await page.getByRole('button', { name: 'Save Product' }).click();
await expect(page.getByText('Product added.')).toBeVisible();
await expect(page.getByText('Playwright Cola')).toBeVisible();
await page.getByRole('button', { name: 'Edit Playwright Cola' }).click();
const editNameField = page.getByLabel('Name').nth(1);
await expect(editNameField).toBeVisible();
await editNameField.fill('Playwright Cola Zero');
const saveButton = page.locator('[aria-label="Save product"]');
await expect(saveButton).toBeEnabled();
await saveButton.click();
await expect(page.getByText('Playwright Cola Zero')).toBeVisible();
});
});