import { describe, expect, it } from "vite-plus/test"; import { resolveBrowserSurfacePanelRect, useBrowserSurfaceStore } from "./browserSurfaceStore"; describe("browserSurfaceStore", () => { it("tracks content dimensions for a browser that has never been visible", () => { const tabId = "hidden-browser-surface-content-test"; useBrowserSurfaceStore.getState().presentContent(tabId, { x: 0, y: 0, width: 393, height: 852, scale: 1, scrollLeft: 0, scrollTop: 0, }); expect(useBrowserSurfaceStore.getState().byTabId[tabId]).toMatchObject({ rect: null, visible: false, content: { width: 393, height: 852 }, }); }); it("uses the live panel rect for a hidden background tab", () => { const staleRect = { x: 0, y: 0, width: 500, height: 700 }; const liveRect = { x: 10, y: 20, width: 900, height: 640 }; expect( resolveBrowserSurfacePanelRect( { hidden: { rect: staleRect, visible: false, content: null, updatedAt: 1 }, active: { rect: liveRect, visible: true, content: null, updatedAt: 2 }, }, "hidden", ), ).toEqual(liveRect); });});
import { describe, expect, it } from "vite-plus/test";
import { resolveBrowserSurfacePanelRect, useBrowserSurfaceStore } from "./browserSurfaceStore";
describe("browserSurfaceStore", () => {
it("tracks content dimensions for a browser that has never been visible", () => {
const tabId = "hidden-browser-surface-content-test";
useBrowserSurfaceStore.getState().presentContent(tabId, {
x: 0,
y: 0,
width: 393,
height: 852,
scale: 1,
scrollLeft: 0,
scrollTop: 0,
});
expect(useBrowserSurfaceStore.getState().byTabId[tabId]).toMatchObject({
rect: null,
visible: false,
content: { width: 393, height: 852 },
});
});
it("uses the live panel rect for a hidden background tab", () => {
const staleRect = { x: 0, y: 0, width: 500, height: 700 };
const liveRect = { x: 10, y: 20, width: 900, height: 640 };
expect(
resolveBrowserSurfacePanelRect(
{
hidden: { rect: staleRect, visible: false, content: null, updatedAt: 1 },
active: { rect: liveRect, visible: true, content: null, updatedAt: 2 },
},
"hidden",
),
).toEqual(liveRect);
});
});