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

test("Community theme download counts follow a language change in an English browser", WEB, async ({ t3, app, browser, screen }) => {
  const project = await t3.project("demo");
  await t3.thread({ project, title: "Theme preview", messages: ["Start"] });
  await t3.open("/settings/appearance");
  await screen.getByRole("button", "Add theme", { exact: true }).tap();
  await screen.getByRole("button", "Dracula", { exact: true }).tap();
  await screen.getByText(/^dracula-theme ·/).waitFor({ timeout: 60000 });
  await app.screenshot("english-download-counts");
  await browser.keyboard.press("Escape");
  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("/settings/appearance");
  await screen.getByRole("button", "Design hinzufügen", { exact: true }).tap();
  await screen.getByRole("button", "Dracula", { exact: true }).tap();
  const count = screen.getByText(/^dracula-theme ·/);
  await count.waitFor({ timeout: 60000 });
  await app.screenshot("german-download-counts");
  await expect(count).toHaveText(/^dracula-theme · \d{1,3}(?:\.\d{3})+ Downloads$/);
});
