feat(short-drama-agent-front): 完善镜头定位与项目配置
This commit is contained in:
1 parent
470b52e26d
commit
5b134207b8
66 files changed
+2042
-984
No files matched your search
@@ -9,10 +9,53 @@ import { referenceLocation, referenceTargets } from '@/features/production/asset
|
||||
import StaleKeyframeNotice from '@/features/production/components/StaleKeyframeNotice.vue'
|
||||
import SubjectImagesPage from '@/features/subject-images/SubjectImagesPage.vue'
|
||||
import ProductionPage from '@/features/production/ProductionPage.vue'
|
||||
import ImageGalleryDialog from '@/features/subject-images/components/ImageGalleryDialog.vue'
|
||||
import type { CreativeProfile, GenerationModelCatalog } from '@/features/generation-config/types'
|
||||
import { directionsResult, storyboardCheckpoint } from '@/features/storyboard/testing/fixtures'
|
||||
import type { ProductionIssue } from '@/features/production/types'
|
||||
import type { ShotReferences } from '@/features/storyboard/types'
|
||||
|
||||
/** 使用后端模型目录结构,避免空数组被误当成可用模型。 */
|
||||
const imageCatalog: GenerationModelCatalog = {
|
||||
defaults: { imageProvider: 'qwen-image', videoProvider: 'seedance' },
|
||||
images: [
|
||||
{
|
||||
type: 'image',
|
||||
provider: 'qwen-image',
|
||||
providerLabel: 'Qwen',
|
||||
model: 'qwen-image-3.0-pro',
|
||||
modelLabel: 'Qwen Image',
|
||||
supported: true,
|
||||
enabled: true,
|
||||
isDefault: true,
|
||||
capabilities: {},
|
||||
generationOptions: [
|
||||
{
|
||||
key: 'size',
|
||||
label: '图片尺寸',
|
||||
type: 'size',
|
||||
required: true,
|
||||
options: [{ label: '1:1 · 2048×2048', value: '2048*2048' }]
|
||||
}
|
||||
],
|
||||
defaults: { size: '2048*2048' },
|
||||
projectConstraints: []
|
||||
}
|
||||
],
|
||||
videos: []
|
||||
}
|
||||
/** 模拟当前项目持久化的创作配置。 */
|
||||
const creativeProfile: CreativeProfile = {
|
||||
projectId: 'capability-test',
|
||||
aspectRatio: '1:1',
|
||||
imageProvider: 'qwen-image',
|
||||
imageModel: 'qwen-image-3.0-pro',
|
||||
imageOptions: { size: '2048*2048' },
|
||||
videoProvider: 'seedance',
|
||||
videoModel: 'seedance',
|
||||
videoOptions: {}
|
||||
}
|
||||
|
||||
let wrapper: VueWrapper | undefined
|
||||
afterEach(() => {
|
||||
wrapper?.unmount()
|
||||
@@ -98,29 +141,40 @@ function fixture() {
|
||||
}
|
||||
const fetcher = vi.fn<typeof fetch>().mockImplementation(async url => {
|
||||
const path = String(url)
|
||||
const data = path.endsWith('/subject-forms')
|
||||
? [first, second, other]
|
||||
: path.includes('/keyframes/readiness')
|
||||
? keyframes
|
||||
: path.includes('/videos/readiness')
|
||||
? videos
|
||||
: path.endsWith('/references')
|
||||
? references
|
||||
: []
|
||||
const data = path.endsWith('/generation-models')
|
||||
? imageCatalog
|
||||
: path.endsWith('/creative-profile')
|
||||
? creativeProfile
|
||||
: path.endsWith('/subject-forms')
|
||||
? [first, second, other]
|
||||
: path.includes('/keyframes/readiness')
|
||||
? keyframes
|
||||
: path.includes('/videos/readiness')
|
||||
? videos
|
||||
: path.endsWith('/references')
|
||||
? references
|
||||
: []
|
||||
return new Response(JSON.stringify({ data }))
|
||||
})
|
||||
vi.stubGlobal('fetch', fetcher)
|
||||
return { first, second, other, references, issues, keyframes, videos, fetcher }
|
||||
}
|
||||
|
||||
/** 在真实内存路由中验证跨页 URL,不替换 RouterLink 行为。 */
|
||||
async function gallery(query = '') {
|
||||
/**
|
||||
* 在真实内存路由中验证跨页 URL,并在首次请求前设置服务端状态。
|
||||
* @param query 初始素材定位参数
|
||||
* @param prepare 挂载前准备当前项目的接口响应
|
||||
* @returns 当前接口数据与真实内存路由
|
||||
*/
|
||||
async function gallery(query = '', prepare?: (data: ReturnType<typeof fixture>) => void) {
|
||||
const data = fixture()
|
||||
prepare?.(data)
|
||||
const router = createRouter({
|
||||
history: createMemoryHistory(),
|
||||
routes: [
|
||||
{ path: '/projects/:projectId/subject-images', component: SubjectImagesPage },
|
||||
{ path: '/projects/:projectId/production', component: { template: '<div />' } }
|
||||
{ path: '/projects/:projectId/production', component: { template: '<div />' } },
|
||||
{ path: '/projects/:projectId/storyboard', component: { template: '<div />' } }
|
||||
]
|
||||
})
|
||||
await router.push('/projects/capability-test/subject-images' + query)
|
||||
@@ -132,14 +186,24 @@ async function gallery(query = '') {
|
||||
return { ...data, router }
|
||||
}
|
||||
|
||||
/**
|
||||
* 模拟图片记录中的主图变更完成通知,验证父页重读图库及影响状态。
|
||||
* @returns 全部资产查询完成
|
||||
*/
|
||||
async function assetsChanged() {
|
||||
wrapper!.findComponent(ImageGalleryDialog).vm.$emit('changed')
|
||||
await flushPromises()
|
||||
}
|
||||
|
||||
describe('过期首帧到具体素材定位', () => {
|
||||
it('没有图片的形态卡片标记为方形占位', async () => {
|
||||
const { first } = await gallery()
|
||||
first.images = []
|
||||
await wrapper!.get('[aria-label="刷新图库"]').trigger('click')
|
||||
await flushPromises()
|
||||
const { first } = await gallery('', data => {
|
||||
data.first.images = []
|
||||
})
|
||||
const card = wrapper!.findAll('.form-image-card').find(item => item.attributes('data-form-id') === first.id)!
|
||||
expect(card.get('.asset-image').classes()).toContain('form-image-empty')
|
||||
expect(card.get('.asset-image').classes()).not.toContain('form-image-has-source')
|
||||
expect(card.get('.asset-image-empty').text()).toContain('尚未生成主参考图')
|
||||
expect(card.find('img').exists()).toBe(false)
|
||||
})
|
||||
|
||||
it('网格与瀑布流切换保留卡片、滚动容器和筛选,不发起额外请求', async () => {
|
||||
@@ -159,7 +223,7 @@ describe('过期首帧到具体素材定位', () => {
|
||||
.get('.gallery-layout-switch')
|
||||
.findAll('button')
|
||||
.map(button => button.attributes('aria-label'))
|
||||
).toEqual(['网格布局', '瀑布流布局', '刷新图库', '批量生图'])
|
||||
).toEqual(['网格布局', '瀑布流布局', '批量生图'])
|
||||
await wrapper!.get('[aria-label="网格布局"]').trigger('click')
|
||||
expect(wrapper!.find('.form-image-masonry').exists()).toBe(false)
|
||||
expect(wrapper!.get('[aria-label="网格布局"]').attributes('aria-pressed')).toBe('true')
|
||||
@@ -182,7 +246,7 @@ describe('过期首帧到具体素材定位', () => {
|
||||
expect(fetcher).toHaveBeenCalledTimes(requestCount)
|
||||
})
|
||||
|
||||
it('图库与关联检查不定时刷新,手动刷新仍能更新数据', async () => {
|
||||
it('图库与关联检查不定时刷新,图片记录变更后更新数据', async () => {
|
||||
vi.useFakeTimers()
|
||||
const { fetcher } = await gallery('?sourceShotId=shot-target')
|
||||
const count = fetcher.mock.calls.length
|
||||
@@ -191,13 +255,12 @@ describe('过期首帧到具体素材定位', () => {
|
||||
await flushPromises()
|
||||
expect(fetcher).toHaveBeenCalledTimes(count)
|
||||
expect(wrapper!.get('.form-image-grid').element).toBe(grid)
|
||||
const refresh = wrapper!.get('[aria-label="刷新图库"]')
|
||||
await refresh.trigger('click')
|
||||
await flushPromises()
|
||||
await assetsChanged()
|
||||
expect(fetcher.mock.calls.length).toBeGreaterThan(count)
|
||||
const refreshed = fetcher.mock.calls.length
|
||||
await vi.advanceTimersByTimeAsync(30_000)
|
||||
expect(fetcher).toHaveBeenCalledTimes(refreshed)
|
||||
expect(fetcher.mock.calls.every(([, init]) => init?.method === 'GET')).toBe(true)
|
||||
})
|
||||
|
||||
it('切换镜头时筛选、关联说明和图片共用稳定纵向容器,长关联列表单独横向滚动', async () => {
|
||||
@@ -224,8 +287,7 @@ describe('过期首帧到具体素材定位', () => {
|
||||
})
|
||||
: original(url, init)
|
||||
)
|
||||
await wrapper!.get('[aria-label="刷新图库"]').trigger('click')
|
||||
await flushPromises()
|
||||
await assetsChanged()
|
||||
wrapper!
|
||||
.findAllComponents(NSelect)
|
||||
.find(item => item.attributes('aria-label') === '选择关联镜头')!
|
||||
@@ -428,8 +490,7 @@ describe('过期首帧到具体素材定位', () => {
|
||||
it('精简图库没有历史母版字段时,不误报形态过期或破坏定位', async () => {
|
||||
const { first, router } = await gallery('?subjectFormId=form-other')
|
||||
first.subject.identity = { id: 'identity-1', isLocked: true, anchorImageId: 'anchor-new' }
|
||||
await wrapper!.get('[aria-label="刷新图库"]').trigger('click')
|
||||
await flushPromises()
|
||||
await assetsChanged()
|
||||
expect(wrapper!.text()).not.toContain('形态主图需要更新')
|
||||
expect(router.currentRoute.value.query.subjectFormId).toBe('form-other')
|
||||
expect(wrapper!.findAll('button').some(item => item.text() === '重新生成过期形态')).toBe(false)
|
||||
@@ -437,8 +498,7 @@ describe('过期首帧到具体素材定位', () => {
|
||||
it('仅视频接口报告过期时也显示警告,并明确两种检查不一致', async () => {
|
||||
const { keyframes } = await gallery('?sourceShotId=shot-target&subjectFormId=form-special')
|
||||
keyframes.items[0]!.primaryKeyframeStale = false
|
||||
await wrapper!.get('[aria-label="刷新图库"]').trigger('click')
|
||||
await flushPromises()
|
||||
await assetsChanged()
|
||||
expect(wrapper!.get('[data-keyframe-impact]').text()).toContain('检查结果不一致')
|
||||
expect(wrapper!.get('.form-image-card').text()).toContain('不要据此重复生图')
|
||||
})
|
||||
@@ -446,8 +506,7 @@ describe('过期首帧到具体素材定位', () => {
|
||||
const { keyframes, videos } = await gallery('?sourceShotId=shot-target&subjectFormId=form-special')
|
||||
keyframes.items[0]!.primaryKeyframeStale = false
|
||||
videos.items[0]!.issues = []
|
||||
await wrapper!.get('[aria-label="刷新图库"]').trigger('click')
|
||||
await flushPromises()
|
||||
await assetsChanged()
|
||||
expect(wrapper!.find('[data-keyframe-impact]').exists()).toBe(false)
|
||||
expect(wrapper!.text()).toContain('未被标记为过期')
|
||||
})
|
||||
@@ -466,8 +525,7 @@ describe('过期首帧到具体素材定位', () => {
|
||||
? Promise.resolve(new Response('{}', { status: 500 }))
|
||||
: original(url, init)
|
||||
)
|
||||
await wrapper!.get('[aria-label="刷新图库"]').trigger('click')
|
||||
await flushPromises()
|
||||
await assetsChanged()
|
||||
expect(wrapper!.text()).toContain('暂时无法确认有无过期首帧')
|
||||
expect(wrapper!.findAll('.form-image-card')).toHaveLength(3)
|
||||
})
|
||||
@@ -480,11 +538,15 @@ describe('过期首帧到具体素材定位', () => {
|
||||
const path = String(url)
|
||||
return new Response(
|
||||
JSON.stringify({
|
||||
data: path.includes('/storyboard-directions')
|
||||
? data
|
||||
: path.includes('/readiness') || path.endsWith('/videos/status')
|
||||
? { total: 0, items: [] }
|
||||
: []
|
||||
data: path.endsWith('/generation-models')
|
||||
? imageCatalog
|
||||
: path.endsWith('/creative-profile')
|
||||
? creativeProfile
|
||||
: path.includes('/storyboard-directions')
|
||||
? data
|
||||
: path.includes('/readiness') || path.endsWith('/videos/status')
|
||||
? { total: 0, items: [] }
|
||||
: []
|
||||
})
|
||||
)
|
||||
})
|
||||
|
||||
Reference in new issue
Block a user