fix(central-ui): ParameterValueForm — raise ValidChanged on schema set so required-field validity is never stale

Claude-Session: https://claude.ai/code/session_01NcMG6xXdsJbmD2wYAgkK29
This commit is contained in:
Joseph Doherty
2026-09-08 01:15:40 -04:00
parent a36c813b89
commit 912e519954
2 changed files with 66 additions and 0 deletions
@@ -297,4 +297,32 @@ public class ParameterValueFormTests : BunitContext
input.Input("5");
Assert.True(valid.Last());
}
[Fact]
public void ValidChanged_ReportsFalseOnFirstRender_WhenARequiredFieldIsEmpty()
{
var valid = new List<bool>();
var cut = Render<ParameterValueForm>(p => p
.Add(x => x.ParameterDefinitions, """{"type":"object","properties":{"n":{"type":"integer"}},"required":["n"]}""")
.Add(x => x.ValidChanged, v => valid.Add(v)));
// Reported without any input from the user...
Assert.False(valid.Last());
// ...and no red error text is painted for the untouched required field (the
// component has no "untouched" concept, so the validity check for
// ValidChanged deliberately does not populate _parseErrors on first render).
Assert.Empty(cut.FindAll(".text-danger"));
}
[Fact]
public void ValidChanged_ReportsTrueOnFirstRender_WhenNothingIsRequired()
{
var valid = new List<bool>();
var cut = Render<ParameterValueForm>(p => p
.Add(x => x.ParameterDefinitions, """{"type":"object","properties":{"n":{"type":"integer"}}}""")
.Add(x => x.ValidChanged, v => valid.Add(v)));
Assert.True(valid.Last());
}
}