// 已读取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'); }); });