From 3617778aaf8abc25f1cddbcec22342fc13b93750 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Sun, 3 May 2026 17:33:56 +0100 Subject: [PATCH] test: tolerate prerelease channel metadata --- src/cli/update-cli.test.ts | 4 +++- src/commands/status-all/format.test.ts | 14 +++++++------- src/commands/status-overview-surface.test.ts | 3 ++- src/commands/status.test-support.ts | 16 ++++++++++++++++ src/plugins/manifest-registry.test.ts | 4 ++-- 5 files changed, 30 insertions(+), 11 deletions(-) diff --git a/src/cli/update-cli.test.ts b/src/cli/update-cli.test.ts index dea383f319e..59dfa45883f 100644 --- a/src/cli/update-cli.test.ts +++ b/src/cli/update-cli.test.ts @@ -8,8 +8,10 @@ import { beforeEach, describe, expect, it, vi } from "vitest"; import { TEST_BUNDLED_RUNTIME_SIDECAR_PATHS } from "../../test/helpers/bundled-runtime-sidecars.js"; import type { OpenClawConfig, ConfigFileSnapshot } from "../config/types.openclaw.js"; import { writePackageDistInventory } from "../infra/package-dist-inventory.js"; +import { isBetaTag } from "../infra/update-channels.js"; import type { UpdateRunResult } from "../infra/update-runner.js"; import { withEnvAsync } from "../test-utils/env.js"; +import { VERSION } from "../version.js"; import { createCliRuntimeCapture } from "./test-runtime-capture.js"; import { isOwningNpmCommand } from "./update-cli.test-helpers.js"; @@ -1127,7 +1129,7 @@ describe("update-cli", () => { expect(last).toBeDefined(); const parsed = last as Record; const channel = parsed.channel as { value?: unknown }; - expect(channel.value).toBe("stable"); + expect(channel.value).toBe(isBetaTag(VERSION) ? "beta" : "stable"); }, }, ] as const)("updateStatusCommand rendering: $name", runUpdateCliScenario); diff --git a/src/commands/status-all/format.test.ts b/src/commands/status-all/format.test.ts index 387706494b2..507b1b34cfc 100644 --- a/src/commands/status-all/format.test.ts +++ b/src/commands/status-all/format.test.ts @@ -1,4 +1,8 @@ import { describe, expect, it } from "vitest"; +import { + baseStatusExpectedUpdateChannelInfo, + baseStatusExpectedUpdateChannelLabel, +} from "../status.test-support.ts"; import { buildStatusGatewaySurfaceValues, buildStatusOverviewRows, @@ -78,12 +82,8 @@ describe("status-all format", () => { } as never, }), ).toEqual({ - channelInfo: { - channel: "stable", - source: "config", - label: "stable (config)", - }, - channelLabel: "stable (config)", + channelInfo: baseStatusExpectedUpdateChannelInfo, + channelLabel: baseStatusExpectedUpdateChannelLabel, gitLabel: "main · tag v1.2.3", updateLine: `git main · ↔ origin/main · behind 2 · npm update ${newerRegistryVersion}`, updateAvailable: true, @@ -374,7 +374,7 @@ describe("status-all format", () => { { Item: "Version", Value: "1.0.0" }, { Item: "Dashboard", Value: "http://127.0.0.1:18789/" }, { Item: "Tailscale exposure", Value: "serve · box.tail.ts.net · https://box.tail.ts.net" }, - { Item: "Channel", Value: "stable (config)" }, + { Item: "Channel", Value: baseStatusExpectedUpdateChannelLabel }, { Item: "Git", Value: "main · tag v1.2.3" }, { Item: "Update", Value: "available · custom update" }, { diff --git a/src/commands/status-overview-surface.test.ts b/src/commands/status-overview-surface.test.ts index eee8893459f..ea33fd51c03 100644 --- a/src/commands/status-overview-surface.test.ts +++ b/src/commands/status-overview-surface.test.ts @@ -7,6 +7,7 @@ import { } from "./status-overview-surface.ts"; import { baseStatusCfg, + baseStatusExpectedUpdateChannelLabel, baseStatusGatewaySnapshot, baseStatusOverviewScanFields, baseStatusOverviewSurface, @@ -82,7 +83,7 @@ describe("status-overview-surface", () => { { Item: "OS", Value: "macOS · node 22" }, { Item: "Dashboard", Value: "http://127.0.0.1:18789/" }, { Item: "Tailscale exposure", Value: "muted(off · box.tail.ts.net)" }, - { Item: "Channel", Value: "stable (config)" }, + { Item: "Channel", Value: baseStatusExpectedUpdateChannelLabel }, { Item: "Git", Value: "main · tag v1.2.3" }, { Item: "Update", Value: "available · custom update" }, { diff --git a/src/commands/status.test-support.ts b/src/commands/status.test-support.ts index a0b37c4e4f1..e6cb4ed5190 100644 --- a/src/commands/status.test-support.ts +++ b/src/commands/status.test-support.ts @@ -1,6 +1,8 @@ import type { HeartbeatEventPayload } from "../infra/heartbeat-events.js"; +import { isBetaTag } from "../infra/update-channels.js"; import type { Tone } from "../memory-host-sdk/status.js"; import type { PluginCompatibilityNotice } from "../plugins/status.js"; +import { VERSION } from "../version.js"; import type { buildStatusCommandOverviewRows } from "./status-overview-rows.ts"; import type { StatusOverviewSurface } from "./status-overview-surface.ts"; import type { AgentLocalStatus } from "./status.agent-local.js"; @@ -30,6 +32,20 @@ export const baseStatusUpdate = { registry: { latestVersion: "2026.4.10" }, } as never; +export const baseStatusExpectedUpdateChannelInfo = isBetaTag(VERSION) + ? { + channel: "beta", + source: "installed-version", + label: "beta (installed version)", + } + : { + channel: "stable", + source: "config", + label: "stable (config)", + }; + +export const baseStatusExpectedUpdateChannelLabel = baseStatusExpectedUpdateChannelInfo.label; + export const baseStatusGatewaySnapshot = { gatewayMode: "remote", remoteUrlMissing: false, diff --git a/src/plugins/manifest-registry.test.ts b/src/plugins/manifest-registry.test.ts index e3e77402a70..f14cf15f706 100644 --- a/src/plugins/manifest-registry.test.ts +++ b/src/plugins/manifest-registry.test.ts @@ -308,12 +308,12 @@ describe("loadPluginManifestRegistry", () => { const stateDir = makeTempDir(); const pluginDir = path.join(stateDir, "extensions", "cached-manifest"); mkdirSafe(pluginDir); - fs.writeFileSync(path.join(pluginDir, "index.ts"), "export default function () {}", "utf-8"); + fs.writeFileSync(path.join(pluginDir, "index.js"), "export default function () {}", "utf-8"); fs.writeFileSync( path.join(pluginDir, "package.json"), JSON.stringify({ name: "@openclaw/cached-manifest", - openclaw: { extensions: ["./index.ts"] }, + openclaw: { extensions: ["./index.js"] }, }), "utf-8", );