Frontend Labs
⋯

tests/session.spec.js

// Time-dependent UI without waiting 15 real minutes: Playwright's clock (§77).
import { test, expect } from "./fixtures.js";

test("an idle session warns before it expires", async ({ page }) => {
  await page.clock.install(); // fake Date, setTimeout, setInterval... before the app loads
  await page.goto("/");
  await expect(page.getByRole("textbox", { name: "Message" })).toBeVisible();

  await page.clock.fastForward("14:59");
  await expect(page.getByRole("dialog")).toBeHidden();

  await page.clock.fastForward("00:02");
  const dialog = page.getByRole("dialog", { name: "Your session is about to expire" });
  await expect(dialog).toBeVisible();
  await dialog.getByRole("button", { name: "Stay signed in" }).click();
  await expect(dialog).toBeHidden();
});

Generated from SOURCE.md · 8 Oct 2026 16:36