feat: 同步管理端、用户端与后端业务,并接通线上 Web 接口
补齐平台订阅、外部登录、CRM 同步与用户端页面;Nginx 转发用户端接口,登录页使用 Google 与 Apple 标志。 Co-authored-by: Cursor <cursoragent@cursor.com>
这个提交包含在:
@@ -2,6 +2,7 @@
|
||||
* OmniCard AI (CRMmp) - 名片主移动潜客列表测试套件 (TDD Red -> Green)
|
||||
*
|
||||
* 严格按照 AGENTS.md 3.3、4.3、5.1 规范与 pages/owner/leads 设计编写
|
||||
* R30:筛选只用接口真实 status / intentScore;空态与失败不填示例线索
|
||||
*/
|
||||
|
||||
import * as fs from 'fs';
|
||||
@@ -68,6 +69,20 @@ type LoadLeadsResult = {
|
||||
errorMessage: string;
|
||||
};
|
||||
|
||||
type LeadsState = {
|
||||
list: LeadEntity[];
|
||||
radarTracks: unknown[];
|
||||
hotUnread: number;
|
||||
page: number;
|
||||
size: number;
|
||||
total: number;
|
||||
status: string;
|
||||
keyWord: string;
|
||||
loading: boolean;
|
||||
empty: boolean;
|
||||
errorMessage: string;
|
||||
};
|
||||
|
||||
type UseLeadsModule = {
|
||||
parseLeadStatus: (raw: string | null | undefined) => LeadStatus | null;
|
||||
formatHotUnread: (unread: number) => string;
|
||||
@@ -75,9 +90,14 @@ type UseLeadsModule = {
|
||||
query: LoadLeadsQuery,
|
||||
api?: LoadLeadsApi
|
||||
) => Promise<LoadLeadsResult>;
|
||||
createLeadsState: () => LeadsState;
|
||||
applyLeadStatusFilter: (state: LeadsState, status: string) => void;
|
||||
applyLoadResult: (state: LeadsState, result: LoadLeadsResult) => void;
|
||||
sanitizeLeadQuery: (query: LoadLeadsQuery) => OwnerPageQuery;
|
||||
};
|
||||
|
||||
const EMOJI_RE = /[\u2600-\u27BF\uFE0F]|[\uD83C-\uDBFF][\uDC00-\uDFFF]/;
|
||||
const SAMPLE_NAME_RE = /Alex Vance|Nexus Tech|示例线索|Fatima Al-Rashid|演示潜客/;
|
||||
|
||||
function buildLead(overrides?: Partial<LeadEntity>): LeadEntity {
|
||||
return {
|
||||
@@ -143,13 +163,14 @@ describe('OmniCard AI 名片主移动潜客列表 (useLeads.uts)', () => {
|
||||
expect(fetchOwnerLeadPage).toHaveBeenCalledTimes(1);
|
||||
expect(result.list).toHaveLength(1);
|
||||
expect(result.list[0].name).toBe('Alex Vance');
|
||||
expect(result.list[0].status).toBe('hot');
|
||||
expect(result.list[0].intentScore).toBe(91);
|
||||
expect(result.empty).toBe(false);
|
||||
expect(result.errorMessage).toBe('');
|
||||
expect(result.pagination.total).toBe(1);
|
||||
});
|
||||
|
||||
it('1.2 空列表标记空态,不写错误', async () => {
|
||||
it('1.2 空列表标记空态,不写错误、不填示例', async () => {
|
||||
const { loadLeads } = loadUseLeads();
|
||||
const fetchOwnerLeadPage = jest.fn(
|
||||
async (): Promise<OwnerPageData<LeadEntity>> => emptyPage(1, 10)
|
||||
@@ -164,9 +185,12 @@ describe('OmniCard AI 名片主移动潜客列表 (useLeads.uts)', () => {
|
||||
expect(result.list).toEqual([]);
|
||||
expect(result.empty).toBe(true);
|
||||
expect(result.errorMessage).toBe('');
|
||||
expect(result.list.some((item) => SAMPLE_NAME_RE.test(item.name))).toBe(
|
||||
false
|
||||
);
|
||||
});
|
||||
|
||||
it('1.3 接口失败写入错误,不伪装空态成功', async () => {
|
||||
it('1.3 接口失败写入错误,列表清空,不伪装空态成功', async () => {
|
||||
const { loadLeads } = loadUseLeads();
|
||||
const fetchOwnerLeadPage = jest.fn(async (): Promise<OwnerPageData<LeadEntity>> => {
|
||||
throw new Error('lead page unavailable');
|
||||
@@ -194,6 +218,8 @@ describe('OmniCard AI 名片主移动潜客列表 (useLeads.uts)', () => {
|
||||
expect(parseLeadStatus('won')).toBe('won');
|
||||
expect(parseLeadStatus('archived')).toBe('archived');
|
||||
expect(parseLeadStatus('pending')).toBeNull();
|
||||
expect(parseLeadStatus('warm')).toBeNull();
|
||||
expect(parseLeadStatus('cold')).toBeNull();
|
||||
expect(parseLeadStatus('NEW')).toBeNull();
|
||||
expect(parseLeadStatus('')).toBeNull();
|
||||
expect(parseLeadStatus(null)).toBeNull();
|
||||
@@ -223,6 +249,87 @@ describe('OmniCard AI 名片主移动潜客列表 (useLeads.uts)', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('3. R30 真实 status / intentScore 筛选与失败清列表', () => {
|
||||
it('3.1 sanitizeLeadQuery 只透传契约 status,不伪造 intent', () => {
|
||||
const { sanitizeLeadQuery } = loadUseLeads();
|
||||
const hot = sanitizeLeadQuery({
|
||||
page: 1,
|
||||
size: 20,
|
||||
status: 'hot',
|
||||
keyWord: 'score',
|
||||
});
|
||||
expect(hot.status).toBe('hot');
|
||||
expect(hot.keyWord).toBe('score');
|
||||
expect(Object.prototype.hasOwnProperty.call(hot, 'intentScore')).toBe(
|
||||
false
|
||||
);
|
||||
|
||||
const cleared = sanitizeLeadQuery({
|
||||
page: 1,
|
||||
size: 20,
|
||||
status: 'warm',
|
||||
});
|
||||
expect(cleared.status).toBeUndefined();
|
||||
});
|
||||
|
||||
it('3.2 applyLeadStatusFilter 只写入真实 status 枚举', () => {
|
||||
const { createLeadsState, applyLeadStatusFilter } = loadUseLeads();
|
||||
const state = createLeadsState();
|
||||
|
||||
applyLeadStatusFilter(state, 'hot');
|
||||
expect(state.status).toBe('hot');
|
||||
expect(state.page).toBe(1);
|
||||
|
||||
applyLeadStatusFilter(state, 'contacted');
|
||||
expect(state.status).toBe('contacted');
|
||||
|
||||
applyLeadStatusFilter(state, 'warm');
|
||||
expect(state.status).toBe('');
|
||||
|
||||
applyLeadStatusFilter(state, '');
|
||||
expect(state.status).toBe('');
|
||||
});
|
||||
|
||||
it('3.3 失败结果写回 state 时清空上一批线索名,不保留示例', () => {
|
||||
const { createLeadsState, applyLoadResult } = loadUseLeads();
|
||||
const state = createLeadsState();
|
||||
state.list = [buildLead({ name: 'Alex Vance', intentScore: 91 })];
|
||||
state.total = 1;
|
||||
state.empty = false;
|
||||
state.errorMessage = '';
|
||||
|
||||
applyLoadResult(state, {
|
||||
list: [],
|
||||
pagination: { page: 1, size: 20, total: 0 },
|
||||
empty: false,
|
||||
errorMessage: 'lead page unavailable',
|
||||
});
|
||||
|
||||
expect(state.list).toEqual([]);
|
||||
expect(state.total).toBe(0);
|
||||
expect(state.empty).toBe(false);
|
||||
expect(state.errorMessage).toBe('lead page unavailable');
|
||||
expect(state.list.some((item) => item.name === 'Alex Vance')).toBe(false);
|
||||
});
|
||||
|
||||
it('3.4 空列表写回 state 标记空态,列表保持空数组', () => {
|
||||
const { createLeadsState, applyLoadResult } = loadUseLeads();
|
||||
const state = createLeadsState();
|
||||
state.list = [buildLead()];
|
||||
|
||||
applyLoadResult(state, {
|
||||
list: [],
|
||||
pagination: { page: 1, size: 20, total: 0 },
|
||||
empty: true,
|
||||
errorMessage: '',
|
||||
});
|
||||
|
||||
expect(state.list).toEqual([]);
|
||||
expect(state.empty).toBe(true);
|
||||
expect(state.errorMessage).toBe('');
|
||||
});
|
||||
});
|
||||
|
||||
it('formatHotUnread 有未读才显示红点文案', () => {
|
||||
const { formatHotUnread } = loadUseLeads();
|
||||
expect(formatHotUnread(0)).toBe('');
|
||||
@@ -278,4 +385,41 @@ describe('OmniCard AI 名片主潜客列表页契约 (leads.uvue)', () => {
|
||||
expect(/<view[^>]*v-for/.test(template)).toBe(false);
|
||||
expect(template.includes('<list-item')).toBe(true);
|
||||
});
|
||||
|
||||
it('R30: 展示用真实 status/intentScore,空态无示例,芯片筛选会刷新', () => {
|
||||
const pageSource = fs.readFileSync(LEADS_PAGE, 'utf8');
|
||||
const logicSource = fs.readFileSync(LEADS_UTS, 'utf8');
|
||||
const template = pageSource.split('<script')[0];
|
||||
const script = pageSource.includes('<script')
|
||||
? pageSource.split('<script')[1].split('</script>')[0]
|
||||
: '';
|
||||
|
||||
expect(template.includes('item.intentScore')).toBe(true);
|
||||
expect(template.includes('item.status')).toBe(true);
|
||||
expect(template.includes('state.empty')).toBe(true);
|
||||
expect(
|
||||
template.includes("t('empty')") || template.includes('t("empty")')
|
||||
).toBe(true);
|
||||
expect(template.includes('leads-feedback')).toBe(true);
|
||||
|
||||
expect(SAMPLE_NAME_RE.test(pageSource)).toBe(false);
|
||||
expect(SAMPLE_NAME_RE.test(logicSource)).toBe(false);
|
||||
expect(logicSource.includes('示例')).toBe(false);
|
||||
expect(pageSource.includes('示例')).toBe(false);
|
||||
|
||||
expect(script.includes("'统计'") || script.includes('"统计"')).toBe(false);
|
||||
expect(script.includes('resolveLeadsText')).toBe(true);
|
||||
|
||||
expect(script.includes('applyLeadStatusFilter')).toBe(true);
|
||||
expect(script.includes('refreshLeads')).toBe(true);
|
||||
expect(
|
||||
/function selectStatus[\s\S]*?applyLeadStatusFilter[\s\S]*?refreshLeads/.test(
|
||||
script
|
||||
)
|
||||
).toBe(true);
|
||||
|
||||
expect(logicSource.includes('sanitizeLeadQuery')).toBe(true);
|
||||
expect(logicSource.includes('parseLeadStatus')).toBe(true);
|
||||
expect(logicSource.includes('intentScore')).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
在新工单中引用
屏蔽一个用户