Files
openclaw-zero-token/commands/status.link-channel.test.ts
sjhu 571e14a236 feat: upgrade to upstream v2026.3.28
Major upgrade from e26988a38 to upstream v2026.3.28 (f9b107928).
Key changes:
- Upstream src/, ui/, extensions/ (89 bundled extensions)
- Zero-token web providers preserved in src/zero-token/
- AskOnce plugin restored and registered as CLI command
- Added missing packages: @anthropic-ai/vertex-sdk, @modelcontextprotocol/sdk
- Fixed tsconfig rootDir, skipLibCheck for plugin-sdk DTS build
- Added askonce to bundled plugin metadata and package.json exports
- Fixed AskOnce CLI command registration (missing commands metadata)
- Restored AskOnce adapter imports (correct 5-level relative paths)
- Removed stale migration artifacts from root directory
2026-03-30 17:58:12 +08:00

56 lines
1.6 KiB
TypeScript

import { describe, expect, it, vi } from "vitest";
import type { OpenClawConfig } from "../config/config.js";
const pluginRegistry = vi.hoisted(() => ({ list: [] as unknown[] }));
vi.mock("../channels/plugins/index.js", () => ({
listChannelPlugins: () => pluginRegistry.list,
}));
import { resolveLinkChannelContext } from "./status.link-channel.js";
describe("resolveLinkChannelContext", () => {
it("returns linked context from read-only inspected account state", async () => {
const account = { configured: true, enabled: true };
pluginRegistry.list = [
{
id: "discord",
meta: { label: "Discord" },
config: {
listAccountIds: () => ["default"],
inspectAccount: () => account,
resolveAccount: () => {
throw new Error("should not be called in read-only mode");
},
},
status: {
buildChannelSummary: () => ({ linked: true, authAgeMs: 1234 }),
},
},
];
const result = await resolveLinkChannelContext({} as OpenClawConfig);
expect(result?.linked).toBe(true);
expect(result?.authAgeMs).toBe(1234);
expect(result?.account).toBe(account);
});
it("degrades safely when account resolution throws", async () => {
pluginRegistry.list = [
{
id: "discord",
meta: { label: "Discord" },
config: {
listAccountIds: () => ["default"],
resolveAccount: () => {
throw new Error("missing secret");
},
},
},
];
const result = await resolveLinkChannelContext({} as OpenClawConfig);
expect(result).toBeNull();
});
});