- 新派单(余额支付立即入池 / 微信支付确认后入池)向在线认证大神推送 ORDER_POOL 站内通知;雷达 20s、接单大厅 30s 自动轮询 - 新增 order_messages 表与订单会话接口:仅买家与已认领大神可访问,服务端拦截手机号与违规内容,消息落库并推送 CHAT 通知 - 新增 pages/order/chat 聊天页(3s 轮询、已读、发送),买家订单「联系大神」与大神工作台「联系老板」接入 - 114 套件/744 用例全绿;线上实测聊天/越权/手机号拦截/新单通知均通过,测试数据已清理
64 行
2.7 KiB
TypeScript
64 行
2.7 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 mysql = read('server/src/db/mysql.ts');
|
|
const repo = read('server/src/db/repository.ts');
|
|
const indexCode = read('server/src/index.ts');
|
|
const apiCode = read('pwuniapp/common/api.js');
|
|
const chatPage = read('pwuniapp/pages/order/chat.vue');
|
|
const pagesJson = read('pwuniapp/pages.json');
|
|
const radar = read('pwuniapp/pages/expert/radar.vue');
|
|
const hall = read('pwuniapp/pages/expert/hall.vue');
|
|
|
|
it('订单消息表必须落库且带索引', () => {
|
|
expect(mysql).toContain('CREATE TABLE IF NOT EXISTS order_messages');
|
|
expect(mysql).toContain('idx_order_created');
|
|
expect(mysql).toContain('idx_receiver_read');
|
|
});
|
|
|
|
it('聊天接口必须校验交易双方身份', () => {
|
|
expect(indexCode).toContain("app.get('/api/orders/:id/chat'");
|
|
expect(indexCode).toContain("app.post('/api/orders/:id/chat/messages'");
|
|
expect(indexCode).toContain('仅交易双方可查看该订单会话');
|
|
expect(indexCode).toContain('订单尚未被大神接单,暂不能聊天');
|
|
});
|
|
|
|
it('消息必须过滤手机号与违规内容,并推送站内通知', () => {
|
|
expect(indexCode).toContain("请勿在站内发送手机号");
|
|
expect(indexCode).toContain('contentSecurityService.checkText(content)');
|
|
expect(indexCode).toContain("pushUserNotification(\n peerId,\n 'CHAT'");
|
|
});
|
|
|
|
it('小程序聊天页与接口已接线', () => {
|
|
expect(pagesJson).toContain('pages/order/chat');
|
|
expect(apiCode).toContain('export async function getOrderChat');
|
|
expect(apiCode).toContain('export async function sendOrderMessage');
|
|
expect(chatPage).toContain('setInterval');
|
|
expect(chatPage).toContain('sendOrderMessage');
|
|
});
|
|
|
|
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'");
|
|
});
|
|
});
|