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

test("Projects display favicons for unordered HTML rel tokens", WEB, async ({ t3, app, screen, browser }) => {
  const icon = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32"><rect width="32" height="32" rx="6" fill="#ef2222"/><circle cx="16" cy="16" r="9" fill="#ffdf00"/></svg>';
  const declarations = [
    ["control", "icon"],
    ["html-icon-shortcut", "icon shortcut"],
    ["html-shortcut-icon-preload", "shortcut icon preload"],
    ["html-mixedcase", "Apple-Touch-Icon\tICON"],
  ];
  for (const [title, rel] of declarations) {
    await t3.project(title!, { "index.html": `<link rel="${rel}" href="brand.svg" />`, "brand.svg": icon });
  }
  await t3.project("route-icon-shortcut", {
    "src/routes/__root.tsx": 'export const Route = createRootRoute({ head: () => ({ links: [{ rel: "icon shortcut", href: "/brand.svg" }] }) });',
    "public/brand.svg": icon,
  });
  await t3.open();
  await screen.getByRole("combobox", "Projects").tap();
  await browser.locator('[role="option"]:has-text("control") img:not(.hidden)').waitFor();
  await app.screenshot("project-favicons");
  await expect(browser.locator('[role="option"] img:not(.hidden)')).toHaveCount(5);
});
