Skip to content

Add checkbox model binding integration tests#446

Merged
gunndabad merged 3 commits intomodelbindingtestsfrom
copilot/sub-pr-439
Feb 7, 2026
Merged

Add checkbox model binding integration tests#446
gunndabad merged 3 commits intomodelbindingtestsfrom
copilot/sub-pr-439

Conversation

Copy link
Contributor

Copilot AI commented Feb 1, 2026

Adds integration tests for checkbox tag helper model binding, similar to existing tests for text input, select, and other form elements.

Changes

  • Test coverage: Added Checkboxes_RendersCorrectly test validating name/ID generation, checked state from model, and metadata binding (legend, hint, error message)
  • Test infrastructure: Added CheckboxesTestsModel with List<string> property, controller action, and Checkboxes.cshtml view

Bug fixes discovered during implementation

  • CheckboxesItemTagHelper: Fixed checked state determination when ModelState contains errors. Previously used ModelState.RawValue (null for errors) instead of falling back to model values:
// Before: Always used ModelState.RawValue when entry exists (null for errors)
var value = ViewContext.ModelState.TryGetValue(modelExpression.Name, out var entry) ?
    entry.RawValue : model;

// After: Only use ModelState.RawValue if it's a valid enumerable collection
var value = ViewContext.ModelState.TryGetValue(modelExpression.Name, out var entry) &&
    entry.RawValue is IEnumerable and not string ?
    entry.RawValue : model;
  • CheckboxesContext/RadiosContext: Fixed SetErrorMessage() validation to permit error messages inside open fieldsets (consistent with SetHint() behavior and GDS patterns)

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Co-authored-by: gunndabad <2041280+gunndabad@users.noreply.github.com>
Copilot AI changed the title [WIP] Add tag helper model binding integration tests Add checkbox model binding integration tests Feb 1, 2026
Copilot AI requested a review from gunndabad February 1, 2026 16:06
@gunndabad gunndabad marked this pull request as ready for review February 7, 2026 09:22
@gunndabad gunndabad merged commit e98d07d into modelbindingtests Feb 7, 2026
6 checks passed
@gunndabad gunndabad deleted the copilot/sub-pr-439 branch February 7, 2026 09:30
gunndabad added a commit that referenced this pull request Feb 7, 2026
* Add tag helper model binding integration tests for text input

* Add password input tests to TagHelperModelBindingTests (#440)

* Initial plan

* Add password input tests to TagHelperModelBindingTests

Co-authored-by: gunndabad <2041280+gunndabad@users.noreply.github.com>

* Remove PauseAsync debug statement

Co-authored-by: gunndabad <2041280+gunndabad@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: gunndabad <2041280+gunndabad@users.noreply.github.com>

* Add date input tests to TagHelperModelBindingTests (#441)

* Initial plan

* Add date input tests to TagHelperModelBindingTests

Co-authored-by: gunndabad <2041280+gunndabad@users.noreply.github.com>

* Add separate test for overriden item names and IDs

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: gunndabad <2041280+gunndabad@users.noreply.github.com>
Co-authored-by: James Gunn <james@gunn.io>

* Add textarea model binding integration tests (#442)

* Initial plan

* Add textarea tests to TagHelperModelBindingTests

Co-authored-by: gunndabad <2041280+gunndabad@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: gunndabad <2041280+gunndabad@users.noreply.github.com>

* Add character count model binding integration tests (#443)

* Initial plan

* Add character count model binding integration tests

Co-authored-by: gunndabad <2041280+gunndabad@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: gunndabad <2041280+gunndabad@users.noreply.github.com>

* Add file upload model binding integration tests (#444)

* Initial plan

* Add file upload model binding integration tests

Co-authored-by: gunndabad <2041280+gunndabad@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: gunndabad <2041280+gunndabad@users.noreply.github.com>

* Add select tag helper model binding integration tests (#445)

* Initial plan

* Add select model binding integration tests

Co-authored-by: gunndabad <2041280+gunndabad@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: gunndabad <2041280+gunndabad@users.noreply.github.com>

* Add checkbox model binding integration tests (#446)

* Initial plan

* Add checkbox model binding integration test

Co-authored-by: gunndabad <2041280+gunndabad@users.noreply.github.com>

* Add test for overridden attributes

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: gunndabad <2041280+gunndabad@users.noreply.github.com>
Co-authored-by: James Gunn <james@gunn.io>

* Add radios model binding integration tests (#447)

* Initial plan

* Add radios model binding integration tests

Co-authored-by: gunndabad <2041280+gunndabad@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: gunndabad <2041280+gunndabad@users.noreply.github.com>

---------

Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
Co-authored-by: gunndabad <2041280+gunndabad@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants