Files
creator-hub/web/tests/gateway-health.test.cjs
T
rogee a34ba07d5b feat(web): gateway management for outbound access keys
- 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
2026-10-09 08:36:34 +08:00

37 lines
1.7 KiB
JavaScript

const assert = require('node:assert/strict');
const { readFileSync } = require('node:fs');
const { test } = require('node:test');
const ts = require('typescript');
// 网关在线状态列:出站 WS 会话维护 online/last_seen_at;从未连接与离线不得混用。
const source = ts.createSourceFile(
'gateways-page',
readFileSync(`${__dirname}/../src/pages/gateways/index.tsx`, 'utf8'),
ts.ScriptTarget.Latest,
true,
ts.ScriptKind.TSX,
);
const code = source.getFullText();
test('网关列表展示会话维护的在线状态', () => {
assert.match(code, /在线状态/, '应有在线状态列');
assert.match(code, /online: boolean; lastSeenAt/, '应绑定 online 与 last_seen_at');
assert.match(code, /\['在线', 'success'\]/, '在线展示 success');
assert.match(code, /\['离线', 'error'\]/, '离线展示 error');
assert.match(code, /最近在线:/, '离线时在 Tooltip 展示最近在线时间');
});
test('从未连接不冒充离线', () => {
const render = code.match(/function OnlineCell[\s\S]*?\n}/);
assert.ok(render, '应有独立的 OnlineCell 组件');
assert.match(render[0], /从未连接/, '应存在从未连接文案');
assert.match(render[0], /lastSeenAt\s*\?\s*\['离线', 'error'\]\s*:\s*\['从未连接', 'default'\]/, '无 last_seen_at 时落在从未连接静默分支');
});
test('在线细节收进 Tooltip,不挤占表格密度', () => {
const render = code.match(/function OnlineCell[\s\S]*?\n}/);
assert.ok(render, '应有独立的 OnlineCell 组件');
assert.match(render[0], /Tooltip/, '细节应放 Tooltip');
assert.doesNotMatch(render[0], /Typography\.Text type="secondary"/, '不应在单元格内平铺长文本');
});