/** * @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')); }); });