feat: render dashboard from model
This commit is contained in:
parent
13e3ff867b
commit
fede33e8a7
11 changed files with 372 additions and 139 deletions
|
|
@ -4,6 +4,7 @@ import { tmpdir } from "node:os";
|
|||
import { join } from "node:path";
|
||||
import { afterEach, describe, expect, test } from "vitest";
|
||||
import { dimensionLabDashboardFixture } from "$lib/model/fixtures/dimensionlab";
|
||||
import { genericDashboardFixture } from "$lib/model/fixtures/generic";
|
||||
import { createDashboardStore, type DashboardStore } from "./db/dashboard-store";
|
||||
import { loadDashboardRuntime } from "./dashboard";
|
||||
|
||||
|
|
@ -21,13 +22,30 @@ describe("dashboard runtime loader", () => {
|
|||
|
||||
const runtime = loadDashboardRuntime(store);
|
||||
|
||||
expect(runtime.title).toBe(dimensionLabDashboardFixture.metadata.title);
|
||||
expect(runtime.subtitle).toBe(dimensionLabDashboardFixture.metadata.subtitle);
|
||||
expect(runtime.status).toBe("building");
|
||||
expect(runtime.state).toBe("ready");
|
||||
if (runtime.state !== "ready") throw new Error("expected ready dashboard");
|
||||
expect(runtime.document.metadata.title).toBe(dimensionLabDashboardFixture.metadata.title);
|
||||
expect(runtime.document.metadata.subtitle).toBe(dimensionLabDashboardFixture.metadata.subtitle);
|
||||
expect(runtime.schemaVersion).toBe(dimensionLabDashboardFixture.schemaVersion);
|
||||
expect(runtime.currentRevisionId).toBe(store.getActiveDashboard()?.currentRevisionId);
|
||||
expect(store.listRevisions()).toHaveLength(1);
|
||||
});
|
||||
|
||||
test("loads an existing active dashboard without reseeding", async () => {
|
||||
const store = await createTestStore();
|
||||
const seed = store.commitDashboard(genericDashboardFixture, {
|
||||
actor: "test",
|
||||
message: "existing dashboard",
|
||||
});
|
||||
|
||||
const runtime = loadDashboardRuntime(store);
|
||||
|
||||
expect(runtime.state).toBe("ready");
|
||||
if (runtime.state !== "ready") throw new Error("expected ready dashboard");
|
||||
expect(runtime.currentRevisionId).toBe(seed.id);
|
||||
expect(runtime.document.metadata.title).toBe(genericDashboardFixture.metadata.title);
|
||||
expect(store.listRevisions()).toHaveLength(1);
|
||||
});
|
||||
});
|
||||
|
||||
async function createTestStore() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue