feat: render dashboard from model
This commit is contained in:
parent
13e3ff867b
commit
fede33e8a7
11 changed files with 372 additions and 139 deletions
|
|
@ -1,17 +1,16 @@
|
|||
import { render } from "svelte/server";
|
||||
import { describe, expect, test } from "vitest";
|
||||
import { genericDashboardFixture } from "$lib/model/fixtures/generic";
|
||||
import Page from "./+page.svelte";
|
||||
|
||||
describe("home page design-system preview", () => {
|
||||
test("renders the runtime dashboard data from the server load", () => {
|
||||
describe("home page model renderer", () => {
|
||||
test("renders the active dashboard model from the server load", () => {
|
||||
const { body } = render(Page, {
|
||||
props: {
|
||||
data: {
|
||||
dashboard: {
|
||||
title: "Runtime Surface",
|
||||
subtitle: "Loaded from persistence",
|
||||
status: "building",
|
||||
message: "Runtime model is available.",
|
||||
state: "ready",
|
||||
document: genericDashboardFixture,
|
||||
schemaVersion: "dashboard.v1",
|
||||
currentRevisionId: "revision-1234567890",
|
||||
},
|
||||
|
|
@ -19,10 +18,31 @@ describe("home page design-system preview", () => {
|
|||
},
|
||||
});
|
||||
|
||||
expect(body).toContain("Runtime Surface");
|
||||
expect(body).toContain("Loaded from persistence");
|
||||
expect(body).toContain("revision");
|
||||
expect(body).toContain("primary");
|
||||
expect(body).toContain("secondary");
|
||||
expect(body).toContain("Operations Console");
|
||||
expect(body).toContain("Service Uptime");
|
||||
expect(body).toContain("Identity");
|
||||
expect(body).toContain("data-model-id=\"service-uptime\"");
|
||||
expect(body).not.toContain("primary");
|
||||
expect(body).not.toContain("secondary");
|
||||
});
|
||||
|
||||
test("renders invalid model state without crashing", () => {
|
||||
const { body } = render(Page, {
|
||||
props: {
|
||||
data: {
|
||||
dashboard: {
|
||||
state: "invalid",
|
||||
title: "Invalid Dashboard",
|
||||
subtitle: "Validation failed",
|
||||
message: "Dashboard document is invalid.",
|
||||
errors: ["/metadata/title is required"],
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
expect(body).toContain("Invalid Dashboard");
|
||||
expect(body).toContain("Validation failed");
|
||||
expect(body).toContain("Dashboard document is invalid.");
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue