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>
40 lines
1.2 KiB
TypeScript
40 lines
1.2 KiB
TypeScript
import type { Locator } from 'playwright-core';
|
|
import { expect } from 'vitest';
|
|
|
|
/**
|
|
* Assert that a Playwright locator is visible.
|
|
* Waits up to 5 seconds for the element to become visible.
|
|
*/
|
|
export async function expectVisible(locator: Locator, timeout = 5000) {
|
|
await locator.waitFor({ state: 'visible', timeout });
|
|
expect(await locator.isVisible()).toBe(true);
|
|
}
|
|
|
|
/**
|
|
* Assert that a Playwright locator is NOT visible.
|
|
* Waits briefly to ensure it doesn't appear.
|
|
*/
|
|
export async function expectNotVisible(locator: Locator, timeout = 2000) {
|
|
try {
|
|
await locator.waitFor({ state: 'hidden', timeout });
|
|
} catch {
|
|
// Element may not exist at all, which is fine
|
|
}
|
|
expect(await locator.isVisible()).toBe(false);
|
|
}
|
|
|
|
/**
|
|
* Assert that a locator has specific text content.
|
|
*/
|
|
export async function expectText(locator: Locator, text: string) {
|
|
await locator.waitFor({ state: 'visible', timeout: 5000 });
|
|
expect(await locator.textContent()).toBe(text);
|
|
}
|
|
|
|
/**
|
|
* Assert that a locator is disabled.
|
|
*/
|
|
export async function expectDisabled(locator: Locator) {
|
|
await locator.waitFor({ state: 'visible', timeout: 5000 });
|
|
expect(await locator.isDisabled()).toBe(true);
|
|
}
|