Anforderungen  |   Konzepte  |   Entwurf  |   Entwicklung  |   Qualitätssicherung  |   Lebenszyklus  |   Steuerung
 
 
 
 


Impressum status-json-payload.test.ts

  Sprache: JAVA
 

Spracherkennung für: .ts vermutete Sprache: Unknown {[0] [0] [0]} [Methode: Schwerpunktbildung, einfache Gewichte, sechs Dimensionen]

import { beforeEach, describe, expect, it, vi } from "vitest";
import { buildStatusJsonPayload, resolveStatusUpdateChannelInfo } from "./status-json-payload.ts";

const mocks = vi.hoisted(() => ({
  normalizeUpdateChannel: vi.fn((value?: string | null) => value ?? null),
  resolveUpdateChannelDisplay: vi.fn(() => ({
    channel: "stable",
    source: "config",
    label: "stable",
  })),
}));

vi.mock("../infra/update-channels.js", () => ({
  normalizeUpdateChannel: mocks.normalizeUpdateChannel,
  resolveUpdateChannelDisplay: mocks.resolveUpdateChannelDisplay,
}));

describe("status-json-payload", () => {
  beforeEach(() => {
    vi.clearAllMocks();
  });

  it("resolves update channel info through the shared channel display path", () => {
    expect(
      resolveStatusUpdateChannelInfo({
        updateConfigChannel: "beta",
        update: {
          installKind: "package",
          git: {
            tag: "v1.2.3",
            branch: "main",
          },
        },
      }),
    ).toEqual({
      channel: "stable",
      source: "config",
      label: "stable",
    });
    expect(mocks.normalizeUpdateChannel).toHaveBeenCalledWith("beta");
    expect(mocks.resolveUpdateChannelDisplay).toHaveBeenCalledWith({
      configChannel: "beta",
      installKind: "package",
      gitTag: "v1.2.3",
      gitBranch: "main",
    });
  });

  it("builds the shared status json payload with optional sections", () => {
    expect(
      buildStatusJsonPayload({
        summary: { ok: true },
        surface: {
          cfg: { update: { channel: "stable" }, gateway: {} },
          update: {
            root: "/tmp/openclaw",
            installKind: "package",
            packageManager: "npm",
            registry: { latestVersion: "1.2.3" },
          } as never,
          tailscaleMode: "serve",
          gatewayMode: "remote",
          remoteUrlMissing: false,
          gatewayConnection: { url: "wss://gateway.example.com", urlSource: "config" },
          gatewayReachable: true,
          gatewayProbe: { connectLatencyMs: 42, error: null },
          gatewayProbeAuth: { token: "tok" },
          gatewaySelf: { host: "gateway" },
          gatewayProbeAuthWarning: "warn",
          gatewayService: { label: "LaunchAgent", installed: true, loadedText: "loaded" },
          nodeService: { label: "node", installed: true, loadedText: "loaded" },
        },
        osSummary: { platform: "linux" },
        memory: null,
        memoryPlugin: { enabled: true },
        agents: [{ id: "main" }],
        secretDiagnostics: ["diag"],
        securityAudit: { summary: { critical: 1 } },
        health: { ok: true },
        usage: { providers: [] },
        lastHeartbeat: { status: "ok" },
        pluginCompatibility: [
          {
            pluginId: "legacy",
            code: "legacy-before-agent-start",
            severity: "warn",
            message: "warn",
          },
        ],
      }),
    ).toEqual({
      ok: true,
      os: { platform: "linux" },
      update: {
        root: "/tmp/openclaw",
        installKind: "package",
        packageManager: "npm",
        registry: { latestVersion: "1.2.3" },
      },
      updateChannel: "stable",
      updateChannelSource: "config",
      memory: null,
      memoryPlugin: { enabled: true },
      gateway: {
        mode: "remote",
        url: "wss://gateway.example.com",
        urlSource: "config",
        misconfigured: false,
        reachable: true,
        connectLatencyMs: 42,
        self: { host: "gateway" },
        error: null,
        authWarning: "warn",
      },
      gatewayService: { label: "LaunchAgent", installed: true, loadedText: "loaded" },
      nodeService: { label: "node", installed: true, loadedText: "loaded" },
      agents: [{ id: "main" }],
      secretDiagnostics: ["diag"],
      securityAudit: { summary: { critical: 1 } },
      health: { ok: true },
      usage: { providers: [] },
      lastHeartbeat: { status: "ok" },
      pluginCompatibility: {
        count: 1,
        warnings: [
          {
            pluginId: "legacy",
            code: "legacy-before-agent-start",
            severity: "warn",
            message: "warn",
          },
        ],
      },
    });
  });

  it("omits optional sections when they are absent", () => {
    expect(
      buildStatusJsonPayload({
        summary: { ok: true },
        surface: {
          cfg: { gateway: {} },
          update: {
            root: "/tmp/openclaw",
            installKind: "package",
            packageManager: "npm",
          } as never,
          tailscaleMode: "off",
          gatewayMode: "local",
          remoteUrlMissing: false,
          gatewayConnection: { url: "ws://127.0.0.1:18789" },
          gatewayReachable: false,
          gatewayProbe: null,
          gatewayProbeAuth: null,
          gatewaySelf: null,
          gatewayProbeAuthWarning: null,
          gatewayService: { label: "LaunchAgent", installed: false, loadedText: "not installed" },
          nodeService: { label: "node", installed: false, loadedText: "not installed" },
        },
        osSummary: { platform: "linux" },
        memory: null,
        memoryPlugin: null,
        agents: [],
        secretDiagnostics: [],
      }),
    ).not.toHaveProperty("securityAudit");
  });
});

¤ Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.0.21Bemerkung:  (vorverarbeitet am  2026-04-27) ¤

*Bot Zugriff






Wurzel

Suchen

Beweissystem der NASA

Beweissystem Isabelle

NIST Cobol Testsuite

Cephes Mathematical Library

Wiener Entwicklungsmethode

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.






                                                                                                                                                                                                                                                                                                                                                                                                     


Neuigkeiten

     Aktuelles
     Motto des Tages

Software

     Produkte
     Quellcodebibliothek

Aktivitäten

     Artikel über Sicherheit
     Anleitung zur Aktivierung von SSL

Muße

     Gedichte
     Musik
     Bilder

Jenseits des Üblichen ....

Besucherstatistik

Besucherstatistik

Monitoring

Montastic status badge