文件
OmniCard/admin/tests/nfc-devices.test.ts
wikiboss eec259a3a7 feat: 完成全系统30个功能点开发与E2E全链路验收 (8轮调度32个子代理闭环)
- 模块一: 出海案例作品集、博客动态发布、人名发音语音条、RTL阿语多语言切换
- 模块二: AI顾问人设配置、行业术语库润色、RAG切片沙盒调试、流式会话与意向留资卡片
- 模块三: 全球访客雷达大屏、多维加权意向算分、外部CRM对接推送、团队公海池流转
- 模块四: 移动端NFC安全挂失、NFC动态路由规则配置、动态防伪验签、展会制卡Zip批量导出
- 模块五: 组织架构与名片分配、移动端个人中心设置、离职交接与历史线索迁移、安全审计日志
- 模块六: Stripe国际信用卡订阅Webhook、独立二级域名与SSL检测、坐席配额预警、多币种发票
- 模块七: 纸质名片OCR解析入库、国际商务日程RFC 5545 ICS日历、微官网离线SWR预加载、展会实时排行榜大屏
- 模块八: 全球出海SEO OpenGraph元标签注入与社交爬虫探测、30点端到端全链路业务流集成测试套件
2026-09-20 23:47:47 +08:00

92 行
4.7 KiB
TypeScript

import test from 'node:test';
import assert from 'node:assert/strict';
import fs from 'node:fs';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
const adminRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
const devicesPagePath = path.join(adminRoot, 'src/pages/nfc/devices/index.tsx');
const devicesLocalePath = path.join(adminRoot, 'src/pages/nfc/devices/locale/index.ts');
test('1. nfc/devices 页面必须请求 admin/nfc/device/page 并使用 Arco Table', () => {
assert.ok(fs.existsSync(devicesPagePath), 'NFC 设备池页面必须存在');
const content = fs.readFileSync(devicesPagePath, 'utf-8');
assert.ok(
content.includes('admin/nfc/device/page'),
'必须请求 POST /api/admin/nfc/device/page'
);
assert.ok(content.includes('Table'), '必须使用 Arco Table');
assert.ok(
content.includes("from '@arco-design/web-react'"),
'必须从 @arco-design/web-react 引入组件'
);
assert.ok(content.includes('NFCRecord'), '必须使用 NFCRecord 类型');
assert.ok(
content.includes('code === 1000') || content.includes('code ===1000'),
'必须按 Cool-Admin code === 1000 判断成功'
);
assert.ok(content.includes('Message.error'), '失败必须使用 Arco Message.error');
assert.ok(!content.includes('Mock.js') && !content.includes("from 'mockjs'"), '禁止用 Mock.js 假数据冒充成功');
assert.ok(!/\bany\b/.test(content), '禁止使用 any');
});
test('2. nfc/devices 必须复用 NFC 契约、筛选列与挂失/重置', () => {
const content = fs.readFileSync(devicesPagePath, 'utf-8');
assert.ok(content.includes('NFCStatus'), '必须使用 NFCStatus 类型');
assert.ok(content.includes('NFCMaterial'), '必须使用 NFCMaterial 类型');
assert.ok(content.includes('NFCSceneMode'), '必须使用 NFCSceneMode 类型');
assert.ok(content.includes("from '@/types/omni'"), '必须复用 admin/src/types/omni.ts');
assert.ok(content.includes('Form'), '必须使用 Arco Form');
assert.ok(content.includes('Select'), '必须使用 Arco Select');
assert.ok(content.includes('Tag'), '必须使用 Arco Tag');
assert.ok(content.includes('Badge'), '必须使用 Arco Badge');
assert.ok(content.includes('Popconfirm'), '挂失/重置必须使用 Arco Popconfirm');
assert.ok(content.includes('lightColors'), '颜色必须引用 lightColors token');
assert.ok(!/#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6})\b/.test(content), '禁止硬编码颜色');
assert.ok(content.includes('uid'), '必须展示 uid');
assert.ok(content.includes('batchNo'), '必须展示 batchNo');
assert.ok(content.includes('material'), '必须展示 material');
assert.ok(content.includes('cardId'), '必须展示 cardId');
assert.ok(content.includes('status'), '必须展示 status');
assert.ok(content.includes('sceneMode'), '必须展示 sceneMode');
assert.ok(content.includes('lastScannedAt'), '必须展示 lastScannedAt');
assert.ok(content.includes('keyWord'), '筛选必须支持 keyWord');
for (const status of ['active', 'suspended', 'unbound']) {
assert.ok(content.includes(`'${status}'`), `必须支持状态: ${status}`);
}
for (const material of ['wood', 'metal', 'pvc']) {
assert.ok(content.includes(`'${material}'`), `必须支持材质: ${material}`);
}
assert.ok(
content.includes('admin/nfc/security/freeze'),
'必须请求 POST /api/admin/nfc/security/freeze'
);
assert.ok(
content.includes('admin/nfc/security/reset'),
'必须请求 POST /api/admin/nfc/security/reset'
);
assert.ok(content.includes('type="primary"'), '查询必须是主按钮');
assert.ok(content.includes('type="secondary"'), '挂失/重置必须是次按钮');
assert.ok(!content.includes('<Pagination'), '禁止手写分页器,必须使用 Table 自带分页');
});
test('3. nfc/devices locale 必须包含 menu.nfc.devices 与中英文案', () => {
assert.ok(fs.existsSync(devicesLocalePath), 'NFC 设备池语言包必须存在');
const content = fs.readFileSync(devicesLocalePath, 'utf-8');
assert.ok(content.includes("'menu.nfc.devices'"), '页面语言包必须包含 menu.nfc.devices');
assert.ok(content.includes("'en-US'"), '必须包含英文案');
assert.ok(content.includes("'zh-CN'"), '必须包含中文案');
assert.ok(content.includes('nfcDevices.request.fail'), '必须包含失败提示文案');
assert.ok(content.includes('nfcDevices.status.active'), '必须包含状态文案');
assert.ok(content.includes('nfcDevices.material.wood'), '必须包含材质文案');
assert.ok(content.includes('nfcDevices.action.freeze'), '必须包含挂失文案');
assert.ok(content.includes('nfcDevices.action.reset'), '必须包含重置文案');
assert.ok(!/\bany\b/.test(content), 'locale 禁止使用 any');
});