Files
X-Financial/web/tests/finance-dashboard-ranking.test.mjs

60 lines
2.4 KiB
JavaScript
Raw Normal View History

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'
)
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/)
})