✨ feat(core): 实现详情面板动画逻辑并完善相关测试

* 新增 detailMotion 工具类以支持更精细的动画控制
* 优化 FileManageView 面板渲染逻辑,改用 v-show 提升交互性能
* 调整 Transition 组件为手动控制模式以适配自定义动画
* 在 package.json 中配置自动化测试脚本
* 补充 detailMotion 相关的单元测试与测试说明文档
This commit is contained in:
orion committed 2026-09-15 11:25:43 +08:00
1 parent 9bac0c0040
commit af009cf3c5
6 files changed
+307 -138

No files matched your search

+77
View File
@@ -0,0 +1,77 @@
// Run in the local app with a file detail dialog open (more than 3 lifecycle rows
// and retrieval events). Reads real data and toggles presentation only.
export async function runDetailMotionChecks({ reducedMotion = false } = {}) {
const results = []
const wait = ms => new Promise(resolve => setTimeout(resolve, ms))
const assert = (condition, message) => { if (!condition) throw new Error(message) }
const lifecycle = () => document.querySelector('.fcb-lifecycle-viewport')
const toggle = (kind, expanded) => {
const label = kind === 'lifecycle'
? (expanded ? '展开全部生命周期记录' : '收起生命周期记录')
: (expanded ? '展开全部取件记录' : '收起取件记录')
const button = [...document.querySelectorAll('button')].find(b => b.textContent.includes(label))
if (button) button.click()
}
const assertNaturalHeight = label => {
const v = lifecycle()
const actual = v.getBoundingClientRect().height
const expected = v.firstElementChild.getBoundingClientRect().height
assert(Math.abs(actual - expected) < 1, `${label}: viewport ${actual}, content ${expected}`)
assert(!v.style.height && v.getAnimations().length === 0, `${label}: retained height effect`)
results.push({ label, height: actual, contentHeight: expected })
}
assert(lifecycle(), 'Open a file detail dialog first')
toggle('lifecycle', false)
await wait(500)
const initial = lifecycle().getBoundingClientRect().height
for (let cycle = 0; cycle < 3; cycle++) {
toggle('lifecycle', true)
await wait(30)
if (!reducedMotion) {
const animation = lifecycle().getAnimations()[0]
assert(animation, 'Missing outer height animation')
const frames = animation.effect.getKeyframes()
assert(frames[0].height !== frames[1].height, 'Identical start and end heights')
assert(animation.effect.getTiming().duration === 420, 'Unexpected height duration')
}
await wait(500)
assertNaturalHeight(`expanded-${cycle}`)
toggle('lifecycle', false)
await wait(500)
assertNaturalHeight(`collapsed-${cycle}`)
assert(Math.abs(lifecycle().getBoundingClientRect().height - initial) < 1, 'Collapsed height drift')
assert(lifecycle().querySelectorAll('.fcb-lifecycle-row').length === 3, 'Unexpected collapsed rows')
}
toggle('lifecycle', true)
await wait(500)
toggle('retrieval', true)
await wait(500)
const panel = document.querySelector('.fcb-retrieval-panel')
assert(panel && panel.getBoundingClientRect().height > 0, 'Retrieval panel is hidden')
assert(panel.querySelectorAll('.font-medium').length > 0, 'Missing retrieval records')
assert(getComputedStyle(panel).transform === 'none', 'Retrieval records translate vertically')
assertNaturalHeight('retrieval-expanded')
for (let i = 0; i < 6; i++) {
const before = panel.getBoundingClientRect().height
toggle('retrieval', i % 2 !== 0)
await wait(60)
const after = panel.getBoundingClientRect().height
assert(i % 2 === 0 ? after <= before : after >= before, 'Reversal jumps in the wrong direction')
}
await wait(500)
assertNaturalHeight('rapid-retrieval-reversal')
for (let i = 0; i < 6; i++) {
toggle('lifecycle', i % 2 !== 0)
await wait(60)
}
await wait(500)
assertNaturalHeight('rapid-lifecycle-reversal')
toggle('retrieval', false)
await wait(500)
assert(getComputedStyle(document.querySelector('.fcb-retrieval-panel')).display === 'none', 'Retrieval panel remains visible')
assertNaturalHeight('retrieval-collapsed')
toggle('lifecycle', false)
await wait(500)
assertNaturalHeight('final-collapsed')
return results
}