fix(short-drama-agent-front): 修复代码格式检查问题

This commit is contained in:
GJ committed 2026-10-21 17:04:02 +08:00
1 parent 81d6a85260
commit 48fce3975f
87 files changed
+5714 -1436

No files matched your search

@@ -10,21 +10,37 @@ import type { CandidateCommitPreview } from '@/features/breakdown/candidate.type
/** 真实确认弹窗挂载于 body,验证完成后清理。 */
let wrapper: VueWrapper | undefined
beforeEach(() => { vi.spyOn(projectsApi, 'checkpoints').mockResolvedValue([candidateCheckpoint()]) })
afterEach(() => { wrapper?.unmount(); wrapper = undefined; document.body.innerHTML = ''; vi.restoreAllMocks() })
beforeEach(() => {
vi.spyOn(projectsApi, 'checkpoints').mockResolvedValue([candidateCheckpoint()])
})
afterEach(() => {
wrapper?.unmount()
wrapper = undefined
document.body.innerHTML = ''
vi.restoreAllMocks()
})
/** 创建质量已通过但尚未经过安全预检查的面板。 */
function openPanel() {
wrapper = mount(BreakdownCandidatePanel, {
attachTo: document.body,
props: { projectId: 'candidate-project', checkpointId: 'candidate-current', state: candidateState(), quality: breakdownQuality(selectBreakdownSource([candidateCheckpoint()]), candidateReview()), disabled: false }
props: {
projectId: 'candidate-project',
checkpointId: 'candidate-current',
state: candidateState(),
quality: breakdownQuality(selectBreakdownSource([candidateCheckpoint()]), candidateReview()),
disabled: false
}
})
return wrapper
}
/** 点击只读预检查入口,不直接提交。 */
async function checkCandidate() {
await wrapper!.findAll('button').find(button => button.text() === '提交候选为正式结果')!.trigger('click')
await wrapper!
.findAll('button')
.find(button => button.text() === '提交候选为正式结果')!
.trigger('click')
await flushPromises()
}
@@ -32,19 +48,33 @@ async function checkCandidate() {
async function confirmCandidate() {
const dialog = new DOMWrapper(document.querySelector<HTMLElement>('.app-dialog'))
await dialog.get('[role="checkbox"]').trigger('click')
await dialog.findAll('button').find(button => button.text() === '确认提交候选为正式结果')!.trigger('click')
await dialog
.findAll('button')
.find(button => button.text() === '确认提交候选为正式结果')!
.trigger('click')
await flushPromises()
}
describe('候选预检查与最终提交门禁', () => {
it('审核通过不会直接提交;预检查及最终确认均通过后只提交一次并刷新', async () => {
const preview = vi.spyOn(breakdownApi, 'candidateCommitPreview').mockResolvedValue(commitPreview())
const commit = vi.spyOn(breakdownApi, 'commitCandidate').mockResolvedValue({ projectId: 'candidate-project', subjectCount: 2, subjectFormCount: 2, episodeCount: 1, beatCount: 1, shotCount: 2, shotSubjectCount: 2 })
const commit = vi.spyOn(breakdownApi, 'commitCandidate').mockResolvedValue({
projectId: 'candidate-project',
subjectCount: 2,
subjectFormCount: 2,
episodeCount: 1,
beatCount: 1,
shotCount: 2,
shotSubjectCount: 2
})
openPanel()
expect(preview).not.toHaveBeenCalled()
expect(commit).not.toHaveBeenCalled()
expect(wrapper!.findAll('button').some(button => button.text() === '重新检查')).toBe(true)
await wrapper!.findAll('button').find(button => button.text() === '重新检查')!.trigger('click')
await wrapper!
.findAll('button')
.find(button => button.text() === '重新检查')!
.trigger('click')
expect(wrapper!.emitted('refresh')).toHaveLength(1)
await checkCandidate()
expect(commit).not.toHaveBeenCalled()
@@ -55,7 +85,15 @@ describe('候选预检查与最终提交门禁', () => {
expect(wrapper!.emitted('refresh')).toHaveLength(2)
expect(wrapper!.text()).toContain('拆解结果已保存并采用')
expect(wrapper!.findAll('button').some(button => button.text() === '重新检查')).toBe(false)
await wrapper!.setProps({ state: candidateState({ storyboardPersisted: true, candidateCommitted: true }), quality: breakdownQuality(selectBreakdownSource([candidateCheckpoint(candidateState({ storyboardPersisted: true, candidateCommitted: true }))]), null) })
await wrapper!.setProps({
state: candidateState({ storyboardPersisted: true, candidateCommitted: true }),
quality: breakdownQuality(
selectBreakdownSource([
candidateCheckpoint(candidateState({ storyboardPersisted: true, candidateCommitted: true }))
]),
null
)
})
expect(wrapper!.findAll('button').some(button => button.text() === '提交候选为正式结果')).toBe(false)
expect(wrapper!.findAll('button').some(button => button.text() === '重新检查')).toBe(false)
})
@@ -92,7 +130,9 @@ describe('候选预检查与最终提交门禁', () => {
expect(wrapper!.emitted('refresh')).toHaveLength(1)
})
it('最终确认时安全条件改变,原先通过的预检查不能继续使用', async () => {
vi.spyOn(breakdownApi, 'candidateCommitPreview').mockResolvedValueOnce(commitPreview()).mockResolvedValueOnce(commitPreview({ ready: false }))
vi.spyOn(breakdownApi, 'candidateCommitPreview')
.mockResolvedValueOnce(commitPreview())
.mockResolvedValueOnce(commitPreview({ ready: false }))
const commit = vi.spyOn(breakdownApi, 'commitCandidate')
openPanel()
await checkCandidate()
@@ -102,10 +142,18 @@ describe('候选预检查与最终提交门禁', () => {
})
it('版本变化后晚到的预检查响应不会重新打开确认窗口', async () => {
let resolve!: (value: CandidateCommitPreview) => void
const preview = vi.spyOn(breakdownApi, 'candidateCommitPreview').mockImplementation(() => new Promise(done => { resolve = done }))
const preview = vi.spyOn(breakdownApi, 'candidateCommitPreview').mockImplementation(
() =>
new Promise(done => {
resolve = done
})
)
openPanel()
await checkCandidate()
await wrapper!.findAll('button').find(button => button.text() === '提交候选为正式结果')!.trigger('click')
await wrapper!
.findAll('button')
.find(button => button.text() === '提交候选为正式结果')!
.trigger('click')
expect(preview).toHaveBeenCalledTimes(1)
await wrapper!.setProps({ checkpointId: 'new' })
resolve(commitPreview())