fix(review): propagate HubException from ApproveReviewAsync so blocked merges surface errors
TryInvokeAsync swallowed all exceptions including HubException, so a blocked merge (uncommitted changes in target, mid-merge state, inactive worktree) returned null silently — the task stayed WaitingForReview with no feedback shown. Switch to a direct _hub.InvokeAsync so both VM catch blocks (TasksIsland ErrorReported, DetailsIsland ShowErrorAsync) actually fire. Add regression tests for both call sites verifying that a throwing worker causes the error to be reported.
This commit is contained in:
@@ -137,4 +137,28 @@ public class DetailsIslandReviewActionsTests : IDisposable
|
||||
Assert.True(vm.ShowReviewDiffHint);
|
||||
Assert.False(vm.ApproveReviewCommand.CanExecute(null));
|
||||
}
|
||||
|
||||
private sealed class ThrowingWorkerClient : StubWorkerClient
|
||||
{
|
||||
public override bool IsConnected => true;
|
||||
public string ExceptionMessage { get; init; } = "blocked: target working tree has uncommitted changes";
|
||||
public override Task<MergeResultDto?> ApproveReviewAsync(string taskId, string targetBranch) =>
|
||||
throw new Exception(ExceptionMessage);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ApproveReview_WhenWorkerThrows_CallsShowErrorAsync()
|
||||
{
|
||||
var worker = new ThrowingWorkerClient();
|
||||
var vm = BuildVm(worker);
|
||||
vm.Bind(new TaskRowViewModel { Id = "task-err-1", Status = TaskStatus.WaitingForReview });
|
||||
vm.Monitor.ApplyState(TaskStatus.WaitingForReview);
|
||||
|
||||
string? reportedError = null;
|
||||
vm.ShowErrorAsync = msg => { reportedError = msg; return Task.CompletedTask; };
|
||||
|
||||
await vm.ApproveReviewCommand.ExecuteAsync(null);
|
||||
|
||||
Assert.Equal(worker.ExceptionMessage, reportedError);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user