@@ -98,21 +98,30 @@ describe("bundle plugin hooks", () => {
|
98 | 98 | }; |
99 | 99 | } |
100 | 100 | |
| 101 | +function requireOnlyHookEntry(entries: ReturnType<typeof loadWorkspaceHookEntries>) { |
| 102 | +expect(entries).toHaveLength(1); |
| 103 | +const [entry] = entries; |
| 104 | +if (!entry) { |
| 105 | +throw new Error("Expected bundled hook entry"); |
| 106 | +} |
| 107 | +return entry; |
| 108 | +} |
| 109 | + |
101 | 110 | it("exposes enabled bundle hook dirs as plugin-managed hook entries", async () => { |
102 | 111 | const bundleRoot = await writeBundleHookFixture(); |
103 | 112 | |
104 | 113 | const entries = loadWorkspaceHookEntries(workspaceDir, { |
105 | 114 | config: createConfig(true), |
106 | 115 | }); |
107 | 116 | |
108 | | -expect(entries).toHaveLength(1); |
109 | | -expect(entries[0]?.hook.name).toBe("bundle-hook"); |
110 | | -expect(entries[0]?.hook.source).toBe("openclaw-plugin"); |
111 | | -expect(entries[0]?.hook.pluginId).toBe("sample-bundle"); |
112 | | -expect(entries[0]?.hook.baseDir).toBe( |
| 117 | +const entry = requireOnlyHookEntry(entries); |
| 118 | +expect(entry.hook.name).toBe("bundle-hook"); |
| 119 | +expect(entry.hook.source).toBe("openclaw-plugin"); |
| 120 | +expect(entry.hook.pluginId).toBe("sample-bundle"); |
| 121 | +expect(entry.hook.baseDir).toBe( |
113 | 122 | fs.realpathSync.native(path.join(bundleRoot, "hooks", "bundle-hook")), |
114 | 123 | ); |
115 | | -expect(entries[0]?.metadata?.events).toEqual(["command:new"]); |
| 124 | +expect(entry.metadata?.events).toEqual(["command:new"]); |
116 | 125 | }); |
117 | 126 | |
118 | 127 | it("loads and executes enabled bundle hooks through the internal hook loader", async () => { |
|