refactor(test): dedupe setup wizard helpers

This commit is contained in:
Peter Steinberger
2026-03-22 00:15:51 +00:00
parent 85722d4cf2
commit 30ad059da8
27 changed files with 322 additions and 186 deletions

View File

@@ -1,32 +1,14 @@
import { describe, expect, it, vi } from "vitest";
import { buildChannelSetupWizardAdapterFromSetupWizard } from "../../../src/channels/plugins/setup-wizard.js";
import {
listLineAccountIds,
resolveDefaultLineAccountId,
resolveLineAccount,
} from "../../../src/line/accounts.js";
import {
createPluginSetupWizardConfigure,
createTestWizardPrompter,
runSetupWizardConfigure,
type WizardPrompter,
} from "../../../test/helpers/extensions/setup-wizard.js";
import type { OpenClawConfig } from "../api.js";
import { lineSetupAdapter, lineSetupWizard } from "./setup-surface.js";
import { linePlugin } from "./channel.js";
const lineConfigureAdapter = buildChannelSetupWizardAdapterFromSetupWizard({
plugin: {
id: "line",
meta: { label: "LINE" },
config: {
listAccountIds: listLineAccountIds,
defaultAccountId: resolveDefaultLineAccountId,
resolveAllowFrom: ({ cfg, accountId }: { cfg: OpenClawConfig; accountId?: string | null }) =>
resolveLineAccount({ cfg, accountId: accountId ?? undefined }).config.allowFrom,
},
setup: lineSetupAdapter,
} as Parameters<typeof buildChannelSetupWizardAdapterFromSetupWizard>[0]["plugin"],
wizard: lineSetupWizard,
});
const lineConfigure = createPluginSetupWizardConfigure(linePlugin);
describe("line setup wizard", () => {
it("configures token and secret for the default account", async () => {
@@ -43,7 +25,7 @@ describe("line setup wizard", () => {
});
const result = await runSetupWizardConfigure({
configure: lineConfigureAdapter.configure,
configure: lineConfigure,
cfg: {} as OpenClawConfig,
prompter,
options: {},