fix(short-drama-agent-front): 修复代码格式检查问题
This commit is contained in:
1 parent
81d6a85260
commit
48fce3975f
87 files changed
+5714
-1436
No files matched your search
@@ -16,16 +16,35 @@ import { getOperation } from '@/features/workflows/operations'
|
||||
function conflict() {
|
||||
const state = resourceConflictState()
|
||||
const shot = state.storyboardEpisodeShots![0]!.beatShots[0]!.shots[0]!
|
||||
const review = candidateReview({ actionQualityBlocks: [{ episodeNo: 1, beatNo: 1, shotNo: 1, status: 'blocked', blockingCodes: ['action_resource_conflict'], warningCodes: [], isPendingEpisode: true }], pendingQualityEpisodeNos: [1] })
|
||||
const review = candidateReview({
|
||||
actionQualityBlocks: [
|
||||
{
|
||||
episodeNo: 1,
|
||||
beatNo: 1,
|
||||
shotNo: 1,
|
||||
status: 'blocked',
|
||||
blockingCodes: ['action_resource_conflict'],
|
||||
warningCodes: [],
|
||||
isPendingEpisode: true
|
||||
}
|
||||
],
|
||||
pendingQualityEpisodeNos: [1]
|
||||
})
|
||||
const quality = breakdownQuality(selectBreakdownSource([candidateCheckpoint(state)]), review)
|
||||
return { state, quality, shot }
|
||||
}
|
||||
|
||||
/** 已有例外与独立全局规则,写入时必须全部保留。 */
|
||||
const policy: ProjectQualityPolicy = {
|
||||
version: 1, physicsMode: 'stylized', allowExaggeratedMotion: true, allowNonPhysicalActions: false,
|
||||
allowSupernaturalAbilities: false, customRules: ['跳跃后正常落地'],
|
||||
actionExceptions: [{ code: 'action_resource_conflict', ownerRef: '@CH0099', resource: 'right_hand', reason: '旧例外依据' }]
|
||||
version: 1,
|
||||
physicsMode: 'stylized',
|
||||
allowExaggeratedMotion: true,
|
||||
allowNonPhysicalActions: false,
|
||||
allowSupernaturalAbilities: false,
|
||||
customRules: ['跳跃后正常落地'],
|
||||
actionExceptions: [
|
||||
{ code: 'action_resource_conflict', ownerRef: '@CH0099', resource: 'right_hand', reason: '旧例外依据' }
|
||||
]
|
||||
}
|
||||
/** 当前真实修订面板实例。 */
|
||||
let wrapper: VueWrapper<InstanceType<typeof ActionExceptionRepair>> | undefined
|
||||
@@ -40,10 +59,18 @@ afterEach(() => {
|
||||
describe('从实际问题建立动作例外', () => {
|
||||
it('只从当前审核的互斥动作证据带入角色、部位与动作,不从文字猜测', () => {
|
||||
const { state, quality, shot } = conflict()
|
||||
expect(actionExceptionTargets(state, quality)).toMatchObject([{
|
||||
episodeNo: 1, beatNo: 1, shotNo: 1, phaseNo: 1, ownerRef: '@CH0001', ownerName: '人物', resource: 'left_hand',
|
||||
actions: ['左手握住铜铃', '左手向村民挥动']
|
||||
}])
|
||||
expect(actionExceptionTargets(state, quality)).toMatchObject([
|
||||
{
|
||||
episodeNo: 1,
|
||||
beatNo: 1,
|
||||
shotNo: 1,
|
||||
phaseNo: 1,
|
||||
ownerRef: '@CH0001',
|
||||
ownerName: '人物',
|
||||
resource: 'left_hand',
|
||||
actions: ['左手握住铜铃', '左手向村民挥动']
|
||||
}
|
||||
])
|
||||
shot.durationPlanning!.phases[0]!.resourceOccupancy = []
|
||||
expect(actionExceptionTargets(state, quality)).toEqual([])
|
||||
})
|
||||
@@ -57,9 +84,14 @@ describe('从实际问题建立动作例外', () => {
|
||||
phase.actionIds = ['hold']
|
||||
expect(actionExceptionTargets(state, quality)).toEqual([])
|
||||
phase.actionIds = ['hold', 'wave']
|
||||
phase.resourceOccupancy!.forEach(item => { item.shareable = true; item.usage = 'hold' })
|
||||
phase.resourceOccupancy!.forEach(item => {
|
||||
item.shareable = true
|
||||
item.usage = 'hold'
|
||||
})
|
||||
expect(actionExceptionTargets(state, quality)).toEqual([])
|
||||
phase.resourceOccupancy!.forEach(item => { item.shareable = false })
|
||||
phase.resourceOccupancy!.forEach(item => {
|
||||
item.shareable = false
|
||||
})
|
||||
expect(actionExceptionTargets(state, { ...quality, source: 'history' })).toEqual([])
|
||||
const resource = phase.resourceOccupancy!.pop()!
|
||||
shot.durationPlanning!.phases.push({ ...phase, resourceOccupancy: [resource] })
|
||||
@@ -69,26 +101,59 @@ describe('从实际问题建立动作例外', () => {
|
||||
it('用户仅填写原因,保存前重读并合并已有例外,不改全局规则或自动放行质量', async () => {
|
||||
const { state, quality } = conflict()
|
||||
const latest = { ...policy, customRules: ['其他入口刚保存的新规则'] }
|
||||
vi.spyOn(projectsApi, 'qualityPolicy').mockResolvedValueOnce(policyReceipt('candidate-project', policy)).mockResolvedValue(policyReceipt('candidate-project', latest))
|
||||
const save = vi.spyOn(projectsApi, 'saveQualityPolicy').mockImplementation(async (id, input) => (policyReceipt(id, input)))
|
||||
wrapper = mount(ActionExceptionRepair, { props: { projectId: 'candidate-project', checkpointId: 'candidate-current', state, quality, disabled: false } })
|
||||
vi.spyOn(projectsApi, 'qualityPolicy')
|
||||
.mockResolvedValueOnce(policyReceipt('candidate-project', policy))
|
||||
.mockResolvedValue(policyReceipt('candidate-project', latest))
|
||||
const save = vi
|
||||
.spyOn(projectsApi, 'saveQualityPolicy')
|
||||
.mockImplementation(async (id, input) => policyReceipt(id, input))
|
||||
wrapper = mount(ActionExceptionRepair, {
|
||||
props: {
|
||||
projectId: 'candidate-project',
|
||||
checkpointId: 'candidate-current',
|
||||
state,
|
||||
quality,
|
||||
disabled: false
|
||||
}
|
||||
})
|
||||
await flushPromises()
|
||||
expect(wrapper.text()).toContain('左手握住铜铃')
|
||||
expect(wrapper.text()).toContain('左手向村民挥动')
|
||||
await wrapper.findAll('button').find(button => button.text() === '添加例外')!.trigger('click')
|
||||
await wrapper
|
||||
.findAll('button')
|
||||
.find(button => button.text() === '添加例外')!
|
||||
.trigger('click')
|
||||
expect(wrapper.find('input').exists()).toBe(false)
|
||||
expect(wrapper.find('textarea').element.value).toBe('')
|
||||
expect(wrapper.text()).not.toContain('请填写允许原因')
|
||||
await wrapper.findAll('button').find(button => button.text() === '保存动作例外')!.trigger('click')
|
||||
await wrapper
|
||||
.findAll('button')
|
||||
.find(button => button.text() === '保存动作例外')!
|
||||
.trigger('click')
|
||||
expect(wrapper.text()).toContain('请填写允许原因')
|
||||
expect(save).not.toHaveBeenCalled()
|
||||
await wrapper.get('textarea').setValue('剧本明确允许左手同时挥动持物')
|
||||
await wrapper.findAll('button').find(button => button.text() === '保存动作例外')!.trigger('click')
|
||||
await wrapper
|
||||
.findAll('button')
|
||||
.find(button => button.text() === '保存动作例外')!
|
||||
.trigger('click')
|
||||
await flushPromises()
|
||||
expect(save).toHaveBeenCalledExactlyOnceWith('candidate-project', { ...latest, actionExceptions: [
|
||||
policy.actionExceptions![0],
|
||||
{ code: 'action_resource_conflict', ownerRef: '@CH0001', resource: 'left_hand', reason: '剧本明确允许左手同时挥动持物' }
|
||||
] }, 2)
|
||||
expect(save).toHaveBeenCalledExactlyOnceWith(
|
||||
'candidate-project',
|
||||
{
|
||||
...latest,
|
||||
actionExceptions: [
|
||||
policy.actionExceptions![0],
|
||||
{
|
||||
code: 'action_resource_conflict',
|
||||
ownerRef: '@CH0001',
|
||||
resource: 'left_hand',
|
||||
reason: '剧本明确允许左手同时挥动持物'
|
||||
}
|
||||
]
|
||||
},
|
||||
2
|
||||
)
|
||||
expect(wrapper.emitted('refresh')).toHaveLength(1)
|
||||
expect(quality.actionStatus).toBe('blocked')
|
||||
expect(wrapper.find('textarea').exists()).toBe(false)
|
||||
@@ -97,14 +162,35 @@ describe('从实际问题建立动作例外', () => {
|
||||
it('保存前出现活动任务或切换检查点时,不提交旧问题的例外', async () => {
|
||||
const { state, quality } = conflict()
|
||||
let finish!: (value: ReturnType<typeof policyReceipt>) => void
|
||||
const read = vi.spyOn(projectsApi, 'qualityPolicy').mockResolvedValue(policyReceipt('candidate-project', policy))
|
||||
const read = vi
|
||||
.spyOn(projectsApi, 'qualityPolicy')
|
||||
.mockResolvedValue(policyReceipt('candidate-project', policy))
|
||||
const save = vi.spyOn(projectsApi, 'saveQualityPolicy')
|
||||
wrapper = mount(ActionExceptionRepair, { props: { projectId: 'candidate-project', checkpointId: 'candidate-current', state, quality, disabled: false } })
|
||||
wrapper = mount(ActionExceptionRepair, {
|
||||
props: {
|
||||
projectId: 'candidate-project',
|
||||
checkpointId: 'candidate-current',
|
||||
state,
|
||||
quality,
|
||||
disabled: false
|
||||
}
|
||||
})
|
||||
await flushPromises()
|
||||
await wrapper.findAll('button').find(button => button.text() === '添加例外')!.trigger('click')
|
||||
await wrapper
|
||||
.findAll('button')
|
||||
.find(button => button.text() === '添加例外')!
|
||||
.trigger('click')
|
||||
await wrapper.get('textarea').setValue('允许原因')
|
||||
read.mockImplementationOnce(() => new Promise(resolve => { finish = resolve }))
|
||||
await wrapper.findAll('button').find(button => button.text() === '保存动作例外')!.trigger('click')
|
||||
read.mockImplementationOnce(
|
||||
() =>
|
||||
new Promise(resolve => {
|
||||
finish = resolve
|
||||
})
|
||||
)
|
||||
await wrapper
|
||||
.findAll('button')
|
||||
.find(button => button.text() === '保存动作例外')!
|
||||
.trigger('click')
|
||||
await wrapper.setProps({ disabled: true })
|
||||
finish(policyReceipt('candidate-project', policy))
|
||||
await flushPromises()
|
||||
@@ -117,13 +203,37 @@ describe('从实际问题建立动作例外', () => {
|
||||
|
||||
it('已有同一角色部位的例外不重复添加,其他例外保持可见', async () => {
|
||||
const { state, quality } = conflict()
|
||||
const existing = { ...policy, actionExceptions: [...policy.actionExceptions!, { code: 'action_resource_conflict' as const, ownerRef: '@CH0001', resource: 'left_hand' as const, reason: '已确认的同类例外' }] }
|
||||
const existing = {
|
||||
...policy,
|
||||
actionExceptions: [
|
||||
...policy.actionExceptions!,
|
||||
{
|
||||
code: 'action_resource_conflict' as const,
|
||||
ownerRef: '@CH0001',
|
||||
resource: 'left_hand' as const,
|
||||
reason: '已确认的同类例外'
|
||||
}
|
||||
]
|
||||
}
|
||||
vi.spyOn(projectsApi, 'qualityPolicy').mockResolvedValue(policyReceipt('candidate-project', existing))
|
||||
const save = vi.spyOn(projectsApi, 'saveQualityPolicy')
|
||||
wrapper = mount(ActionExceptionRepair, { props: { projectId: 'candidate-project', checkpointId: 'candidate-current', state, quality, disabled: false } })
|
||||
wrapper = mount(ActionExceptionRepair, {
|
||||
props: {
|
||||
projectId: 'candidate-project',
|
||||
checkpointId: 'candidate-current',
|
||||
state,
|
||||
quality,
|
||||
disabled: false
|
||||
}
|
||||
})
|
||||
await flushPromises()
|
||||
expect(wrapper.text()).toContain('已有动作例外 · 2 项')
|
||||
expect(wrapper.findAll('button').find(button => button.text() === '已有例外')!.attributes('disabled')).toBeDefined()
|
||||
expect(
|
||||
wrapper
|
||||
.findAll('button')
|
||||
.find(button => button.text() === '已有例外')!
|
||||
.attributes('disabled')
|
||||
).toBeDefined()
|
||||
expect(wrapper.find('textarea').exists()).toBe(false)
|
||||
expect(save).not.toHaveBeenCalled()
|
||||
})
|
||||
@@ -132,11 +242,25 @@ describe('从实际问题建立动作例外', () => {
|
||||
const { state, quality } = conflict()
|
||||
vi.spyOn(projectsApi, 'qualityPolicy').mockResolvedValue(policyReceipt('candidate-project', policy))
|
||||
vi.spyOn(projectsApi, 'saveQualityPolicy').mockRejectedValue(new Error('后端拒绝修改'))
|
||||
wrapper = mount(ActionExceptionRepair, { props: { projectId: 'candidate-project', checkpointId: 'candidate-current', state, quality, disabled: false } })
|
||||
wrapper = mount(ActionExceptionRepair, {
|
||||
props: {
|
||||
projectId: 'candidate-project',
|
||||
checkpointId: 'candidate-current',
|
||||
state,
|
||||
quality,
|
||||
disabled: false
|
||||
}
|
||||
})
|
||||
await flushPromises()
|
||||
await wrapper.findAll('button').find(button => button.text() === '添加例外')!.trigger('click')
|
||||
await wrapper
|
||||
.findAll('button')
|
||||
.find(button => button.text() === '添加例外')!
|
||||
.trigger('click')
|
||||
await wrapper.get('textarea').setValue('仍需保存的依据')
|
||||
await wrapper.findAll('button').find(button => button.text() === '保存动作例外')!.trigger('click')
|
||||
await wrapper
|
||||
.findAll('button')
|
||||
.find(button => button.text() === '保存动作例外')!
|
||||
.trigger('click')
|
||||
await flushPromises()
|
||||
expect(wrapper.get('textarea').element.value).toBe('仍需保存的依据')
|
||||
expect(wrapper.text()).toContain('系统拒绝修改')
|
||||
@@ -149,10 +273,23 @@ describe('从实际问题建立动作例外', () => {
|
||||
const { state, quality } = conflict()
|
||||
vi.spyOn(projectsApi, 'qualityPolicy').mockResolvedValue(policyReceipt('other', policy))
|
||||
const save = vi.spyOn(projectsApi, 'saveQualityPolicy')
|
||||
wrapper = mount(ActionExceptionRepair, { props: { projectId: 'candidate-project', checkpointId: 'candidate-current', state, quality, disabled: false } })
|
||||
wrapper = mount(ActionExceptionRepair, {
|
||||
props: {
|
||||
projectId: 'candidate-project',
|
||||
checkpointId: 'candidate-current',
|
||||
state,
|
||||
quality,
|
||||
disabled: false
|
||||
}
|
||||
})
|
||||
await flushPromises()
|
||||
expect(wrapper.text()).toContain('规则所属项目不一致')
|
||||
expect(wrapper.findAll('button').find(button => button.text() === '添加例外')!.attributes('disabled')).toBeDefined()
|
||||
expect(
|
||||
wrapper
|
||||
.findAll('button')
|
||||
.find(button => button.text() === '添加例外')!
|
||||
.attributes('disabled')
|
||||
).toBeDefined()
|
||||
expect(wrapper.find('textarea').exists()).toBe(false)
|
||||
expect(save).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
Reference in new issue
Block a user