# REF-TASK-004 — Establish narrow frontend HTTP test helpers

**Status:** Implemented  
**Kind:** Test-only refactor  
**Depends on:** None

## Problem and evidence

Frontend tests repeatedly define near-identical `jsonResponse` factories, reset CSRF state, install
global fetch mocks, and hand-code URL dispatch. Examples include `KdsPage.test.tsx`,
`LoginPage.test.tsx`, `MockingBirdConsolePage.test.tsx`, the three product-page test files, and API
client tests. The response factory is genuine shared test infrastructure; endpoint scripts often
encode scenario-specific ordering and are not automatically the same abstraction.

## Proposed change

Add narrowly named helpers under `frontend/src/test/` for constructing JSON responses and for safe
fetch installation/restoration. Evaluate a small route-aware scripted fetch helper only for tests
that already share the same request-matching invariant. Keep scenario state and assertions local.
Migrate a small representative set first, then the remaining exact duplicates in a separate
mechanical pass.

## Constraints and sequence

Do not create a generic mock framework, hide request assertions, reorder mocked calls, or move
production DTOs into test support. Preserve every test title and scenario ID. Compare failures from
one deliberately incorrect request before broad migration so helpers remain diagnostic.

## Validation

Run the migrated frontend test files after each batch, then the full frontend test suite and
`pnpm quality`. No production build/E2E is required because production code is unchanged.

## Guidance / ADR

REF-TASK-018 should document when shared test helpers are appropriate. No ADR.
