feat(prime): add the action kind to the settings viewmodels
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
using ClaudeDo.Data.Models;
|
||||
using ClaudeDo.Ui.Services;
|
||||
using ClaudeDo.Ui.ViewModels.Modals.Settings;
|
||||
|
||||
@@ -27,8 +28,9 @@ public class PrimeClaudeTabViewModelTests
|
||||
public Task DeleteAsync(Guid id) => Task.CompletedTask;
|
||||
}
|
||||
|
||||
private static PrimeScheduleDto Dto(Guid id, int days, TimeSpan time) =>
|
||||
new(id, days, time, true, null, null);
|
||||
private static PrimeScheduleDto Dto(Guid id, int days, TimeSpan time,
|
||||
PrimeActionKind kind = PrimeActionKind.FillMyDay, string? prompt = null) =>
|
||||
new(id, days, time, true, null, prompt, kind);
|
||||
|
||||
[Fact]
|
||||
public async Task Load_Populates_Rows()
|
||||
@@ -116,4 +118,92 @@ public class PrimeClaudeTabViewModelTests
|
||||
var ex = await Assert.ThrowsAsync<Exception>(() => vm.SaveAsync());
|
||||
Assert.Equal(api.ExceptionMessage, ex.Message);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void AddSchedule_Defaults_To_Ping()
|
||||
{
|
||||
var vm = new PrimeClaudeTabViewModel(new FakeApi());
|
||||
vm.AddScheduleCommand.Execute(null);
|
||||
|
||||
Assert.Equal(PrimeActionKind.Ping, vm.Rows[0].Kind);
|
||||
Assert.True(vm.Rows[0].IsPing);
|
||||
Assert.False(vm.Rows[0].IsFillMyDay);
|
||||
Assert.False(vm.Rows[0].IsCustom);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Setting_IsCustom_Flips_Kind_And_Clears_The_Others()
|
||||
{
|
||||
var vm = new PrimeClaudeTabViewModel(new FakeApi());
|
||||
vm.AddScheduleCommand.Execute(null);
|
||||
var row = vm.Rows[0];
|
||||
|
||||
row.IsCustom = true;
|
||||
|
||||
Assert.Equal(PrimeActionKind.Custom, row.Kind);
|
||||
Assert.False(row.IsPing);
|
||||
Assert.False(row.IsFillMyDay);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Row_RadioGroup_Is_Unique_Per_Row()
|
||||
{
|
||||
var vm = new PrimeClaudeTabViewModel(new FakeApi());
|
||||
vm.AddScheduleCommand.Execute(null);
|
||||
vm.AddScheduleCommand.Execute(null);
|
||||
|
||||
Assert.NotEqual(vm.Rows[0].RadioGroup, vm.Rows[1].RadioGroup);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Validate_Rejects_Custom_Without_A_Prompt()
|
||||
{
|
||||
var vm = new PrimeClaudeTabViewModel(new FakeApi());
|
||||
vm.AddScheduleCommand.Execute(null);
|
||||
vm.Rows[0].IsCustom = true;
|
||||
vm.Rows[0].PromptOverride = " ";
|
||||
|
||||
Assert.NotNull(vm.Validate());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Validate_Accepts_Custom_With_A_Prompt()
|
||||
{
|
||||
var vm = new PrimeClaudeTabViewModel(new FakeApi());
|
||||
vm.AddScheduleCommand.Execute(null);
|
||||
vm.Rows[0].IsCustom = true;
|
||||
vm.Rows[0].PromptOverride = "queue the oldest task";
|
||||
|
||||
Assert.Null(vm.Validate());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void AnyFillMyDay_Tracks_Kind_And_Row_Changes()
|
||||
{
|
||||
var vm = new PrimeClaudeTabViewModel(new FakeApi());
|
||||
Assert.False(vm.AnyFillMyDay);
|
||||
|
||||
vm.AddScheduleCommand.Execute(null);
|
||||
Assert.False(vm.AnyFillMyDay);
|
||||
|
||||
vm.Rows[0].IsFillMyDay = true;
|
||||
Assert.True(vm.AnyFillMyDay);
|
||||
|
||||
vm.RemoveScheduleCommand.Execute(vm.Rows[0]);
|
||||
Assert.False(vm.AnyFillMyDay);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Save_Round_Trips_The_Kind()
|
||||
{
|
||||
var api = new FakeApi();
|
||||
var vm = new PrimeClaudeTabViewModel(api);
|
||||
vm.AddScheduleCommand.Execute(null);
|
||||
vm.Rows[0].IsCustom = true;
|
||||
vm.Rows[0].PromptOverride = "do the thing";
|
||||
|
||||
await vm.SaveAsync();
|
||||
|
||||
Assert.Equal(PrimeActionKind.Custom, api.Upserts[0].Kind);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user