feat: 同步质量校验修复并精简工作台操作

This commit is contained in:
GouJ committed 2026-09-03 19:38:57 +08:00
1 parent 771b66cafc
commit 13bb6dc83b
47 files changed
+2244 -260

No files matched your search

+20 -15
View File
@@ -1,4 +1,4 @@
import { computed, nextTick, ref } from 'vue'
import { computed, ref } from 'vue'
import { NImage, NRadioGroup, NScrollbar } from 'naive-ui'
import { createMemoryHistory, createRouter } from 'vue-router'
import { flushPromises, mount, type VueWrapper } from '@vue/test-utils'
@@ -28,7 +28,7 @@ import SubjectIdentityPage from '../subject-identity/SubjectIdentityPage.vue'
import { styleFixture, styleImageFixture } from '../visual-style/testing/fixtures'
import { identityFixture, identityImageFixture } from '../subject-identity/testing/fixtures'
import { getIdentitySession } from '../subject-identity/model'
import { expandSections, selectControl } from '../../testing/naive'
import { expandSections, selectControl, selectMenu } from '../../testing/naive'
import ProductionPage from '../production/ProductionPage.vue'
import { getProductionSession } from '../production/model'
@@ -85,7 +85,9 @@ function context(): ReturnType<typeof useProjectData> {
/** 找到挂载到 body 的 Naive 弹窗按钮。 */
function button(label: string): HTMLButtonElement {
const element = [...document.querySelectorAll('button')].find(item => item.textContent?.trim() === label)
const element = [...document.querySelectorAll('button')].find(
item => item.textContent?.trim() === label || item.getAttribute('aria-label') === label
)
if (!element) throw new Error('找不到按钮:' + label)
return element
}
@@ -429,6 +431,7 @@ describe('视觉风格与主体身份工作区', () => {
vi.stubGlobal('fetch', fetcher)
await mountAssets('style')
expect(wrapper!.text()).toContain('尚未创建')
await expandSections()
expect(wrapper!.text()).toContain('默认采用中国人物选角基线')
expect(wrapper!.text()).toContain('人物风格与选角背景')
await wrapper!.get('#style-constraints').setValue('{"不应静默丢弃":true}')
@@ -548,7 +551,7 @@ describe('视觉风格与主体身份工作区', () => {
await flushPromises()
const post = fetcher.mock.calls.find(([, init]) => init?.method === 'POST')!
expect(post[0]).toBe('/api/subjects/subject-db-1/identity/images')
expect(JSON.parse(post[1]!.body as string)).toEqual({ provider: 'seedream', viewType: 'front' })
expect(JSON.parse(post[1]!.body as string)).toEqual({ viewType: 'front' })
})
it('无项目风格时禁止生成身份和图片,但仍可人工保存身份', async () => {
@@ -831,7 +834,7 @@ describe('工作台页面交互', () => {
expect(fetcher.mock.calls.every(([, init]) => init?.method === 'GET')).toBe(true)
})
it('拆解导出按钮位于 Tabs suffix,且保持空快照禁用状态', () => {
it('拆解更多菜单位于 Tabs suffix,空快照时导出仍禁用', async () => {
wrapper = mount(BreakdownPage, {
attachTo: document.body,
global: { provide: { [projectContextKey as symbol]: context() }, stubs: { RouterLink: true } }
@@ -839,9 +842,13 @@ describe('工作台页面交互', () => {
const toolbar = wrapper.get('.result-toolbar')
expect(toolbar.find('[aria-label="拆解结果"]').exists()).toBe(true)
expect(toolbar.find(':scope > button').exists()).toBe(false)
const exportButton = toolbar.get<HTMLButtonElement>('.n-tabs-nav__suffix button')
expect(exportButton.text()).toBe('导出 JSON')
expect(exportButton.element.disabled).toBe(true)
expect(toolbar.get('.n-tabs-nav__suffix button').attributes('aria-label')).toBe('拆解更多操作')
await toolbar.get('.n-tabs-nav__suffix button').trigger('click')
await flushPromises()
const exportItem = [...document.querySelectorAll('.n-dropdown-option-body')].find(
item => item.textContent?.trim() === '导出 JSON'
)!
expect(exportItem.className).toContain('disabled')
})
it('形态图库自动显示后端已有图片,不需要再次生图;筛选只改变显示', async () => {
@@ -915,7 +922,7 @@ describe('工作台页面交互', () => {
await flushPromises()
const post = fetcher.mock.calls.find(([, init]) => init?.method === 'POST')!
expect(post[0]).toBe('/api/subject-forms/form-db-1/images')
expect(JSON.parse(post[1]!.body as string)).toEqual({ provider: 'seedream', setPrimary: false })
expect(JSON.parse(post[1]!.body as string)).toEqual({ setPrimary: false })
expect(wrapper!.text()).toContain('2 条记录')
expect(wrapper!.get('.form-image-card img').attributes('src')).not.toContain('/storage/new.png')
expect(fetcher.mock.calls.some(([url]) => String(url).includes('production/start'))).toBe(false)
@@ -947,7 +954,7 @@ describe('工作台页面交互', () => {
expect(wrapper!.get('[aria-label="生图批量回执"]').text()).toContain('部分形态生图失败')
expect(wrapper!.text()).toContain('服务暂不可用')
const post = fetcher.mock.calls.find(([, init]) => init?.method === 'POST')!
expect(JSON.parse(post[1]!.body as string)).toEqual({ provider: 'seedream', concurrency: 2, force: false })
expect(JSON.parse(post[1]!.body as string)).toEqual({ concurrency: 2, force: false })
await wrapper!.get('.n-collapse [role="checkbox"]').trigger('click')
await confirmGeneration('为全项目新增候选图')
const lastPost = fetcher.mock.calls.filter(([, init]) => init?.method === 'POST').at(-1)!
@@ -1428,7 +1435,7 @@ describe('工作台页面交互', () => {
global: { provide: { [projectContextKey as symbol]: context() }, stubs: { RouterLink: true } }
})
const suffix = wrapper.get('.script-section .n-tabs-nav__suffix')
expect(suffix.findAll('button').map(item => item.text())).toEqual(['执行记录', '导出剧本'])
expect(suffix.findAll('button').map(item => item.attributes('aria-label'))).toEqual(['剧本更多操作'])
expect(suffix.get('router-link-stub').attributes('to')).toBe(`/projects/${fixture.id}/breakdown`)
const reader = wrapper.get<HTMLElement>('.reader-scroll .n-scrollbar-container').element
reader.scrollTop = 120
@@ -1445,12 +1452,10 @@ describe('工作台页面交互', () => {
expect(wrapper.get('.episode-reader').isVisible()).toBe(true)
expect(wrapper.get('.reader-scroll .n-scrollbar-container').element).toBe(reader)
expect(reader.scrollTop).toBe(120)
button('执行记录').click()
await nextTick()
await selectMenu('剧本更多操作', '执行记录')
expect(wrapper.find('.history-panel').exists()).toBe(true)
expect(wrapper.get('.content-with-history').classes()).not.toContain('history-hidden')
button('收起执行记录').click()
await nextTick()
await selectMenu('剧本更多操作', '收起执行记录')
expect(wrapper.find('.history-panel').exists()).toBe(false)
})