Enhance InputSelect tests by adding edge case scenarios#67015
Enhance InputSelect tests by adding edge case scenarios#67015karmegams02 wants to merge 5 commits into
Conversation
|
@dotnet-policy-service agree company="Syncfusion, Inc." |
lewing
left a comment
There was a problem hiding this comment.
Thanks for the contribution, @karmegams02 — there are genuinely valuable additions here, especially around bool? parsing, nullable-empty handling, and EditContext.IsModified tracking, which were previously uncovered. Requesting changes on a couple of scope items and one consolidation suggestion before merge.
🚩 Please address (out of scope for an "add tests" PR)
-
Revert the
TestEnum.Tree→TestEnum.Threerename (InputSelectTest.cs:260).
This rename isn't mentioned in the PR description and isn't required by any of the new tests exceptChangingValueMultipleTimesAlwaysReflectsLatestValue, which can use the existingTreevalue instead. Renames to pre-existing test infrastructure should land as a separate, clearly-scoped PR. -
Revert the
Single→SingleOrDefaultchange inRendersIdAttribute(InputSelectTest.cs:229).
That test was passing onmainwith the stricterSingleinvariant ("exactly oneidattribute frame"). Relaxing the assertion isn't necessary for any of the new tests, and weakens an existing precondition. If a new test breaks underSingle, that's worth investigating rather than working around.
✂️ Please dedupe (functionally identical to existing tests)
ParsesNotNullableEnumWithExactNameMatchandParsesNullableEnumWithExactNameMatchare duplicates of the existingParsesCurrentValueWhenUsingNotNullableEnumWithNotEmptyValue/ParsesCurrentValueWhenUsingNullableEnumWithNotEmptyValue— same input ("Two"/"One"), same assertion. The only difference is the async wrapperSetCurrentValueAsStringAsync, which just dispatches the same write throughInvokeAsync— no new behavior is covered. Please delete both.
💡 Optional but recommended
The three attribute-pass-through tests (ClassAttributeIsPassedThroughViaAdditionalAttributes, DataAttributesArePassedThroughViaAdditionalAttributes, AriaAttributesArePassedThroughViaAdditionalAttributes) all exercise the same single line in production (builder.AddMultipleAttributes(1, AdditionalAttributes) in InputSelect.cs). Consider collapsing into one [Theory] over the three attribute families — cuts ~100 lines without losing coverage. Same applies to the multi-select pair (MultiSelectWithStringArrayRendersMultipleAttribute + SingleSelectDoesNotRenderMultipleAttribute).
Thanks again — the nullable-bool and validation-lifecycle tests are real coverage gains and worth landing.
Summary
This PR significantly enhances the test coverage for
Microsoft.AspNetCore.Components.Forms.InputSelectcomponent by:Changes
src/Components/Web/test/Forms/InputSelectTest.cs+503 / -7<select>rendering, onchange binding)Testing