From c2fb20b066e080ab8c623ecdc7f0bd153a1683e2 Mon Sep 17 00:00:00 2001 From: vince Date: Thu, 18 Jun 2026 19:29:30 +0200 Subject: [PATCH] fix: complete model renderer states and ids --- src/lib/server/dashboard.ts | 8 ++++++ src/lib/ui/components/DashboardFrame.svelte | 2 +- src/lib/ui/components/ServicePanel.svelte | 8 ++++-- src/lib/ui/components/StatusStrip.svelte | 4 ++- src/lib/ui/components/render.test.ts | 11 +++++++ src/lib/ui/fixtures.ts | 2 ++ src/lib/ui/model-renderer.test.ts | 1 + src/lib/ui/model-renderer.ts | 1 + src/lib/ui/types.ts | 1 + src/routes/+page.svelte | 21 ++++++++++++-- src/routes/page.test.ts | 32 +++++++++++++++++++++ 11 files changed, 84 insertions(+), 7 deletions(-) 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"); + }); });