4c88964473
- 新后台 admin-frontend-vue 整工程入库(base=/admin-vue/、History 路由、Nginx 静态托管方案与 verify-dist 校验) - Java AdminConsoleController 改为入口重定向: /admin|/admin.html、/login|/login.html -> /admin-vue/; 删除 classpath:static 旧 admin.html/login.html 单页与 admin.js 副本 - Flask 后台整体退役: 删除 admin_api/auth/main 蓝图、web_source 页面、static 脚本与 admin 相关测试; app.py 收敛为仅注册 version_bp(/api/version、/api/version/latest, 供桌面端更新检查) - AdminApiGuardFilterTest 豁免样例路径 /admin.html -> /admin-vue/
50 lines
2.0 KiB
TypeScript
50 lines
2.0 KiB
TypeScript
import test from 'node:test'
|
|
import assert from 'node:assert/strict'
|
|
|
|
const BASE = process.env.AIIMAGE_LIVE_BASE || 'http://127.0.0.1:18080'
|
|
|
|
test('test_task_180_public_version_live_reachability', async () => {
|
|
// 公开版本路径可达。
|
|
const res = await fetch(`${BASE}/api/version`)
|
|
assert.equal(res.status, 200)
|
|
const body = (await res.json()) as Record<string, unknown>
|
|
assert.ok('version' in body)
|
|
assert.ok('desc' in body)
|
|
assert.ok('url' in body)
|
|
})
|
|
|
|
test('test_task_180_public_version_live_latest_contract', async () => {
|
|
// latest 契约含 version/file_url(允许 null)。
|
|
const res = await fetch(`${BASE}/api/version/latest`)
|
|
assert.equal(res.status, 200)
|
|
const body = (await res.json()) as Record<string, unknown>
|
|
assert.ok('version' in body)
|
|
assert.ok('file_url' in body)
|
|
})
|
|
|
|
test('test_task_180_public_version_live_no_envelope', async () => {
|
|
// 公开接口无 success 包装。
|
|
const body = (await (await fetch(`${BASE}/api/version`)).json()) as Record<string, unknown>
|
|
assert.equal('success' in body, false, '公开接口不包装 ApiResponse')
|
|
assert.equal('data' in body, false)
|
|
})
|
|
|
|
test('test_task_180_public_version_live_values_type', async () => {
|
|
const body = (await (await fetch(`${BASE}/api/version`)).json()) as Record<string, unknown>
|
|
for (const key of ['version', 'desc', 'url']) {
|
|
const v = body[key]
|
|
assert.ok(v === null || typeof v === 'string' || typeof v === 'number', key)
|
|
}
|
|
})
|
|
|
|
test('test_task_180_public_version_live_latest_keys_only', async () => {
|
|
const body = (await (await fetch(`${BASE}/api/version/latest`)).json()) as Record<string, unknown>
|
|
const keys = Object.keys(body).sort()
|
|
assert.deepEqual(keys, ['file_url', 'version'], 'latest 仅含两个字段')
|
|
})
|
|
|
|
test('test_task_180_public_version_live_download_url_preserved', async () => {
|
|
const body = (await (await fetch(`${BASE}/api/version/latest`)).json()) as Record<string, unknown>
|
|
if (body.file_url) assert.match(String(body.file_url), /^https?:\/\//)
|
|
})
|