// 已读取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 api = fs.readFileSync(path.join(root, 'pwuniapp/common/api.js'), 'utf-8'); const workspace = fs.readFileSync(path.join(root, 'pwuniapp/pages/expert/workspace.vue'), 'utf-8'); it('仓储提供真实 CRUD 与按用户解析大神', () => { expect(repo).toContain('async createExpertService('); expect(repo).toContain('async updateExpertService('); expect(repo).toContain('async deleteExpertService('); expect(repo).toContain('async countExpertServices('); expect(repo).toContain('async getCompanionByUserId('); }); it('不再自动生成演示服务包', () => { expect(repo).not.toContain('排位保星连胜局'); expect(repo).not.toContain('娱乐匹配快乐唠嗑局'); expect(repo).not.toContain('英雄技术单项教学指导'); }); it('后端提供新增/编辑/删除路由与校验', () => { expect(indexCode).toContain("app.post('/api/companions/:id/services'"); expect(indexCode).toContain("app.put('/api/companions/:id/services/:serviceId'"); expect(indexCode).toContain("app.delete('/api/companions/:id/services/:serviceId'"); expect(indexCode).toContain('validateExpertServicePayload'); expect(indexCode).toContain('SERVICE_MAX_PER_EXPERT'); expect(indexCode).toContain("app.get('/api/expert/me'"); }); it('小程序工作台具备自助维护入口并解析真实大神 id', () => { expect(api).toContain('export async function createExpertService('); expect(api).toContain('export async function updateExpertService('); expect(api).toContain('export async function deleteExpertService('); expect(api).toContain('export async function getMyExpertProfile('); expect(workspace).toContain('currentExpertId'); expect(workspace).toContain('openServiceForm'); expect(workspace).toContain('removeService'); expect(workspace).toContain('getMyExpertProfile'); }); });