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\(async \(\) => \{\s*await loadDashboardData\(\)\s*showQualificationReminderOnce\(\)\s*\}\)/) }) test('prompts once per session for incomplete company qualification and opens the upload dialog', () => { assert.match(source, /\['PROFILE_REQUIRED', 'REJECTED'\]\.includes\(tenant\.company\.auditStatus\)/) assert.match(source, /sessionStorage\.getItem\(reminderKey\)/) assert.match(source, /sessionStorage\.setItem\(reminderKey, 'shown'\)/) assert.match(source, /title="完善企业认证资料"/) assert.match(source, /立即上传认证资料/) assert.match(source, /router\.push\(\{ path: '\/company\/profile', query: \{ qualification: 'upload' \} \}\)/) }) test('isolates recoverable dashboard failures without hiding successful sections', () => { assert.match(source, /Promise\.allSettled/) assert.match(source, /Partial>/) 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, /