import { expect } from "e2e";
import { test, WEB } from "./t3.ts";
const locales = [
  {
    "locale": "ko",
    "name": "한국어",
    "language": "언어",
    "search": "설정 검색",
    "title": "프로젝트 개요",
    "queries": [
      "고정",
      "고정된 프로젝트는 프로젝트 선택기에서 맨 앞에 표시됩니다."
    ]
  }
];
test("Korean Pin terms find Project overview with readable fonts", WEB, async ({ t3, app, browser, screen }) => {
  await t3.project("server");
  await t3.open("/settings/general");
  let languageLabel = "Language";
  const found: boolean[] = [];
  for (const locale of locales) {
    await screen.getByLabel(languageLabel, { exact: true }).tap();
    await screen.getByText(locale.name, { exact: true }).tap();
    await screen.getByLabel(locale.language, { exact: true }).waitFor();
    languageLabel = locale.language;
    for (const [index, query] of locale.queries.entries()) {
      await screen.getByRole("combobox", locale.search).fill(query);
      // Keep the real search results readable in the recording.
      await browser.evaluate(() => new Promise<void>((resolve) => setTimeout(resolve, 1200)));
      await app.screenshot(`${locale.locale}-pin-${index}`);
      found.push(await screen.getByRole("option").filter({ hasText: locale.title }).isVisible());
    }
    await screen.getByRole("combobox", locale.search).fill("");
  }
  expect(found).toEqual(locales.flatMap(() => [true, true]));
});
