Open History to see the last commit
1import type { PreviewAutomationOpenInput, PreviewSessionSnapshot } from "@t3tools/contracts";
2import { describe, expect, it } from "vite-plus/test";
3
4import { previewAutomationOpenNeedsOverlay } from "./previewAutomationOpenReadiness";
5
6const snapshot = (navStatus: PreviewSessionSnapshot["navStatus"]): PreviewSessionSnapshot => ({
7 threadId: "thread-1",
8 tabId: "tab-1",
9 navStatus,
10 canGoBack: false,
11 canGoForward: false,
12 updatedAt: "2026-06-26T00:00:00.000Z",
13});
14
15describe("preview automation open readiness", () => {
16 it("does not wait for a desktop overlay when opening an empty tab", () => {
17 expect(
18 previewAutomationOpenNeedsOverlay(
19 {} as PreviewAutomationOpenInput,
20 snapshot({ _tag: "Idle" }),
21 ),
22 ).toBe(false);
23 });
24
25 it("waits when an empty tab is immediately given a URL", () => {
26 expect(
27 previewAutomationOpenNeedsOverlay(
28 { url: "https://example.com" } as PreviewAutomationOpenInput,
29 snapshot({ _tag: "Idle" }),
30 ),
31 ).toBe(true);
32 });
33
34 it("waits for existing tabs that already have rendered content", () => {
35 expect(
36 previewAutomationOpenNeedsOverlay(
37 {} as PreviewAutomationOpenInput,
38 snapshot({
39 _tag: "Success",
40 url: "https://example.com/",
41 title: "Example",
42 }),
43 ),
44 ).toBe(true);
45 });
46});