2026-07-30 17:59:42 +08:00
|
|
|
import assert from 'node:assert/strict'
|
|
|
|
|
import fs from 'node:fs'
|
|
|
|
|
import test from 'node:test'
|
|
|
|
|
|
|
|
|
|
const routerSource = fs.readFileSync(new URL('../router/index.ts', import.meta.url), 'utf8')
|
|
|
|
|
const navigationSource = fs.readFileSync(new URL('../navigation/clientNavigation.ts', import.meta.url), 'utf8')
|
|
|
|
|
const viewSource = fs.readFileSync(new URL('./AccountProfileView.vue', import.meta.url), 'utf8')
|
|
|
|
|
const authSource = fs.readFileSync(new URL('../stores/auth.ts', import.meta.url), 'utf8')
|
|
|
|
|
const authApiSource = fs.readFileSync(new URL('../api/auth.ts', import.meta.url), 'utf8')
|
|
|
|
|
|
|
|
|
|
test('registers the account profile route and navigation entry', () => {
|
|
|
|
|
assert.match(routerSource, /account\/profile'.*AccountProfileView\.vue/)
|
|
|
|
|
assert.match(routerSource, /permission: 'account:profile:view'/)
|
|
|
|
|
assert.match(navigationSource, /title: '我的信息'.*path: '\/account\/profile'/)
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
test('implements profile view, edit, save and cancel states', () => {
|
|
|
|
|
assert.match(viewSource, /基本信息/)
|
2026-08-01 12:17:33 +08:00
|
|
|
assert.doesNotMatch(viewSource, /account-identity/)
|
2026-08-03 10:51:53 +08:00
|
|
|
assert.doesNotMatch(viewSource, /<h2>基本信息<\/h2>|<h2>修改密码<\/h2>/)
|
2026-07-30 17:59:42 +08:00
|
|
|
assert.match(viewSource, /function startEditing\(\)/)
|
|
|
|
|
assert.match(viewSource, /function cancelEditing\(\)/)
|
|
|
|
|
assert.match(viewSource, /async function saveProfile\(\)/)
|
|
|
|
|
assert.match(viewSource, /账号标识暂不支持在客户端修改/)
|
|
|
|
|
assert.match(viewSource, /企业归属由平台审核关系确定/)
|
|
|
|
|
assert.match(authSource, /async function savePersonalProfile\(/)
|
|
|
|
|
assert.match(viewSource, /await auth\.savePersonalProfile/)
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
test('implements password validation, strength feedback and double-submit protection', () => {
|
|
|
|
|
assert.match(viewSource, /async function changePassword\(\)/)
|
|
|
|
|
assert.match(viewSource, /validatePasswordChange/)
|
|
|
|
|
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/)
|
|
|
|
|
})
|