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

test("SCP paths with question marks suggest the repository folder", WEB, async ({ t3, app, screen, browser }) => {
  const project = await t3.project("demo");
  const thread = await t3.thread({ project, title: "Current work", messages: ["Start"] });
  await t3.open(thread);
  await screen.getByText("Start", { exact: true }).waitFor({ timeout: 30_000 });
  await browser.keyboard.press("Control+k");
  const palette = screen.getByRole("dialog", "Command palette");
  await palette.getByRole("combobox").fill("> Add project");
  await palette.getByText("Add project", { exact: true }).tap();
  await palette.getByRole("option", /^Git URL/).tap();
  await palette.getByRole("combobox").fill("git@host.example:team?region=us/repo.git");
  await browser.keyboard.press("Enter");
  await palette.getByRole("button", /^(?:Create & )?Clone \(/).waitFor();
  await app.screenshot("suggested-repository-folder");
  expect(await palette.getByRole("combobox").getAttribute("value")).toMatch(/\/repo$/);
});
