* TaskRepository.UpdateAsync defensively detaches any locally tracked entity with the same Id before attaching the patched copy, preventing EF identity conflicts when callers load via AsNoTracking and write back through the same DbContext (surfaced by ExternalMcpService UpdateTask integration tests). * TasksIslandViewModel auto-collapse now only fires for Finalized planning parents that are not yet Done. Active-phase parents stay expanded while the user is editing the plan, and Done parents stay expanded so all completed children land in CompletedItems alongside the parent. * Update three Ui.Tests fakes (ConflictResolution, PlanningDiff, DetailsIslandPlanning) to implement the two new IWorkerClient members (OpenInteractiveTerminalAsync, QueuePlanningSubtasksAsync). * Rewrite StreamLineFormatterTests to exercise the current assistant/user/result/system message format instead of the legacy stream_event parsing that was removed in the formatter rewrite. * Align AppSettingsRepository seed-default assertion with the permission-mode default that flipped from bypassPermissions to auto. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
75 lines
2.5 KiB
C#
75 lines
2.5 KiB
C#
using ClaudeDo.Data.Models;
|
|
using ClaudeDo.Data.Repositories;
|
|
using ClaudeDo.Worker.Tests.Infrastructure;
|
|
|
|
namespace ClaudeDo.Worker.Tests.Repositories;
|
|
|
|
public class AppSettingsRepositoryTests : IDisposable
|
|
{
|
|
private readonly DbFixture _db = new();
|
|
|
|
public void Dispose() => _db.Dispose();
|
|
|
|
[Fact]
|
|
public async Task GetAsync_Returns_Seeded_Defaults()
|
|
{
|
|
using var ctx = _db.CreateContext();
|
|
var repo = new AppSettingsRepository(ctx);
|
|
|
|
var row = await repo.GetAsync();
|
|
|
|
Assert.Equal(AppSettingsEntity.SingletonId, row.Id);
|
|
Assert.Equal("sonnet", row.DefaultModel);
|
|
Assert.Equal(100, row.DefaultMaxTurns);
|
|
Assert.Equal("auto", row.DefaultPermissionMode);
|
|
Assert.Equal("sibling", row.WorktreeStrategy);
|
|
Assert.Null(row.CentralWorktreeRoot);
|
|
Assert.False(row.WorktreeAutoCleanupEnabled);
|
|
}
|
|
|
|
[Fact]
|
|
public async Task UpdateAsync_Persists_And_RoundTrips()
|
|
{
|
|
using (var ctx = _db.CreateContext())
|
|
{
|
|
var repo = new AppSettingsRepository(ctx);
|
|
await repo.UpdateAsync(new AppSettingsEntity
|
|
{
|
|
DefaultClaudeInstructions = "be terse",
|
|
DefaultModel = "opus",
|
|
DefaultMaxTurns = 42,
|
|
DefaultPermissionMode = "acceptEdits",
|
|
WorktreeStrategy = "central",
|
|
CentralWorktreeRoot = "C:/worktrees",
|
|
WorktreeAutoCleanupEnabled = true,
|
|
WorktreeAutoCleanupDays = 14,
|
|
});
|
|
}
|
|
|
|
using var readCtx = _db.CreateContext();
|
|
var readRepo = new AppSettingsRepository(readCtx);
|
|
var row = await readRepo.GetAsync();
|
|
|
|
Assert.Equal("be terse", row.DefaultClaudeInstructions);
|
|
Assert.Equal("opus", row.DefaultModel);
|
|
Assert.Equal(42, row.DefaultMaxTurns);
|
|
Assert.Equal("acceptEdits", row.DefaultPermissionMode);
|
|
Assert.Equal("central", row.WorktreeStrategy);
|
|
Assert.Equal("C:/worktrees", row.CentralWorktreeRoot);
|
|
Assert.True(row.WorktreeAutoCleanupEnabled);
|
|
Assert.Equal(14, row.WorktreeAutoCleanupDays);
|
|
}
|
|
|
|
[Fact]
|
|
public async Task UpdateAsync_Blank_CentralRoot_Stored_As_Null()
|
|
{
|
|
using var ctx = _db.CreateContext();
|
|
var repo = new AppSettingsRepository(ctx);
|
|
|
|
await repo.UpdateAsync(new AppSettingsEntity { CentralWorktreeRoot = " " });
|
|
var row = await repo.GetAsync();
|
|
|
|
Assert.Null(row.CentralWorktreeRoot);
|
|
}
|
|
}
|