feat(short-drama-agent-front): 接入空间母版恢复与修订
This commit is contained in:
1 parent
c808a58a3f
commit
7e149a10c0
18 files changed
+2732
-12
No files matched your search
@@ -0,0 +1,108 @@
|
||||
import { mount, flushPromises, type VueWrapper } from '@vue/test-utils'
|
||||
import { NCheckbox, NInput, NSelect, NTabs } from 'naive-ui'
|
||||
import { afterEach, describe, expect, it, vi } from 'vitest'
|
||||
import SceneMasterManager from '@/features/spatial-layouts/components/SceneMasterManager.vue'
|
||||
import { createMasterMock } from '../../fixtures/spatial-masters'
|
||||
|
||||
/** 固定栏与长内容在 Chrome 验收,组件层使用实际表单和正式接口 Mock。 */
|
||||
let wrapper: VueWrapper
|
||||
/**
|
||||
* 点击可见业务按钮,保留实际提交门禁。
|
||||
* @param label 完整按钮名称
|
||||
*/
|
||||
async function click(label: string) {
|
||||
const button = wrapper.findAll('button').find(item => item.text() === label)
|
||||
expect(button).toBeDefined()
|
||||
await button!.trigger('click')
|
||||
await flushPromises()
|
||||
}
|
||||
/**
|
||||
* 创建隔离管理页,不把初始读取变成审核或生成。
|
||||
* @returns 请求 Mock 状态
|
||||
*/
|
||||
async function setup() {
|
||||
const mock = createMasterMock()
|
||||
vi.stubGlobal('fetch', mock.fetcher)
|
||||
wrapper = mount(SceneMasterManager, {
|
||||
props: { open: true, projectId: 'p', layoutId: 'layout' },
|
||||
global: { stubs: { AppDrawer: { template: '<div><slot/><slot name="footer"/></div>' }, AssetImage: true } }
|
||||
})
|
||||
await flushPromises()
|
||||
return mock
|
||||
}
|
||||
afterEach(() => {
|
||||
wrapper?.unmount()
|
||||
sessionStorage.clear()
|
||||
vi.unstubAllGlobals()
|
||||
})
|
||||
describe('F04 空间母版管理增量流程', () => {
|
||||
it('打开不调用 Provider,确认历史不冒充当前母版,预检没有报价不伪造金额', async () => {
|
||||
const mock = await setup()
|
||||
expect(wrapper.text()).toContain('暂无当前版本已确认母版')
|
||||
expect(wrapper.text()).toContain('机器:AI 视觉审核未通过或未运行')
|
||||
expect(mock.calls.every(call => call.method === 'GET')).toBe(true)
|
||||
expect(wrapper.findAll('.n-form-item--error')).toHaveLength(0)
|
||||
wrapper.findComponent(NTabs).vm.$emit('update:value', 'generate')
|
||||
await flushPromises()
|
||||
await click('免费预检母版输入')
|
||||
expect(wrapper.text()).toContain('预检接口未提供报价')
|
||||
expect(wrapper.text()).not.toContain('¥0.60')
|
||||
expect(mock.calls.filter(call => call.url.endsWith('/generate'))).toHaveLength(0)
|
||||
})
|
||||
it('人工逐项确认使用真实身份和版本,独立保存 Human Passed,不自动 Vision', async () => {
|
||||
const mock = await setup()
|
||||
const select = wrapper
|
||||
.findAllComponents(NSelect)
|
||||
.find(item => item.attributes('aria-label') === '第 1 项人工结论')!
|
||||
select.vm.$emit('update:value', 'passed')
|
||||
for (const input of wrapper.findAllComponents(NInput)) {
|
||||
const placeholder = input.props('placeholder')
|
||||
input.vm.$emit('update:value', placeholder === '填写真实确认人' ? 'goujun' : '清晰可见固定连接位置')
|
||||
}
|
||||
await flushPromises()
|
||||
await click('正式人工确认母版')
|
||||
expect(mock.calls.filter(call => call.url.endsWith('/confirm'))).toHaveLength(1)
|
||||
expect(mock.calls.filter(call => call.url.endsWith('/validate'))).toHaveLength(0)
|
||||
expect(wrapper.text()).toContain('人工:人工审核通过')
|
||||
expect(wrapper.text()).toContain('机器:AI 视觉审核未通过或未运行')
|
||||
const body = mock.calls.find(call => call.url.endsWith('/confirm'))!.body
|
||||
expect(body.confirmedBy).toBe('goujun')
|
||||
expect(body.reviewResults).toEqual([{ index: 1, result: 'passed', evidence: '清晰可见固定连接位置' }])
|
||||
})
|
||||
it('AI 通过仍为 Draft,不自动填人工通过或确认;必须独立勾选费用', async () => {
|
||||
const mock = await setup()
|
||||
const button = wrapper.findAll('button').find(item => item.text() === 'AI 视觉审核')!
|
||||
expect(button.attributes('disabled')).toBeDefined()
|
||||
wrapper
|
||||
.findAllComponents(NCheckbox)
|
||||
.find(item => item.text().includes('单独确认'))!
|
||||
.vm.$emit('update:checked', true)
|
||||
await flushPromises()
|
||||
await click('AI 视觉审核')
|
||||
expect(wrapper.text()).toContain('机器:AI 视觉审核通过')
|
||||
expect(wrapper.text()).toContain('资产:草稿')
|
||||
expect(mock.calls.filter(call => call.url.endsWith('/confirm'))).toHaveLength(0)
|
||||
expect(
|
||||
wrapper
|
||||
.findAll('button')
|
||||
.find(item => item.text() === '正式人工确认母版')!
|
||||
.attributes('disabled')
|
||||
).toBeDefined()
|
||||
})
|
||||
it('按需读取来源影响,原件可读与过期独立展示,不改历史 Primary', async () => {
|
||||
const mock = await setup()
|
||||
expect(mock.calls.filter(call => call.url.endsWith('/recovery-impact'))).toHaveLength(0)
|
||||
wrapper.findComponent(NTabs).vm.$emit('update:value', 'impact')
|
||||
await flushPromises()
|
||||
expect(wrapper.text()).toContain('图片原件有效 ≠ 来源当前有效')
|
||||
expect(wrapper.text()).toContain('关联镜头8')
|
||||
const headings = wrapper.findAll('.n-collapse-item__header-main')
|
||||
await headings.find(item => item.text().includes('星港相遇'))!.trigger('click')
|
||||
await flushPromises()
|
||||
expect(wrapper.text()).toContain('原件与原审核一致')
|
||||
expect(wrapper.text()).toContain('布局版本已变化')
|
||||
expect(wrapper.text()).toContain('历史主首帧(Primary)')
|
||||
expect(wrapper.text()).toContain('需要重新核验')
|
||||
expect(mock.calls.every(call => call.method === 'GET')).toBe(true)
|
||||
})
|
||||
})
|
||||
Reference in new issue
Block a user