

























@@ -193,6 +193,9 @@ function registerExternalChatSetupPlugin(pluginId = "@vendor/external-chat-plugi
193193type SignalAfterAccountConfigWritten = NonNullable<
194194NonNullable<ChannelPlugin["setup"]>["afterAccountConfigWritten"]
195195>;
196+type ApplyAccountConfigParams = Parameters<
197+NonNullable<NonNullable<ChannelPlugin["setup"]>["applyAccountConfig"]>
198+>[0];
196199197200function createSignalPlugin(
198201afterAccountConfigWritten: SignalAfterAccountConfigWritten,
@@ -306,6 +309,154 @@ describe("channelsAddCommand", () => {
306309expect(lifecycleMocks.onAccountConfigChanged).not.toHaveBeenCalled();
307310});
308311312+it("maps legacy Nextcloud Talk add flags to setup input fields", async () => {
313+const applyAccountConfig = vi.fn(({ cfg, input }) => ({
314+ ...cfg,
315+channels: {
316+ ...cfg.channels,
317+"nextcloud-talk": {
318+enabled: true,
319+baseUrl: input.baseUrl,
320+botSecret: input.secret,
321+botSecretFile: input.secretFile,
322+},
323+},
324+}));
325+setActivePluginRegistry(
326+createTestRegistry([
327+{
328+pluginId: "nextcloud-talk",
329+plugin: {
330+ ...createChannelTestPluginBase({
331+id: "nextcloud-talk",
332+label: "Nextcloud Talk",
333+}),
334+setup: { applyAccountConfig },
335+},
336+source: "test",
337+},
338+]),
339+);
340+configMocks.readConfigFileSnapshot.mockResolvedValue({ ...baseConfigSnapshot });
341+342+await channelsAddCommand(
343+{
344+channel: "nextcloud-talk",
345+account: "default",
346+url: "https://cloud.example.com/",
347+token: "shared-secret",
348+},
349+runtime,
350+{ hasFlags: true },
351+);
352+353+expect(applyAccountConfig).toHaveBeenCalledWith(
354+expect.objectContaining({
355+input: expect.objectContaining({
356+url: "https://cloud.example.com/",
357+token: "shared-secret",
358+baseUrl: "https://cloud.example.com/",
359+secret: "shared-secret",
360+}),
361+}),
362+);
363+expect(configMocks.writeConfigFile).toHaveBeenCalledWith(
364+expect.objectContaining({
365+channels: {
366+"nextcloud-talk": {
367+enabled: true,
368+baseUrl: "https://cloud.example.com/",
369+botSecret: "shared-secret",
370+botSecretFile: undefined,
371+},
372+},
373+}),
374+);
375+376+configMocks.writeConfigFile.mockClear();
377+applyAccountConfig.mockClear();
378+await channelsAddCommand(
379+{
380+channel: "nextcloud-talk",
381+account: "default",
382+url: "https://cloud.example.com",
383+tokenFile: "/tmp/nextcloud-secret",
384+},
385+runtime,
386+{ hasFlags: true },
387+);
388+389+expect(applyAccountConfig).toHaveBeenCalledWith(
390+expect.objectContaining({
391+input: expect.objectContaining({
392+baseUrl: "https://cloud.example.com",
393+secretFile: "/tmp/nextcloud-secret",
394+}),
395+}),
396+);
397+});
398+399+it("passes channel auth directory overrides through add setup input", async () => {
400+setActivePluginRegistry(
401+createTestRegistry([
402+{
403+pluginId: "whatsapp",
404+plugin: {
405+ ...createChannelTestPluginBase({
406+id: "whatsapp",
407+label: "WhatsApp",
408+}),
409+setup: {
410+applyAccountConfig: (params: ApplyAccountConfigParams) => ({
411+ ...params.cfg,
412+channels: {
413+ ...params.cfg.channels,
414+whatsapp: {
415+enabled: true,
416+accounts: {
417+[params.accountId]: {
418+enabled: true,
419+authDir: params.input.authDir,
420+},
421+},
422+},
423+},
424+}),
425+},
426+},
427+source: "test",
428+},
429+]),
430+);
431+configMocks.readConfigFileSnapshot.mockResolvedValue({ ...baseConfigSnapshot });
432+433+await channelsAddCommand(
434+{
435+channel: "whatsapp",
436+account: "work",
437+authDir: "/tmp/openclaw-wa-auth",
438+},
439+runtime,
440+{ hasFlags: true },
441+);
442+443+expect(configMocks.writeConfigFile).toHaveBeenCalledWith(
444+expect.objectContaining({
445+channels: {
446+whatsapp: {
447+enabled: true,
448+accounts: {
449+work: {
450+enabled: true,
451+authDir: "/tmp/openclaw-wa-auth",
452+},
453+},
454+},
455+},
456+}),
457+);
458+});
459+309460it("loads external channel setup snapshots for newly installed and existing plugins", async () => {
310461configMocks.readConfigFileSnapshot.mockResolvedValue({ ...baseConfigSnapshot });
311462setActivePluginRegistry(createTestRegistry());
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。