// One-off probe: does clicking an hx-confirm button open the CUSTOM // modal (#confirm-modal) or a native dialog? Clicks "Remove Feed" on a // hard-coded feed, then CANCELS whichever appears (nothing is deleted). import { test, expect } from "@playwright/test"; const BASE = process.env.BH_BASE ?? "http://localhost:8765"; const FEED = process.env.BH_FEED ?? ""; test.skip(!FEED, "set BH_FEED= against a running dev server"); test("hx-confirm uses the custom modal", async ({ page }) => { const nativeDialogs: string[] = []; page.on("console", (m) => { if (m.type() === "error" || m.type() === "warning") console.log("[console]", m.type(), m.text().slice(0, 300)); }); page.on("pageerror", (e) => console.log("[pageerror]", String(e).slice(0, 400))); page.on("dialog", async (d) => { nativeDialogs.push(d.message()); await d.dismiss(); // never accept }); // Login via the API form (session cookie sticks to the context). await page.request.post(`${BASE}/api/auth/login`, { data: { login: "testuser", password: "Test@Pass123!" }, }); await page.goto(`${BASE}/podcasts/${FEED}`); const modal = page.locator("#confirm-modal"); await expect(modal).toHaveCount(1); // the modal must exist on the page await expect(modal).toBeHidden(); await page.getByRole("button", { name: "Remove Feed" }).click(); if (nativeDialogs.length > 0) { throw new Error( `NATIVE dialog opened (${nativeDialogs[0]}) — htmx:confirm interceptor did not preventDefault`, ); } await expect(modal).toBeVisible({ timeout: 3000 }); await expect(page.locator("#confirm-modal-message")).toContainText("remove this feed"); // Cancel — no request fires. await page.locator("#confirm-modal-cancel").click(); await expect(modal).toBeHidden(); });