Conversation
The seven core stub renderers under FormCraft/Forms/Rendering/ read Context.Field.IsDisabled directly, so .DisabledWhen(...) had no effect on the no-adapter-registered fallback path even though FieldComponentBase.IsDisabled already resolves it correctly for both UI adapters (#479). Apply the same expression here: Context.Field.DisabledCondition?.Invoke(Context.Model) ?? Context.Field.IsDisabled Also stub IFieldConfiguration.DisabledCondition to null in the existing Fake-based test helpers across these seven test files: FakeItEasy returns a dummy Func<TModel,bool> (not null) for an unconfigured delegate property, and invoking it returns false, which was silently overriding an explicitly stubbed IsDisabled=true once the renderers started reading DisabledCondition first. Closes #483
FileUploadFieldRendererTests had two pre-existing assertions that checked internal state rather than rendered output (out of scope for #478/#486, which targeted ShouldNotBeNull()): - Render_WithMultipleFilesConfiguration_ConfiguresForMultipleUpload asserted uploadConfig.Multiple.ShouldBeTrue() — an Arrange-time fact about the config object, not the rendered DOM. Replaced with a DOM assertion that "accept" stays absent, consistent with the sibling tests' documented fact that this stub never reads FileUploadConfiguration. - Render_ClearsValidationErrors_OnSuccessfulUpload asserted additionalAttributes.ShouldNotContainKey("FileUploadErrors") against a dict the renderer never touches. Replaced with a DOM assertion that "multiple" stays absent, matching the same fixed-markup fact already established in the file's other CurrentValue-driven tests. Closes #488
- FileUploadFieldRendererTests: give the two rendered-DOM replacement assertions (#488) something real to pin instead of proving "nothing is emitted from nothing" — set AcceptedFileTypes on the FileUploadConfiguration the "accept" assertion checks against, and stub ActualFieldType so the "multiple" assertion actually reflects a single-file scenario. - CoreRendererDisabledWhenTests: assert the file-upload facts render an <input type="file"> in addition to the disabled state, so a future regression that accidentally resolved a different renderer for the field would be caught rather than silently asserting on the wrong element.
…erer-disabled-condition
phmatray
marked this pull request as ready for review
September 24, 2026 09:55
This was referenced Sep 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
FormCraft/Forms/Rendering/so their rendereddisabledattribute followsContext.Field.DisabledCondition?.Invoke(Context.Model) ?? Context.Field.IsDisabled— the same expressionFieldComponentBase.IsDisabledalready uses(fix(core): evaluate DisabledCondition on render, mirroring VisibleWhen (#476) #479) — instead of the static
Context.Field.IsDisabledflag alone..DisabledWhen(...)nowworks on the no-adapter-registered fallback path exactly as it does on both UI adapters.
CoreRendererDisabledWhenTests(4 facts) proving.DisabledWhen(...)is honored for botha plain field (
StringFieldRenderer) and the structurally differentFileUploadFieldRenderer.IFieldConfiguration.DisabledConditiontonullin the seven existingA.Fake-based renderer test helpers: FakeItEasy returns a non-null dummyFunc<TModel,bool>for an unconfigured delegate property, and invoking it returns
false, which was silentlyoverriding an explicitly stubbed
IsDisabled = trueonce the renderers started readingDisabledConditionfirst. Without this, 7 pre-existing tests regressed.FileUploadFieldRendererTestswithrendered-DOM assertions, in the style test(core): replace tautological renderFragment.ShouldNotBeNull() assertions (#478) #486 already used for this file:
uploadConfig.Multiple.ShouldBeTrue()(an Arrange-time fact) → asserts the renderedacceptattribute stays absent;
additionalAttributes.ShouldNotContainKey("FileUploadErrors")(a dictthe renderer never touches) → asserts the rendered
multipleattribute stays absent.Test plan
dotnet test FormCraft.UnitTests/FormCraft.UnitTests.csproj -c Release -- --filter-namespace FormCraft.UnitTests.Rendering— 239/239 passeddotnet test -c Release(full suite, all three projects) — 2130/2130 passed./build.sh Format— clean, no diffCloses #483
Closes #488
🤖 Generated with Claude Code