Registry Mirror
Skip to content

Conversation

@phmatray

Copy link
Copy Markdown
Owner

Summary

  • Fixes the seven core stub renderers under FormCraft/Forms/Rendering/ so their rendered
    disabled attribute follows Context.Field.DisabledCondition?.Invoke(Context.Model) ?? Context.Field.IsDisabled — the same expression FieldComponentBase.IsDisabled already uses
    (fix(core): evaluate DisabledCondition on render, mirroring VisibleWhen (#476) #479) — instead of the static Context.Field.IsDisabled flag alone. .DisabledWhen(...) now
    works on the no-adapter-registered fallback path exactly as it does on both UI adapters.
  • Adds CoreRendererDisabledWhenTests (4 facts) proving .DisabledWhen(...) is honored for both
    a plain field (StringFieldRenderer) and the structurally different FileUploadFieldRenderer.
  • Along the way, stubs IFieldConfiguration.DisabledCondition to null in the seven existing
    A.Fake-based renderer test helpers: FakeItEasy returns a non-null dummy Func<TModel,bool>
    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. Without this, 7 pre-existing tests regressed.
  • Replaces the two remaining internal-state assertions in FileUploadFieldRendererTests with
    rendered-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 rendered accept
    attribute stays absent; additionalAttributes.ShouldNotContainKey("FileUploadErrors") (a dict
    the renderer never touches) → asserts the rendered multiple attribute stays absent.

Test plan

  • dotnet test FormCraft.UnitTests/FormCraft.UnitTests.csproj -c Release -- --filter-namespace FormCraft.UnitTests.Rendering — 239/239 passed
  • dotnet test -c Release (full suite, all three projects) — 2130/2130 passed
  • ./build.sh Format — clean, no diff

Closes #483
Closes #488

🤖 Generated with Claude Code

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.
@phmatray
phmatray marked this pull request as ready for review September 24, 2026 09:55
@phmatray
phmatray merged commit f9df972 into dev Sep 24, 2026
3 checks passed
@phmatray
phmatray deleted the fix/483-core-stub-renderer-disabled-condition branch September 24, 2026 10:00
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.

test(file-upload): review pre-existing assertions in FileUploadFieldRendererTests fix(core): core stub renderers ignore DisabledWhen

1 participant