/** * Live grid layouts saved by 0.18. * * 0.18 stored every new tile at y 0 and let the grid compact the tiles at * render, in render order (Birdseye, then camera order). Its stored layouts * can share cells and hold gaps that never showed. Conversion compacts the same * way, so each layout opens exactly as 0.18 displayed it. * * Each stored layout below was captured from 0.18's IndexedDB, and each * expected cell is where 0.18 rendered that tile. */ import { test, expect } from "../fixtures/frigate-test"; import { BASE_CONFIG } from "../fixtures/mock-data/config"; import { LivePage } from "../pages/live.page"; import { persistedLayoutKey, readLayout, seedLayout, type LayoutItem, } from "../helpers/grid-layout"; // one 0.18 cell is 32 columns by 72 rows on the current grid const CELL_W = 32; const CELL_H = 72; const tile = (i: string, x: number, y: number) => ({ i, x, y, w: 4, h: 4 }); type Scenario = { name: string; cameras: string[]; stored: LayoutItem[]; rendered: Record; }; const SCENARIOS: Scenario[] = [ { name: "a group created with Birdseye", cameras: ["birdseye", "front_door", "backyard", "garage"], stored: [ tile("birdseye", 0, 0), tile("front_door", 4, 0), tile("backyard", 8, 0), tile("garage", 0, 0), ], rendered: { birdseye: [0, 0], front_door: [1, 0], backyard: [2, 0], garage: [0, 1], }, }, { name: "Birdseye and a camera added after a drag", cameras: [ "front_door", "backyard", "garage", "porch", "driveway", "birdseye", ], stored: [ tile("front_door", 0, 4), tile("backyard", 4, 0), tile("garage", 8, 0), tile("porch", 0, 0), tile("driveway", 4, 0), tile("birdseye", 0, 0), ], rendered: { birdseye: [0, 0], backyard: [1, 0], garage: [2, 0], porch: [0, 1], driveway: [1, 1], front_door: [0, 2], }, }, { name: "a camera added ahead of the others in camera order", cameras: ["backyard", "garage", "porch", "driveway", "front_door"], stored: [ tile("backyard", 0, 0), tile("garage", 4, 0), tile("porch", 8, 0), tile("driveway", 0, 0), tile("front_door", 0, 0), ], rendered: { front_door: [0, 0], garage: [1, 0], porch: [2, 0], backyard: [0, 1], driveway: [0, 2], }, }, { name: "a camera removed after a drag", cameras: ["front_door", "backyard", "garage"], stored: [ tile("front_door", 0, 4), tile("backyard", 4, 0), tile("garage", 8, 0), ], rendered: { front_door: [0, 0], backyard: [1, 0], garage: [2, 0], }, }, ]; const frontDoor = BASE_CONFIG.cameras.front_door; test.describe("Live grid 0.18 layouts @critical", () => { test.skip( ({ frigateApp }) => frigateApp.isMobile, "Draggable grid is desktop-only", ); SCENARIOS.forEach(({ name, cameras, stored, rendered }, index) => { test(`opens ${name} as 0.18 showed it`, async ({ frigateApp }) => { const group = `legacy${index}`; await frigateApp.installDefaults({ config: { cameras: { porch: { ...frontDoor, name: "porch" }, driveway: { ...frontDoor, name: "driveway" }, }, camera_groups: { [group]: { cameras, icon: "LuCar", order: 1 } }, }, }); await frigateApp.goto(`/?group=${group}`); const key = await persistedLayoutKey(frigateApp.page, group); await seedLayout(frigateApp.page, key, stored); await frigateApp.page.reload(); await expect .poll(async () => (await readLayout(frigateApp.page, key))?.version, { timeout: 10_000, }) .toBe(2); const layout = (await readLayout(frigateApp.page, key))!.layout; const cells = Object.fromEntries( layout.map((item) => [item.i, [item.x / CELL_W, item.y / CELL_H]]), ); expect(cells).toEqual(rendered); if (cameras.includes("birdseye")) { await new LivePage(frigateApp.page, true).birdseyeTile.click(); await expect(frigateApp.page).toHaveURL(/#birdseye/); } }); }); }); test.describe("Live grid 0.18 layouts on mobile @critical @mobile", () => { test("a group with Birdseye shows every tile in the static grid", async ({ frigateApp, }) => { test.skip(!frigateApp.isMobile, "Mobile-only"); const { cameras } = SCENARIOS[0]; await frigateApp.installDefaults({ config: { camera_groups: { legacy: { cameras, icon: "LuCar", order: 1 } }, }, }); await frigateApp.goto("/?group=legacy"); const live = new LivePage(frigateApp.page, false); for (const camera of cameras.filter((name) => name !== "birdseye")) { await expect(live.cameraCard(camera).first()).toBeVisible({ timeout: 10_000, }); } // the static grid never reads a stored layout, so nothing can cover Birdseye await expect(frigateApp.page.locator(".react-grid-item")).toHaveCount(0); await expect( frigateApp.page.locator( "#pageRoot .aspect-video:not([data-camera]):not(:has([data-camera]))", ), ).toBeVisible(); }); });