38 lines
1.9 KiB
JavaScript
38 lines
1.9 KiB
JavaScript
import assert from 'node:assert/strict'
|
|
import { readFileSync } from 'node:fs'
|
|
import test from 'node:test'
|
|
|
|
const source = readFileSync(new URL('./DashboardView.vue', import.meta.url), 'utf8')
|
|
|
|
test('loads real dashboard data allowed by the current permissions', () => {
|
|
assert.match(source, /auth\.hasPermission\('company:profile:view'\).*tenant\.loadCompanyContext\(\)/)
|
|
assert.match(source, /auth\.hasPermission\('company:member:list'\).*tenant\.loadMembers\(\)/)
|
|
assert.match(source, /auth\.hasPermission\('order:first-leg:list'\).*orders\.load\(\)/)
|
|
assert.match(source, /onMounted\(\(\) => void loadDashboardData\(\)\)/)
|
|
})
|
|
|
|
test('isolates recoverable dashboard failures without hiding successful sections', () => {
|
|
assert.match(source, /Promise\.allSettled/)
|
|
assert.match(source, /Partial<Record<DashboardDataSource, string>>/)
|
|
assert.match(source, /:aria-busy="loading"/)
|
|
assert.match(source, /role="alert"/)
|
|
assert.match(source, /部分业务数据加载失败/)
|
|
assert.match(source, /ordersUnavailable/)
|
|
assert.match(source, /companyUnavailable/)
|
|
assert.match(source, /订单数据暂不可用,请重新加载后查看。/)
|
|
assert.match(source, /企业资料暂不可用,请重新加载后查看。/)
|
|
assert.match(source, /@click="loadDashboardData"/)
|
|
assert.doesNotMatch(source, /<template v-else>\s*<section class="quick-order-band">/)
|
|
})
|
|
|
|
test('matches the prototype business overview while keeping real order routing and data', () => {
|
|
assert.match(source, /选择业务,快速下单/)
|
|
assert.match(source, /海外采购/)
|
|
assert.match(source, /美国本土卡/)
|
|
assert.match(source, /美本土散板/)
|
|
assert.match(source, /void router\.push\('\/orders\/first-leg\/create'\)/)
|
|
assert.match(source, /order\.status === 'DELIVERED'/)
|
|
assert.match(source, /currentMonthOrderCount/)
|
|
assert.match(source, /提交订单后,专属客户经理将在 24 小时内与您联系/)
|
|
})
|