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

test("German pull request URL validation uses compound hyphens", WEB, async ({ t3, app, browser, screen }) => {
  const project = await t3.project("German spelling demo");
  await runPromise(run("git", ["remote", "add", "origin", "https://github.com/pingdotgg/t3code.git"], { cwd: project }));
  const thread = await t3.thread({ project, title: "German spelling", messages: ["Start"] });
  await browser.setViewport({ width: 1280, height: 800 });
  await t3.open("/settings/general");
  await screen.getByLabel("Language", { exact: true }).tap();
  await screen.getByText("Deutsch", { exact: true }).tap();
  await screen.getByLabel("Sprache", { exact: true }).waitFor();
  await t3.open("/");
  await browser.locator('[data-slot="combobox-trigger"][aria-label^="Branch:"]:visible').first().click();
  await screen.getByPlaceholder(/Refs durchsuchen|Referenzen durchsuchen|Search refs/).fill("#42");
  await screen.getByRole("option", /Pull Request auschecken/).tap();
  const dialog = screen.getByRole("dialog", "Pull Request auschecken");
  await dialog.getByText("Improve terminal navigation shortcuts and streamline git action PR flow", { exact: true }).waitFor();
  await dialog.getByRole("textbox").fill("not-a-pr");
  await dialog.getByText(/Verwende eine/).waitFor();
  await app.screenshot("german-pull-request-url-validation");
  await expect(dialog).toContainText("Verwende eine Pull-Request-URL, einen Checkout-Befehl, 123 oder #123.");
});
