Files
Web_BAI_Manage_ApiServer/back-end/tests/integration/wechat.test.js
XuJiacheng 02d5686c7b feat: 完善微信认证功能,新增用户资料更新与token刷新接口
- 新增 userService.js,包含用户认证、资料更新、token 刷新等功能
- 新增 wechatService.js,处理微信API交互,获取openid和手机号
- 新增 appError.js,封装应用错误处理
- 新增 logger.js,提供日志记录功能
- 新增 response.js,统一成功响应格式
- 新增 sanitize.js,提供输入数据清洗功能
- 更新 OpenAPI 文档,描述新增接口及请求响应格式
- 更新 PocketBase 数据库结构,调整用户表字段及索引策略
- 增强错误处理机制,确保错误信息可观测性
- 更新变更记录文档,详细记录本次变更内容
2026-03-24 10:36:19 +08:00

25 lines
871 B
JavaScript

const test = require('node:test')
const assert = require('node:assert/strict')
const request = require('supertest')
const { createApp } = require('../../src/index')
test('POST /api/health 仍返回统一结构', async () => {
const app = createApp()
const response = await request(app).post('/api/health').send({})
assert.equal(response.status, 200)
assert.equal(response.body.code, 200)
assert.equal(response.body.msg, '服务运行正常')
assert.equal(response.body.data.status, 'healthy')
})
test('未匹配路由返回统一 404', async () => {
const app = createApp()
const response = await request(app).get('/not-found-route')
assert.equal(response.status, 404)
assert.equal(response.body.code, 404)
assert.equal(response.body.msg, 'Route not found')
assert.equal(response.body.data.path, '/not-found-route')
})