import assert from 'node:assert/strict' import fs from 'node:fs' import test from 'node:test' const routerSource = fs.readFileSync(new URL('../routes.ts', import.meta.url), 'utf8') const viewSource = fs.readFileSync(new URL('./AccountProfileView.vue', import.meta.url), 'utf8') const authSource = fs.readFileSync(new URL('../../auth/store/auth.ts', import.meta.url), 'utf8') const authApiSource = fs.readFileSync(new URL('../../auth/api/auth.ts', import.meta.url), 'utf8') const iamApiSource = fs.readFileSync(new URL('../../tenant-management/api/merchantIam.ts', import.meta.url), 'utf8') test('registers the account profile route and navigation entry', () => { assert.match(routerSource, /path: 'account\/profile'[\s\S]*?component: \(\) => import\('\.\/views\/AccountProfileView\.vue'\)/) assert.match(routerSource, /release: 'active'/) assert.match(routerSource, /permission: 'account:profile:view'/) assert.match(routerSource, /navigation: \{ key: 'account-profile'/) }) test('implements profile view, edit, save and cancel states', () => { assert.match(viewSource, /基本信息/) assert.doesNotMatch(viewSource, /account-identity/) assert.doesNotMatch(viewSource, /

基本信息<\/h2>|

修改密码<\/h2>/) assert.match(viewSource, /function startEditing\(\)/) assert.match(viewSource, /function cancelEditing\(\)/) assert.match(viewSource, /async function saveProfile\(\)/) assert.match(viewSource, /请在“登录标识”中修改/) assert.match(viewSource, /
登录手机号<\/dt>
\{\{ auth\.profile\.phone/) assert.doesNotMatch(viewSource, /
联系电话<\/dt>
\{\{ auth\.profile\.phone/) assert.match(viewSource, /企业归属由平台审核关系确定/) assert.match(authSource, /async function savePersonalProfile\(/) assert.match(viewSource, /await auth\.savePersonalProfile/) }) test('changes username and mobile with current-password verification then clears every local session', () => { assert.match(viewSource, /name="identifiers"/) assert.match(viewSource, /validateLoginIdentifierChange/) assert.match(viewSource, /await updateMerchantLoginIdentifiers/) assert.match(iamApiSource, /url: '\/merchant\/v1\/iam\/profile\/login-identifiers'/) assert.match(iamApiSource, /data: payload/) assert.match(viewSource, /error\.code === 'A0409'/) assert.match(viewSource, /error\.code === 'A0401'/) assert.match(viewSource, /auth\.clearSession\(\)/) assert.match(viewSource, /reason: 'identifiers-updated'/) assert.match(viewSource, /label="登录手机号" prop="phone"/) assert.match(viewSource, /全部登录会话都会立即退出/) assert.doesNotMatch(viewSource, /auth\.logout\(\)[\s\S]*identifiers-updated/) }) test('implements password validation, strength feedback and double-submit protection', () => { assert.match(viewSource, /async function changePassword\(\)/) assert.match(viewSource, /validatePasswordChange/) assert.match(viewSource, /callback\(new Error\('请输入新密码'\)\)/) assert.match(viewSource, /getPasswordStrength/) assert.match(viewSource, /passwordStrengthState/) assert.match(viewSource, /if \(passwordSaving\.value\) return/) assert.match(viewSource, /await changeCurrentPassword/) assert.match(authApiSource, /method: 'PUT', url: '\/auth\/password'/) assert.match(viewSource, /安全记录已更新/) assert.match(viewSource, /await router\.replace\('\/login'\)/) assert.doesNotMatch(viewSource, /DEMO_CURRENT_PASSWORD|静态演示/) }) test('provides explicit responsive account layouts', () => { assert.match(viewSource, /@media \(max-width: 820px\)/) assert.match(viewSource, /@media \(max-width: 620px\)/) assert.match(viewSource, /\.account-info-grid, \.account-form-grid \{ grid-template-columns: 1fr; \}/) assert.match(viewSource, /min-height: 44px/) })