feat(short-drama-agent-front): 接入联合修订与图片费用审计
This commit is contained in:
1 parent
87427d9d43
commit
f6edc4eb70
52 files changed
+5060
-516
No files matched your search
@@ -0,0 +1,40 @@
|
||||
import { defineComponent, h } from 'vue'
|
||||
import { flushPromises, mount } from '@vue/test-utils'
|
||||
import { expect, it, vi } from 'vitest'
|
||||
import BeatShotDirectory from '@/features/storyboard/components/BeatShotDirectory.vue'
|
||||
import { designedShot } from '@/features/storyboard/testing/fixtures'
|
||||
|
||||
it('定位嵌套镜头时避让所属段落标题,首行镜号不被吸顶标题遮挡', async () => {
|
||||
const wrapper = mount(
|
||||
defineComponent({
|
||||
props: { activeId: { type: String, required: true } },
|
||||
setup: props => () =>
|
||||
h('div', { class: 'n-scrollbar-container' }, [
|
||||
h(BeatShotDirectory, {
|
||||
shots: [designedShot('first'), { ...designedShot('next'), beatNo: 2 }],
|
||||
activeId: props.activeId,
|
||||
itemClass: 'shot-link'
|
||||
})
|
||||
])
|
||||
}),
|
||||
{ props: { activeId: 'first' } }
|
||||
)
|
||||
try {
|
||||
await flushPromises()
|
||||
const viewport = wrapper.get<HTMLElement>('.n-scrollbar-container').element
|
||||
const selected = wrapper.findAll<HTMLElement>('.directory-item')[1]!.element
|
||||
const heading = selected.closest('[role="group"]')!.querySelector('h4')!
|
||||
Object.defineProperty(heading, 'offsetHeight', { configurable: true, value: 38 })
|
||||
vi.spyOn(viewport, 'getBoundingClientRect').mockReturnValue(new DOMRect(0, 100, 240, 400))
|
||||
vi.spyOn(selected, 'getBoundingClientRect').mockReturnValue(new DOMRect(0, 180, 240, 88))
|
||||
viewport.scrollTop = 80
|
||||
/** 记录目录自身滚动目标,断言标题避让距离。 */
|
||||
const scrollTo = vi.fn<(options: ScrollToOptions) => void>()
|
||||
Object.defineProperty(viewport, 'scrollTo', { configurable: true, value: scrollTo })
|
||||
await wrapper.setProps({ activeId: 'next' })
|
||||
await flushPromises()
|
||||
expect(scrollTo).toHaveBeenLastCalledWith({ top: 122, behavior: 'smooth' })
|
||||
} finally {
|
||||
wrapper.unmount()
|
||||
}
|
||||
})
|
||||
Reference in new issue
Block a user