mirror of
https://github.com/azaion/ui.git
synced 2026-06-21 10:41:10 +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>
65 lines
2.0 KiB
TypeScript
65 lines
2.0 KiB
TypeScript
import '@testing-library/jest-dom/vitest'
|
|
import { afterAll, afterEach, beforeAll } from 'vitest'
|
|
import { cleanup } from '@testing-library/react'
|
|
import { server } from './msw/server'
|
|
import { setToken, setNavigateToLogin } from '../src/api/client'
|
|
|
|
// JSDOM polyfills for browser APIs production code touches at mount time.
|
|
// These are no-op stubs — tests that exercise the actual behavior install
|
|
// richer fakes per-suite (e.g. `tests/sse_lifecycle.test.tsx` overrides
|
|
// `globalThis.EventSource` and restores it; that pattern still works).
|
|
class NoopResizeObserver {
|
|
observe(): void {}
|
|
unobserve(): void {}
|
|
disconnect(): void {}
|
|
}
|
|
|
|
class NoopEventSource extends EventTarget {
|
|
url: string
|
|
readyState: 0 | 1 | 2 = 0
|
|
onopen: ((e: Event) => void) | null = null
|
|
onmessage: ((e: MessageEvent) => void) | null = null
|
|
onerror: ((e: Event) => void) | null = null
|
|
constructor(url: string | URL) {
|
|
super()
|
|
this.url = String(url)
|
|
}
|
|
close(): void {
|
|
this.readyState = 2
|
|
}
|
|
static readonly CONNECTING = 0
|
|
static readonly OPEN = 1
|
|
static readonly CLOSED = 2
|
|
}
|
|
|
|
const g = globalThis as unknown as {
|
|
ResizeObserver?: typeof NoopResizeObserver
|
|
EventSource?: typeof NoopEventSource
|
|
}
|
|
if (!g.ResizeObserver) g.ResizeObserver = NoopResizeObserver
|
|
if (!g.EventSource) g.EventSource = NoopEventSource
|
|
|
|
// MSW boundary configured per AZ-456 AC-3:
|
|
// - All outbound /api/<service>/... fetches MUST be intercepted.
|
|
// - A test missing a handler for a network request is a HARD failure
|
|
// (onUnhandledRequest: 'error'). This is how AC-3 is enforced for
|
|
// fast-profile tests; a leaked external request would otherwise
|
|
// escape the test environment silently.
|
|
beforeAll(() => {
|
|
server.listen({ onUnhandledRequest: 'error' })
|
|
})
|
|
|
|
afterEach(() => {
|
|
cleanup()
|
|
server.resetHandlers()
|
|
setToken(null)
|
|
setNavigateToLogin(() => {
|
|
/* default no-op for tests; production accessor restored implicitly
|
|
on next module reload — tests must re-seed if they assert on it. */
|
|
})
|
|
})
|
|
|
|
afterAll(() => {
|
|
server.close()
|
|
})
|