import { expect } from "e2e";
import { IOS, test } from "./t3-mobile.ts";

test("Floating iOS tab accessibility names follow the app language immediately", IOS, async ({ t3, app, screen, device }) => {
  const project = await t3.project("Language demo");
  await t3.thread({ project, title: "Language verification", messages: ["hello"] });
  await app.clearState().catch(() => {});
  await t3.open();
  await screen.getByText("Language demo", { exact: false }).first().waitFor({ timeout: 120_000 });
  const settings = async (page: string) => {
    await device.openLink(`t3code-dev://settings/${page}`, { app: "com.t3tools.t3code.dev" });
    await device.alert("accept").catch(() => {});
  };
  await settings("language");
  await screen.getByLabel("Deutsch", { exact: true }).tap();
  await screen.getByText("Sprache", { exact: true }).first().waitFor();
  await settings("");
  await screen.getByText("Allgemein", { exact: true }).first().waitFor();
  await app.screenshot("german-settings-tab-names");
  await expect(screen.getByLabel("Nutzung", { exact: true })).toBeVisible();
  await expect(screen.getByLabel("Einstellungen", { exact: true }).last()).toBeVisible();
  await settings("language");
  await screen.getByLabel("English", { exact: true }).tap();
  await screen.getByText("Language", { exact: true }).first().waitFor();
  await settings("");
  await app.screenshot("english-settings-tab-names");
  await expect(screen.getByLabel("Usage", { exact: true })).toBeVisible();
  await expect(screen.getByLabel("Settings", { exact: true }).last()).toBeVisible();
});
