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
This commit is contained in:
1 parent
3cc3012b3a
commit
e8a29a0087
291 files changed
+12194
-3979
No files matched your search
@@ -0,0 +1,81 @@
|
||||
import { cleanup, fireEvent, render, screen, waitFor } from "@testing-library/react";
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
|
||||
import { ChannelQrConnectFlow } from "@/components/settings/channels/ChannelQrConnectFlow";
|
||||
import { FeishuConnectFlow } from "../../../nanobot/channels/feishu/webui/FeishuConnectFlow";
|
||||
|
||||
const { requestMutation } = vi.hoisted(() => ({ requestMutation: vi.fn() }));
|
||||
|
||||
vi.mock("@/providers/ClientProvider", () => {
|
||||
const client = { requestMutation };
|
||||
return { useClient: () => ({ client }) };
|
||||
});
|
||||
|
||||
const labels = {
|
||||
qrAlt: "Connection QR code",
|
||||
scanTitle: "Scan to connect",
|
||||
scanDescription: "Scan with your app",
|
||||
waiting: "Waiting",
|
||||
connected: "Connected",
|
||||
stopped: "Stopped",
|
||||
connecting: "Connecting",
|
||||
scanAgain: "Scan again",
|
||||
connect: "Connect",
|
||||
};
|
||||
|
||||
beforeEach(() => {
|
||||
requestMutation.mockReset().mockResolvedValue({
|
||||
session_id: "link-1",
|
||||
status: "succeeded",
|
||||
});
|
||||
});
|
||||
|
||||
afterEach(cleanup);
|
||||
|
||||
describe("channel QR connect parameters", () => {
|
||||
it("forwards current channel parameters without restarting on rerender and preserves forced retries", async () => {
|
||||
const props = {
|
||||
token: "tok",
|
||||
channelName: "plugin-chat",
|
||||
autoStart: true,
|
||||
forceOnRepeat: true,
|
||||
labels,
|
||||
onFeaturesUpdate: vi.fn(),
|
||||
};
|
||||
const view = render(<ChannelQrConnectFlow {...props} startParams={{ region: "eu" }} />);
|
||||
await waitFor(() => expect(requestMutation).toHaveBeenCalledTimes(1));
|
||||
expect(requestMutation).toHaveBeenLastCalledWith(
|
||||
"settings.channel.connect.start",
|
||||
{ channel: "plugin-chat", region: "eu" },
|
||||
150_000,
|
||||
);
|
||||
await screen.findByText("Connected");
|
||||
|
||||
view.rerender(<ChannelQrConnectFlow {...props} startParams={{ region: "us" }} />);
|
||||
expect(requestMutation).toHaveBeenCalledTimes(1);
|
||||
fireEvent.click(screen.getByRole("button", { name: "Scan again" }));
|
||||
await waitFor(() => expect(requestMutation).toHaveBeenCalledTimes(2));
|
||||
expect(requestMutation).toHaveBeenLastCalledWith(
|
||||
"settings.channel.connect.start",
|
||||
{ channel: "plugin-chat", region: "us", force: true },
|
||||
150_000,
|
||||
);
|
||||
});
|
||||
|
||||
it("preserves the Feishu-owned registration domain and instance creation mode", async () => {
|
||||
render(
|
||||
<FeishuConnectFlow
|
||||
token="tok"
|
||||
instanceId="support"
|
||||
mode="create"
|
||||
connectRequestId={1}
|
||||
onFeaturesUpdate={vi.fn()}
|
||||
/>,
|
||||
);
|
||||
await waitFor(() => expect(requestMutation).toHaveBeenCalledWith(
|
||||
"settings.channel.connect.start",
|
||||
{ channel: "feishu", domain: "feishu", instance_id: "support", mode: "create" },
|
||||
150_000,
|
||||
));
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user