feat(short-drama-agent-front): 完善视觉资产审核流程
This commit is contained in:
1 parent
dc8bb17a23
commit
b88ad8770f
45 files changed
+2258
-352
No files matched your search
@@ -1,3 +1,4 @@
|
||||
import { validationPreviewResponse } from '../../fixtures/image-preview'
|
||||
import { mount, flushPromises, type VueWrapper } from '@vue/test-utils'
|
||||
import { afterEach, describe, expect, it, vi } from 'vitest'
|
||||
import ImageGalleryDialog from '@/features/subject-images/components/ImageGalleryDialog.vue'
|
||||
@@ -34,25 +35,26 @@ describe('候选质量与主图门禁', () => {
|
||||
qualityPassed: false,
|
||||
qualityIssues: [{ type: 'form_mismatch', severity: 'error', description: '原始数量不一致' }]
|
||||
})
|
||||
const fetcher = vi.fn<typeof fetch>().mockImplementation(
|
||||
async (_url, init) =>
|
||||
new Response(
|
||||
JSON.stringify({
|
||||
data:
|
||||
init?.method === 'POST'
|
||||
? {
|
||||
subjectId: 'subject-db-1',
|
||||
subjectFormId: 'form-db-1',
|
||||
imageId: 'candidate',
|
||||
passed: false,
|
||||
sourceRequirementsPassed: false,
|
||||
sourceVisualRequirements: [],
|
||||
summary: '需核对数量',
|
||||
issues: []
|
||||
}
|
||||
: [candidate, original]
|
||||
})
|
||||
)
|
||||
const fetcher = vi.fn<typeof fetch>().mockImplementation(async (url, init) =>
|
||||
String(url).endsWith('/validate/preview')
|
||||
? validationPreviewResponse(String(url))
|
||||
: new Response(
|
||||
JSON.stringify({
|
||||
data:
|
||||
init?.method === 'POST'
|
||||
? {
|
||||
subjectId: 'subject-db-1',
|
||||
subjectFormId: 'form-db-1',
|
||||
imageId: 'candidate',
|
||||
passed: false,
|
||||
sourceRequirementsPassed: false,
|
||||
sourceVisualRequirements: [],
|
||||
summary: '需核对数量',
|
||||
issues: []
|
||||
}
|
||||
: [candidate, original]
|
||||
})
|
||||
)
|
||||
)
|
||||
vi.stubGlobal('fetch', fetcher)
|
||||
wrapper = mount(ImageGalleryDialog, {
|
||||
@@ -67,7 +69,7 @@ describe('候选质量与主图门禁', () => {
|
||||
expect(fetcher.mock.calls.every(([, init]) => init?.method === 'GET')).toBe(true)
|
||||
button('审核此图片').click()
|
||||
await flushPromises()
|
||||
expect(fetcher).toHaveBeenCalledOnce()
|
||||
expect(fetcher.mock.calls.every(([, init]) => init?.method === 'GET')).toBe(true)
|
||||
button('确认费用并审核').click()
|
||||
await flushPromises()
|
||||
expect(fetcher.mock.calls.filter(([, init]) => init?.method === 'POST')).toHaveLength(1)
|
||||
@@ -75,16 +77,38 @@ describe('候选质量与主图门禁', () => {
|
||||
expect(original.isPrimary).toBe(true)
|
||||
expect(document.body.textContent).toContain('需核对数量')
|
||||
})
|
||||
it('来源过期禁止发起审核与主图确认,保留该候选', async () => {
|
||||
const image = imageFixture({ isPrimary: false, qualityPassed: true })
|
||||
const fetcher = vi
|
||||
.fn<typeof fetch>()
|
||||
.mockImplementation(async url =>
|
||||
String(url).endsWith('/validate/preview')
|
||||
? validationPreviewResponse(String(url), false)
|
||||
: new Response(JSON.stringify({ data: [image] }))
|
||||
)
|
||||
vi.stubGlobal('fetch', fetcher)
|
||||
wrapper = mount(ImageGalleryDialog, {
|
||||
attachTo: document.body,
|
||||
props: { projectId: 'quality-flow', form: formFixture(), disabled: false, open: true }
|
||||
})
|
||||
await flushPromises()
|
||||
expect(document.body.textContent).toContain('本次机位采用的几何已过期')
|
||||
expect(button('审核此图片').disabled).toBe(true)
|
||||
expect(button('设为主参考图').disabled).toBe(true)
|
||||
expect(fetcher.mock.calls.every(([, init]) => init?.method === 'GET')).toBe(true)
|
||||
})
|
||||
it('主图晋升 409 保留原主图,不乐观切换或自动重试', async () => {
|
||||
const original = imageFixture({ id: 'old' })
|
||||
const fetcher = vi.fn<typeof fetch>().mockImplementation(async (_url, init) =>
|
||||
init?.method === 'PUT'
|
||||
? new Response(JSON.stringify({ message: '审核证据已过期,请明确重新审核' }), { status: 409 })
|
||||
: new Response(
|
||||
JSON.stringify({
|
||||
data: [imageFixture({ id: 'candidate', isPrimary: false, qualityPassed: true }), original]
|
||||
})
|
||||
)
|
||||
const fetcher = vi.fn<typeof fetch>().mockImplementation(async (url, init) =>
|
||||
String(url).endsWith('/validate/preview')
|
||||
? validationPreviewResponse(String(url))
|
||||
: init?.method === 'PUT'
|
||||
? new Response(JSON.stringify({ message: '审核证据已过期,请明确重新审核' }), { status: 409 })
|
||||
: new Response(
|
||||
JSON.stringify({
|
||||
data: [imageFixture({ id: 'candidate', isPrimary: false, qualityPassed: true }), original]
|
||||
})
|
||||
)
|
||||
)
|
||||
vi.stubGlobal('fetch', fetcher)
|
||||
wrapper = mount(ImageGalleryDialog, {
|
||||
@@ -105,26 +129,27 @@ describe('候选质量与主图门禁', () => {
|
||||
})
|
||||
it('质量处理默认预算为零,只有明确确认后发出一次请求', async () => {
|
||||
const image = imageFixture({ isPrimary: false })
|
||||
const fetcher = vi.fn<typeof fetch>().mockImplementation(
|
||||
async (_url, init) =>
|
||||
new Response(
|
||||
JSON.stringify({
|
||||
data:
|
||||
init?.method === 'POST'
|
||||
? {
|
||||
subjectFormId: 'form-db-1',
|
||||
initialImageId: image.id,
|
||||
finalImageId: image.id,
|
||||
passed: false,
|
||||
repaired: false,
|
||||
repairAttempts: 0,
|
||||
maxRepairAttempts: 0,
|
||||
primaryChanged: false,
|
||||
attempts: []
|
||||
}
|
||||
: [image]
|
||||
})
|
||||
)
|
||||
const fetcher = vi.fn<typeof fetch>().mockImplementation(async (url, init) =>
|
||||
String(url).endsWith('/validate/preview')
|
||||
? validationPreviewResponse(String(url))
|
||||
: new Response(
|
||||
JSON.stringify({
|
||||
data:
|
||||
init?.method === 'POST'
|
||||
? {
|
||||
subjectFormId: 'form-db-1',
|
||||
initialImageId: image.id,
|
||||
finalImageId: image.id,
|
||||
passed: false,
|
||||
repaired: false,
|
||||
repairAttempts: 0,
|
||||
maxRepairAttempts: 0,
|
||||
primaryChanged: false,
|
||||
attempts: []
|
||||
}
|
||||
: [image]
|
||||
})
|
||||
)
|
||||
)
|
||||
vi.stubGlobal('fetch', fetcher)
|
||||
wrapper = mount(ImageGalleryDialog, {
|
||||
|
||||
Reference in new issue
Block a user