✨ feat(vscode): 审查列可以申请同事移交工单

This commit is contained in:
cruldra committed 2026-09-28 00:17:09 +08:00
1 parent 65583a001c
commit 6342f39de0
22 files changed
+450 -31

No files matched your search

@@ -0,0 +1,46 @@
import { describe, expect, it } from 'vitest'
import { canAnswerHandoffRequest, canAskHandoff, canCancelHandoffRequest, handoffRequestNotices } from './handoffRequest'
const review = {
source: 'gitea' as const,
column: 'review' as const,
assignees: ['chw'],
}
describe('移交申请', () => {
it('审查列里同事的工单可以申请', () => {
expect(canAskHandoff(review, 'cruldra')).toBe(true)
})
it('自己的、没人负责的、不在审查列的、YouTrack 的、已在移交中的,不能申请', () => {
expect(canAskHandoff(review, 'chw')).toBe(false)
expect(canAskHandoff({ ...review, assignees: [] }, 'cruldra')).toBe(false)
expect(canAskHandoff({ ...review, column: 'in-progress' }, 'cruldra')).toBe(false)
expect(canAskHandoff({ ...review, source: 'youtrack' }, 'cruldra')).toBe(false)
expect(canAskHandoff({ ...review, handoffAttachmentId: '9' }, 'cruldra')).toBe(false)
expect(canAskHandoff(review, undefined)).toBe(false)
})
it('已经有一条申请时,别人不能再申请,申请人可以取消', () => {
const pending = { ...review, handoffRequestFrom: 'cruldra' }
expect(canAskHandoff(pending, 'other')).toBe(false)
expect(canCancelHandoffRequest(pending, 'cruldra')).toBe(true)
expect(canCancelHandoffRequest(pending, 'other')).toBe(false)
})
it('负责人看到申请,申请人看到拒绝和失败原因', () => {
const pending = { ...review, number: 435, handoffRequestFrom: 'cruldra' }
expect(handoffRequestNotices({ ...review, number: 435 }, pending, 'chw')).toEqual(['cruldra 想要 #435'])
expect(handoffRequestNotices(pending, { ...pending, handoffRequestFrom: undefined, handoffRequestError: 'rejected' }, 'cruldra'))
.toEqual(['#435 的移交申请被拒绝了'])
expect(handoffRequestNotices(pending, { ...pending, handoffRequestError: '会话太大' }, 'cruldra'))
.toEqual(['#435 没交出来:会话太大'])
})
it('只有负责人能同意或拒绝', () => {
const pending = { ...review, handoffRequestFrom: 'cruldra' }
expect(canAnswerHandoffRequest(pending, 'chw')).toBe(true)
expect(canAnswerHandoffRequest(pending, 'cruldra')).toBe(false)
expect(canAnswerHandoffRequest({ ...pending, column: 'todo' }, 'chw')).toBe(false)
})
})