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

test("Custom snooze calendar follows the French app language", WEB, async ({ t3, app, browser, screen }) => {
  const project = await t3.project("Calendar demo");
  const thread = await t3.thread({ project, title: "French Greeting", messages: ["bonjour"], model: "multi-turn" });
  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(thread);
  await screen.getByRole("button", "French Greeting, Calendar demo", { exact: true }).hover();
  await screen.getByRole("button", "Reporter le fil", { exact: true }).tap();
  await screen.getByRole("menuitem", "Personnalisé…", { exact: true }).tap();
  await screen.getByRole("button", "Date", { exact: true }).tap();
  await screen.getByRole("grid").waitFor();
  await browser.evaluate(async () => {
    const popup = document.querySelector('[data-slot="popover-popup"]');
    await Promise.all(popup?.getAnimations({ subtree: true }).map((animation) => animation.finished) ?? []);
    return null;
  });
  await app.screenshot("french-custom-snooze-calendar");
  await expect(screen.getByRole("grid")).toHaveAttribute("aria-label", "novembre 2026");
  await expect(browser.locator("[data-slot=calendar] thead th").nth(1)).toHaveText("lun.");
});
