Open History to see the last commit
1import { describe, expect, it } from "vite-plus/test";
2
3import { resolveBrowserSurfacePanelRect, useBrowserSurfaceStore } from "./browserSurfaceStore";
4
5describe("browserSurfaceStore", () => {
6 it("tracks content dimensions for a browser that has never been visible", () => {
7 const tabId = "hidden-browser-surface-content-test";
8 useBrowserSurfaceStore.getState().presentContent(tabId, {
9 x: 0,
10 y: 0,
11 width: 393,
12 height: 852,
13 scale: 1,
14 scrollLeft: 0,
15 scrollTop: 0,
16 });
17
18 expect(useBrowserSurfaceStore.getState().byTabId[tabId]).toMatchObject({
19 rect: null,
20 visible: false,
21 content: { width: 393, height: 852 },
22 });
23 });
24
25 it("uses the live panel rect for a hidden background tab", () => {
26 const staleRect = { x: 0, y: 0, width: 500, height: 700 };
27 const liveRect = { x: 10, y: 20, width: 900, height: 640 };
28 expect(
29 resolveBrowserSurfacePanelRect(
30 {
31 hidden: { rect: staleRect, visible: false, content: null, updatedAt: 1 },
32 active: { rect: liveRect, visible: true, content: null, updatedAt: 2 },
33 },
34 "hidden",
35 ),
36 ).toEqual(liveRect);
37 });
38});