[AZ-460] [AZ-462] [AZ-466] [AZ-475] Batch 4 - destructive UX/forms/overlay/save

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>
This commit is contained in:
Oleksandr Bezdieniezhnykh
2026-05-11 04:15:01 +03:00
parent 2051088706
commit 1dd25edee3
20 changed files with 1812 additions and 32 deletions
+62
View File
@@ -0,0 +1,62 @@
import { test, expect } from '@playwright/test'
// AZ-466 — e2e companion for the destructive UX policy.
//
// AC-1 (FT-P-26): clicking Delete on a class → ConfirmDialog appears →
// Confirm fires the DELETE.
// AC-2 (FT-N-07): clicking Delete → Cancel → NO DELETE fires.
//
// Both currently `test.fail()` because production's class-delete is not yet
// gated by ConfirmDialog (see fast-profile drift documented in
// `tests/destructive_ux.test.tsx`).
//
// Requires the suite docker-compose stack and parent-suite `:test` images.
test.describe('AZ-466 — destructive UX (e2e companion)', () => {
test.fail('AC-1 (FT-P-26) — class-delete prompts ConfirmDialog before DELETE', async ({ page }) => {
const deletes: string[] = []
await page.route('**/api/admin/classes/**', async (route) => {
const req = route.request()
if (req.method() === 'DELETE') deletes.push(req.url())
await route.continue()
})
await page.goto('/admin')
const deleteBtn = page.locator('table tr button').first()
if (!(await deleteBtn.isVisible({ timeout: 5000 }).catch(() => false))) {
test.skip(true, 'Suite seed has no detection class to delete')
}
await deleteBtn.click()
// Drift: ConfirmDialog never mounts; DELETE fires immediately.
const dialog = page.getByRole('dialog')
await expect(dialog).toBeVisible({ timeout: 1000 })
expect(deletes).toHaveLength(0)
await page.getByRole('button', { name: /confirm/i }).click()
await page.waitForTimeout(500)
expect(deletes.length).toBeGreaterThan(0)
})
test.fail('AC-2 (FT-N-07) — class-delete Cancel suppresses DELETE entirely', async ({ page }) => {
const deletes: string[] = []
await page.route('**/api/admin/classes/**', async (route) => {
const req = route.request()
if (req.method() === 'DELETE') deletes.push(req.url())
await route.continue()
})
await page.goto('/admin')
const deleteBtn = page.locator('table tr button').first()
if (!(await deleteBtn.isVisible({ timeout: 5000 }).catch(() => false))) {
test.skip(true, 'Suite seed has no detection class to delete')
}
await deleteBtn.click()
const dialog = page.getByRole('dialog')
await expect(dialog).toBeVisible({ timeout: 1000 })
await page.getByRole('button', { name: /cancel/i }).click()
await page.waitForTimeout(500)
expect(deletes).toHaveLength(0)
})
})