From 95ef5eb7620a6599cebe4dca0996d1bfd6e64536 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Sun, 3 May 2026 23:30:45 +0100 Subject: [PATCH] test(e2e): require configured plugin npm repair --- .../e2e/lib/upgrade-survivor/assertions.mjs | 49 ++++++++----------- 1 file changed, 20 insertions(+), 29 deletions(-) diff --git a/scripts/e2e/lib/upgrade-survivor/assertions.mjs b/scripts/e2e/lib/upgrade-survivor/assertions.mjs index f241e024304..fd008e1cf72 100644 --- a/scripts/e2e/lib/upgrade-survivor/assertions.mjs +++ b/scripts/e2e/lib/upgrade-survivor/assertions.mjs @@ -382,8 +382,8 @@ function assertExternalPluginInstall(records, pluginId, packageName) { const record = records[pluginId]; assert(record, `configured external ${pluginId} plugin install record missing`); assert( - record.source === "clawhub" || record.source === "npm", - `configured external ${pluginId} plugin installed from unexpected source: ${record.source}`, + record.source === "npm", + `configured external ${pluginId} plugin must be installed from npm, got: ${record.source}`, ); const installPath = resolveHomePath(record.installPath); assert( @@ -398,32 +398,20 @@ function assertExternalPluginInstall(records, pluginId, packageName) { fs.existsSync(path.join(installPath, "package.json")), `configured external ${pluginId} plugin package.json missing: ${installPath}`, ); - if (record.source === "clawhub") { - assert( - String(record.spec ?? "").startsWith(`clawhub:${packageName}`), - `configured external ${pluginId} plugin ClawHub spec changed`, - ); - } else { - const npmRoot = path.join(requireEnv("OPENCLAW_STATE_DIR"), "npm", "node_modules"); - assert( - isPathInside(npmRoot, installPath), - `configured external ${pluginId} npm install path outside managed npm root: ${installPath}`, - ); - assert( - String(record.spec ?? record.resolvedSpec ?? "").startsWith(packageName), - `configured external ${pluginId} plugin npm spec changed`, - ); - } -} - -function assertConfiguredPluginAvailable(index, pluginId, packageName) { - const records = index.installRecords ?? {}; - const bundled = (index.plugins ?? []).find((plugin) => plugin?.pluginId === pluginId); - if (bundled) { - assert(bundled.enabled !== false, `configured bundled ${pluginId} plugin is disabled`); - return; - } - assertExternalPluginInstall(records, pluginId, packageName); + const packageJson = readJson(path.join(installPath, "package.json")); + assert( + packageJson.name === packageName, + `configured external ${pluginId} package name changed: ${packageJson.name}`, + ); + const npmRoot = path.join(requireEnv("OPENCLAW_STATE_DIR"), "npm", "node_modules"); + assert( + isPathInside(npmRoot, installPath), + `configured external ${pluginId} npm install path outside managed npm root: ${installPath}`, + ); + assert( + String(record.spec ?? record.resolvedSpec ?? "").startsWith(packageName), + `configured external ${pluginId} plugin npm spec changed`, + ); } function assertConfiguredPluginInstalls() { @@ -442,7 +430,10 @@ function assertConfiguredPluginInstalls() { assert(!matrix, "internal matrix plugin should not be installed externally"); assert(bundledMatrix, "configured bundled matrix plugin is missing from the plugin index"); assert(bundledMatrix.enabled !== false, "configured bundled matrix plugin is disabled"); - assertConfiguredPluginAvailable(index, "brave", "@openclaw/brave-plugin"); + const brave = (index.plugins ?? []).find((plugin) => plugin?.pluginId === "brave"); + assert(brave, "configured external brave plugin is missing from the plugin index"); + assert(brave.enabled !== false, "configured external brave plugin is disabled"); + assertExternalPluginInstall(records, "brave", "@openclaw/brave-plugin"); assert(!records.telegram, "internal telegram plugin should not be installed externally"); }