# Testing Strategy Testing begins with the first implementation. ## Unit Test domain rules and pure services: - status transitions - listing requirements - cost basis - profit - valuation strategies - outlier handling - condition rules ## API / integration Test: - authentication - authorization - repositories - API validation - Product/provider mapping - inventory lifecycle - sales transactions - public/private DTO boundaries Run the isolated PostgreSQL/Redis integration suite with the test environment loaded into the shell: ```sh set -a . ./.env set +a npm run test:integration ``` The PostgreSQL database name must end in `_test`. The suite covers catalog, session, image derivative, listing visibility, Redis login throttling, acquisition, pricing observations/valuations, multi-item sales, audited sale voiding, and seller ownership persistence. ## Component Test important Vue components and composables. Every new or changed visual component must include a colocated Storybook story or an update to an existing story before its vertical slice is committed. For visual slices, run the complete Storybook gate from the repository root: ```sh npm run test --workspace=@pokemon-inventory/web npm run build --workspace=@pokemon-inventory/web npm run build-storybook --workspace=@pokemon-inventory/web npm run test-storybook ``` Stories should use mock fixture data and cover the component states that users can encounter, including keyboard focus, selected, disabled, loading, empty, error, responsive, and light/dark theme behavior where applicable. Do not add production domain behavior just to make a story render. ## E2E Core workflows: 1. Login 2. Add Product 3. Find/link provider mappings 4. Add Inventory Item 5. Upload images 6. Calculate pricing 7. Publish listing 8. Search public site 9. Record sale 10. View dashboard The authenticated browser suite currently covers the core catalog workflow and the Settings, Saved Views, and export-controls workflow. Both require the local admin credentials and services described in the repository setup docs. ## Accessibility Run automated accessibility checks and maintain manual keyboard/assistive technology coverage for critical workflows. ## CI GitHub Actions should run: - linting - unit tests - integration/API tests - component tests - E2E tests as appropriate - accessibility checks - build validation The Storybook build and interaction/accessibility runner are part of the visual-slice commit gate. Backend-only slices may omit them when no visual component or UI contract changes. Do not weaken or skip tests to obtain a passing build.