feat: add admin dashboard data adapter
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
import assert from 'node:assert/strict'
|
||||
import { existsSync, readFileSync } from 'node:fs'
|
||||
import { resolve } from 'node:path'
|
||||
|
||||
const root = resolve(import.meta.dirname, '..')
|
||||
const servicePath = resolve(root, 'admin-web/src/services/dashboard.ts')
|
||||
const typePath = resolve(root, 'admin-web/src/types/dashboard.ts')
|
||||
|
||||
assert.ok(existsSync(servicePath), '缺少工作台数据适配层')
|
||||
assert.ok(existsSync(typePath), '缺少工作台数据模型')
|
||||
|
||||
const service = readFileSync(servicePath, 'utf8')
|
||||
const types = readFileSync(typePath, 'utf8')
|
||||
|
||||
assert.match(service, /export async function loadDashboard/, '必须导出 loadDashboard')
|
||||
assert.match(service, /const REQUEST_TIMEOUT = \d+/, '工作台必须定义明确的请求超时')
|
||||
assert.match(service, /timeout:\s*REQUEST_TIMEOUT/, '工作台请求必须使用超时配置')
|
||||
assert.match(service, /Promise\.allSettled/, '多来源工作台数据必须隔离局部接口失败')
|
||||
assert.doesNotMatch(service, /\|\|\s*(3|6|8|9|12|18|23|28|86)\b/, '不得用参考图演示数字兜底')
|
||||
|
||||
for (const field of ['metrics', 'todos', 'activities', 'serviceOverview', 'effectiveness']) {
|
||||
assert.ok(types.includes(field), `DashboardModel 缺少 ${field}`)
|
||||
}
|
||||
assert.match(types, /available:\s*boolean/, '工作台模块必须显式标识数据是否可用')
|
||||
|
||||
console.log('Admin dashboard data contracts passed')
|
||||
Reference in New Issue
Block a user