import assert from 'node:assert/strict'; import test from 'node:test'; import React from 'react'; import { renderToStaticMarkup } from 'react-dom/server'; import { DiscordAccountCard, DiscordSettingsTab, } from '../../../plugin-src/client/channels/discord/index.js'; test('Discord settings exposes a Bot Token action without a fake QR action', () => { const markup = renderToStaticMarkup(React.createElement(DiscordSettingsTab, { rpcCall: async () => ({ ok: true, value: { bots: [] } }), })); assert.match(markup, /aria-label="使用 Bot Token 接入 Discord 机器人"/); assert.match(markup, />手动接入 { const markup = renderToStaticMarkup(React.createElement(DiscordAccountCard, { account: { botId: 'discord_test', connected: true, state: 'connected', bot: { name: 'Harness Bot', username: 'HarnessBot', idMasked: '123•••' }, health: { summary: 'Discord Gateway 长连接运行正常', lastCheckedAt: Date.now() }, error: null, }, onReconnect() {}, onRequestRemove() {}, onConfirmRemove() {}, onCancelRemove() {}, })); assert.match(markup, /data-im-channel-logo="discord"/); assert.match(markup, /@HarnessBot/); assert.match(markup, /class="dim-botHealthGroup"[^]*class="dim-lastChecked">最近检查<\/span>/); assert.doesNotMatch(markup, /Gateway 长连接|消息通道|dim-botMetric/); assert.match(markup, />检查连接移除接入