- 新表 user_notifications + 仓储方法(创建/列表/未读数/标记已读) - 用户接口 GET /api/notifications、POST /api/notifications/read(生产需登录) - 关键节点落库:订单开始服务/接单/拒单/申请完成/完成结算/提现到账/报名成功/退款受理 - 小程序新增「消息通知」页(pages/user/notifications) + 个人中心入口与未读角标;api.js 增加 getNotifications/markNotificationsRead - 清理后台伪造数据:/api/user/certification 改空态、/api/user/my-project/list 改空数组、/api/user/info 去掉编造邮箱/电话/网址 - 更新 pages 数量断言(26→27);新增回归护栏 notification-center.spec.ts(92 套件/658 用例全绿);冒烟 9/9
52 行
2.4 KiB
TypeScript
52 行
2.4 KiB
TypeScript
// 已读取AGENTS.md
|
|
import * as fs from 'fs';
|
|
import * as path from 'path';
|
|
|
|
/**
|
|
* 第七十六批:站内消息通知中心(用户端真实数据源)+ 清理后台假数据。
|
|
*/
|
|
describe('第七十六批消息通知中心闸门', () => {
|
|
const root = path.resolve(__dirname, '../../');
|
|
const indexCode = fs.readFileSync(path.join(root, 'server/src/index.ts'), 'utf-8');
|
|
const repo = fs.readFileSync(path.join(root, 'server/src/db/repository.ts'), 'utf-8');
|
|
const mysql = fs.readFileSync(path.join(root, 'server/src/db/mysql.ts'), 'utf-8');
|
|
const api = fs.readFileSync(path.join(root, 'pwuniapp/common/api.js'), 'utf-8');
|
|
const userPage = fs.readFileSync(path.join(root, 'pwuniapp/pages/user/index.vue'), 'utf-8');
|
|
const pagesJson = fs.readFileSync(path.join(root, 'pwuniapp/pages.json'), 'utf-8');
|
|
|
|
it('数据库与仓储具备通知能力', () => {
|
|
expect(mysql).toContain('CREATE TABLE IF NOT EXISTS user_notifications');
|
|
expect(repo).toContain('async createUserNotification(');
|
|
expect(repo).toContain('async getUserNotifications(');
|
|
expect(repo).toContain('async getUserUnreadNotificationCount(');
|
|
expect(repo).toContain('async markUserNotificationsRead(');
|
|
});
|
|
|
|
it('提供用户端通知接口', () => {
|
|
expect(indexCode).toContain("app.get('/api/notifications'");
|
|
expect(indexCode).toContain("app.post('/api/notifications/read'");
|
|
expect(indexCode).toContain('function pushUserNotification(');
|
|
});
|
|
|
|
it('关键动作写入站内通知(订单/提现/报名/退款)', () => {
|
|
expect(indexCode).toContain("pushUserNotification(buyer, 'ORDER_STATUS'");
|
|
expect(indexCode).toContain("'WITHDRAW', '提现已到账'");
|
|
expect(indexCode).toContain("'ACTIVITY', '报名成功'");
|
|
expect(indexCode).toContain("'ORDER_REFUND'");
|
|
});
|
|
|
|
it('小程序具备消息中心页面与入口', () => {
|
|
expect(pagesJson).toContain('pages/user/notifications');
|
|
expect(api).toContain('export async function getNotifications(');
|
|
expect(api).toContain('export async function markNotificationsRead(');
|
|
expect(userPage).toContain('openNotifications');
|
|
expect(userPage).toContain('noticeUnread');
|
|
});
|
|
|
|
it('后台伪造数据已清理', () => {
|
|
expect(indexCode).not.toContain('同城生活陪伴运营服务中心');
|
|
expect(indexCode).not.toContain('91110108MA00000000');
|
|
expect(indexCode).not.toContain('admin@peiwan.com');
|
|
});
|
|
});
|