mirror of
https://github.com/hansjone/dsh-im-ops.git
synced 2026-10-09 05:20:46 +08:00
43 lines
1.7 KiB
JavaScript
43 lines
1.7 KiB
JavaScript
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, />手动接入</);
|
|
assert.doesNotMatch(markup, /扫码接入机器人|dim-scanButton/);
|
|
});
|
|
|
|
test('Discord account card matches the unified compact card layout', () => {
|
|
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>最近检查<\/span>/);
|
|
assert.doesNotMatch(markup, /Gateway 长连接|消息通道|dim-botMetric/);
|
|
assert.match(markup, />检查连接</);
|
|
assert.match(markup, />移除接入</);
|
|
assert.doesNotMatch(markup, /dim-cardSummary/);
|
|
});
|