test(ci): align channel defaults and clean stale hook tests

This commit is contained in:
Peter Steinberger
2026-04-04 04:51:24 +01:00
parent f4fa53de3f
commit 5b144655f2
7 changed files with 30 additions and 136 deletions

View File

@@ -6,59 +6,23 @@ import type { PluginManifestRecord, PluginManifestRegistry } from "../plugins/ma
import { createConfigIO } from "./io.js";
import type { OpenClawConfig } from "./types.js";
type LoadPluginManifestRegistry =
typeof import("../plugins/manifest-registry.js").loadPluginManifestRegistry;
// Mock the plugin manifest registry so we can register a fake channel whose
// AJV JSON Schema carries a `default` value. This lets the #56772 regression
// test exercise the exact code path that caused the bug: AJV injecting
// defaults during the write-back validation pass.
const mockLoadPluginManifestRegistry = vi.hoisted(() =>
vi.fn((): PluginManifestRegistry => ({
diagnostics: [],
plugins: [],
})),
vi.fn(
(): PluginManifestRegistry => ({
diagnostics: [],
plugins: [],
}),
),
);
vi.mock("../plugins/manifest-registry.js", () => ({
loadPluginManifestRegistry: mockLoadPluginManifestRegistry,
}));
function createBundledChannelManifestRecord(params: {
id: string;
channelId: string;
name?: string;
version?: string;
origin?: PluginManifestRecord["origin"];
providers?: string[];
cliBackends?: string[];
skills?: string[];
hooks?: string[];
rootDir?: string;
source?: string;
manifestPath?: string;
channelCatalogMeta: NonNullable<PluginManifestRecord["channelCatalogMeta"]>;
channelConfigs: NonNullable<PluginManifestRecord["channelConfigs"]>;
}): PluginManifestRecord {
const origin = params.origin ?? "bundled";
return {
id: params.id,
name: params.name,
version: params.version,
origin,
channels: [params.channelId],
providers: params.providers ?? [],
cliBackends: params.cliBackends ?? [],
skills: params.skills ?? [],
hooks: params.hooks ?? [],
rootDir: params.rootDir ?? `/tmp/${params.id}`,
source: params.source ?? origin,
manifestPath: params.manifestPath ?? `/tmp/${params.id}/openclaw.plugin.json`,
channelCatalogMeta: params.channelCatalogMeta,
channelConfigs: params.channelConfigs,
};
}
describe("config io write", () => {
let fixtureRoot = "";
let homeCaseId = 0;
@@ -493,83 +457,8 @@ describe("config io write", () => {
// write-back leak.
mockLoadPluginManifestRegistry.mockReturnValue({
diagnostics: [],
<<<<<<< HEAD
plugins: [
createBundledChannelManifestRecord({
id: "bluebubbles",
name: "BlueBubbles",
version: "0.0.0-test",
origin: "bundled",
providers: [],
cliBackends: [],
skills: [],
hooks: [],
rootDir: "/mock/bluebubbles",
source: "bundled",
manifestPath: "/mock/bluebubbles/openclaw.plugin.json",
channelId: "bluebubbles",
channelCatalogMeta: {
id: "bluebubbles",
label: "BlueBubbles",
blurb: "BlueBubbles channel",
},
channelConfigs: {
bluebubbles: {
schema: {
type: "object",
properties: {
enrichGroupParticipantsFromContacts: {
type: "boolean",
default: true,
},
serverUrl: {
type: "string",
},
},
additionalProperties: true,
},
uiHints: {},
},
},
}),
],
} satisfies PluginManifestRegistry);
||||||| parent of 2d00c45c74 (perf: split infra, tooling, and provider test lanes)
plugins: [
{
id: "bluebubbles",
origin: "bundled",
channels: ["bluebubbles"],
channelCatalogMeta: {
id: "bluebubbles",
label: "BlueBubbles",
blurb: "BlueBubbles channel",
},
channelConfigs: {
bluebubbles: {
schema: {
type: "object",
properties: {
enrichGroupParticipantsFromContacts: {
type: "boolean",
default: true,
},
serverUrl: {
type: "string",
},
},
additionalProperties: true,
},
uiHints: {},
},
},
},
],
});
=======
plugins: [createBlueBubblesManifestRecord()],
});
>>>>>>> 2d00c45c74 (perf: split infra, tooling, and provider test lanes)
await withSuiteHome(async (home) => {
const { configPath, io, snapshot } = await writeConfigAndCreateIo({

View File

@@ -328,18 +328,17 @@ describe("installHooksFromPath", () => {
});
describe("installHooksFromNpmSpec", () => {
it("forwards dangerous force unsafe install through npm-spec archive params", async () => {
it("does not expose dangerous force unsafe install through npm-spec archive params", async () => {
const installFromValidatedNpmSpecArchiveSpy = vi
.spyOn(hookInstallRuntime, "installFromValidatedNpmSpecArchive")
.mockImplementation(
async (
params: Parameters<typeof hookInstallRuntime.installFromValidatedNpmSpecArchive>[0],
) => {
expect(params.archiveInstallParams).toEqual(
expect.objectContaining({
dangerouslyForceUnsafeInstall: true,
}),
);
expect(
"dangerouslyForceUnsafeInstall" in
(params.archiveInstallParams as Record<string, unknown>),
).toBe(false);
return {
ok: true,
hookPackId: "test-hooks",
@@ -353,7 +352,6 @@ describe("installHooksFromNpmSpec", () => {
try {
const result = await installHooksFromNpmSpec({
spec: "@openclaw/test-hooks@0.0.1",
dangerouslyForceUnsafeInstall: true,
});
expect(result.ok).toBe(true);