fix: keep federated docker updates tab visible

This commit is contained in:
Pi Web Agent
2026-06-29 16:12:40 +00:00
parent 4885aa0dd5
commit 01c75298f9
8 changed files with 136 additions and 10 deletions
+24 -1
View File
@@ -1,6 +1,6 @@
import { describe, expect, it } from "vitest";
import type { PiWebComponentStatus, PiWebStatusMessage, PiWebStatusResponse, PluginRuntimeState } from "@jmfederico/pi-web/plugin-api";
import { additionalCommands, formatVersion, installationLabel, messageCount, recommendedCommand, shouldShowUpdatesPanel } from "./updatesLogic";
import { additionalCommands, fallbackDockerStatus, formatVersion, installationLabel, messageCount, recommendedCommand, shouldShowUpdatesPanel } from "./updatesLogic";
function component(overrides: Partial<PiWebComponentStatus> = {}): PiWebComponentStatus {
return {
@@ -181,6 +181,11 @@ describe("shouldShowUpdatesPanel", () => {
expect(shouldShowUpdatesPanel(stateWith(value))).toBe(true);
});
it("shows the panel when a federated Docker runtime hint is available before status is parsed", () => {
expect(shouldShowUpdatesPanel(undefined, { dockerMode: "dev" })).toBe(true);
expect(shouldShowUpdatesPanel(undefined, { dockerMode: "runtime" })).toBe(true);
});
it("hides the panel when status is unavailable", () => {
expect(shouldShowUpdatesPanel(stateWith(undefined))).toBe(false);
expect(shouldShowUpdatesPanel(undefined)).toBe(false);
@@ -223,6 +228,24 @@ describe("shouldShowUpdatesPanel", () => {
});
});
describe("fallbackDockerStatus", () => {
it("creates Docker development commands from a federated runtime hint", () => {
const fallback = fallbackDockerStatus({ dockerMode: "dev" }, "generated");
expect(fallback?.generatedAt).toBe("generated");
expect(fallback?.components.web.installation).toEqual({ kind: "docker", dockerMode: "dev" });
expect(fallback?.commands).toMatchObject({
update: "pi-web-docker --dev update",
restart: "pi-web-docker --dev restart",
status: "pi-web-docker --dev status",
});
expect(fallback?.messages[0]?.id).toBe("docker-status-compatibility");
});
it("does not create a fallback without a Docker runtime hint", () => {
expect(fallbackDockerStatus({})).toBeUndefined();
});
});
describe("messageCount", () => {
it("counts messages and tolerates missing status", () => {
expect(messageCount(undefined)).toBe(0);