|
1 | 1 | import fs from "node:fs"; |
2 | 2 | import path from "node:path"; |
3 | | -import { afterAll, beforeEach, describe, expect, it, vi } from "vitest"; |
| 3 | +import { afterAll, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; |
4 | 4 | import type { |
5 | 5 | ConversationRef, |
6 | 6 | SessionBindingAdapter, |
@@ -167,6 +167,21 @@ afterAll(() => { |
167 | 167 | cleanupTrackedTempDirs(tempDirs); |
168 | 168 | }); |
169 | 169 |
|
| 170 | +beforeAll(async () => { |
| 171 | + ({ |
| 172 | + __testing, |
| 173 | + buildPluginBindingApprovalCustomId, |
| 174 | + detachPluginConversationBinding, |
| 175 | + getCurrentPluginConversationBinding, |
| 176 | + parsePluginBindingApprovalCustomId, |
| 177 | + requestPluginConversationBinding, |
| 178 | + resolvePluginConversationBindingApproval, |
| 179 | + } = await import("./conversation-binding.js")); |
| 180 | + ({ registerSessionBindingAdapter, unregisterSessionBindingAdapter } = |
| 181 | + await import("../infra/outbound/session-binding-service.js")); |
| 182 | + ({ setActivePluginRegistry } = await import("./runtime.js")); |
| 183 | +}); |
| 184 | + |
170 | 185 | function createDiscordCodexBindRequest( |
171 | 186 | conversationId: string, |
172 | 187 | summary: string, |
@@ -389,44 +404,7 @@ async function expectResolutionDoesNotWait(params: { |
389 | 404 | } |
390 | 405 |
|
391 | 406 | describe("plugin conversation binding approvals", () => { |
392 | | - beforeEach(async () => { |
393 | | - vi.resetModules(); |
394 | | - vi.doMock("../infra/home-dir.js", async () => { |
395 | | - const actual = |
396 | | - await vi.importActual<typeof import("../infra/home-dir.js")>("../infra/home-dir.js"); |
397 | | - return { |
398 | | - ...actual, |
399 | | - expandHomePrefix: (value: string) => { |
400 | | - if (value === "~/.openclaw/plugin-binding-approvals.json") { |
401 | | - return approvalsPath; |
402 | | - } |
403 | | - return actual.expandHomePrefix(value); |
404 | | - }, |
405 | | - }; |
406 | | - }); |
407 | | - vi.doMock("./runtime.js", async () => { |
408 | | - const actual = await vi.importActual<typeof import("./runtime.js")>("./runtime.js"); |
409 | | - return { |
410 | | - ...actual, |
411 | | - getActivePluginRegistry: () => pluginRuntimeState.registry, |
412 | | - getActivePluginChannelRegistry: () => pluginRuntimeState.registry, |
413 | | - setActivePluginRegistry: (registry: PluginRegistry) => { |
414 | | - pluginRuntimeState.registry = registry; |
415 | | - }, |
416 | | - }; |
417 | | - }); |
418 | | - ({ |
419 | | - __testing, |
420 | | - buildPluginBindingApprovalCustomId, |
421 | | - detachPluginConversationBinding, |
422 | | - getCurrentPluginConversationBinding, |
423 | | - parsePluginBindingApprovalCustomId, |
424 | | - requestPluginConversationBinding, |
425 | | - resolvePluginConversationBindingApproval, |
426 | | - } = await import("./conversation-binding.js")); |
427 | | - ({ registerSessionBindingAdapter, unregisterSessionBindingAdapter } = |
428 | | - await import("../infra/outbound/session-binding-service.js")); |
429 | | - ({ setActivePluginRegistry } = await import("./runtime.js")); |
| 407 | + beforeEach(() => { |
430 | 408 | sessionBindingState.reset(); |
431 | 409 | __testing.reset(); |
432 | 410 | setActivePluginRegistry(createEmptyPluginRegistry()); |
|
0 commit comments