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

test("German custom source badge is searchable", WEB, async ({ t3, app, browser, screen }) => {
  const project = await t3.project("demo");
  await t3.thread({ project, title: "Shortcut search", messages: ["Start"], model: "default" });
  await browser.setViewport({ width: 1440, height: 1000 });
  await t3.open("/settings/general");
  await screen.getByRole("combobox", "Language", { exact: true }).tap();
  await screen.getByRole("option", "Deutsch", { exact: true }).tap();
  await t3.open("/settings/keybindings");
  await browser.locator('input[aria-label="Tastenkürzel durchsuchen"]').fill("Chat: Neu");
  await screen.getByRole("button", "Tastenkürzel für Chat: Neu bearbeiten: Ctrl+N", { exact: true }).tap();
  await browser.keyboard.press("Control+Alt+n");
  await screen.getByRole("button", "Speichern", { exact: true }).tap();
  await screen.getByText("Benutzerdefiniert", { exact: true }).waitFor();
  await app.screenshot("customized-shortcut");
  const search = browser.locator('input[aria-label="Tastenkürzel durchsuchen"]');
  await search.fill("Custom");
  await screen.getByText("Benutzerdefiniert", { exact: true }).waitFor();
  await app.screenshot("english-source-search");
  await search.fill("Benutzerdefiniert");
  await app.screenshot("translated-source-search");
  await expect(screen.getByText("Benutzerdefiniert", { exact: true })).toBeVisible();
  await search.fill("bEnUtZeRdEfInIeRt");
  await expect(screen.getByText("Benutzerdefiniert", { exact: true })).toBeVisible();
});
