mirror of
https://github.com/hansjone/dsh-im-ops.git
synced 2026-10-09 03:03:24 +08:00
65 lines
2.9 KiB
JavaScript
65 lines
2.9 KiB
JavaScript
import assert from 'node:assert/strict';
|
|
import { readFile } from 'node:fs/promises';
|
|
import test from 'node:test';
|
|
|
|
import React from 'react';
|
|
import { renderToStaticMarkup } from 'react-dom/server';
|
|
|
|
import { IMSettingsTab } from '../plugin-src/client/index.js';
|
|
import { DINGTALK_ENDPOINTS } from '../plugin-src/client/channels/dingtalk/api.js';
|
|
|
|
const STYLES_URL = new URL('../plugin-src/client/styles.js', import.meta.url);
|
|
const CLIENT_BUNDLE_URL = new URL('../lib/client.js', import.meta.url);
|
|
const DINGTALK_CLIENT_SOURCE_URL = new URL(
|
|
'../plugin-src/client/channels/dingtalk/index.js',
|
|
import.meta.url,
|
|
);
|
|
|
|
test('IM settings renders three compact logo channel tabs without enable switches', () => {
|
|
const markup = renderToStaticMarkup(React.createElement(IMSettingsTab, {
|
|
feishuRpcCall: async () => ({ ok: true, value: {} }),
|
|
weixinRpcCall: async () => ({ ok: true, value: {} }),
|
|
dingtalkRpcCall: async () => ({ ok: true, value: {} }),
|
|
}));
|
|
|
|
assert.match(markup, /IM机器人/);
|
|
assert.match(markup, /通过扫码把机器人接入 DeepSeek Harness/);
|
|
assert.match(markup, />微信</);
|
|
assert.match(markup, />飞书</);
|
|
assert.match(markup, />钉钉</);
|
|
assert.match(markup, /dim-logoWeixin/);
|
|
assert.match(markup, /dim-logoFeishu/);
|
|
assert.match(markup, /dim-logoDingtalk/);
|
|
assert.equal((markup.match(/role="tab"/g) ?? []).length, 3);
|
|
assert.equal((markup.match(/aria-selected="true"/g) ?? []).length, 1);
|
|
assert.doesNotMatch(markup, /role="switch"|type="checkbox"/);
|
|
assert.doesNotMatch(markup, /dim-chevron|扫码绑定<\/small>|扫码接入<\/small>/);
|
|
assert.doesNotMatch(markup, />INSTANT MESSAGING<|>Channel<|>微信设置</);
|
|
});
|
|
|
|
test('the DingTalk QR card stacks within the narrow combined-channel panel', async () => {
|
|
const styles = await readFile(STYLES_URL, 'utf8');
|
|
assert.match(styles, /\.dim-panel \{ min-width: 0; container-type: inline-size; \}/);
|
|
assert.match(
|
|
styles,
|
|
/@container \(max-width: 680px\)[\s\S]*\.dim-panel \.ddt-qrLayout \{ grid-template-columns: minmax\(0, 1fr\); justify-items: center;/,
|
|
);
|
|
assert.match(styles, /\.dim-panel \.ddt-qrFrame, \.dim-panel \.ddt-countdown \{ width: min\(270px, 100%\); \}/);
|
|
assert.match(styles, /\.dim-panel \.ddt-qrColumn \{ width: 100%; min-width: 0; \}/);
|
|
assert.match(styles, /\.dim-panel \.ddt-qrCopy \{ width: 100%; min-width: 0; overflow-wrap: anywhere; \}/);
|
|
});
|
|
|
|
test('the bundled DingTalk channel has no local sender approval workflow', async () => {
|
|
const [source, bundle] = await Promise.all([
|
|
readFile(DINGTALK_CLIENT_SOURCE_URL, 'utf8'),
|
|
readFile(CLIENT_BUNDLE_URL, 'utf8'),
|
|
]);
|
|
|
|
assert.equal('approveSender' in DINGTALK_ENDPOINTS, false);
|
|
assert.equal('revokeSender' in DINGTALK_ENDPOINTS, false);
|
|
assert.doesNotMatch(source, /SenderAccess|onApprove|onRevoke|approveSender|revokeSender/);
|
|
assert.doesNotMatch(
|
|
bundle,
|
|
/bot\.sender\.approve|bot\.sender\.revoke|允许使用机器人的钉钉账号|批准使用/,
|
|
);
|
|
});
|