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

test("Coinciding Tomorrow and Saturday remain visible in one snooze row", WEB, async ({ t3, app, screen, browser }) => {
  const project = await t3.project("Snooze demo");
  await t3.thread({ project, title: "Review release notes", messages: ["Prepare release notes"] });
  await t3.open();
  await screen.getByRole("button", "Add project").waitFor();
  await browser.addInitScript(() => {
    const RealDate = Date;
    const fixed = new RealDate("2026-11-13T12:00:00Z").getTime();
    class FridayDate extends RealDate {
      constructor(...args: any[]) { if (args.length === 0) super(fixed); else super(...args as [string]); }
      static now() { return fixed; }
    }
    globalThis.Date = FridayDate as DateConstructor;
  });
  await app.open("/settings/threads#snooze-options");
  await screen.getByRole("button", "Add option").tap();
  await screen.getByRole("group", "Snooze option 6").getByRole("combobox", "When").tap();
  await screen.getByRole("option", "Saturday").tap();
  await app.screenshot("configured-options");
  await app.open("/");
  await browser.locator("[data-thread-item]").first().secondaryTap();
  await screen.getByRole("menuitem", "Snooze", { exact: true }).hover();
  await screen.getByRole("menuitem", /Tomorrow/).waitFor();
  await app.screenshot("snooze-menu");
  const combined = screen.getByRole("menuitem", /Tomorrow · Saturday/);
  await expect(combined).toBeVisible();
  await combined.tap();
  await app.screenshot("snoozed-thread");
});
