文件
shanghaipeiwan/server/tests/order-chat-realtime.spec.ts
xcbyy d941a16d28 fix(miniapp): 清理剩余身份兜底并修正待接单状态/客服入口
- 修复 user/index 使用 normalizeUserId 未导入(分享按钮会报错)

- 待接单独立为 PENDING_ACCEPT:新增待接单 tab/状态色/取消订单与联系客服操作,不再显示为进行中

- 移除 hall/bill-records/reports/settings/favorites/order-create/activity-create/activity-detail/apply 的 1001/2006 身份兜底

- 线下订单(含指定大神)必须填写碰面地点;再次预约不再兜底到 101 号大神;评价不预选标签

- 接单大厅去掉「已实名认证/信誉积分100」等伪造信任文案;客服按钮统一为「联系客服」

- 114 套件/745 用例全绿
2026-10-22 09:25:27 +08:00

73 行
3.1 KiB
TypeScript

// 已读取AGENTS.md
import * as fs from 'fs';
import * as path from 'path';
/**
* 第九十九批:派单实时化;站内聊天已按产品要求移除(沟通统一走官方客服)。
*/
describe('第九十九批派单实时化与客服沟通约束', () => {
const root = path.resolve(__dirname, '../../');
const read = (rel: string) => fs.readFileSync(path.join(root, rel), 'utf-8');
const indexCode = read('server/src/index.ts');
const mysql = read('server/src/db/mysql.ts');
const pagesJson = read('pwuniapp/pages.json');
const radar = read('pwuniapp/pages/expert/radar.vue');
const hall = read('pwuniapp/pages/expert/hall.vue');
const orderList = read('pwuniapp/pages/order/list.vue');
const workspace = read('pwuniapp/pages/expert/workspace.vue');
it('新派单必须通知在线认证大神,雷达/大厅自动轮询', () => {
expect(indexCode).toContain('notifyNearbyExpertsForOrder');
expect(indexCode).toContain("c.status = '接单中'");
expect(indexCode).toContain("pushUserNotification(\n uid,\n 'ORDER_POOL'");
expect(radar).toContain('startPolling');
expect(radar).toContain('}, 20000);');
expect(hall).toContain('startHallPolling');
expect(hall).toContain('}, 30000);');
});
it('新单通知跳转会正确处理接单页 tab 路由', () => {
const notifications = read('pwuniapp/pages/user/notifications.vue');
expect(notifications).toContain("'/pages/expert/radar'");
expect(notifications).toContain("'/pages/expert/hall'");
});
it('站内聊天必须彻底移除(页面/接口/表/客户端方法)', () => {
expect(fs.existsSync(path.join(root, 'pwuniapp/pages/order/chat.vue'))).toBe(false);
expect(pagesJson).not.toContain('pages/order/chat');
expect(indexCode).not.toContain('/chat/messages');
expect(mysql).not.toContain('order_messages');
const apiCode = read('pwuniapp/common/api.js');
expect(apiCode).not.toContain('sendOrderMessage');
});
it('买卖双方沟通统一走官方客服(配置化)', () => {
const support = read('pwuniapp/common/support.js');
expect(support).toContain('openSupportSheet');
expect(support).toContain('customer_service');
expect(orderList).toContain('openSupportSheet');
expect(workspace).toContain('openSupportSheet');
expect(orderList).not.toContain('pages/order/chat');
});
it('待接单必须是独立状态,不能伪装成进行中', () => {
const apiCode = read('pwuniapp/common/api.js');
expect(apiCode).toContain("statusKey === '待接单') statusKey = 'PENDING_ACCEPT'");
expect(orderList).toContain("order.status === 'PENDING_ACCEPT'");
expect(orderList).toContain('PENDING_ACCEPT:');
});
it('剩余演示身份兜底必须清理', () => {
expect(hall).not.toContain('|| 2006');
expect(hall).toContain('normalizeUserId()');
const bill = read('pwuniapp/pages/user/bill-records.vue');
expect(bill).not.toContain('|| 2006');
});
it('线下下单必须选择碰面地点', () => {
const createPage = read('pwuniapp/pages/order/create.vue');
expect(createPage).toContain('请填写或选择碰面地点');
});
});