|
1 | | -import { describe, expect, it, vi } from "vitest"; |
| 1 | +import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; |
| 2 | +import { |
| 3 | + namedAccountPromotionKeys as matrixNamedAccountPromotionKeys, |
| 4 | + resolveSingleAccountPromotionTarget as resolveMatrixSingleAccountPromotionTarget, |
| 5 | + singleAccountKeysToMove as matrixSingleAccountKeysToMove, |
| 6 | +} from "../../../extensions/matrix/contract-api.js"; |
| 7 | +import { singleAccountKeysToMove as telegramSingleAccountKeysToMove } from "../../../extensions/telegram/contract-api.js"; |
2 | 8 | import { |
3 | 9 | resolveSetupWizardAllowFromEntries, |
4 | 10 | resolveSetupWizardGroupAllowlist, |
5 | 11 | } from "../../../test/helpers/plugins/setup-wizard.js"; |
6 | 12 | import type { OpenClawConfig } from "../../config/config.js"; |
| 13 | +import { resetPluginRuntimeStateForTest, setActivePluginRegistry } from "../../plugins/runtime.js"; |
7 | 14 | import { DEFAULT_ACCOUNT_ID } from "../../routing/session-key.js"; |
| 15 | +import { |
| 16 | + createChannelTestPluginBase, |
| 17 | + createTestRegistry, |
| 18 | +} from "../../test-utils/channel-plugins.js"; |
8 | 19 | import { |
9 | 20 | applySingleTokenPromptResult, |
10 | 21 | buildSingleChannelSecretPromptState, |
@@ -60,6 +71,39 @@ import { |
60 | 71 | splitSetupEntries, |
61 | 72 | } from "./setup-wizard-helpers.js"; |
62 | 73 |
|
| 74 | +beforeEach(() => { |
| 75 | + setActivePluginRegistry( |
| 76 | + createTestRegistry([ |
| 77 | + { |
| 78 | + pluginId: "matrix", |
| 79 | + source: "test", |
| 80 | + plugin: { |
| 81 | + ...createChannelTestPluginBase({ id: "matrix", label: "Matrix" }), |
| 82 | + setup: { |
| 83 | + singleAccountKeysToMove: matrixSingleAccountKeysToMove, |
| 84 | + namedAccountPromotionKeys: matrixNamedAccountPromotionKeys, |
| 85 | + resolveSingleAccountPromotionTarget: resolveMatrixSingleAccountPromotionTarget, |
| 86 | + }, |
| 87 | + }, |
| 88 | + }, |
| 89 | + { |
| 90 | + pluginId: "telegram", |
| 91 | + source: "test", |
| 92 | + plugin: { |
| 93 | + ...createChannelTestPluginBase({ id: "telegram", label: "Telegram" }), |
| 94 | + setup: { |
| 95 | + singleAccountKeysToMove: telegramSingleAccountKeysToMove, |
| 96 | + }, |
| 97 | + }, |
| 98 | + }, |
| 99 | + ]), |
| 100 | + ); |
| 101 | +}); |
| 102 | + |
| 103 | +afterEach(() => { |
| 104 | + resetPluginRuntimeStateForTest(); |
| 105 | +}); |
| 106 | + |
63 | 107 | function createPrompter(inputs: string[]) { |
64 | 108 | return { |
65 | 109 | text: vi.fn(async () => inputs.shift() ?? ""), |
|
0 commit comments