1
0
Files
nex/frontend/src/__tests__/api/version.test.ts
lanyuanxiaoyao 8eea30ea11 feat: 统一品牌标识、关于页面三卡片布局与版本诊断功能
- 统一品牌为 Nex:侧边栏、托盘 tooltip、HTML 标题、favicon (PNG 替代 SVG)
- 重构关于页面为三卡片布局(品牌/版本/链接),版本状态 Tag 绝对定位右上角
- 新增 GET /api/version 后端接口,返回 version/commit/build_time
- 新增前端版本一致性诊断:匹配/不匹配/不可判断三种状态
- 同步 delta specs 到主 specs 并归档变更
2026-05-05 03:28:22 +08:00

31 lines
902 B
TypeScript

import { http, HttpResponse } from 'msw'
import { setupServer } from 'msw/node'
import { describe, it, expect, beforeAll, afterEach, afterAll } from 'vitest'
import { getBackendVersion } from '@/api/version'
describe('version API', () => {
const server = setupServer()
beforeAll(() => server.listen({ onUnhandledRequest: 'bypass' }))
afterEach(() => server.resetHandlers())
afterAll(() => server.close())
it('fetches backend version and converts build_time to buildTime', async () => {
server.use(
http.get('http://localhost:3000/api/version', () => {
return HttpResponse.json({
version: '0.1.0',
commit: 'abc1234',
build_time: '2026-05-05T00:00:00Z',
})
})
)
await expect(getBackendVersion()).resolves.toEqual({
version: '0.1.0',
commit: 'abc1234',
buildTime: '2026-05-05T00:00:00Z',
})
})
})