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) }) })