23 lines
1.4 KiB
TypeScript
23 lines
1.4 KiB
TypeScript
import { describe, expect, it } from 'vitest'
|
|
import { videoOperationAllowed } from '@/features/production/video-permissions'
|
|
import { videoFixture } from '@/features/production/testing/fixtures'
|
|
|
|
describe('视频候选操作权限', () => {
|
|
it('每个候选独立使用后端权限,两个空版本不自行视为过期', () => {
|
|
const first = videoFixture({ canValidate: false, canRepair: true, canSetPrimary: false })
|
|
const second = videoFixture({ canValidate: true, canRepair: false, canSetPrimary: true })
|
|
expect(videoOperationAllowed(first, 'validate')).toBe(false)
|
|
expect(videoOperationAllowed(first, 'repair')).toBe(true)
|
|
expect(videoOperationAllowed(second, 'repair')).toBe(false)
|
|
expect(videoOperationAllowed(second, 'primary')).toBe(true)
|
|
})
|
|
it.each(['validate', 'repair', 'primary'] as const)('过期或已终止候选不能执行 %s,即使曾经通过', action => {
|
|
const permissions = { canValidate: true, canRepair: true, canSetPrimary: true }
|
|
expect(videoOperationAllowed(videoFixture({ ...permissions, motionPlanStale: true }), action)).toBe(false)
|
|
expect(
|
|
videoOperationAllowed(videoFixture({ ...permissions, qualityTerminalStatus: 'stale_motion_plan' }), action)
|
|
).toBe(false)
|
|
})
|
|
it('缺失权限不能当作允许操作', () => expect(videoOperationAllowed({}, 'validate')).toBe(false))
|
|
})
|