import { expect } from "e2e";
import { test, WEB } from "./t3.ts";

test("Hosted app loads without URL.canParse", WEB, async ({ app, browser, screen }) => {
  await browser.addInitScript(() => { delete (URL as unknown as { canParse?: unknown }).canParse; });
  await app.open("/");
  try {
    await expect(screen.getByText("No computer connected", { exact: true })).toBeVisible({ timeout: 120_000 });
  } finally {
    await browser.evaluate(() => {
      for (const element of document.querySelectorAll("pre")) {
        element.textContent = element.textContent?.replace(/http:\/\/127\.0\.0\.1:\d+\/[^\s)]+/g, "[local application bundle]") ?? "";
      }
    });
    await app.screenshot("hosted-without-url-canparse");
  }
});
