// Regression probe (2026-11-02): the CONFIRM PROMISE API path must wire // the global modal's buttons too. purgeArchivedItems() (admin archived // page) opens confirmDialog() directly — no hx-confirm element fires — // and both buttons were dead whenever no hx-confirm had been clicked // first: the modal opened and Cancel/Confirm did nothing (user report). // The purge request itself is INTERCEPTED here — nothing is deleted. import { test, expect } from "@playwright/test"; const BASE = process.env.BH_BASE ?? "http://localhost:8765"; test("confirmDialog promise path wires Cancel/Confirm", async ({ page }) => { await page.addInitScript(() => { const t = new URLSearchParams(window.location.search).get("token"); if (t) localStorage.setItem("token", t); }); // testuser login via endpoint, then seed cookie+localStorage like the // other probes (rls_sweep pattern, kept inline to stay one file). const res = await page.request.post(`${BASE}/api/auth/login`, { data: { login: "testuser", password: "Test@Pass123!" }, }); const { access_token: token } = (await res.json()) as { access_token?: string }; expect(token).toBeTruthy(); await page.context().addCookies([{ name: "token", value: token!, url: BASE }]); await page.addInitScript((t) => localStorage.setItem("token", t), token!); // The purge POST is intercepted: Cancel/Confirm behavior is asserted // without ever deleting the dev data. let purgeRequested = false; await page.route("**/api/media-items/purge-archived", (route) => { purgeRequested = true; route.fulfill({ status: 200, contentType: "application/json", body: '{"purged":0}' }); }); await page.goto(`${BASE}/admin/archived`); await expect(page.locator("#confirm-modal")).toBeAttached(); // Fresh page: no hx-confirm has fired, so pre-fix the buttons were // unwired (data-wired absent) and Cancel did nothing. await page.getByRole("button", { name: "Purge All Archived" }).click(); const modal = page.locator("#confirm-modal"); await expect(modal).toBeVisible(); await expect(page.locator("#confirm-modal-cancel")).toHaveAttribute("data-wired", "1"); await page.locator("#confirm-modal-cancel").click(); await expect(modal).toBeHidden(); // Confirm path: modal closes AND the guarded request issues. await page.getByRole("button", { name: "Purge All Archived" }).click(); await expect(modal).toBeVisible(); await page.locator("#confirm-modal-accept").click(); await expect(modal).toBeHidden(); expect(purgeRequested).toBe(true); });