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

test("Clone URL query and fragment retain the same repository identity", WEB, async ({ t3, app, screen }) => {
  for (const [title, suffix] of [["Plain clone", ""], ["Query clone", "?view=compact"], ["Fragment clone", "#section"]]) {
    await t3.project(title, {
      ".git/config": `[remote "origin"]\n\turl = "https://github.com/owner/repo.git${suffix}"\n\tfetch = +refs/heads/*:refs/remotes/origin/*\n`,
      "README.md": `Synthetic checkout: https://github.com/owner/repo.git${suffix}\n`,
    });
  }
  await t3.open();
  await screen.getByRole("combobox", "Filter threads by project").tap();
  await app.screenshot("repository-identity");
  await expect(screen.getByRole("option", "owner/repo", { exact: true })).toBeVisible();
  await expect(screen.getByText("owner/repo.git", { exact: true })).toBeHidden();
  await expect(screen.getByRole("option", "Query clone", { exact: true })).toBeHidden();
  await expect(screen.getByRole("option", "Fragment clone", { exact: true })).toBeHidden();
  await expect(screen.getByRole("option", "Plain clone", { exact: true })).toBeHidden();
});
