test: keep packaged provider setup discoverable

This commit is contained in:
Peter Steinberger
2026-04-26 02:07:04 +01:00
parent 371b69b3e2
commit 0731fc1942
3 changed files with 34 additions and 0 deletions

View File

@@ -61,6 +61,7 @@ if ! docker run --rm \
-e OPENCLAW_NPM_ONBOARD_CHANNEL="$CHANNEL" \
-e OPENCLAW_CURRENT_PACKAGE_TGZ="$DOCKER_PACKAGE_TGZ" \
-v "$PACKAGE_TGZ:$DOCKER_PACKAGE_TGZ:ro" \
-v "$ROOT_DIR/scripts/e2e:/app/scripts/e2e:ro" \
-i "$IMAGE_NAME" bash -s >"$run_log" 2>&1 <<'EOF'
set -euo pipefail

View File

@@ -43,6 +43,7 @@ function createCandidate(
rootDir: string,
id = "demo",
origin: PluginCandidate["origin"] = "global",
options: { enabledByDefault?: boolean } = {},
): PluginCandidate {
fs.writeFileSync(
path.join(rootDir, "index.ts"),
@@ -54,6 +55,7 @@ function createCandidate(
JSON.stringify({
id,
name: id,
...(options.enabledByDefault ? { enabledByDefault: true } : {}),
configSchema: { type: "object" },
providers: [id],
}),
@@ -184,6 +186,34 @@ describe("plugin registry install migration", () => {
]);
});
it("keeps enabled-by-default bundled provider plugins discoverable for setup", async () => {
const stateDir = makeTempDir();
const openaiDir = path.join(stateDir, "plugins", "openai");
const unusedBundledDir = path.join(stateDir, "plugins", "unused-bundled");
fs.mkdirSync(openaiDir, { recursive: true });
fs.mkdirSync(unusedBundledDir, { recursive: true });
await expect(
migratePluginRegistryForInstall({
stateDir,
candidates: [
createCandidate(openaiDir, "openai", "bundled", { enabledByDefault: true }),
createCandidate(unusedBundledDir, "unused-bundled", "bundled"),
],
readConfig: async () => ({}),
env: hermeticEnv(),
}),
).resolves.toMatchObject({
status: "migrated",
current: {
plugins: [expect.objectContaining({ pluginId: "openai", enabledByDefault: true })],
},
});
const persisted = await readPersistedInstalledPluginIndex({ stateDir });
expect(persisted?.plugins.map((plugin) => plugin.pluginId)).toEqual(["openai"]);
});
it("supports dry-run preflight without reading config or writing the registry", async () => {
const stateDir = makeTempDir();
const readConfig = vi.fn(async () => ({}));

View File

@@ -226,6 +226,9 @@ export function listMigrationRelevantPluginRecords(params: {
if (plugin.origin !== "bundled") {
return true;
}
if (plugin.enabledByDefault && plugin.contributions.providers.length > 0) {
return true;
}
if (installedPluginIds.has(plugin.pluginId) || referencedPluginIds.has(plugin.pluginId)) {
return true;
}