Slice 4/5 of task-numbers: TaskRowViewModel.Number renders as a dimmed "#123" before the row title; DetailsIslandViewModel.TaskIdBadge now shows "#123" instead of the unusable "#T<guid-prefix>" handle; and the curated WorkerLog business events in TaskRunner, TaskMergeService, and TaskResetService prefix their quoted title with "#<Number>".
82 lines
2.7 KiB
C#
82 lines
2.7 KiB
C#
using ClaudeDo.Data;
|
|
using ClaudeDo.Ui.Services;
|
|
using ClaudeDo.Ui.ViewModels.Islands;
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
namespace ClaudeDo.Ui.Tests.ViewModels;
|
|
|
|
// Slice 4 of the task-numbers feature: the detail-pane header badge shows "#<Number>" instead of
|
|
// the old "#T<guid-prefix>" handle, which nobody could correlate back to a task.
|
|
public class DetailsIslandTaskIdBadgeTests : IDisposable
|
|
{
|
|
private readonly string _dbPath;
|
|
|
|
public DetailsIslandTaskIdBadgeTests()
|
|
{
|
|
_dbPath = Path.Combine(Path.GetTempPath(), $"claudedo_badge_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 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 NullServiceProvider : IServiceProvider
|
|
{
|
|
public object? GetService(Type serviceType) => null;
|
|
}
|
|
|
|
private sealed class DefaultStub : StubWorkerClient { }
|
|
|
|
private DetailsIslandViewModel NewVm()
|
|
{
|
|
var factory = new TestDbFactory(NewContext);
|
|
return new DetailsIslandViewModel(factory, new DefaultStub(), new NullServiceProvider(), new StubNotesApi(), new ClaudeDo.Ui.Services.MergeCoordinator());
|
|
}
|
|
|
|
[Fact]
|
|
public void TaskIdBadge_NoTaskBound_IsEmpty()
|
|
{
|
|
var vm = NewVm();
|
|
|
|
Assert.Equal("", vm.TaskIdBadge);
|
|
}
|
|
|
|
[Fact]
|
|
public void TaskIdBadge_BoundTask_IsHashNumber()
|
|
{
|
|
var vm = NewVm();
|
|
|
|
vm.Bind(new TaskRowViewModel { Id = Guid.NewGuid().ToString("N"), Number = 123 });
|
|
|
|
Assert.Equal("#123", vm.TaskIdBadge);
|
|
}
|
|
}
|