后端新增风险图谱算法模块、风险观察与反馈服务、规则 DSL 校验器和可解释性引擎,完善系统仪表盘和财务仪表盘统计, 优化 agent 运行和编排执行链路,清理旧开发文档,前端新增 系统趋势、负载热力图等多种仪表盘图表组件,完善操作反馈 对话框和工作台日期选择器,优化报销创建和审批详情交互, 补充单元测试覆盖。
52 lines
1.6 KiB
JavaScript
52 lines
1.6 KiB
JavaScript
import assert from 'node:assert/strict'
|
|
import { readFileSync } from 'node:fs'
|
|
import test from 'node:test'
|
|
import { fileURLToPath } from 'node:url'
|
|
|
|
import { checkBackendHealth, useBackendHealth } from '../src/composables/useBackendHealth.js'
|
|
|
|
const routerScript = readFileSync(
|
|
fileURLToPath(new URL('../src/router/index.js', import.meta.url)),
|
|
'utf8'
|
|
)
|
|
|
|
test('app route guard allows stale healthy state when health check times out', () => {
|
|
assert.match(routerScript, /checkBackendHealth\(\{\s*allowStaleOnTimeout:\s*true\s*\}\)/)
|
|
})
|
|
|
|
test('authenticated in-app navigation does not wait for backend health check', () => {
|
|
assert.match(routerScript, /function isAuthenticatedAppNavigation\(to, from\)/)
|
|
assert.match(
|
|
routerScript,
|
|
/if \(isAuthenticatedAppNavigation\(to, from\)\) \{[\s\S]*scheduleBackgroundBackendHealthCheck\(\)[\s\S]*return true[\s\S]*\}/
|
|
)
|
|
})
|
|
|
|
test('backend health timeout does not block app rendering when stale fallback is allowed', async () => {
|
|
const originalFetch = global.fetch
|
|
|
|
global.fetch = async (_url, options = {}) =>
|
|
new Promise((_, reject) => {
|
|
options.signal.addEventListener('abort', () => {
|
|
const error = new Error('aborted')
|
|
error.name = 'AbortError'
|
|
reject(error)
|
|
})
|
|
})
|
|
|
|
try {
|
|
const ok = await checkBackendHealth({
|
|
force: true,
|
|
allowStaleOnTimeout: true,
|
|
timeoutMs: 1
|
|
})
|
|
const { backendHealthy, backendError } = useBackendHealth()
|
|
|
|
assert.equal(ok, true)
|
|
assert.equal(backendHealthy.value, true)
|
|
assert.match(backendError.value, /健康检查超时|health/i)
|
|
} finally {
|
|
global.fetch = originalFetch
|
|
}
|
|
})
|