fix(worker): allow the done toggle from any non-Running status
MarkDoneAsync was Idle-only, so a finished task (typically a list-handler run with no worktree to merge) could not be ticked off. Guard on Running instead and cover the other statuses with tests.
This commit is contained in:
@@ -504,6 +504,24 @@ public sealed class TaskStateServiceTests : IDisposable
|
||||
Assert.Equal(TaskStatus.Running, await GetStatusAsync(id));
|
||||
}
|
||||
|
||||
// The done toggle is a manual affordance and must work from any non-Running status --
|
||||
// notably WaitingForReview, where it deliberately skips the merge.
|
||||
[Theory]
|
||||
[InlineData(TaskStatus.Queued)]
|
||||
[InlineData(TaskStatus.WaitingForReview)]
|
||||
[InlineData(TaskStatus.WaitingForChildren)]
|
||||
[InlineData(TaskStatus.Failed)]
|
||||
[InlineData(TaskStatus.Cancelled)]
|
||||
public async Task MarkDoneAsync_FromNonRunningStatus_TransitionsToDone(TaskStatus from)
|
||||
{
|
||||
var id = await SeedTaskAsync(from);
|
||||
|
||||
var result = await _sut.MarkDoneAsync(id, DateTime.UtcNow, default);
|
||||
|
||||
Assert.True(result.Ok);
|
||||
Assert.Equal(TaskStatus.Done, await GetStatusAsync(id));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task UnmarkDoneAsync_FromDone_TransitionsToIdle()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user