Files
X-Financial/web/tests/finance-dashboard-ranking.test.mjs
caoxiaozhu 34457f9c3e feat: 本体字段治理与风险规则模板执行器重构
- 新增本体字段注册表与字段治理审计脚本
- 重构风险规则模板执行器、DSL 验证与清单分类器
- 完善票据夹服务与差旅请求详情页交互
- 优化趋势图表与总览页数据展示
- 增强报销平台风险分级与模拟公司筛选
- 补充本体字段、风险规则生成与票据夹服务测试覆盖
2026-06-03 15:46:56 +08:00

94 lines
4.2 KiB
JavaScript

import assert from 'node:assert/strict'
import { readFileSync } from 'node:fs'
import test from 'node:test'
import { fileURLToPath } from 'node:url'
import { departmentRangeOptions } from '../src/data/metrics.js'
const overviewView = readFileSync(
fileURLToPath(new URL('../src/views/OverviewView.vue', import.meta.url)),
'utf8'
)
const overviewViewModel = readFileSync(
fileURLToPath(new URL('../src/composables/useOverviewView.js', import.meta.url)),
'utf8'
)
const analyticsService = readFileSync(
fileURLToPath(new URL('../src/services/analytics.js', import.meta.url)),
'utf8'
)
const barChart = readFileSync(
fileURLToPath(new URL('../src/components/charts/BarChart.vue', import.meta.url)),
'utf8'
)
const trendChart = readFileSync(
fileURLToPath(new URL('../src/components/charts/TrendChart.vue', import.meta.url)),
'utf8'
)
test('finance dashboard keeps legacy ranking range constants for backend compatibility', () => {
assert.deepEqual(departmentRangeOptions, [
'\u672c\u6708',
'\u672c\u5b63\u5ea6',
'\u672c\u5e74',
'\u5168\u90e8'
])
assert.match(analyticsService, /department_employee_mix/)
assert.match(analyticsService, /departmentEmployeeMix/)
assert.match(analyticsService, /department_range/)
})
test('finance dashboard rankings follow top range and render department employee mix chart', () => {
assert.match(overviewView, /departmentEmployeeLegend/)
assert.match(overviewView, /departmentEmployeeCenterValue/)
assert.match(overviewView, /class="top-claim-split"/)
assert.match(overviewView, /card-range-chip/)
assert.doesNotMatch(overviewView, /aria-label="\u90e8\u95e8\u6392\u884c\u65f6\u95f4\u8303\u56f4"/)
assert.doesNotMatch(overviewView, /aria-label="\u4e2a\u4eba\u6392\u884c\u65f6\u95f4\u8303\u56f4"/)
assert.doesNotMatch(overviewView, /v-model="activeDepartmentRange"/)
assert.doesNotMatch(overviewView, /v-model="activeTrendRange"/)
assert.match(overviewViewModel, /financeDepartmentEmployeeMix/)
assert.match(overviewViewModel, /departmentEmployeeLegend/)
assert.match(overviewViewModel, /employeeCount/)
assert.match(overviewViewModel, /trendRange: resolveTopRangeKey/)
assert.match(overviewViewModel, /departmentRange: resolveTopRangeKey/)
assert.match(overviewViewModel, /const topRangeDays = computed/)
})
test('finance ranking bar chart can display ranking metadata', () => {
assert.match(barChart, /rank-meta/)
assert.match(barChart, /item\.meta/)
assert.match(overviewViewModel, /meta: `\$\{Number\(item\.employeeCount/)
assert.match(overviewViewModel, /meta: `\$\{item\.department/)
})
test('daily amount trend uses stacked category bars with clear unit and legend', () => {
assert.match(overviewView, /:category-amount-series="activeTrend\.categoryAmountSeries"/)
assert.match(overviewView, /:key="`finance-amount-\$\{financeDashboardRenderKey\}`"/)
assert.match(overviewView, /:key="`finance-count-\$\{financeDashboardRenderKey\}`"/)
assert.match(overviewView, /return financeDashboardLoading\.value\s*\n\}/)
assert.doesNotMatch(overviewView, /financeDashboardLoading\.value && !financeDashboardLoaded\.value/)
assert.match(overviewViewModel, /categoryAmountSeries: \[\]/)
assert.match(overviewViewModel, /financeDashboardRenderKey/)
assert.match(overviewViewModel, /financeDashboardRequestSeq/)
assert.match(overviewViewModel, /requestSeq !== financeDashboardRequestSeq/)
assert.match(overviewViewModel, /financeDashboardRenderKey\.value \+= 1/)
assert.match(trendChart, /categoryAmountSeries/)
assert.match(trendChart, /CustomChart as EChartsCustomChart/)
assert.match(trendChart, /type: 'custom'/)
assert.match(trendChart, /renderStackedAmountBar/)
assert.match(trendChart, /resolveCategoryColor/)
assert.match(trendChart, /expenseCategoryColorMap/)
assert.match(trendChart, /clipPath/)
assert.match(trendChart, /enterFrom/)
assert.match(trendChart, /originY: zeroY/)
assert.match(trendChart, /scaleY: 0/)
assert.match(trendChart, /chart-unit/)
assert.match(trendChart, /unitLabel/)
assert.match(trendChart, /legendItems/)
assert.match(trendChart, /单位:元/)
assert.match(trendChart, /单位:单/)
assert.doesNotMatch(trendChart, /name:\s*isCountMode\.value/)
assert.doesNotMatch(trendChart, /stack: 'expenseAmount'/)
})