perf(short-drama-agent-front): 优化记录加载与工作区体验

This commit is contained in:
GJ committed 2026-11-06 20:56:25 +08:00
1 parent d0264c08ce
commit db9aea1694
111 files changed
+1680 -1290

No files matched your search

@@ -265,7 +265,7 @@ describe('过期首帧到具体素材定位', () => {
})
it('切换镜头时筛选、关联说明和图片共用稳定纵向容器,长关联列表单独横向滚动', async () => {
const { keyframes, videos, references, fetcher } = await gallery('?sourceShotId=shot-target')
const { keyframes, references, fetcher, router } = await gallery('?sourceShotId=shot-target')
expect(wrapper!.find('.workspace-heading-scroll').exists()).toBe(false)
const scroll = wrapper!.get<HTMLElement>('.workspace-scroll > .n-scrollbar-container').element
const content = wrapper!.get('.workspace-scroll-content').element
@@ -277,8 +277,7 @@ describe('过期首帧到具体素材定位', () => {
expect(wrapper!.get('.form-image-grid').element.parentElement).toBe(content)
scroll.scrollTop = 480
keyframes.items.push({ ...keyframes.items[0]!, shotId: 'shot-next', shotNo: 2 })
videos.items.push({ ...videos.items[0]!, shotId: 'shot-next', shotNo: 2 })
keyframes.total = videos.total = 2
keyframes.total = 2
let finish!: (response: Response) => void
const original = fetcher.getMockImplementation()!
fetcher.mockImplementation((url, init) =>
@@ -289,10 +288,7 @@ describe('过期首帧到具体素材定位', () => {
: original(url, init)
)
await assetsChanged()
wrapper!
.findAllComponents(NSelect)
.find(item => item.attributes('aria-label') === '选择关联镜头')!
.vm.$emit('update:value', 'shot-next')
await router.push({ query: { sourceShotId: 'shot-next' } })
await flushPromises()
expect(wrapper!.text()).toContain('正在读取镜头关联素材')
finish(
@@ -415,62 +411,15 @@ describe('过期首帧到具体素材定位', () => {
expect(router.currentRoute.value.query.subjectFormId).toBe('form-special')
expect(fetcher.mock.calls.every(([, init]) => init?.method === 'GET')).toBe(true)
})
it('图库直接访问即显示下游警告,但不把有效素材误标成身份过期', async () => {
it('普通图库入口不展示下游警告,也不请求首帧或视频就绪列表', async () => {
const { fetcher } = await gallery()
expect(wrapper!.get('[data-keyframe-impact]').text()).toContain('1 个镜头')
expect(wrapper!.text()).toContain('不表示形态图片本身失效')
expect(wrapper!.findAll('.form-image-card')).toHaveLength(3)
expect(wrapper!.text()).not.toContain('个形态主图与当前已锁定身份母版不一致')
expect(fetcher.mock.calls.some(([url]) => String(url).endsWith('/references'))).toBe(false)
// 镜头选择和图库筛选共享上方工具栏;未选择镜头时不留下空的关联说明面板。
const toolbar = wrapper!.get('.form-image-toolbar')
const picker = toolbar.get('.asset-impact-picker').element
expect(toolbar.classes()).toContain('has-impact-picker')
expect(picker.nextElementSibling).toBe(toolbar.get('.form-image-filters').element)
expect(toolbar.find('input[aria-label="搜索形态图片"]').exists()).toBe(true)
expect(wrapper!.find('.asset-impact-picker').exists()).toBe(false)
expect(wrapper!.text()).not.toContain('下游主首帧需要处理')
expect(
toolbar
.findAllComponents(NSelect)
.some((item: VueWrapper) => item.attributes('aria-label') === '筛选图片状态')
).toBe(true)
expect(wrapper!.find('.asset-impact-context').exists()).toBe(false)
const select = wrapper!
.findAllComponents(NSelect)
.find(item => item.attributes('aria-label') === '选择关联镜头')!
select.vm.$emit('update:value', 'shot-target')
await flushPromises()
expect(wrapper!.get('.asset-impact-context').element.previousElementSibling).toBe(
wrapper!.get('.form-image-filter-region').element
)
expect(wrapper!.text()).toContain('待处理首帧关联此素材')
expect(fetcher.mock.calls.filter(([url]) => String(url).endsWith('/references'))).toHaveLength(1)
fetcher.mock.calls.some(([url]) => /\/(keyframes|videos)\/readiness|\/references$/.test(String(url)))
).toBe(false)
})
it('警告列出具体集数与镜头,可定位关联素材或打开对应生产镜头', async () => {
const { router, fetcher } = await gallery()
const warning = wrapper!.get('[data-keyframe-impact]')
expect(warning.text()).toContain('第 2 集 · 剧情段落 2 / 镜头 1')
const shotLink = warning.get('a[data-impact-shot-link]')
const location = new URL(shotLink.attributes('href')!, 'http://localhost')
expect(location.pathname).toBe('/projects/capability-test/production')
expect(location.searchParams.get('episodeNo')).toBe('2')
expect(location.searchParams.get('shotId')).toBe('shot-target')
await warning.get('[data-impact-materials]').trigger('click')
await flushPromises()
expect(router.currentRoute.value.query.sourceShotId).toBe('shot-target')
expect(wrapper!.get('.asset-impact-context').text()).toContain('雨夜形态')
expect(fetcher.mock.calls.every(([, init]) => init?.method === 'GET')).toBe(true)
})
it('警告重新检查后移除已恢复的镜头,不继续展示旧结果', async () => {
const { keyframes, videos, fetcher } = await gallery()
keyframes.items[0]!.primaryKeyframeStale = false
videos.items[0]!.issues = []
await wrapper!.get('[data-refresh-keyframe-impact]').trigger('click')
await flushPromises()
expect(wrapper!.find('[data-keyframe-impact]').exists()).toBe(false)
expect(fetcher.mock.calls.every(([, init]) => init?.method === 'GET')).toBe(true)
})
it('镜头导航与筛选共行,无关联说明时不留横条,查看全部素材清除定位和筛选', async () => {
const { references, router, fetcher } = await gallery()
references.references = []
@@ -522,20 +471,11 @@ describe('过期首帧到具体素材定位', () => {
expect(router.currentRoute.value.query.subjectFormId).toBe('form-other')
expect(wrapper!.findAll('button').some(item => item.text() === '重新生成过期形态')).toBe(false)
})
it('仅视频接口报告过期时也显示警告,并明确两种检查不一致', async () => {
const { keyframes } = await gallery('?sourceShotId=shot-target&subjectFormId=form-special')
keyframes.items[0]!.primaryKeyframeStale = false
await assetsChanged()
expect(wrapper!.get('[data-keyframe-impact]').text()).toContain('检查结果不一致')
expect(wrapper!.get('.form-image-card').text()).toContain('不要据此重复生图')
})
it('镜头修复后清除过期警告,保留明确的当前状态和返回入口', async () => {
const { keyframes, videos } = await gallery('?sourceShotId=shot-target&subjectFormId=form-special')
keyframes.items[0]!.primaryKeyframeStale = false
videos.items[0]!.issues = []
await assetsChanged()
expect(wrapper!.find('[data-keyframe-impact]').exists()).toBe(false)
expect(wrapper!.text()).toContain('未被标记为过期')
it('从镜头进入时保留关联素材,图库不重复显示制作警告', async () => {
const { fetcher } = await gallery('?sourceShotId=shot-target&subjectFormId=form-special')
expect(wrapper!.get('.asset-impact-context').text()).toContain('雨夜形态')
expect(wrapper!.text()).not.toContain('待处理首帧')
expect(fetcher.mock.calls.some(([url]) => String(url).includes('/videos/readiness'))).toBe(false)
})
it('无效镜头和已移除形态不发跨项目请求,也不误定位其他素材', async () => {
const { fetcher } = await gallery('?sourceShotId=foreign-shot&subjectFormId=deleted-form')
@@ -544,8 +484,8 @@ describe('过期首帧到具体素材定位', () => {
expect(wrapper!.findAll('.form-image-card')).toHaveLength(0)
expect(fetcher.mock.calls.some(([url]) => String(url).includes('foreign-shot/references'))).toBe(false)
})
it('影响查询失败不能当成没有过期首帧,仍然显示已有图库', async () => {
const { fetcher } = await gallery()
it('从镜头进入时查询失败仍保留已有图库', async () => {
const { fetcher } = await gallery('?sourceShotId=shot-target')
const original = fetcher.getMockImplementation()!
fetcher.mockImplementation((url, init) =>
String(url).includes('/readiness')
@@ -553,7 +493,7 @@ describe('过期首帧到具体素材定位', () => {
: original(url, init)
)
await assetsChanged()
expect(wrapper!.text()).toContain('暂时无法确认有无过期首帧')
expect(wrapper!.text()).toContain('无法读取镜头')
expect(wrapper!.findAll('.form-image-card')).toHaveLength(3)
})
it('素材返回生产页时按正式 Shot ID 选择,不误选同编号的另一个 Beat', async () => {