fix(mcp): stop set_list_config from clearing settings it doesn't expose

This commit is contained in:
mika kuns
2026-08-11 08:32:52 +02:00
parent d451edd367
commit f31b1b4fb2
2 changed files with 83 additions and 4 deletions
@@ -223,6 +223,72 @@ public sealed class ConfigMcpToolsTests : IDisposable
_sut.SetTaskConfig(task.Id, clearFields: new[] { "bogus" }, cancellationToken: CancellationToken.None));
}
[Fact]
public async Task SetListConfig_PreservesSettingsItDoesNotExpose()
{
var listId = await SeedListAsync();
await _lists.SetConfigAsync(new ListConfigEntity
{
ListId = listId,
Model = "sonnet",
SessionSkills = "[\"superpowers\"]",
VerifyCommand = "dotnet build",
SerializeOnFileOverlap = true,
});
await _sut.SetListConfig(listId, model: "opus", cancellationToken: CancellationToken.None);
var cfg = await _lists.GetConfigAsync(listId);
Assert.NotNull(cfg);
Assert.Equal("opus", cfg!.Model);
Assert.Equal("[\"superpowers\"]", cfg.SessionSkills);
Assert.Equal("dotnet build", cfg.VerifyCommand);
// SetConfigAsync copies the entity verbatim, so a field this tool doesn't expose would
// reset to its default unless it is carried over explicitly.
Assert.True(cfg.SerializeOnFileOverlap);
}
[Fact]
public async Task SetListConfig_ClearingEveryExposedField_KeepsRowWhenOtherSettingsRemain()
{
var listId = await SeedListAsync();
await _lists.SetConfigAsync(new ListConfigEntity
{
ListId = listId,
Model = "sonnet",
VerifyCommand = "dotnet build",
SerializeOnFileOverlap = true,
});
var result = await _sut.SetListConfig(
listId,
clearFields: new[] { "model", "systemPrompt", "agentPath", "maxTurns" },
cancellationToken: CancellationToken.None);
Assert.True(result.Ok);
Assert.Null(result.Config);
var cfg = await _lists.GetConfigAsync(listId);
Assert.NotNull(cfg);
Assert.Null(cfg!.Model);
Assert.Equal("dotnet build", cfg.VerifyCommand);
Assert.True(cfg.SerializeOnFileOverlap);
}
[Fact]
public async Task SetListConfig_ClearingEveryField_DeletesRowWhenNothingElseIsSet()
{
var listId = await SeedListAsync();
await _sut.SetListConfig(listId, "sonnet", cancellationToken: CancellationToken.None);
await _sut.SetListConfig(
listId,
clearFields: new[] { "model", "systemPrompt", "agentPath", "maxTurns" },
cancellationToken: CancellationToken.None);
Assert.Null(await _lists.GetConfigAsync(listId));
}
[Fact]
public async Task GetTaskConfig_NoOverrideSet_ReturnsNotFound()
{