perf(web): restore last known dashboard tiles
This commit is contained in:
parent
243d71686d
commit
4ce42fb52b
4 changed files with 412 additions and 8 deletions
|
|
@ -2,7 +2,11 @@ import { renderToString } from "react-dom/server";
|
|||
import { describe, expect, test } from "vitest";
|
||||
import { genericDashboardFixture } from "@dimensionlab/dashboard-model/fixtures";
|
||||
import { dimensionLabDashboardFixture } from "$lib/dashboard-seed/dimensionlab";
|
||||
import { AppStateView, dashboardHydrationTiles } from "./App";
|
||||
import {
|
||||
AppStateView,
|
||||
dashboardHydrationTiles,
|
||||
restoreDashboardTileSnapshots,
|
||||
} from "./App";
|
||||
|
||||
describe("React app dashboard state view", () => {
|
||||
test("renders loading dashboard state", () => {
|
||||
|
|
@ -120,4 +124,39 @@ describe("React app dashboard state view", () => {
|
|||
),
|
||||
);
|
||||
});
|
||||
|
||||
test("applies restored tile snapshots without marking them as loading", () => {
|
||||
const restored = restoreDashboardTileSnapshots(
|
||||
{
|
||||
state: "ready",
|
||||
document: dimensionLabDashboardFixture,
|
||||
schemaVersion: "dashboard.v1",
|
||||
currentRevisionId: "revision-a",
|
||||
},
|
||||
[
|
||||
{
|
||||
ageMs: 60_000,
|
||||
response: {
|
||||
state: "ready",
|
||||
tile: { kind: "telemetry", id: "infra-ram" },
|
||||
item: {
|
||||
...dimensionLabDashboardFixture.telemetry[0],
|
||||
detail: "cached - stale 60s",
|
||||
severity: "stale",
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
);
|
||||
|
||||
expect(restored.restoredItemIds).toEqual(new Set(["telemetry:infra-ram"]));
|
||||
if (restored.dashboard.state !== "ready") {
|
||||
throw new Error("Expected dashboard to be ready");
|
||||
}
|
||||
expect(restored.dashboard.document.telemetry[0]).toMatchObject({
|
||||
id: "infra-ram",
|
||||
detail: "cached - stale 60s",
|
||||
severity: "stale",
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue