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

test("French labels distinguish webhook replacement and spoken languages", WEB, async ({ t3, app, browser, screen }) => {
  const project = await t3.project("demo");
  await t3.thread({ project, title: "Translation example", model: "default", messages: ["Hello"] });
  await t3.open("/settings/general");
  await screen.getByLabel("Language", { exact: true }).tap();
  await screen.getByText("Français", { exact: true }).tap();
  await screen.getByLabel("Langue", { exact: true }).waitFor();
  await t3.open("/settings/scheduled-tasks");
  await screen.getByRole("button", "Nouvelle tâche", { exact: true }).tap();
  await browser.locator('#scheduled-task-title').fill("Repro webhook");
  await browser.locator('#scheduled-task-prompt').fill("Say hello");
  await screen.getByText("Sur webhook", { exact: true }).tap();
  await screen.getByRole("button", "Créer la tâche", { exact: true }).tap();
  await screen.getByRole("button", /Actions.*Repro webhook/).tap();
  await screen.getByRole("menuitem", "Modifier", { exact: true }).tap();
  await screen.getByRole("button", "Copier", { exact: true }).waitFor();
  await screen.getByRole("button", "Copier", { exact: true }).scrollIntoView();
  await app.screenshot("french-webhook-replacement");
  const webhookText = await browser.locator('body').textContent();
  await screen.getByRole("button", "Annuler", { exact: true }).tap();
  await t3.open("/settings/voice");
  await screen.getByRole("combobox", "Transcrire avec", { exact: true }).waitFor();
  await app.screenshot("french-voice-input");
  const voiceText = await browser.locator('body').textContent();
  await screen.getByRole("combobox", "Transcrire avec", { exact: true }).tap();
  await screen.getByRole("option").nth(1).tap();
  await screen.getByRole("button", /Filtrer par langue/).tap();
  await app.screenshot("french-spoken-language-search");
  const languageSearch = await browser.locator('[role="menu"] input').getAttribute("placeholder");
  expect(webhookText).not.toContain("Pivoter");
  expect(voiceText).not.toContain("Champ de saisie");
  expect(languageSearch).toBe("Rechercher une langue");
});
