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

test("Equivalent SCP and SSH remotes with repeated slashes share a repository group", WEB, async ({ t3, app, screen, browser }) => {
  await browser.setViewport({ width: 1280, height: 800 });
  const remoteConfig = (url: string) => ({ ".git/config": `[core]\n repositoryformatversion = 0\n bare = false\n[remote "origin"]\n url = ${url}\n fetch = +refs/heads/*:refs/remotes/origin/*\n` });
  const project = await t3.project("repo", remoteConfig("git@forge.example:/team//repo.git"));
  await t3.project("repo", remoteConfig("ssh://git@forge.example/team//repo.git"));
  await t3.project("ctl", remoteConfig("git@forge.example:team/ctl.git"));
  await t3.project("ctl", remoteConfig("ssh://git@forge.example/team/ctl.git"));
  const thread = await t3.thread({ project, title: "Repository grouping", messages: ["Start"] });
  await t3.open(thread);
  await screen.getByRole("combobox", "Projects").tap();
  await screen.getByRole("option", /^team\/ctl/).waitFor();
  await app.screenshot("repository-groups");
  await expect(screen.getByRole("option", /^team\/repo/)).toBeVisible();
});
