123456789101112131415import "./_setup"; 16import { describe, expect, it, vi } from "vitest";17import * as inject from "./inject";1819const showTotpCopyToast = (inject as unknown as {20 showTotpCopyToast?: (secondsUntilClear: number) => void;21}).showTotpCopyToast;2223describe.skipIf(typeof showTotpCopyToast !== "function")(24 "Addendum 2 — proposed showTotpCopyToast (requires inject.ts change)",25 () => {26 const toast = showTotpCopyToast!;2728 it("T-M11: renders a toast showing the configured clear time", () => {29 document.body.innerHTML = "";30 expect(() => toast(30)).not.toThrow();31 expect(document.body.textContent ?? "").toMatch(/clears in 30/i);32 });3334 it("T-M12: a second copy while showing resets, leaving a single toast", () => {35 document.body.innerHTML = "";36 toast(30);37 toast(30);38 const toasts = document.querySelectorAll('[data-peach-toast], .peach-totp-toast');39 expect(toasts.length).toBeLessThanOrEqual(1);40 });4142 it("T-M13: auto-dismisses after ~3s", () => {43 document.body.innerHTML = "";44 vi.useFakeTimers();45 toast(30);46 vi.advanceTimersByTime(3500);47 vi.useRealTimers();48 expect(document.body.textContent ?? "").not.toMatch(/2FA code copied/i);49 });50 }51);5253545556describe("Addendum 2 status", () => {57 it("exposes showTotpCopyToast now that the addendum is implemented", () => {58 expect(typeof showTotpCopyToast).toBe("function");59 });60});