补齐平台订阅、外部登录、CRM 同步与用户端页面;Nginx 转发用户端接口,登录页使用 Google 与 Apple 标志。 Co-authored-by: Cursor <cursoragent@cursor.com>
118 行
4.8 KiB
TypeScript
118 行
4.8 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 leadsPagePath = path.join(adminRoot, 'src/pages/crm/leads/index.tsx');
|
|
const leadsLocalePath = path.join(adminRoot, 'src/pages/crm/leads/locale/index.ts');
|
|
|
|
test('1. crm/leads 页面必须请求 admin/crm/lead/page 并使用 Arco Table', () => {
|
|
assert.ok(fs.existsSync(leadsPagePath), '潜客线索页面必须存在');
|
|
const content = fs.readFileSync(leadsPagePath, 'utf-8');
|
|
|
|
assert.ok(
|
|
content.includes('admin/crm/lead/page'),
|
|
'必须请求 POST /api/admin/crm/lead/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('LeadStatus'), '必须使用 LeadStatus 类型');
|
|
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. crm/leads 必须复用 LeadEntity 契约与状态/来源筛选', () => {
|
|
const content = fs.readFileSync(leadsPagePath, 'utf-8');
|
|
|
|
assert.ok(content.includes('LeadEntity'), '必须使用 LeadEntity 类型');
|
|
assert.ok(content.includes('LeadSource'), '必须使用 LeadSource 类型');
|
|
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('intentScore'), '必须展示 intentScore');
|
|
assert.ok(content.includes('notes'), '必须展示 notes 摘要');
|
|
|
|
for (const status of ['new', 'contacted', 'hot', 'won', 'archived']) {
|
|
assert.ok(content.includes(`'${status}'`), `必须支持状态: ${status}`);
|
|
}
|
|
for (const source of ['nfc', 'qr', 'link', 'ai_chat']) {
|
|
assert.ok(content.includes(`'${source}'`), `必须支持来源: ${source}`);
|
|
}
|
|
});
|
|
|
|
test('3. crm/leads locale 必须包含中英文案', () => {
|
|
assert.ok(fs.existsSync(leadsLocalePath), '潜客线索语言包必须存在');
|
|
const content = fs.readFileSync(leadsLocalePath, 'utf-8');
|
|
|
|
assert.ok(content.includes("'menu.crm.leads'"), '页面语言包必须包含 menu.crm.leads');
|
|
assert.ok(content.includes('crmLeads.request.fail'), '必须包含失败提示文案');
|
|
assert.ok(content.includes('crmLeads.status.new'), '必须包含状态文案');
|
|
assert.ok(content.includes('crmLeads.source.ai_chat'), '必须包含来源文案');
|
|
});
|
|
|
|
test('4. crm/leads 导出必须调用 batchExport,空数据不落盘', () => {
|
|
const content = fs.readFileSync(leadsPagePath, 'utf-8');
|
|
const localeContent = fs.readFileSync(leadsLocalePath, 'utf-8');
|
|
|
|
assert.ok(
|
|
content.includes('admin/crm/lead/batchExport'),
|
|
'必须请求 POST /api/admin/crm/lead/batchExport'
|
|
);
|
|
assert.ok(
|
|
content.includes('crmLeads.export') || content.includes("t['crmLeads.export"),
|
|
'必须有导出按钮文案'
|
|
);
|
|
assert.ok(
|
|
content.includes('crmLeads.export.empty'),
|
|
'空数据必须提示 crmLeads.export.empty'
|
|
);
|
|
assert.ok(
|
|
/exportCount\s*<=\s*0|list\.length\s*===\s*0/.test(content),
|
|
'必须判断空导出,禁止空表头落盘冒充成功'
|
|
);
|
|
assert.ok(
|
|
/crmLeads\.export\.empty[\s\S]{0,120}return|Message\.info\([\s\S]{0,80}export\.empty[\s\S]{0,40}return/.test(
|
|
content
|
|
),
|
|
'空数据提示后必须 return,禁止继续下载'
|
|
);
|
|
assert.ok(
|
|
content.includes('createObjectURL') || content.includes('Blob'),
|
|
'有数据时必须下载 csv/xlsx'
|
|
);
|
|
assert.ok(
|
|
content.includes('.csv') || content.includes('.xlsx'),
|
|
'下载文件必须是 csv 或 xlsx'
|
|
);
|
|
assert.ok(
|
|
!content.includes('Alex') &&
|
|
!content.includes('John Doe') &&
|
|
!content.includes('示例客户') &&
|
|
!content.includes('张三') &&
|
|
!content.includes('假客户'),
|
|
'禁止前端写死示例客户冒充导出成功'
|
|
);
|
|
|
|
for (const key of [
|
|
'crmLeads.export',
|
|
'crmLeads.export.empty',
|
|
'crmLeads.export.success',
|
|
'crmLeads.export.fail',
|
|
]) {
|
|
assert.ok(localeContent.includes(key), `locale 必须包含 ${key}`);
|
|
}
|
|
assert.ok(localeContent.includes("'en-US'"), 'locale 必须含 en-US');
|
|
assert.ok(localeContent.includes("'zh-CN'"), 'locale 必须含 zh-CN');
|
|
assert.ok(localeContent.includes("'ar-SA'"), 'locale 必须含 ar-SA');
|
|
});
|