Files
openclaw/src/commands/channel-setup/registry.test.ts
Gustavo Madeira Santana 9786946b2d fix(matrix): restore guided setup flow (#59462)
Merged via squash.

Prepared head SHA: 9b29023c68
Co-authored-by: gumadeiras <5599352+gumadeiras@users.noreply.github.com>
Co-authored-by: gumadeiras <5599352+gumadeiras@users.noreply.github.com>
Reviewed-by: @gumadeiras
2026-04-02 02:15:32 -04:00

59 lines
1.9 KiB
TypeScript

import { describe, expect, it } from "vitest";
import type { ChannelSetupPlugin } from "../../channels/plugins/setup-wizard-types.js";
import type { ChannelSetupWizard } from "../../channels/plugins/setup-wizard.js";
import type { OpenClawConfig } from "../../config/config.js";
import { createChannelTestPluginBase } from "../../test-utils/channel-plugins.js";
import { resolveChannelSetupWizardAdapterForPlugin } from "./registry.js";
function createSetupPlugin(params: {
setupWizard: ChannelSetupPlugin["setupWizard"];
}): ChannelSetupPlugin {
return {
...createChannelTestPluginBase({
id: "demo",
label: "Demo",
}),
setup: {
applyAccountConfig: ({ cfg }: { cfg: OpenClawConfig }) => cfg,
},
setupWizard: params.setupWizard,
};
}
describe("resolveChannelSetupWizardAdapterForPlugin", () => {
it("builds and caches adapters from the plugin setupWizard surface", () => {
const setupWizard: ChannelSetupWizard = {
channel: "demo",
status: {
configuredLabel: "Configured",
unconfiguredLabel: "Not configured",
resolveConfigured: () => false,
},
credentials: [],
};
const plugin = createSetupPlugin({ setupWizard });
const adapter = resolveChannelSetupWizardAdapterForPlugin(plugin);
expect(adapter?.channel).toBe("demo");
expect(typeof adapter?.getStatus).toBe("function");
expect(typeof adapter?.configure).toBe("function");
expect(resolveChannelSetupWizardAdapterForPlugin(plugin)).toBe(adapter);
});
it("passes through adapter-shaped setupWizard surfaces", () => {
const setupWizard = {
channel: "demo",
getStatus: async () => ({
channel: "demo",
configured: false,
statusLines: [],
}),
configure: async ({ cfg }: { cfg: OpenClawConfig }) => ({ cfg }),
};
const plugin = createSetupPlugin({ setupWizard });
expect(resolveChannelSetupWizardAdapterForPlugin(plugin)).toBe(setupWizard);
});
});