Compare commits
No commits in common. "29077923e82744d29bc345c98c3aeae462c9671f" and "216545b83812ff14783330fddeba7d70323fcda9" have entirely different histories.
29077923e8
...
216545b838
4 changed files with 2 additions and 150 deletions
|
|
@ -161,68 +161,6 @@ describe("React app dashboard state view", () => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
test("does not restore aggregate health snapshots over the fresh shell", () => {
|
|
||||||
const restored = restoreDashboardTileSnapshots(
|
|
||||||
{
|
|
||||||
state: "ready",
|
|
||||||
document: dimensionLabDashboardFixture,
|
|
||||||
schemaVersion: "dashboard.v1",
|
|
||||||
currentRevisionId: "revision-a",
|
|
||||||
},
|
|
||||||
[
|
|
||||||
{
|
|
||||||
ageMs: 60_000,
|
|
||||||
response: {
|
|
||||||
state: "ready",
|
|
||||||
tile: { kind: "status", stripId: "footer-status", id: "system-status" },
|
|
||||||
item: {
|
|
||||||
id: "system-status",
|
|
||||||
label: "System Status",
|
|
||||||
value: "20 services down",
|
|
||||||
severity: "stale",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
ageMs: 60_000,
|
|
||||||
response: {
|
|
||||||
state: "ready",
|
|
||||||
tile: { kind: "module", id: "runtime-health-summary" },
|
|
||||||
item: {
|
|
||||||
id: "runtime-health-summary",
|
|
||||||
kind: "summary",
|
|
||||||
title: "Runtime Health",
|
|
||||||
value: "20 services down",
|
|
||||||
detail: "0 warnings - 8 services ok - stale 60s",
|
|
||||||
severity: "stale",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
);
|
|
||||||
|
|
||||||
expect(restored.restoredItemIds).toEqual(new Set());
|
|
||||||
if (restored.dashboard.state !== "ready") {
|
|
||||||
throw new Error("Expected dashboard to be ready");
|
|
||||||
}
|
|
||||||
expect(
|
|
||||||
restored.dashboard.document.statusStrips[0].items.find((item) =>
|
|
||||||
item.id === "system-status"
|
|
||||||
),
|
|
||||||
).toMatchObject({
|
|
||||||
id: "system-status",
|
|
||||||
value: "Fallback operational",
|
|
||||||
});
|
|
||||||
expect(
|
|
||||||
restored.dashboard.document.modules?.find((module) =>
|
|
||||||
module.id === "runtime-health-summary"
|
|
||||||
),
|
|
||||||
).toMatchObject({
|
|
||||||
id: "runtime-health-summary",
|
|
||||||
value: "fallback",
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
test("uses structured tile match keys for delimiter-bearing ids", () => {
|
test("uses structured tile match keys for delimiter-bearing ids", () => {
|
||||||
expect(
|
expect(
|
||||||
dashboardTileMatchKey({ kind: "service", groupId: "a:b", id: "c" }),
|
dashboardTileMatchKey({ kind: "service", groupId: "a:b", id: "c" }),
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,6 @@ import {
|
||||||
createDashboardTileSnapshotStore,
|
createDashboardTileSnapshotStore,
|
||||||
createDashboardTileBackoff,
|
createDashboardTileBackoff,
|
||||||
createDashboardRequestAborter,
|
createDashboardRequestAborter,
|
||||||
isPersistableDashboardTileSnapshot,
|
|
||||||
runViewportAwareDashboardHydrationQueue,
|
runViewportAwareDashboardHydrationQueue,
|
||||||
shouldPauseDashboardRefresh,
|
shouldPauseDashboardRefresh,
|
||||||
subscribeToDashboardTileEvents,
|
subscribeToDashboardTileEvents,
|
||||||
|
|
@ -691,9 +690,7 @@ export function restoreDashboardTileSnapshots(
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
return snapshots.filter((snapshot) =>
|
return snapshots.reduce(
|
||||||
isPersistableDashboardTileSnapshot(snapshot.response.tile)
|
|
||||||
).reduce(
|
|
||||||
(current, snapshot) => ({
|
(current, snapshot) => ({
|
||||||
dashboard: {
|
dashboard: {
|
||||||
...current.dashboard,
|
...current.dashboard,
|
||||||
|
|
|
||||||
|
|
@ -518,77 +518,6 @@ describe("dashboard refresh lifecycle", () => {
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
test("ignores restored aggregate health snapshots", () => {
|
|
||||||
const storage = createMemoryStorage();
|
|
||||||
storage.setItem(
|
|
||||||
"dimensionlab.dashboard.tiles.v1",
|
|
||||||
JSON.stringify({
|
|
||||||
currentRevisionId: "revision-a",
|
|
||||||
schemaVersion: "dashboard.v1",
|
|
||||||
tiles: [
|
|
||||||
{
|
|
||||||
item: {
|
|
||||||
id: "system-status",
|
|
||||||
label: "System Status",
|
|
||||||
value: "20 services down",
|
|
||||||
severity: "danger",
|
|
||||||
},
|
|
||||||
savedAt: 1_000,
|
|
||||||
tile: { kind: "status", stripId: "footer-status", id: "system-status" },
|
|
||||||
},
|
|
||||||
{
|
|
||||||
item: {
|
|
||||||
id: "runtime-health-summary",
|
|
||||||
kind: "summary",
|
|
||||||
title: "Runtime Health",
|
|
||||||
value: "20 services down",
|
|
||||||
detail: "0 warnings - 8 services ok",
|
|
||||||
severity: "danger",
|
|
||||||
},
|
|
||||||
savedAt: 1_000,
|
|
||||||
tile: { kind: "module", id: "runtime-health-summary" },
|
|
||||||
},
|
|
||||||
{
|
|
||||||
item: {
|
|
||||||
id: "infra-ram",
|
|
||||||
label: "Infra RAM",
|
|
||||||
value: { kind: "percent", value: 42 },
|
|
||||||
detail: "live",
|
|
||||||
severity: "ok",
|
|
||||||
},
|
|
||||||
savedAt: 1_000,
|
|
||||||
tile: { kind: "telemetry", id: "infra-ram" },
|
|
||||||
},
|
|
||||||
],
|
|
||||||
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",
|
|
||||||
label: "Infra RAM",
|
|
||||||
value: { kind: "percent", value: 42 },
|
|
||||||
detail: "live - stale 15s",
|
|
||||||
severity: "stale",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
]);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
async function waitFor(predicate: () => boolean) {
|
async function waitFor(predicate: () => boolean) {
|
||||||
|
|
|
||||||
|
|
@ -617,9 +617,7 @@ export function createDashboardTileSnapshotStore(
|
||||||
return {
|
return {
|
||||||
currentRevisionId: payload.currentRevisionId,
|
currentRevisionId: payload.currentRevisionId,
|
||||||
schemaVersion: payload.schemaVersion,
|
schemaVersion: payload.schemaVersion,
|
||||||
tiles: payload.tiles
|
tiles: payload.tiles.filter(isDashboardTileSnapshotRecord),
|
||||||
.filter(isDashboardTileSnapshotRecord)
|
|
||||||
.filter((record) => isPersistableDashboardTileSnapshot(record.tile)),
|
|
||||||
version: 1,
|
version: 1,
|
||||||
};
|
};
|
||||||
} catch {
|
} catch {
|
||||||
|
|
@ -662,8 +660,6 @@ export function createDashboardTileSnapshotStore(
|
||||||
response: Extract<DashboardTileSnapshotResponse, { state: "ready" }>;
|
response: Extract<DashboardTileSnapshotResponse, { state: "ready" }>;
|
||||||
},
|
},
|
||||||
): void {
|
): void {
|
||||||
if (!isPersistableDashboardTileSnapshot(input.response.tile)) return;
|
|
||||||
|
|
||||||
const payload = matchingPayload(input);
|
const payload = matchingPayload(input);
|
||||||
const key = dashboardTileSnapshotKey(input.response.tile);
|
const key = dashboardTileSnapshotKey(input.response.tile);
|
||||||
const nextRecord: DashboardTileSnapshotRecord = {
|
const nextRecord: DashboardTileSnapshotRecord = {
|
||||||
|
|
@ -724,14 +720,6 @@ function dashboardTileSnapshotKey(tile: DashboardTileReference): string {
|
||||||
return JSON.stringify(tile);
|
return JSON.stringify(tile);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function isPersistableDashboardTileSnapshot(
|
|
||||||
tile: DashboardTileReference,
|
|
||||||
): boolean {
|
|
||||||
if (tile.kind === "status" && tile.id === "system-status") return false;
|
|
||||||
if (tile.kind === "module" && tile.id === "runtime-health-summary") return false;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
function isDashboardTileSnapshotRecord(
|
function isDashboardTileSnapshotRecord(
|
||||||
value: unknown,
|
value: unknown,
|
||||||
): value is DashboardTileSnapshotRecord {
|
): value is DashboardTileSnapshotRecord {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue