merge: maestro/tsk_PbcHccuPmwxV [任务取消/删除的 UI 入口]
# Conflicts: # web/style.css
This commit is contained in:
@@ -189,6 +189,56 @@ test('createTask:deps 引用不存在/跨项目任务被拒绝', () => {
|
||||
s.close();
|
||||
});
|
||||
|
||||
test('deleteTask:删除叶子任务,不影响同项目其他任务', () => {
|
||||
const s = freshStore();
|
||||
const p = s.createProject({ name: 'del1', repoPath: '/tmp/del1-' + Math.random() });
|
||||
const a = s.createTask({ projectId: p.id, title: 'A', complexity: 'easy' });
|
||||
const b = s.createTask({ projectId: p.id, title: 'B', complexity: 'easy' });
|
||||
const { deleted } = s.deleteTask(a.id);
|
||||
assert.equal(deleted, 1);
|
||||
assert.equal(s.getTask(a.id), null); // 已删
|
||||
assert.ok(s.getTask(b.id)); // 不受影响
|
||||
s.close();
|
||||
});
|
||||
|
||||
test('deleteTask:级联删除带子任务的父任务', () => {
|
||||
const s = freshStore();
|
||||
const p = s.createProject({ name: 'del2', repoPath: '/tmp/del2-' + Math.random() });
|
||||
const root = s.createTask({ projectId: p.id, title: 'root', complexity: 'hard' });
|
||||
s.setPlan(root.id, '拆'); s.transition(root.id, 'plan_review'); s.decide(root.id, 'accept', 'user');
|
||||
const c1 = s.createTask({ projectId: p.id, parentId: root.id, title: 'c1', complexity: 'easy' });
|
||||
const c2 = s.createTask({ projectId: p.id, parentId: root.id, title: 'c2', complexity: 'easy' });
|
||||
// c1 下再建孙子
|
||||
const gc = s.createTask({ projectId: p.id, parentId: c1.id, title: 'gc', complexity: 'easy' });
|
||||
const { deleted } = s.deleteTask(root.id);
|
||||
assert.equal(deleted, 4); // root + c1 + c2 + gc
|
||||
assert.equal(s.getTask(root.id), null);
|
||||
assert.equal(s.getTask(c1.id), null);
|
||||
assert.equal(s.getTask(c2.id), null);
|
||||
assert.equal(s.getTask(gc.id), null);
|
||||
s.close();
|
||||
});
|
||||
|
||||
test('deleteTask:不存在的任务抛 StoreError', () => {
|
||||
const s = freshStore();
|
||||
assert.throws(() => s.deleteTask('tsk_nonexistent'), (e: Error) => e.message.includes('任务不存在'));
|
||||
s.close();
|
||||
});
|
||||
|
||||
test('transition → cancelled:合法的状态流转(init/ready/executing 等)', () => {
|
||||
const s = freshStore();
|
||||
const p = s.createProject({ name: 'can', repoPath: '/tmp/can-' + Math.random() });
|
||||
|
||||
const t1 = s.createTask({ projectId: p.id, title: 'init task', complexity: 'easy' });
|
||||
assert.equal(t1.status, 'ready');
|
||||
const cancelled = s.transition(t1.id, 'cancelled', { by: 'user' });
|
||||
assert.equal(cancelled.status, 'cancelled');
|
||||
|
||||
// 已取消的任务不可再次流转
|
||||
assert.throws(() => s.transition(t1.id, 'ready'), (e: Error) => e.message.includes('非法状态流转'));
|
||||
s.close();
|
||||
});
|
||||
|
||||
test('容器收口:已拆解 Hard 的子任务全 done → 容器自动 done(逐级向上)', () => {
|
||||
const s = freshStore();
|
||||
const p = s.createProject({ name: 'cc', repoPath: '/tmp/cc-' + Math.random() });
|
||||
|
||||
Reference in New Issue
Block a user