惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

博客园 - 叶小钗
爱范儿
爱范儿
WordPress大学
WordPress大学
Last Week in AI
Last Week in AI
博客园 - 聂微东
雷峰网
雷峰网
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
博客园 - 三生石上(FineUI控件)
T
Tailwind CSS Blog
博客园 - Franky
酷 壳 – CoolShell
酷 壳 – CoolShell
博客园_首页
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
博客园 - 司徒正美
月光博客
月光博客
大猫的无限游戏
大猫的无限游戏
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
The Cloudflare Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
人人都是产品经理
人人都是产品经理
宝玉的分享
宝玉的分享
罗磊的独立博客
Jina AI
Jina AI

Recent Commits to openclaw:main

test: merge chat side-result checks · openclaw/openclaw@ddd2c2a test: merge cron history checks · openclaw/openclaw@f7eb746 test: merge responsive navigation shell checks · openclaw/openclaw@c2e4b47 docs(changelog): add codex oauth fixes · openclaw/openclaw@628e6cd test: merge navigation routing cases · openclaw/openclaw@5d8cecb Tests: mock channel registry bundled fallback · openclaw/openclaw@2b08233 Secrets: avoid broad web search discovery for single plugin config · openclaw/openclaw@a464f59 test: merge config view browser checks · openclaw/openclaw@20cf511 fix(status): align oauth health with runtime · openclaw/openclaw@eed7116 feat: add macOS screen snapshots for monitor preview (#67954) thanks … · openclaw/openclaw@f377db1 fix: report shared auth scopes in hello-ok (#67810) thanks @BunsDev · openclaw/openclaw@0b6c39b Auto-reply: avoid eager bundled route fallback · openclaw/openclaw@3ea1bf4 Tests: narrow session binding contract setup · openclaw/openclaw@54e4e16 fix(macOS): enable undo/redo in webchat composer text input (#34962) · openclaw/openclaw@00951dc Tests: speed up channel setup promotion · openclaw/openclaw@82b529a Docs: refresh agent instructions · openclaw/openclaw@5775fe2 fix(auth): serialize OAuth refresh across agents to fix #26322 (#67876) · openclaw/openclaw@8e79080 test: allow ollama public surface boundary test · openclaw/openclaw@7d4f1a6 Docs: add test performance guardrails · openclaw/openclaw@89706d3 Tests: restore context-engine usage proof · openclaw/openclaw@e4c4f95 Tests: slim context engine runtime coverage · openclaw/openclaw@74c198f ci: retry failed custom checkouts · openclaw/openclaw@0ee5baf test: trim duplicate provider auth onboarding cases · openclaw/openclaw@1ffc02e matrix: fix sessions_spawn --thread subagent session spawning (#67643) · openclaw/openclaw@1ce2596 test: reduce auth choice fixture churn · openclaw/openclaw@857b9cd test: mock health status config boundaries · openclaw/openclaw@9d5ab4a test: mock onboard config io boundary · openclaw/openclaw@299694d test: mock legacy state plugin boundaries · openclaw/openclaw@2713089 test: mock channel install boundaries · openclaw/openclaw@b945248 test: mock doctor preview channel boundaries · openclaw/openclaw@b1a3ad4
ui: gate WhatsApp QR actions by link state · openclaw/ope...
BunsDev · 2026-05-08 · via Recent Commits to openclaw:main

@@ -1,10 +1,13 @@

1-

import { describe, expect, it } from "vitest";

1+

import { render } from "lit";

2+

import { describe, expect, it, vi } from "vitest";

3+

import type { WhatsAppStatus } from "../types.ts";

24

import {

35

channelEnabled,

46

resolveChannelConfigured,

57

resolveChannelDisplayState,

68

} from "./channels.shared.ts";

79

import type { ChannelsProps } from "./channels.types.ts";

10+

import { renderWhatsAppCard } from "./channels.whatsapp.ts";

811912

function createProps(snapshot: ChannelsProps["snapshot"]): ChannelsProps {

1013

return {

@@ -41,6 +44,45 @@ function createProps(snapshot: ChannelsProps["snapshot"]): ChannelsProps {

4144

};

4245

}

434647+

function createWhatsAppStatus(overrides: Partial<WhatsAppStatus> = {}): WhatsAppStatus {

48+

return {

49+

configured: true,

50+

linked: false,

51+

running: false,

52+

connected: false,

53+

reconnectAttempts: 0,

54+

...overrides,

55+

};

56+

}

57+58+

function renderWhatsAppButtons(params: {

59+

linked?: boolean;

60+

qrDataUrl?: string | null;

61+

onWhatsAppStart?: ChannelsProps["onWhatsAppStart"];

62+

}) {

63+

const whatsapp = createWhatsAppStatus({ linked: params.linked === true });

64+

const props = createProps({

65+

ts: Date.now(),

66+

channelOrder: ["whatsapp"],

67+

channelLabels: { whatsapp: "WhatsApp" },

68+

channels: { whatsapp },

69+

channelAccounts: {},

70+

channelDefaultAccountId: {},

71+

});

72+

props.whatsappQrDataUrl = params.qrDataUrl ?? null;

73+

if (params.onWhatsAppStart) {

74+

props.onWhatsAppStart = params.onWhatsAppStart;

75+

}

76+77+

const container = document.createElement("div");

78+

render(renderWhatsAppCard({ props, whatsapp, accountCountLabel: null }), container);

79+

const buttons = Array.from(container.querySelectorAll("button"));

80+

return {

81+

buttons,

82+

labels: buttons.map((button) => button.textContent?.trim()),

83+

};

84+

}

85+4486

describe("channel display selectors", () => {

4587

it("returns the channel summary configured flag when present", () => {

4688

const props = createProps({

@@ -118,3 +160,44 @@ describe("channel display selectors", () => {

118160

expect(channelEnabled("quietchat", props)).toBe(false);

119161

});

120162

});

163+164+

describe("WhatsApp card actions", () => {

165+

it("shows QR as the primary action before WhatsApp is linked", () => {

166+

const onWhatsAppStart = vi.fn();

167+

const { buttons, labels } = renderWhatsAppButtons({

168+

linked: false,

169+

onWhatsAppStart,

170+

});

171+172+

expect(labels).toContain("Show QR");

173+

expect(labels).not.toContain("Relink");

174+

expect(labels).not.toContain("Wait for scan");

175+176+

buttons.find((button) => button.textContent?.trim() === "Show QR")?.click();

177+

expect(onWhatsAppStart).toHaveBeenCalledWith(false);

178+

});

179+180+

it("uses relink as the explicit action after WhatsApp is linked", () => {

181+

const onWhatsAppStart = vi.fn();

182+

const { buttons, labels } = renderWhatsAppButtons({

183+

linked: true,

184+

onWhatsAppStart,

185+

});

186+187+

expect(labels).toContain("Relink");

188+

expect(labels).not.toContain("Show QR");

189+190+

buttons.find((button) => button.textContent?.trim() === "Relink")?.click();

191+

expect(onWhatsAppStart).toHaveBeenCalledWith(true);

192+

});

193+194+

it("shows wait for scan only while a QR is displayed", () => {

195+

const { labels } = renderWhatsAppButtons({

196+

linked: false,

197+

qrDataUrl: "data:image/png;base64,current-qr",

198+

});

199+200+

expect(labels).toContain("Show QR");

201+

expect(labels).toContain("Wait for scan");

202+

});

203+

});