Files
nanobot/webui/src/tests/channel-ui-registry.test.ts
T
chengyongru e8a29a0087 feat(webui): improve setup flows across chat channels (NAN-112) (#5356)
* feat(webui): improve channel setup flows

* fix(webui): refine channel setup interactions (NAN-112)

* fix(webui): keep email setup sections channel-owned

* fix(webui): remove concrete channel details from shared components

* refactor(webui): remove unused channel setup resources

* fix(webui): finish channel-owned setup boundaries

* fix(webui): update channel switches optimistically

* test(channels): remove obsolete absence assertions

* fix(webui): flatten channel instance settings disclosure

* fix(webui): complete channel setup and connection flows

* fix(whatsapp): wait for session database release

* fix(webui): preserve scrolling channel controls

* fix(webui): stage channel connection checks

* fix(channels): align verification actions

* fix(email): expose connection checks

* fix(webui): align channel field actions

* fix(email): verify account credentials

* fix(wecom): bypass system proxy for websocket

* fix(channels): stabilize async connection cleanup

* fix(webui): autosave channel credentials

* fix(email): make provider presets non-destructive

* test(weixin): isolate persisted QR credentials
2026-09-11 15:22:14 +08:00

42 lines
1.8 KiB
TypeScript

import { readFileSync } from "node:fs";
import { resolve } from "node:path";
import { describe, expect, it } from "vitest";
import {
channelUiContribution,
channelUiOwner,
channelUiPresentation,
registeredChannelUiContributions,
} from "@/channel-plugins/registry";
describe("channel UI contributions", () => {
it("selects channel-owned UI only through the backend manifest entry", () => {
expect(channelUiContribution("feishu", "webui/index.tsx")?.Panel).toBeDefined();
expect(channelUiContribution("weixin", "webui/index.tsx")?.ConnectFlow).toBeDefined();
expect(channelUiContribution("feishu", undefined)).toBeUndefined();
expect(channelUiContribution("feishu", "webui/missing.tsx")).toBeUndefined();
expect(channelUiContribution("missing", "webui/index.tsx")).toBeUndefined();
const registrations = registeredChannelUiContributions();
const channels = registrations.map((entry) => entry.channel);
expect(channels).toEqual(expect.arrayContaining(["feishu", "weixin"]));
expect(new Set(channels).size).toBe(channels.length);
expect(registrations.every((entry) => /^webui\/index\.tsx?$/.test(entry.webui))).toBe(true);
expect(channelUiContribution("slack", "webui/index.ts")?.presentation.displayName).toBe("Slack");
});
it("keeps aliases inside the owning channel contribution", () => {
expect(channelUiPresentation("lark")?.displayName).toBe("Lark");
expect(channelUiPresentation("wechat")?.displayName).toBe("WeChat");
expect(channelUiOwner("lark")).toBe("feishu");
expect(channelUiOwner("wechat")).toBe("weixin");
});
it("includes channel-owned UI in Tailwind's production scan", () => {
const source = readFileSync(resolve(process.cwd(), "tailwind.config.js"), "utf8");
expect(source).toContain("../nanobot/channels/*/webui/**/*.{ts,tsx}");
});
});