mirror of
https://github.com/hansjone/dsh-im-ops.git
synced 2026-10-11 09:20:52 +08:00
Add Telegram and Discord IM channels
This commit is contained in:
parent
7123fce47a
commit
cb74e1c4c7
66 changed files with 8579 additions and 1910 deletions
42
test/channels/telegram/client-ui.test.mjs
Normal file
42
test/channels/telegram/client-ui.test.mjs
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
import assert from 'node:assert/strict';
|
||||
import test from 'node:test';
|
||||
|
||||
import React from 'react';
|
||||
import { renderToStaticMarkup } from 'react-dom/server';
|
||||
|
||||
import {
|
||||
TelegramAccountCard,
|
||||
TelegramSettingsTab,
|
||||
} from '../../../plugin-src/client/channels/telegram/index.js';
|
||||
|
||||
test('Telegram settings exposes a Bot Token action without a fake QR action', () => {
|
||||
const markup = renderToStaticMarkup(React.createElement(TelegramSettingsTab, {
|
||||
rpcCall: async () => ({ ok: true, value: { bots: [] } }),
|
||||
}));
|
||||
assert.match(markup, /aria-label="使用 Bot Token 接入 Telegram 机器人"/);
|
||||
assert.match(markup, />手动接入</);
|
||||
assert.doesNotMatch(markup, /扫码接入机器人|dim-scanButton/);
|
||||
});
|
||||
|
||||
test('Telegram account card matches the unified compact card layout', () => {
|
||||
const markup = renderToStaticMarkup(React.createElement(TelegramAccountCard, {
|
||||
account: {
|
||||
botId: 'telegram_test',
|
||||
connected: true,
|
||||
state: 'connected',
|
||||
bot: { name: 'Harness Bot', username: 'harness_bot', idMasked: '123•••' },
|
||||
health: { summary: 'Telegram Bot API 长轮询运行正常', lastCheckedAt: Date.now() },
|
||||
error: null,
|
||||
},
|
||||
onReconnect() {},
|
||||
onRequestRemove() {},
|
||||
onConfirmRemove() {},
|
||||
onCancelRemove() {},
|
||||
}));
|
||||
assert.match(markup, /data-im-channel-logo="telegram"/);
|
||||
assert.match(markup, /@harness_bot/);
|
||||
assert.match(markup, />Bot API 长轮询</);
|
||||
assert.match(markup, />检查连接</);
|
||||
assert.match(markup, />移除接入</);
|
||||
assert.doesNotMatch(markup, /dim-cardSummary/);
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue