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

test("SSH clone destinations preserve hashes in both layouts", WEB, async ({ t3, app, screen, browser }) => {
  await t3.project("Demo");
  await t3.open();
  const remote = "ssh://git@forge.example/team#1/spec#2026.git";
  const openDestination = async () => {
    await screen.getByRole("combobox", "Projects", { exact: true }).tap();
    await screen.getByRole("option", "Add project", { exact: true }).tap();
    await screen.getByText("Git URL", { exact: true }).tap();
    await screen.getByRole("combobox").fill(remote);
    await browser.keyboard.press("Enter");
    await screen.getByRole("button", "Create & Clone", { exact: false }).waitFor();
    await screen.getByText("Loading folders...", { exact: true }).waitFor({ state: "hidden" });
  };
  await openDestination();
  await app.screenshot("flat-destination");
  const flat = await screen.getByRole("combobox").getAttribute("value");
  await browser.keyboard.press("Escape");
  await t3.open("/settings/threads");
  await screen.getByRole("switch", "Clone into host folders", { exact: true }).tap();
  await t3.open();
  await openDestination();
  await app.screenshot("host-folder-destination");
  await expect(screen.getByRole("combobox")).toHaveValue("~/forge.example/team#1/spec#2026");
  expect(flat).toBe("~/spec#2026");
});
