2026-06-03 09:25:23 +08:00
|
|
|
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'
|
|
|
|
|
)
|
2026-06-03 15:46:56 +08:00
|
|
|
const trendChart = readFileSync(
|
|
|
|
|
fileURLToPath(new URL('../src/components/charts/TrendChart.vue', import.meta.url)),
|
|
|
|
|
'utf8'
|
|
|
|
|
)
|
2026-06-03 09:25:23 +08:00
|
|
|
|
2026-06-03 10:47:11 +08:00
|
|
|
test('finance dashboard keeps legacy ranking range constants for backend compatibility', () => {
|
|
|
|
|
assert.deepEqual(departmentRangeOptions, [
|
|
|
|
|
'\u672c\u6708',
|
|
|
|
|
'\u672c\u5b63\u5ea6',
|
|
|
|
|
'\u672c\u5e74',
|
|
|
|
|
'\u5168\u90e8'
|
|
|
|
|
])
|
2026-06-03 09:25:23 +08:00
|
|
|
assert.match(analyticsService, /department_employee_mix/)
|
|
|
|
|
assert.match(analyticsService, /departmentEmployeeMix/)
|
|
|
|
|
assert.match(analyticsService, /department_range/)
|
|
|
|
|
})
|
|
|
|
|
|
2026-06-03 10:47:11 +08:00
|
|
|
test('finance dashboard rankings follow top range and render department employee mix chart', () => {
|
2026-06-03 09:25:23 +08:00
|
|
|
assert.match(overviewView, /departmentEmployeeLegend/)
|
|
|
|
|
assert.match(overviewView, /departmentEmployeeCenterValue/)
|
2026-06-03 10:47:11 +08:00
|
|
|
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"/)
|
2026-06-03 09:25:23 +08:00
|
|
|
assert.match(overviewViewModel, /financeDepartmentEmployeeMix/)
|
|
|
|
|
assert.match(overviewViewModel, /departmentEmployeeLegend/)
|
|
|
|
|
assert.match(overviewViewModel, /employeeCount/)
|
2026-06-03 10:47:11 +08:00
|
|
|
assert.match(overviewViewModel, /trendRange: resolveTopRangeKey/)
|
|
|
|
|
assert.match(overviewViewModel, /departmentRange: resolveTopRangeKey/)
|
|
|
|
|
assert.match(overviewViewModel, /const topRangeDays = computed/)
|
2026-06-03 09:25:23 +08:00
|
|
|
})
|
|
|
|
|
|
|
|
|
|
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/)
|
|
|
|
|
})
|
2026-06-03 15:46:56 +08:00
|
|
|
|
|
|
|
|
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'/)
|
|
|
|
|
})
|