- create/edit by name only; platform-issued key echoed once with gateway config guide (CREATOR_PLATFORM_URL + CREATOR_GATEWAY_KEY) - online/offline/never-connected tag from channel session state, version column, pending task count linking to per-gateway task history drawer (paginated, duration, status tag, error) - reset-key action with confirm; api layer adds gatewayAction and gatewayTasks; delete whitelist includes gateways - tests updated for the outbound model; events ellipsis checklist entry removed (field no longer truncated); table header test picks the sticky table
69 lines
2.9 KiB
JavaScript
69 lines
2.9 KiB
JavaScript
const assert = require('node:assert/strict');
|
|
const { readFileSync } = require('node:fs');
|
|
const { test } = require('node:test');
|
|
const ts = require('typescript');
|
|
|
|
const source = ts.createSourceFile(
|
|
'gateways.tsx',
|
|
readFileSync(`${__dirname}/../src/pages/gateways/index.tsx`, 'utf8'),
|
|
ts.ScriptTarget.Latest,
|
|
true,
|
|
ts.ScriptKind.TSX,
|
|
);
|
|
const code = source.getFullText();
|
|
|
|
test('创建网关只需名称,access key 由平台生成', () => {
|
|
assert.ok(!code.includes('Endpoint'), '出站模型不再登记 endpoint');
|
|
assert.ok(!code.includes('GATEWAY_TOKEN'), '旧令牌语义已删除');
|
|
assert.ok(!code.includes('token'), '不应残留 token 字段');
|
|
const formItems = [...code.matchAll(/<Form\.Item[\s\S]*?name="(\w+)"/g)].map(match => match[1]);
|
|
assert.deepEqual(formItems, ['name'], '创建/编辑表单只含名称');
|
|
assert.match(code, /const record = await create\('gateways', values\);/);
|
|
assert.match(code, /setCreated\(record\?\.data \?\? record\);/);
|
|
});
|
|
|
|
test('key 生成后回显配置指引且只在本次显示', () => {
|
|
assert.match(code, /KeyGuideAlert/);
|
|
assert.match(code, /CREATOR_PLATFORM_URL=/);
|
|
assert.match(code, /CREATOR_GATEWAY_KEY=\$\{accessKey\}/);
|
|
assert.match(code, /只在本次显示/);
|
|
assert.match(code, /旧 key 立即失效/);
|
|
assert.match(code, /copyable=\{\{ text: guide/);
|
|
});
|
|
|
|
test('在线状态区分在线、离线与从未连接', () => {
|
|
assert.match(code, /\['在线', 'success'\]/);
|
|
assert.match(code, /\['离线', 'error'\]/);
|
|
assert.match(code, /\['从未连接', 'default'\]/);
|
|
assert.match(code, /online: boolean; lastSeenAt\?/);
|
|
assert.match(code, /最近在线:/);
|
|
});
|
|
|
|
test('任务记录 Drawer 展示方法路径状态与耗时,分页请求真实接口', () => {
|
|
assert.match(code, /TaskHistoryDrawer/);
|
|
assert.match(code, /await gatewayTasks\(gateway\.name, targetPage, pageSize\);/);
|
|
assert.match(code, /taskStatusMeta/);
|
|
assert.ok(taskStatusMetaSrc.includes('pending') && taskStatusMetaSrc.includes('dispatched') && taskStatusMetaSrc.includes('succeeded') && taskStatusMetaSrc.includes('failed'));
|
|
assert.match(code, /dataIndex: 'response_status'/);
|
|
assert.match(code, /dispatched_at/);
|
|
assert.match(code, /finished_at/);
|
|
});
|
|
|
|
test('任务队列列与重置 key 动作接入真实接口', () => {
|
|
assert.match(code, /dataIndex: 'pending_tasks'/);
|
|
assert.match(code, /await gatewayAction\(gateway\.name, 'reset-key'\);/);
|
|
assert.match(code, /旧 key 立即失效,网关需重新配置/);
|
|
assert.match(code, /setTasksGateway\(gateway\)/);
|
|
});
|
|
|
|
test('弃用 API 不回潮', () => {
|
|
assert.ok(!code.includes('Space direction'), '纵向堆叠用 Flex vertical');
|
|
assert.ok(!code.includes('Alert message='), 'Alert 用 title/description');
|
|
assert.match(code, /<Flex vertical gap=\{4\}>/);
|
|
});
|
|
|
|
const taskStatusMetaSrc = code.slice(
|
|
Math.max(0, code.indexOf('const taskStatusMeta')),
|
|
code.indexOf('function TaskHistoryDrawer'),
|
|
);
|