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

test("One-letter schemes stay links while explicit file URLs open files", WEB, async ({ t3, app, screen }) => {
  const project = await t3.project("demo", { "README.md": "# Link proof\n\nExplicit file links still open this README.\n" });
  const thread = await t3.thread({ project, title: "Windows link schemes", messages: ["Ready for link verification."] });
  await t3.open(thread);
  const file = `file:///${project.replaceAll("\\", "/")}/README.md`;
  await screen.getByRole("textbox").fill(`Links: [one](d:alert(1)) [two](c:foo) [three](x:y) [readme](${file}) [web](https://example.com)`);
  await screen.getByRole("textbox").press("Enter");
  await screen.getByText("Links:", { exact: false }).first().waitFor({ state: "visible" });
  await app.screenshot("rendered-links");
  await expect(screen.getByRole("link", "one", { exact: true })).toBeVisible();
  await expect(screen.getByRole("link", "two", { exact: true })).toBeVisible();
  await expect(screen.getByRole("link", "three", { exact: true })).toBeVisible();
  await screen.getByRole("link", "README.md", { exact: false }).first().tap();
  await app.screenshot("explicit-file-open");
  await expect(screen.getByText("Explicit file links still open this README.", { exact: false })).toBeVisible();
});
