dsh-im-ops/test/channels/qq/client-ui.test.mjs
2026-08-15 17:51:48 +08:00

40 lines
1.6 KiB
JavaScript

import assert from 'node:assert/strict';
import test from 'node:test';
import React from 'react';
import { renderToStaticMarkup } from 'react-dom/server';
import { AccountCard, QqSettingsTab } from '../../../plugin-src/client/channels/qq/index.js';
test('QQ settings uses the shared compact channel toolbar', () => {
const markup = renderToStaticMarkup(React.createElement(QqSettingsTab, {
rpcCall: async () => ({ ok: true, value: {} }),
}));
assert.match(markup, /class="ddt-page dqq-page dim-channelPage"/);
assert.match(markup, /class="ddt-button dim-scanButton"/);
assert.match(markup, />扫码绑定QQ机器人</);
assert.doesNotMatch(markup, /凭据仅保存在本机|role="switch"|type="checkbox"/);
});
test('QQ bot cards match the shared two-metric card treatment', () => {
const markup = renderToStaticMarkup(React.createElement(AccountCard, {
account: {
botId: 'qq_bot',
connected: true,
state: 'connected',
bot: { name: 'QQ机器人', appIdMasked: '123••••456' },
health: { summary: 'QQ WebSocket 长连接运行正常', lastCheckedAt: Date.now() },
error: null,
},
onReconnect() {},
onRequestRemove() {},
onConfirmRemove() {},
onCancelRemove() {},
}));
assert.match(markup, /class="ddt-card dim-botCard"/);
assert.match(markup, /data-im-channel-logo="qq"/);
assert.equal((markup.match(/class="ddt-metric dim-botMetric"/g) ?? []).length, 2);
assert.match(markup, />消息通道<[^]*>最近检查</);
assert.match(markup, />检查连接<[^]*>移除接入</);
assert.doesNotMatch(markup, /收到\s*\/\s*回复/);
});