Files
superwork/vscode/src/panel/handlers/todoReset.test.ts
T

63 lines
1.8 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { describe, expect, it } from 'vitest'
import { canResetToTodo, todoResetStateExtra, todoResetUiPatch } from './todoReset'
describe('canResetToTodo', () => {
it('允许从 in-progress 重置', () => {
expect(canResetToTodo('in-progress')).toBe(true)
})
it('允许从 review 重置', () => {
expect(canResetToTodo('review')).toBe(true)
})
it('已在 todo 不允许(handler 走 no-op', () => {
expect(canResetToTodo('todo')).toBe(false)
})
it('done 不允许(handler 拒绝并 rollback', () => {
expect(canResetToTodo('done')).toBe(false)
})
})
describe('todoResetStateExtra', () => {
it('清空实施痕迹并回到 todo,保留规划侧字段不在 extra 里', () => {
const extra = todoResetStateExtra()
expect(extra).toEqual({
column: 'todo',
branch: '',
implementStatus: '',
pr: '',
prMerged: false,
prMergedAt: '',
worktreePath: '',
implementSessionId: '',
reviewSessionId: '',
})
expect(extra).not.toHaveProperty('sessionId')
expect(extra).not.toHaveProperty('planFile')
expect(extra).not.toHaveProperty('specFile')
expect(extra).not.toHaveProperty('profilePath')
expect(extra).not.toHaveProperty('brainstormProfilePath')
expect(extra).not.toHaveProperty('testProfilePath')
expect(extra).not.toHaveProperty('color')
expect(extra).not.toHaveProperty('autoReview')
})
})
describe('todoResetUiPatch', () => {
it('用 null 清空 UI 字段,避免 postMessage 丢掉 undefined', () => {
expect(todoResetUiPatch()).toEqual({
column: 'todo',
branch: null,
implementStatus: null,
pr: null,
prMerged: false,
prMergedAt: null,
worktreePath: null,
implementSessionId: null,
reviewSessionId: null,
worktreeExists: false,
})
})
})