kammer/e2e/specs/flows/create-item.spec.ts
Christopher Mühl 307ef24b78 test: E2E test suite + handoff documentation
50 Playwright E2E tests across 13 spec files covering all routes and
user flows (items CRUD, check-out/in, locations, labels, scanning,
search/filter). Uses vitest as runner with playwright-core for browser
automation (bun-compatible alternative to @playwright/test).

Includes Gherkin .feature files as living documentation, test support
infrastructure (IDB seeding, item factories, assertion helpers, layout
measurement), and HANDOFF.md covering project state, deployment, and
open design decisions.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-26 20:53:08 +01:00

70 lines
2.2 KiB
TypeScript

/**
* @feature Create Item Flow
* @see e2e/features/flows/create-item.feature
*/
import { describe, test } from 'vitest';
import { setupBrowser } from '../../support/browser';
import { waitForAppReady, clearItems } from '../../support/seed';
import { expectVisible } from '../../support/expect';
const { getPage } = setupBrowser();
describe('Create Item Flow', () => {
test('create a basic durable item', async () => {
const page = getPage();
await page.goto('/');
await waitForAppReady(page);
await clearItems(page);
await page.goto('/items/new');
await waitForAppReady(page);
await page.getByLabel('Name *').fill('Electric Drill');
await page.getByLabel('Category').fill('Tools');
await page.getByLabel('Brand').fill('Bosch');
await page.getByRole('button', { name: 'Create Item' }).click();
await page.waitForURL(/\/items\//);
await expectVisible(page.getByText('Electric Drill'));
await expectVisible(page.getByText('Tools'));
});
test('created item appears in items list', async () => {
const page = getPage();
await page.goto('/');
await waitForAppReady(page);
await clearItems(page);
await page.goto('/items/new');
await waitForAppReady(page);
await page.getByLabel('Name *').fill('Hammer');
await page.getByRole('button', { name: 'Create Item' }).click();
await page.waitForURL(/\/items\//);
await page.goto('/items');
await waitForAppReady(page);
await expectVisible(page.getByText('Hammer'));
});
test('create a consumable with quantity tracking', async () => {
const page = getPage();
await page.goto('/');
await waitForAppReady(page);
await clearItems(page);
await page.goto('/items/new');
await waitForAppReady(page);
await page.getByLabel('Name *').fill('Printer Paper');
await page.getByLabel('Type').selectOption('consumable');
await page.getByLabel('Current').fill('8');
await page.getByLabel('Original').fill('10');
await page.getByLabel('Unit').fill('reams');
await page.getByRole('button', { name: 'Create Item' }).click();
await page.waitForURL(/\/items\//);
await expectVisible(page.getByText('Printer Paper'));
});
});