mirror of
https://github.com/azaion/ui.git
synced 2026-06-21 16:51:12 +00:00
1dd25edee3
AZ-466 — Destructive UX policy + ConfirmDialog a11y + no-alert (4pts):
src/components/ConfirmDialog.test.tsx (8 fast),
tests/destructive_ux.test.tsx (4 fast, AdminPage class-delete drift),
e2e/tests/destructive_ux.e2e.ts. New static checks STC-SEC7 (alert
allowlist) + STC-SEC8 (destructive-surfaces gated/drift) wired through
scripts/check-banned-deps.mjs reading tests/security/banned-deps.json.
AZ-475 — Numeric form input rejection (2pts):
tests/form_hygiene.test.tsx (3 fast). Documents two SettingsPage drifts:
silent zero coercion via parseInt(v)||0 and labels missing htmlFor.
AZ-462 — Overlay membership at in-window edges (2pts):
tests/overlay_membership.test.tsx (6 fast). Documents getTimeWindowDetections
strict < drift; AC-1 boundary tests are it.fails(); AC-2 / control PASS.
Mocks HTMLCanvasElement.getContext to capture strokeRect.
AZ-460 — Annotation save URL + payload contract (2pts):
tests/annotations_endpoint.test.tsx (6 fast),
e2e/tests/annotations_endpoint.e2e.ts. AC-1 URL canary PASSes; AC-2
payload missing 4 fields documented as it.fails(); AC-3 manual-draw
PASS, AI-suggestion-accept + bulk-edit-save QUARANTINE skip.
Test infrastructure:
- tests/setup.ts: NoopResizeObserver + NoopEventSource JSDOM polyfills.
- tests/msw/handlers/annotations.ts: doubly-prefixed paths matching
production calls (e.g. /api/annotations/annotations).
- tests/msw/handlers/flights.ts: plural /aircrafts paths.
Verification: bun run test:fast → 80 passed, 13 skipped (14 files).
scripts/run-tests.sh --static-only → 24/24 PASS (was 22; +STC-SEC7/SEC8).
Per-batch self-review verdict: PASS_WITH_WARNINGS. Cumulative review
of batches 04-06 due after batch 6 per implement/SKILL.md Step 14.5.
Report: _docs/03_implementation/batch_04_report.md.
Also includes the previously-untracked
_docs/03_implementation/cumulative_review_batches_01-03_report.md
generated at the start of this session before batch 4 began.
Co-authored-by: Cursor <cursoragent@cursor.com>
72 lines
2.7 KiB
TypeScript
72 lines
2.7 KiB
TypeScript
import { http } from 'msw'
|
|
import { jsonResponse, noContent, sse } from '../helpers'
|
|
import { seedFlights } from '../../fixtures/seed_flights'
|
|
import { seedAircraft } from '../../fixtures/seed_aircraft'
|
|
|
|
// Default `/api/flights/*` handlers. Live-GPS SSE returns a deterministic
|
|
// 3-event stream so AC-08 timing assertions have something to drive even
|
|
// without per-test overrides.
|
|
|
|
export const flightsHandlers = [
|
|
http.get('/api/flights', () => jsonResponse(seedFlights)),
|
|
|
|
http.get('/api/flights/:id', ({ params }) => {
|
|
const flight = seedFlights.find((f) => f.id === params.id)
|
|
if (!flight) return new Response(null, { status: 404 })
|
|
return jsonResponse(flight)
|
|
}),
|
|
|
|
http.post('/api/flights', async ({ request }) => {
|
|
const body = (await request.json()) as Record<string, unknown>
|
|
return jsonResponse({ id: 'flight-new', createdDate: new Date().toISOString(), ...body }, { status: 201 })
|
|
}),
|
|
|
|
http.put('/api/flights/:id', async ({ request, params }) => {
|
|
const body = (await request.json()) as Record<string, unknown>
|
|
return jsonResponse({ id: params.id, ...body })
|
|
}),
|
|
|
|
http.delete('/api/flights/:id', () => noContent()),
|
|
|
|
http.get('/api/flights/:id/waypoints', ({ params }) =>
|
|
jsonResponse([
|
|
{
|
|
id: 'wp-1',
|
|
flightId: params.id,
|
|
name: 'WP1',
|
|
latitude: 50.45,
|
|
longitude: 30.52,
|
|
order: 1,
|
|
},
|
|
]),
|
|
),
|
|
|
|
http.post('/api/flights/:id/waypoints', async ({ request, params }) => {
|
|
const body = (await request.json()) as Record<string, unknown>
|
|
return jsonResponse({ id: 'wp-new', flightId: params.id, ...body }, { status: 201 })
|
|
}),
|
|
|
|
http.get('/api/flights/:id/live-gps', ({ params }) =>
|
|
sse([
|
|
{ event: 'gps', data: { flightId: params.id, lat: 50.45, lon: 30.52, t: 0 }, id: '1' },
|
|
{ event: 'gps', data: { flightId: params.id, lat: 50.46, lon: 30.53, t: 1000 }, id: '2' },
|
|
{ event: 'gps', data: { flightId: params.id, lat: 50.47, lon: 30.54, t: 2000 }, id: '3' },
|
|
]),
|
|
),
|
|
|
|
// Production uses the plural path `/api/flights/aircrafts`. Singular alias kept
|
|
// for any future test that follows REST-singular conventions; production paths win.
|
|
http.get('/api/flights/aircrafts', () => jsonResponse(seedAircraft)),
|
|
http.get('/api/flights/aircraft', () => jsonResponse(seedAircraft)),
|
|
|
|
http.patch('/api/flights/aircrafts/:id', async ({ request, params }) => {
|
|
const body = (await request.json()) as Record<string, unknown>
|
|
return jsonResponse({ id: params.id, ...body })
|
|
}),
|
|
|
|
http.post('/api/flights/aircraft', async ({ request }) => {
|
|
const body = (await request.json()) as Record<string, unknown>
|
|
return jsonResponse({ id: 'aircraft-new', ...body }, { status: 201 })
|
|
}),
|
|
]
|