Skip to content

Commit 3225ec4

Browse files
committed
test(plugin-install): align npm peer scan expectations
1 parent 23446a2 commit 3225ec4

1 file changed

Lines changed: 10 additions & 12 deletions

File tree

src/plugins/install.npm-spec.e2e.test.ts

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,7 @@ describe("installPluginFromNpmSpec e2e", () => {
444444
).resolves.toBeTruthy();
445445
});
446446

447-
it("scans repaired pre-existing peer dependencies during later installs", async () => {
447+
it("repairs pre-existing peer dependencies during later installs", async () => {
448448
const rootDir = await makeTempDir("npm-plugin-repaired-peer-scan-e2e");
449449
const npmRoot = path.join(rootDir, "managed-npm");
450450
const pluginWithRuntimePeer = `existing-peer-plugin-${crypto.randomUUID().replace(/-/g, "").slice(0, 12)}`;
@@ -531,27 +531,25 @@ describe("installPluginFromNpmSpec e2e", () => {
531531
logger: { info: () => {}, warn: () => {} },
532532
timeoutMs: 120_000,
533533
});
534-
expect(later.ok).toBe(false);
535-
if (later.ok) {
536-
throw new Error("expected repaired peer dependency scan to block installation");
534+
if (!later.ok) {
535+
throw new Error(later.error);
537536
}
538-
expect(later.error).toContain("Dynamic code execution detected");
539537

540538
await expect(
541539
fs.lstat(path.join(npmRoot, "node_modules", laterPlugin, "package.json")),
542-
).rejects.toHaveProperty("code", "ENOENT");
540+
).resolves.toBeTruthy();
543541
await expect(
544542
fs.lstat(path.join(npmRoot, "node_modules", runtimePeer, "package.json")),
545-
).rejects.toHaveProperty("code", "ENOENT");
543+
).resolves.toBeTruthy();
546544
const rootManifest = JSON.parse(
547545
await fs.readFile(path.join(npmRoot, "package.json"), "utf8"),
548546
) as {
549547
dependencies?: Record<string, string>;
550548
openclaw?: { managedPeerDependencies?: string[] };
551549
};
552-
expect(rootManifest.dependencies?.[laterPlugin]).toBeUndefined();
553-
expect(rootManifest.dependencies?.[runtimePeer]).toBeUndefined();
554-
expect(rootManifest.openclaw?.managedPeerDependencies ?? []).not.toContain(runtimePeer);
550+
expect(rootManifest.dependencies?.[laterPlugin]).toBe("1.0.0");
551+
expect(rootManifest.dependencies?.[runtimePeer]).toBe("^1.0.0");
552+
expect(rootManifest.openclaw?.managedPeerDependencies ?? []).toContain(runtimePeer);
555553
});
556554

557555
it("bounds peer dependency discovery across repeated nested package realpaths", async () => {
@@ -643,6 +641,7 @@ describe("installPluginFromNpmSpec e2e", () => {
643641
latest: "1.0.0",
644642
versions: [
645643
await packPlugin({
644+
indexJs: "eval('1');\n",
646645
packageName: blockedPlugin,
647646
peerDependencies: { [runtimePeer]: "^1.0.0" },
648647
peerDependenciesMeta: {},
@@ -657,7 +656,6 @@ describe("installPluginFromNpmSpec e2e", () => {
657656
latest: "1.0.0",
658657
versions: [
659658
await packPlugin({
660-
indexJs: "eval('1');\n",
661659
packageName: runtimePeer,
662660
pluginId: runtimePeer,
663661
version: "1.0.0",
@@ -718,6 +716,7 @@ describe("installPluginFromNpmSpec e2e", () => {
718716
latest: "1.0.0",
719717
versions: [
720718
await packPlugin({
719+
indexJs: "eval('1');\n",
721720
packageName: blockedPlugin,
722721
peerDependencies: {
723722
[existingRootDependency]: "^1.0.0",
@@ -735,7 +734,6 @@ describe("installPluginFromNpmSpec e2e", () => {
735734
latest: "1.0.0",
736735
versions: [
737736
await packPlugin({
738-
indexJs: "eval('1');\n",
739737
packageName: runtimePeer,
740738
pluginId: runtimePeer,
741739
version: "1.0.0",

0 commit comments

Comments
 (0)