diff --git a/src/components/displays/superuser/system/SystemStatusDashboard.vue b/src/components/displays/superuser/system/SystemStatusDashboard.vue index 68a56eff..42059b41 100644 --- a/src/components/displays/superuser/system/SystemStatusDashboard.vue +++ b/src/components/displays/superuser/system/SystemStatusDashboard.vue @@ -1,5 +1,5 @@ diff --git a/tests/e2e/superuser-system-status.smoke.spec.js b/tests/e2e/superuser-system-status.smoke.spec.js index 418f88cf..f942bdaf 100644 --- a/tests/e2e/superuser-system-status.smoke.spec.js +++ b/tests/e2e/superuser-system-status.smoke.spec.js @@ -784,14 +784,17 @@ test.describe("Superuser system status smoke", () => { await expect(page).toHaveURL(/\/superuser$/); await expect(page.getByTestId("system-status-dashboard")).toBeVisible({ timeout: PAGE_READY_TIMEOUT }); + await expect(page.getByTestId("system-status-dashboard-tabs")).toBeVisible({ timeout: PAGE_READY_TIMEOUT }); await expect(page.getByTestId("status-card-database")).toContainText("truckwash", { timeout: PAGE_READY_TIMEOUT }); await expect(page.getByTestId("status-card-database-replication")).toContainText("100.0% replikering"); await expect(page.getByTestId("status-card-minio-replication")).toContainText("67.4% replikering"); + await page.getByTestId("system-status-tab-sessions").click(); await expect(page.locator("body")).toContainText("Acme Logistics"); await expect(page.locator("body")).toContainText("Kunde"); await expect(page.locator("body")).toContainText("Bruger"); await expect(page.locator("body")).toContainText("Computer"); await expect(page.locator("body")).toContainText("/superuser/vehicles"); + await page.getByTestId("system-status-tab-modules").click(); await expect(page.locator("body")).toContainText("Forbindelse til OpenAI API bekræftet."); await expect(page.locator("body")).toContainText("Redis er utilgængelig; cache til modulprober omgås."); await expect(page.locator("body")).not.toContainText("OpenAI API connectivity confirmed."); @@ -975,6 +978,7 @@ test.describe("Superuser system status smoke", () => { await installSystemStatusMock(page, longReasonSnapshot); await page.goto("/superuser"); + await page.getByTestId("system-status-tab-modules").click(); const card = page.getByTestId("module-card-shelly"); const title = card.locator(".module-card__title"); @@ -1004,6 +1008,7 @@ test.describe("Superuser system status smoke", () => { await installSystemStatusMock(page, longTitleSnapshot); await page.goto("/superuser"); + await page.getByTestId("system-status-tab-modules").click(); const card = page.getByTestId("module-card-licenseplaterecognizer"); const title = card.locator(".module-card__title"); @@ -1133,6 +1138,7 @@ test.describe("Superuser system status smoke", () => { }); await page.goto("/superuser"); + await page.getByTestId("system-status-tab-gateways").click(); await expect(page.getByTestId("system-status-gateways")).toBeVisible({ timeout: PAGE_READY_TIMEOUT }); await expect(page.getByTestId("gateway-summary-card-total")).toContainText("10"); diff --git a/tests/unit/superuser-system-status-dashboard.spec.js b/tests/unit/superuser-system-status-dashboard.spec.js index aebd2c52..aace4a6f 100644 --- a/tests/unit/superuser-system-status-dashboard.spec.js +++ b/tests/unit/superuser-system-status-dashboard.spec.js @@ -226,6 +226,11 @@ const flushDashboardLoad = async () => { } }; +const openDashboardTab = async (wrapper, tab) => { + await wrapper.get(`[data-testid="system-status-tab-${tab}"]`).trigger("click"); + await flushRendering(); +}; + const resetStatusStore = () => { SuperUserSystemStatusObject.snapshot.value = null; SuperUserSystemStatusObject.loading.value = false; @@ -277,7 +282,7 @@ describe("superuser system status dashboard", () => { resetSessionUser(); }); - it("renders infrastructure, modules, warnings, and recent sessions from the shared snapshot", async () => { + it("renders infrastructure, modules, warnings, and recent sessions from the shared snapshot tabs", async () => { installDashboardMocks(); const wrapper = mountWithApp(SystemStatusDashboard, { @@ -291,10 +296,16 @@ describe("superuser system status dashboard", () => { expect(wrapper.get('[data-testid="status-card-database"]').text()).toContain("truckwash"); expect(wrapper.get('[data-testid="status-card-database-replication"]').text()).toContain("100.0% replication"); expect(wrapper.get('a[href="/superuser/system/replication"]').exists()).toBe(true); + expect(wrapper.get('[data-testid="system-status-dashboard-tabs"]').exists()).toBe(true); + expect(wrapper.get('[data-testid="system-status-panel-infrastructure"]').isVisible()).toBe(true); + expect(wrapper.text()).toContain("Redis is unavailable; module probe caching is bypassed."); + + await openDashboardTab(wrapper, "modules"); + expect(wrapper.get('a[href="/superuser/configuration/openai"]').exists()).toBe(true); + + await openDashboardTab(wrapper, "sessions"); expect(wrapper.text()).toContain("Acme Logistics"); expect(wrapper.text()).toContain("/superuser/vehicles"); - expect(wrapper.text()).toContain("Redis is unavailable; module probe caching is bypassed."); - expect(wrapper.get('a[href="/superuser/configuration/openai"]').exists()).toBe(true); wrapper.unmount(); }); @@ -333,6 +344,30 @@ describe("superuser system status dashboard", () => { expect(authenticatedRequestMock).toHaveBeenCalledWith("/superuser/system/status", "GET", {}); expect(authenticatedRequestMock.mock.calls.some(([path]) => path === "/edge-gateways")).toBe(false); expect(wrapper.find('[data-testid="system-status-gateways"]').exists()).toBe(false); + expect(wrapper.find('[data-testid="system-status-tab-gateways"]').exists()).toBe(false); + + wrapper.unmount(); + }); + + it("returns to infrastructure when the active gateway tab becomes unavailable", async () => { + installDashboardMocks({ + gateways: [createGateway(201, { label: "Gateway Atlas" })], + }); + + const wrapper = mountWithApp(SystemStatusDashboard, { + messages: { en: enMessages }, + }); + + await flushDashboardLoad(); + await openDashboardTab(wrapper, "gateways"); + + expect(wrapper.get('[data-testid="system-status-gateways"]').isVisible()).toBe(true); + + SessionUser.permissions.value = ["user"]; + await flushRendering(); + + expect(wrapper.find('[data-testid="system-status-tab-gateways"]').exists()).toBe(false); + expect(wrapper.get('[data-testid="system-status-panel-infrastructure"]').isVisible()).toBe(true); wrapper.unmount(); }); @@ -425,6 +460,7 @@ describe("superuser system status dashboard", () => { }); await flushDashboardLoad(); + await openDashboardTab(wrapper, "gateways"); expect(wrapper.get('[data-testid="gateway-summary-card-total"]').text()).toContain("10"); expect(wrapper.get('[data-testid="gateway-summary-card-online"]').text()).toContain("4"); @@ -472,6 +508,7 @@ describe("superuser system status dashboard", () => { expect(authenticatedRequestMock.mock.calls.some(([path]) => path === "/edge-gateways")).toBe(true); expect(wrapper.find('[data-testid="system-status-gateways"]').exists()).toBe(false); + expect(wrapper.find('[data-testid="system-status-tab-gateways"]').exists()).toBe(false); expect(wrapper.get('[data-testid="status-card-database"]').text()).toContain("truckwash"); wrapper.unmount(); @@ -487,6 +524,7 @@ describe("superuser system status dashboard", () => { }); await flushDashboardLoad(); + await openDashboardTab(wrapper, "gateways"); expect(wrapper.get('[data-testid="system-status-gateways"]').exists()).toBe(true); expect(wrapper.get('[data-testid="gateway-section-error"]').text()).toContain(