feat(review): unify review actions into the Git-tab cockpit
Grow the detail-pane Git tab into the review+merge cockpit: target, pre-flight mergeability, inspect actions, then the four review verbs (Approve & Merge / Send back / Park / Cancel) plus a demoted Reset (discard branch). The decision block is gated independently of the merge controls so sandbox (no-worktree) review tasks still get the buttons. - Add ParkReviewCommand (-> RejectReviewToIdleAsync) - Send back (reject-to-queue) disabled until feedback is entered - Remove the mislabeled [Continue]/[Reset] line from the Output tab - Accent dot on the Git tab while awaiting review
This commit is contained in:
@@ -0,0 +1,101 @@
|
||||
using ClaudeDo.Data;
|
||||
using ClaudeDo.Data.Models;
|
||||
using ClaudeDo.Ui.Services;
|
||||
using ClaudeDo.Ui.ViewModels.Islands;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using TaskStatus = ClaudeDo.Data.Models.TaskStatus;
|
||||
|
||||
namespace ClaudeDo.Ui.Tests.ViewModels;
|
||||
|
||||
public class DetailsIslandReviewActionsTests : IDisposable
|
||||
{
|
||||
private readonly string _dbPath;
|
||||
|
||||
public DetailsIslandReviewActionsTests()
|
||||
{
|
||||
_dbPath = Path.Combine(Path.GetTempPath(), $"claudedo_review_actions_test_{Guid.NewGuid():N}.db");
|
||||
using var ctx = NewContext();
|
||||
ctx.Database.EnsureCreated();
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
try { File.Delete(_dbPath); } catch { }
|
||||
try { File.Delete(_dbPath + "-wal"); } catch { }
|
||||
try { File.Delete(_dbPath + "-shm"); } catch { }
|
||||
}
|
||||
|
||||
private ClaudeDoDbContext NewContext()
|
||||
{
|
||||
var opts = new DbContextOptionsBuilder<ClaudeDoDbContext>()
|
||||
.UseSqlite($"Data Source={_dbPath}")
|
||||
.Options;
|
||||
return new ClaudeDoDbContext(opts);
|
||||
}
|
||||
|
||||
private sealed class TestDbFactory : IDbContextFactory<ClaudeDoDbContext>
|
||||
{
|
||||
private readonly Func<ClaudeDoDbContext> _create;
|
||||
public TestDbFactory(Func<ClaudeDoDbContext> create) => _create = create;
|
||||
public ClaudeDoDbContext CreateDbContext() => _create();
|
||||
}
|
||||
|
||||
private sealed class NullServiceProvider : IServiceProvider
|
||||
{
|
||||
public object? GetService(Type serviceType) => null;
|
||||
}
|
||||
|
||||
private sealed class StubNotesApi : ClaudeDo.Ui.Services.Interfaces.INotesApi
|
||||
{
|
||||
public Task<List<DailyNoteDto>> ListAsync(DateOnly day) =>
|
||||
Task.FromResult(new List<DailyNoteDto>());
|
||||
public Task<DailyNoteDto?> AddAsync(DateOnly day, string text) =>
|
||||
Task.FromResult<DailyNoteDto?>(null);
|
||||
public Task UpdateAsync(string id, string text) => Task.CompletedTask;
|
||||
public Task DeleteAsync(string id) => Task.CompletedTask;
|
||||
}
|
||||
|
||||
private sealed class RecordingWorkerClient : StubWorkerClient
|
||||
{
|
||||
public override bool IsConnected => true;
|
||||
public string? ParkedTaskId;
|
||||
public override Task RejectReviewToIdleAsync(string taskId)
|
||||
{
|
||||
ParkedTaskId = taskId;
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
|
||||
private DetailsIslandViewModel BuildVm(StubWorkerClient worker)
|
||||
{
|
||||
var factory = new TestDbFactory(NewContext);
|
||||
return new DetailsIslandViewModel(factory, worker, new NullServiceProvider(), new StubNotesApi());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ParkReview_CallsRejectReviewToIdle_ForTheBoundTask()
|
||||
{
|
||||
var worker = new RecordingWorkerClient();
|
||||
var vm = BuildVm(worker);
|
||||
vm.Bind(new TaskRowViewModel { Id = "task-park-1", Status = TaskStatus.WaitingForReview });
|
||||
|
||||
await vm.ParkReviewCommand.ExecuteAsync(null);
|
||||
|
||||
Assert.Equal("task-park-1", worker.ParkedTaskId);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SendBack_IsDisabledUntilFeedbackIsEntered()
|
||||
{
|
||||
var vm = BuildVm(new RecordingWorkerClient());
|
||||
vm.Bind(new TaskRowViewModel { Id = "task-fb-1", Status = TaskStatus.WaitingForReview });
|
||||
|
||||
Assert.False(vm.RejectReviewCommand.CanExecute(null));
|
||||
|
||||
vm.ReviewFeedback = "tighten the error handling";
|
||||
Assert.True(vm.RejectReviewCommand.CanExecute(null));
|
||||
|
||||
vm.ReviewFeedback = " ";
|
||||
Assert.False(vm.RejectReviewCommand.CanExecute(null));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user