fix(web): ignore malformed dashboard tile snapshots
This commit is contained in:
parent
4ce42fb52b
commit
88c448258d
3 changed files with 112 additions and 1 deletions
|
|
@ -164,6 +164,15 @@ describe("dashboard refresh lifecycle", () => {
|
|||
},
|
||||
schemaVersion: "dashboard.v1",
|
||||
});
|
||||
store.saveTile({
|
||||
currentRevisionId: "revision-a",
|
||||
response: {
|
||||
state: "disabled",
|
||||
tile: { kind: "module", id: "disabled-module" },
|
||||
message: "Disabled",
|
||||
},
|
||||
schemaVersion: "dashboard.v1",
|
||||
});
|
||||
|
||||
now = 61_000;
|
||||
|
||||
|
|
@ -193,6 +202,53 @@ describe("dashboard refresh lifecycle", () => {
|
|||
schemaVersion: "dashboard.v1",
|
||||
})).toEqual([]);
|
||||
});
|
||||
|
||||
test("ignores malformed stored tile snapshots", () => {
|
||||
const storage = createMemoryStorage();
|
||||
storage.setItem(
|
||||
"dimensionlab.dashboard.tiles.v1",
|
||||
JSON.stringify({
|
||||
currentRevisionId: "revision-a",
|
||||
schemaVersion: "dashboard.v1",
|
||||
tiles: [
|
||||
{},
|
||||
{
|
||||
item: { id: "infra-ram", detail: "live" },
|
||||
savedAt: 1_000,
|
||||
tile: { kind: "telemetry", id: "infra-ram" },
|
||||
},
|
||||
{
|
||||
item: { id: "broken-detail", detail: 42 },
|
||||
savedAt: 1_000,
|
||||
tile: { kind: "telemetry", id: "broken-detail" },
|
||||
},
|
||||
],
|
||||
version: 1,
|
||||
}),
|
||||
);
|
||||
|
||||
const store = createDashboardTileSnapshotStore(storage, {
|
||||
now: () => 16_000,
|
||||
});
|
||||
|
||||
expect(store.restore({
|
||||
currentRevisionId: "revision-a",
|
||||
schemaVersion: "dashboard.v1",
|
||||
})).toEqual([
|
||||
{
|
||||
ageMs: 15_000,
|
||||
response: {
|
||||
state: "ready",
|
||||
tile: { kind: "telemetry", id: "infra-ram" },
|
||||
item: {
|
||||
id: "infra-ram",
|
||||
detail: "live - stale 15s",
|
||||
severity: "stale",
|
||||
},
|
||||
},
|
||||
},
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
async function waitFor(predicate: () => boolean) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue