diff --git a/src/lib/server/dashboard.ts b/src/lib/server/dashboard.ts index c470399..6a55985 100644 --- a/src/lib/server/dashboard.ts +++ b/src/lib/server/dashboard.ts @@ -10,6 +10,7 @@ import { UnsupportedDashboardModelVersionError } from "$lib/server/db/model-migr export type DashboardRuntimeState = | DashboardRuntimeEmpty | DashboardRuntimeInvalid + | DashboardRuntimeLoading | DashboardRuntimeReady; export interface DashboardRuntimeReady { @@ -26,6 +27,13 @@ export interface DashboardRuntimeEmpty { message: string; } +export interface DashboardRuntimeLoading { + state: "loading"; + title: string; + subtitle: string; + message: string; +} + export interface DashboardRuntimeInvalid { state: "invalid"; title: string; diff --git a/src/lib/ui/components/DashboardFrame.svelte b/src/lib/ui/components/DashboardFrame.svelte index 0a76f67..4a4fff8 100644 --- a/src/lib/ui/components/DashboardFrame.svelte +++ b/src/lib/ui/components/DashboardFrame.svelte @@ -44,7 +44,7 @@ {/each} - + + + diff --git a/src/routes/page.test.ts b/src/routes/page.test.ts index bc4fefc..c302884 100644 --- a/src/routes/page.test.ts +++ b/src/routes/page.test.ts @@ -45,4 +45,36 @@ describe("home page model renderer", () => { expect(body).toContain("Validation failed"); expect(body).toContain("Dashboard document is invalid."); }); + + test("renders empty and loading model states without crashing", () => { + const empty = render(Page, { + props: { + data: { + dashboard: { + state: "empty", + title: "No Dashboard Model", + subtitle: "No active document", + message: "No validated dashboard document is active yet.", + }, + }, + }, + }); + const loading = render(Page, { + props: { + data: { + dashboard: { + state: "loading", + title: "Loading Dashboard", + subtitle: "Fetching active model", + message: "Waiting for the active dashboard document.", + }, + }, + }, + }); + + expect(empty.body).toContain("No Dashboard Model"); + expect(empty.body).toContain("No active document"); + expect(loading.body).toContain("Loading Dashboard"); + expect(loading.body).toContain("Fetching active model"); + }); });