fix(admin-vue): 编辑用户菜单权限已授权回显失效——树数据就绪后 await nextTick 再 setCheckedKeys(el-tree store 异步同步 props.data,旧实现作用在空 store 上勾选丢失),补源码断言防回归测试

This commit is contained in:
2026-09-09 18:32:44 +08:00
parent b3f7b81b9c
commit 02441565a0
2 changed files with 17 additions and 2 deletions
@@ -36,3 +36,15 @@ test('align_user_menu_auth_both_types_fetch_and_submit_source', () => {
const auth = readSource('src/pages/account/user-menu-auth.ts')
assert.match(auth, /type: string/, '授权节点携带 type')
})
test('align_user_menu_auth_echo_waits_tree_render', () => {
// 验收反馈:编辑用户时已授权菜单无回显——load() 在 data 赋值后同步 setCheckedKeys
// el-tree 的 store 异步同步 props.data,勾选作用在空 store 上丢失。
// 修复:data 就绪后先 await nextTick() 再 applyChecked()。
const tree = readSource('src/pages/account/UserMenuAuthTree.vue')
const loadBlock = tree.slice(tree.indexOf('async function load'), tree.indexOf('catch {', tree.indexOf('async function load')))
assert.match(loadBlock, /await nextTick\(\).*applyChecked\(\)/s, ' id')
assert.ok(loadBlock.indexOf('await nextTick') < loadBlock.indexOf('applyChecked()'), 'nextTick 先于 applyChecked')
assert.match(tree, /watch\(/, 'checked 变化时仍兜底回显')
assert.match(tree, /if \(loaded\.value\) applyChecked\(\)/, '兜底回显仅在树加载完成后')
})