mirror of
https://github.com/openclaw/openclaw.git
synced 2026-03-25 17:02:46 +00:00
refactor(test): dedupe setup wizard helpers
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import { createPluginRuntimeMock } from "../../../test/helpers/extensions/plugin-runtime-mock.js";
|
||||
import { createRuntimeEnv } from "../../../test/helpers/extensions/runtime-env.js";
|
||||
import { createNonExitingRuntimeEnv } from "../../../test/helpers/extensions/runtime-env.js";
|
||||
import type { ClawdbotConfig, PluginRuntime, RuntimeEnv } from "../runtime-api.js";
|
||||
import { monitorSingleAccount } from "./monitor.account.js";
|
||||
import { setFeishuRuntime } from "./runtime.js";
|
||||
@@ -183,7 +183,7 @@ async function setupLifecycleMonitor(accountId: "account-A" | "account-B") {
|
||||
});
|
||||
createEventDispatcherMock.mockReturnValueOnce({ register });
|
||||
|
||||
const runtime = createRuntimeEnv({ throwOnExit: false });
|
||||
const runtime = createNonExitingRuntimeEnv();
|
||||
runtimesByAccount.set(accountId, runtime);
|
||||
|
||||
await monitorSingleAccount({
|
||||
|
||||
@@ -5,7 +5,10 @@ import {
|
||||
resolveInboundDebounceMs,
|
||||
} from "../../../src/auto-reply/inbound-debounce.js";
|
||||
import { createPluginRuntimeMock } from "../../../test/helpers/extensions/plugin-runtime-mock.js";
|
||||
import { createRuntimeEnv } from "../../../test/helpers/extensions/runtime-env.js";
|
||||
import {
|
||||
createNonExitingTypedRuntimeEnv,
|
||||
createRuntimeEnv,
|
||||
} from "../../../test/helpers/extensions/runtime-env.js";
|
||||
import type { ClawdbotConfig, RuntimeEnv } from "../runtime-api.js";
|
||||
import { parseFeishuMessageEvent, type FeishuMessageEvent } from "./bot.js";
|
||||
import * as dedup from "./dedup.js";
|
||||
@@ -173,7 +176,7 @@ async function setupDebounceMonitor(params?: {
|
||||
await monitorSingleAccount({
|
||||
cfg: buildDebounceConfig(),
|
||||
account: buildDebounceAccount(),
|
||||
runtime: createRuntimeEnv({ throwOnExit: false }) as RuntimeEnv,
|
||||
runtime: createNonExitingTypedRuntimeEnv<RuntimeEnv>(),
|
||||
botOpenIdSource: {
|
||||
kind: "prefetched",
|
||||
botOpenId: params?.botOpenId ?? "ou_bot",
|
||||
@@ -449,7 +452,7 @@ describe("monitorSingleAccount lifecycle", () => {
|
||||
await monitorSingleAccount({
|
||||
cfg: buildDebounceConfig(),
|
||||
account: buildDebounceAccount(),
|
||||
runtime: createRuntimeEnv({ throwOnExit: false }) as RuntimeEnv,
|
||||
runtime: createNonExitingTypedRuntimeEnv<RuntimeEnv>(),
|
||||
botOpenIdSource: {
|
||||
kind: "prefetched",
|
||||
botOpenId: "ou_bot",
|
||||
@@ -486,7 +489,7 @@ describe("monitorSingleAccount lifecycle", () => {
|
||||
monitorSingleAccount({
|
||||
cfg: buildDebounceConfig(),
|
||||
account: buildDebounceAccount(),
|
||||
runtime: createRuntimeEnv({ throwOnExit: false }) as RuntimeEnv,
|
||||
runtime: createNonExitingTypedRuntimeEnv<RuntimeEnv>(),
|
||||
botOpenIdSource: {
|
||||
kind: "prefetched",
|
||||
botOpenId: "ou_bot",
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { afterEach, describe, expect, it, vi } from "vitest";
|
||||
import { createRuntimeEnv } from "../../../test/helpers/extensions/runtime-env.js";
|
||||
import { createNonExitingRuntimeEnv } from "../../../test/helpers/extensions/runtime-env.js";
|
||||
import type { ClawdbotConfig } from "../runtime-api.js";
|
||||
import { monitorFeishuProvider, stopFeishuMonitor } from "./monitor.js";
|
||||
|
||||
@@ -135,7 +135,7 @@ describe("Feishu monitor startup preflight", () => {
|
||||
});
|
||||
|
||||
const abortController = new AbortController();
|
||||
const runtime = createRuntimeEnv({ throwOnExit: false });
|
||||
const runtime = createNonExitingRuntimeEnv();
|
||||
const monitorPromise = monitorFeishuProvider({
|
||||
config: buildMultiAccountWebsocketConfig(["alpha", "beta"]),
|
||||
runtime,
|
||||
|
||||
@@ -1,16 +1,13 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { buildChannelSetupWizardAdapterFromSetupWizard } from "../../../src/channels/plugins/setup-wizard.js";
|
||||
import { createPluginSetupWizardStatus } from "../../../test/helpers/extensions/setup-wizard.js";
|
||||
import type { OpenClawConfig } from "../runtime-api.js";
|
||||
import { feishuPlugin } from "./channel.js";
|
||||
|
||||
const feishuConfigureAdapter = buildChannelSetupWizardAdapterFromSetupWizard({
|
||||
plugin: feishuPlugin,
|
||||
wizard: feishuPlugin.setupWizard!,
|
||||
});
|
||||
const feishuGetStatus = createPluginSetupWizardStatus(feishuPlugin);
|
||||
|
||||
describe("feishu setup wizard status", () => {
|
||||
it("treats SecretRef appSecret as configured when appId is present", async () => {
|
||||
const status = await feishuConfigureAdapter.getStatus({
|
||||
const status = await feishuGetStatus({
|
||||
cfg: {
|
||||
channels: {
|
||||
feishu: {
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
import { createRuntimeEnv } from "../../../test/helpers/extensions/runtime-env.js";
|
||||
import { createNonExitingTypedRuntimeEnv } from "../../../test/helpers/extensions/runtime-env.js";
|
||||
import {
|
||||
createPluginSetupWizardAdapter,
|
||||
createPluginSetupWizardConfigure,
|
||||
createPluginSetupWizardStatus,
|
||||
createTestWizardPrompter,
|
||||
runSetupWizardConfigure,
|
||||
} from "../../../test/helpers/extensions/setup-wizard.js";
|
||||
@@ -41,7 +42,7 @@ async function withEnvVars(values: Record<string, string | undefined>, run: () =
|
||||
}
|
||||
|
||||
async function getStatusWithEnvRefs(params: { appIdKey: string; appSecretKey: string }) {
|
||||
return await feishuConfigureAdapter.getStatus({
|
||||
return await feishuGetStatus({
|
||||
cfg: {
|
||||
channels: {
|
||||
feishu: {
|
||||
@@ -54,7 +55,9 @@ async function getStatusWithEnvRefs(params: { appIdKey: string; appSecretKey: st
|
||||
});
|
||||
}
|
||||
|
||||
const feishuConfigureAdapter = createPluginSetupWizardAdapter(feishuPlugin);
|
||||
const feishuConfigure = createPluginSetupWizardConfigure(feishuPlugin);
|
||||
const feishuGetStatus = createPluginSetupWizardStatus(feishuPlugin);
|
||||
type FeishuConfigureRuntime = Parameters<typeof feishuConfigure>[0]["runtime"];
|
||||
|
||||
describe("feishu setup wizard", () => {
|
||||
it("does not throw when config appId/appSecret are SecretRef objects", async () => {
|
||||
@@ -73,7 +76,7 @@ describe("feishu setup wizard", () => {
|
||||
|
||||
await expect(
|
||||
runSetupWizardConfigure({
|
||||
configure: feishuConfigureAdapter.configure,
|
||||
configure: feishuConfigure,
|
||||
cfg: {
|
||||
channels: {
|
||||
feishu: {
|
||||
@@ -83,7 +86,7 @@ describe("feishu setup wizard", () => {
|
||||
},
|
||||
} as never,
|
||||
prompter,
|
||||
runtime: createRuntimeEnv({ throwOnExit: false }) as never,
|
||||
runtime: createNonExitingTypedRuntimeEnv<FeishuConfigureRuntime>(),
|
||||
}),
|
||||
).resolves.toBeTruthy();
|
||||
});
|
||||
@@ -91,7 +94,7 @@ describe("feishu setup wizard", () => {
|
||||
|
||||
describe("feishu setup wizard status", () => {
|
||||
it("does not fallback to top-level appId when account explicitly sets empty appId", async () => {
|
||||
const status = await feishuConfigureAdapter.getStatus({
|
||||
const status = await feishuGetStatus({
|
||||
cfg: {
|
||||
channels: {
|
||||
feishu: {
|
||||
|
||||
Reference in New Issue
Block a user