Skip to content

Add initial tests for Toast, Dropdown, OutsideClick, FloatingElement, Forms, and bundle packages - #26

Merged
erinnmclaughlin merged 3 commits into
mainfrom
claude/issue-24-20260715-0100
Jul 15, 2026
Merged

erinnmclaughlin merged 3 commits into
mainfrom
claude/issue-24-20260715-0100

Conversation

@erinnmclaughlin

Copy link
Copy Markdown
Owner

Adds initial, low-hanging-fruit tests for every remaining src package (Toast, Dropdown, OutsideClick, FloatingElement, Forms, and the bundle package), following the two-layer pattern (pure-logic xUnit vs. rendered-component bUnit) already established for Modal/DarkMode.

Closes #24.

Note: I was unable to run dotnet build/dotnet test in my sandbox (no dotnet tool access) - please run the test suite before merging.

Generated with Claude Code

… Forms, and bundle packages

Extends the test project (added for Modal in a prior PR) to cover every other
component package with core, low-hanging-fruit tests: service/builder logic
for Toast (mirroring the existing Modal tests), rendered-component behavior
for Dropdown and the Toast trigger/close buttons, the .NET-side JS-interop
contract for OutsideClick/FloatingElement (mirroring the DarkMode pattern),
pure-logic tests for the Forms edit context/validation store, and a DI
registration test for the bundle package.

Co-authored-by: Erin McLaughlin <22223146+erinnmclaughlin@users.noreply.github.com>
@erinnmclaughlin

Copy link
Copy Markdown
Owner Author

@claude can you fix the failing tests?

Error: /home/runner/work/HeadlessBlazor/HeadlessBlazor/tests/HeadlessBlazor.Tests/Toast/HBToastTriggerTests.cs(13,18): error CS1061: 'BunitServiceProvider' does not contain a definition for 'AddSingleton' and no accessible extension method 'AddSingleton' accepting a first argument of type 'BunitServiceProvider' could be found (are you missing a using directive or an assembly reference?) [/home/runner/work/HeadlessBlazor/HeadlessBlazor/tests/HeadlessBlazor.Tests/HeadlessBlazor.Tests.csproj]

@claude

claude Bot commented Jul 15, 2026 •

Copy link
Copy Markdown

Claude finished @erinnmclaughlin's task in 3m 21s —— View job


Fixed the failing build

  • Investigate build error (BunitServiceProvider has no AddSingleton)
  • Check all new test files for similar issues
  • Fix the failing tests
  • Build/verify (couldn't run locally — see note below)
  • Commit and push fix

CI was actually failing with 4 compile errors, not just the one in the trigger comment. Pulled the full list from the CI and BuildAndPack run logs and fixed all of them (commit 78aea29):

  1. tests/.../Toast/HBToastTriggerTests.cs(13,24,36) — Services.AddSingleton<IToastService>(...) failed to resolve because the file was missing using Microsoft.Extensions.DependencyInjection;. bUnit's BunitContext.Services is typed as BunitServiceProvider, and without that using directive the AddSingleton extension method (which needs IServiceCollection in scope) can't be found — the csproj's global usings only cover Xunit, Bunit, and HeadlessBlazor. Added the missing using, matching the pattern already used in ServiceCollectionExtensionsTests.cs.
  2. tests/.../Forms/HBValidationMessageStoreTests.cs(48,49) — error CS0121: GetValidationMessages(new(person.Address, nameof(Address.City))) was ambiguous because EditContext.GetValidationMessages has both a FieldIdentifier overload and an Expression<Func<object>> overload, and the compiler couldn't infer which type the target-typed new(...) should resolve to. Made it explicit: new FieldIdentifier(person.Address, nameof(Address.City)) (with the necessary using Microsoft.AspNetCore.Components.Forms; added).

Note: Same as the original PR — I don't have dotnet access in this sandbox, so I verified purely by reading the CI build logs (dotnet build/dotnet test error output) rather than reproducing locally. Please re-run CI to confirm these were the only issues; the only other build output was 7 non-fatal BL0005 warnings (setting component parameters outside their component in the FloatingElement/OutsideClick tests), which don't fail the build since TreatWarningsAsErrors isn't set in this repo.
· Branch

- HBToastTriggerTests.cs: add missing `using Microsoft.Extensions.DependencyInjection;` so the `Services.AddSingleton<IToastService>(...)` extension method (on BunitContext's IServiceCollection-typed Services) resolves.
- HBValidationMessageStoreTests.cs: replace the ambiguous target-typed `new(...)` with an explicit `new FieldIdentifier(...)`, since EditContext.GetValidationMessages has both a FieldIdentifier and an Expression<Func<object>> overload and the compiler can't infer which one the target-typed new should satisfy.

Co-authored-by: Erin McLaughlin <22223146+erinnmclaughlin@users.noreply.github.com>
@erinnmclaughlin

Copy link
Copy Markdown
Owner Author

@claude here are the logs now:

2026-07-15T01:23:35.7661526Z ##[group]Run dotnet test tests//*.csproj -c Release
2026-07-15T01:23:35.7661922Z �[36;1mdotnet test tests/
/.csproj -c Release�[0m
2026-07-15T01:23:35.7811822Z shell: /usr/bin/bash -e {0}
2026-07-15T01:23:35.7812117Z env:
2026-07-15T01:23:35.7812309Z DOTNET_ROOT: /usr/share/dotnet
2026-07-15T01:23:35.7812557Z ##[endgroup]
2026-07-15T01:23:36.4981111Z Determining projects to restore...
2026-07-15T01:23:39.3837617Z Restored /home/runner/work/HeadlessBlazor/HeadlessBlazor/src/HeadlessBlazor.DarkMode/HeadlessBlazor.DarkMode.csproj (in 1.77 sec).
2026-07-15T01:23:39.3839116Z Restored /home/runner/work/HeadlessBlazor/HeadlessBlazor/src/HeadlessBlazor.Core/HeadlessBlazor.Core.csproj (in 1.77 sec).
2026-07-15T01:23:39.3851470Z Restored /home/runner/work/HeadlessBlazor/HeadlessBlazor/src/HeadlessBlazor.OutsideClick/HeadlessBlazor.OutsideClick.csproj (in 1.77 sec).
2026-07-15T01:23:39.3853168Z Restored /home/runner/work/HeadlessBlazor/HeadlessBlazor/src/HeadlessBlazor.Toast/HeadlessBlazor.Toast.csproj (in 1.77 sec).
2026-07-15T01:23:39.3947680Z Restored /home/runner/work/HeadlessBlazor/HeadlessBlazor/src/HeadlessBlazor.FloatingElement/HeadlessBlazor.FloatingElement.csproj (in 5 ms).
2026-07-15T01:23:39.3954540Z Restored /home/runner/work/HeadlessBlazor/HeadlessBlazor/src/HeadlessBlazor.Dropdown/HeadlessBlazor.Dropdown.csproj (in 5 ms).
2026-07-15T01:23:39.4022113Z Restored /home/runner/work/HeadlessBlazor/HeadlessBlazor/src/HeadlessBlazor/HeadlessBlazor.csproj (in 9 ms).
2026-07-15T01:23:39.4041324Z Restored /home/runner/work/HeadlessBlazor/HeadlessBlazor/src/HeadlessBlazor.Modal/HeadlessBlazor.Modal.csproj (in 2 ms).
2026-07-15T01:23:39.4100690Z Restored /home/runner/work/HeadlessBlazor/HeadlessBlazor/src/HeadlessBlazor.Forms/HeadlessBlazor.Forms.csproj (in 5 ms).
2026-07-15T01:23:41.2769453Z Restored /home/runner/work/HeadlessBlazor/HeadlessBlazor/tests/HeadlessBlazor.Tests/HeadlessBlazor.Tests.csproj (in 1.88 sec).
2026-07-15T01:23:45.2255570Z HeadlessBlazor.Core -> /home/runner/work/HeadlessBlazor/HeadlessBlazor/src/HeadlessBlazor.Core/bin/Release/net10.0/HeadlessBlazor.Core.dll
2026-07-15T01:23:45.5743343Z Successfully created package '/home/runner/work/HeadlessBlazor/HeadlessBlazor/src/HeadlessBlazor.Core/bin/Release/HeadlessBlazor.Core.0.0.0-alpha.0.nupkg'.
2026-07-15T01:23:45.5777291Z Successfully created package '/home/runner/work/HeadlessBlazor/HeadlessBlazor/src/HeadlessBlazor.Core/bin/Release/HeadlessBlazor.Core.0.0.0-alpha.0.snupkg'.
2026-07-15T01:23:47.0114356Z ##[warning]/home/runner/work/HeadlessBlazor/HeadlessBlazor/src/HeadlessBlazor.Modal/ModalBuilder.cs(24,22): warning CS1572: XML comment has a param tag for 'defaultOptions', but there is no parameter by that name [/home/runner/work/HeadlessBlazor/HeadlessBlazor/src/HeadlessBlazor.Modal/HeadlessBlazor.Modal.csproj]
2026-07-15T01:23:47.0773106Z ##[warning]/home/runner/work/HeadlessBlazor/HeadlessBlazor/src/HeadlessBlazor.Toast/ToastBuilder.cs(22,22): warning CS1572: XML comment has a param tag for 'defaultOptions', but there is no parameter by that name [/home/runner/work/HeadlessBlazor/HeadlessBlazor/src/HeadlessBlazor.Toast/HeadlessBlazor.Toast.csproj]
2026-07-15T01:23:47.0780740Z ##[warning]/home/runner/work/HeadlessBlazor/HeadlessBlazor/src/HeadlessBlazor.Forms/HBFormSubmitEventArgs.cs(7,18): warning CS1572: XML comment has a param tag for 'Model', but there is no parameter by that name [/home/runner/work/HeadlessBlazor/HeadlessBlazor/src/HeadlessBlazor.Forms/HeadlessBlazor.Forms.csproj]
2026-07-15T01:23:47.1852876Z ##[warning]/home/runner/work/HeadlessBlazor/HeadlessBlazor/src/HeadlessBlazor.Forms/HBFormSubmitEventArgs.cs(12,83): warning CS1573: Parameter 'Context' has no matching param tag in the XML comment for 'HBFormSubmitEventArgs.HBFormSubmitEventArgs(HBEditContext, CancellationToken)' (but other parameters do) [/home/runner/work/HeadlessBlazor/HeadlessBlazor/src/HeadlessBlazor.Forms/HeadlessBlazor.Forms.csproj]
2026-07-15T01:23:48.6172150Z HeadlessBlazor.Modal -> /home/runner/work/HeadlessBlazor/HeadlessBlazor/src/HeadlessBlazor.Modal/bin/Release/net10.0/HeadlessBlazor.Modal.dll
2026-07-15T01:23:49.0729707Z Successfully created package '/home/runner/work/HeadlessBlazor/HeadlessBlazor/src/HeadlessBlazor.Modal/bin/Release/HeadlessBlazor.Modal.0.0.0-alpha.0.nupkg'.
2026-07-15T01:23:49.1308148Z Successfully created package '/home/runner/work/HeadlessBlazor/HeadlessBlazor/src/HeadlessBlazor.Modal/bin/Release/HeadlessBlazor.Modal.0.0.0-alpha.0.snupkg'.
2026-07-15T01:23:49.2437977Z HeadlessBlazor.FloatingElement -> /home/runner/work/HeadlessBlazor/HeadlessBlazor/src/HeadlessBlazor.FloatingElement/bin/Release/net10.0/HeadlessBlazor.FloatingElement.dll
2026-07-15T01:23:49.5967278Z HeadlessBlazor.OutsideClick -> /home/runner/work/HeadlessBlazor/HeadlessBlazor/src/HeadlessBlazor.OutsideClick/bin/Release/net10.0/HeadlessBlazor.OutsideClick.dll
2026-07-15T01:23:49.6714570Z HeadlessBlazor.DarkMode -> /home/runner/work/HeadlessBlazor/HeadlessBlazor/src/HeadlessBlazor.DarkMode/bin/Release/net10.0/HeadlessBlazor.DarkMode.dll
2026-07-15T01:23:49.8971672Z Successfully created package '/home/runner/work/HeadlessBlazor/HeadlessBlazor/src/HeadlessBlazor.FloatingElement/bin/Release/HeadlessBlazor.FloatingElement.0.0.0-alpha.0.nupkg'.
2026-07-15T01:23:49.9871923Z Successfully created package '/home/runner/work/HeadlessBlazor/HeadlessBlazor/src/HeadlessBlazor.FloatingElement/bin/Release/HeadlessBlazor.FloatingElement.0.0.0-alpha.0.snupkg'.
2026-07-15T01:23:50.0099602Z HeadlessBlazor.Toast -> /home/runner/work/HeadlessBlazor/HeadlessBlazor/src/HeadlessBlazor.Toast/bin/Release/net10.0/HeadlessBlazor.Toast.dll
2026-07-15T01:23:50.0372639Z HeadlessBlazor.Forms -> /home/runner/work/HeadlessBlazor/HeadlessBlazor/src/HeadlessBlazor.Forms/bin/Release/net10.0/HeadlessBlazor.Forms.dll
2026-07-15T01:23:50.5874976Z Successfully created package '/home/runner/work/HeadlessBlazor/HeadlessBlazor/src/HeadlessBlazor.Toast/bin/Release/HeadlessBlazor.Toast.0.0.0-alpha.0.nupkg'.
2026-07-15T01:23:50.5913943Z Successfully created package '/home/runner/work/HeadlessBlazor/HeadlessBlazor/src/HeadlessBlazor.Toast/bin/Release/HeadlessBlazor.Toast.0.0.0-alpha.0.snupkg'.
2026-07-15T01:23:50.6542633Z Successfully created package '/home/runner/work/HeadlessBlazor/HeadlessBlazor/src/HeadlessBlazor.OutsideClick/bin/Release/HeadlessBlazor.OutsideClick.0.0.0-alpha.0.nupkg'.
2026-07-15T01:23:50.6602386Z Successfully created package '/home/runner/work/HeadlessBlazor/HeadlessBlazor/src/HeadlessBlazor.OutsideClick/bin/Release/HeadlessBlazor.OutsideClick.0.0.0-alpha.0.snupkg'.
2026-07-15T01:23:50.6808201Z Successfully created package '/home/runner/work/HeadlessBlazor/HeadlessBlazor/src/HeadlessBlazor.Forms/bin/Release/HeadlessBlazor.Forms.0.0.0-alpha.0.nupkg'.
2026-07-15T01:23:50.6873619Z Successfully created package '/home/runner/work/HeadlessBlazor/HeadlessBlazor/src/HeadlessBlazor.Forms/bin/Release/HeadlessBlazor.Forms.0.0.0-alpha.0.snupkg'.
2026-07-15T01:23:50.7372815Z Successfully created package '/home/runner/work/HeadlessBlazor/HeadlessBlazor/src/HeadlessBlazor.DarkMode/bin/Release/HeadlessBlazor.DarkMode.0.0.0-alpha.0.nupkg'.
2026-07-15T01:23:50.7433403Z Successfully created package '/home/runner/work/HeadlessBlazor/HeadlessBlazor/src/HeadlessBlazor.DarkMode/bin/Release/HeadlessBlazor.DarkMode.0.0.0-alpha.0.snupkg'.
2026-07-15T01:23:50.9372170Z HeadlessBlazor.Dropdown -> /home/runner/work/HeadlessBlazor/HeadlessBlazor/src/HeadlessBlazor.Dropdown/bin/Release/net10.0/HeadlessBlazor.Dropdown.dll
2026-07-15T01:23:51.1425292Z Successfully created package '/home/runner/work/HeadlessBlazor/HeadlessBlazor/src/HeadlessBlazor.Dropdown/bin/Release/HeadlessBlazor.Dropdown.0.0.0-alpha.0.nupkg'.
2026-07-15T01:23:51.1444051Z Successfully created package '/home/runner/work/HeadlessBlazor/HeadlessBlazor/src/HeadlessBlazor.Dropdown/bin/Release/HeadlessBlazor.Dropdown.0.0.0-alpha.0.snupkg'.
2026-07-15T01:23:51.3374705Z HeadlessBlazor -> /home/runner/work/HeadlessBlazor/HeadlessBlazor/src/HeadlessBlazor/bin/Release/net10.0/HeadlessBlazor.Bundle.dll
2026-07-15T01:23:51.5779875Z Successfully created package '/home/runner/work/HeadlessBlazor/HeadlessBlazor/src/HeadlessBlazor/bin/Release/HeadlessBlazor.0.0.0-alpha.0.nupkg'.
2026-07-15T01:23:51.5807445Z Successfully created package '/home/runner/work/HeadlessBlazor/HeadlessBlazor/src/HeadlessBlazor/bin/Release/HeadlessBlazor.0.0.0-alpha.0.snupkg'.
2026-07-15T01:23:52.3593718Z ##[warning]/home/runner/work/HeadlessBlazor/HeadlessBlazor/tests/HeadlessBlazor.Tests/FloatingElement/HBFloatBehaviorTests.cs(16,46): warning BL0005: Component parameter 'Anchor' should not be set outside of its component. [/home/runner/work/HeadlessBlazor/HeadlessBlazor/tests/HeadlessBlazor.Tests/HeadlessBlazor.Tests.csproj]
2026-07-15T01:23:52.3599237Z ##[warning]/home/runner/work/HeadlessBlazor/HeadlessBlazor/tests/HeadlessBlazor.Tests/FloatingElement/HBFloatBehaviorTests.cs(16,64): warning BL0005: Component parameter 'Content' should not be set outside of its component. [/home/runner/work/HeadlessBlazor/HeadlessBlazor/tests/HeadlessBlazor.Tests/HeadlessBlazor.Tests.csproj]
2026-07-15T01:23:52.3650602Z ##[warning]/home/runner/work/HeadlessBlazor/HeadlessBlazor/tests/HeadlessBlazor.Tests/OutsideClick/HBOutsideClickBehaviorTests.cs(29,13): warning BL0005: Component parameter 'OnClick' should not be set outside of its component. [/home/runner/work/HeadlessBlazor/HeadlessBlazor/tests/HeadlessBlazor.Tests/HeadlessBlazor.Tests.csproj]
2026-07-15T01:23:52.5045467Z HeadlessBlazor.Tests -> /home/runner/work/HeadlessBlazor/HeadlessBlazor/tests/HeadlessBlazor.Tests/bin/Release/net10.0/HeadlessBlazor.Tests.dll
2026-07-15T01:23:52.5121462Z Test run for /home/runner/work/HeadlessBlazor/HeadlessBlazor/tests/HeadlessBlazor.Tests/bin/Release/net10.0/HeadlessBlazor.Tests.dll (.NETCoreApp,Version=v10.0)
2026-07-15T01:23:52.7775074Z A total of 1 test files matched the specified pattern.
2026-07-15T01:23:54.6921913Z [xUnit.net 00:00:01.26] HeadlessBlazor.Tests.Dropdown.HBDropdownTriggerTests.Click_DoesNotToggleTheDropdown_WhenPreventDefaultIsSet [FAIL]
2026-07-15T01:23:54.7026628Z Failed HeadlessBlazor.Tests.Dropdown.HBDropdownTriggerTests.Click_DoesNotToggleTheDropdown_WhenPreventDefaultIsSet [5 ms]
2026-07-15T01:23:54.7076613Z Error Message:
2026-07-15T01:23:54.7101883Z Bunit.MissingEventHandlerException : The element does not have an event handler for the event 'onclick'. It does however have an event handler for the 'onclick:preventdefault' event.
2026-07-15T01:23:54.7130971Z Stack Trace:
2026-07-15T01:23:54.7132335Z at Bunit.TriggerEventDispatchExtensions.TriggerBubblingEventAsync(BunitRenderer renderer, IElement element, String eventName, EventArgs eventArgs) in //src/bunit/EventDispatchExtensions/TriggerEventDispatchExtensions.cs:line 114
2026-07-15T01:23:54.7134578Z at Bunit.TriggerEventDispatchExtensions.TriggerEventsAsync(BunitRenderer renderer, IElement element, String eventName, EventArgs eventArgs) in /
/src/bunit/EventDispatchExtensions/TriggerEventDispatchExtensions.cs:line 86
2026-07-15T01:23:54.7136360Z at Bunit.TriggerEventDispatchExtensions.<>c__DisplayClass3_0.b__0() in //src/bunit/EventDispatchExtensions/TriggerEventDispatchExtensions.cs:line 73
2026-07-15T01:23:54.7137802Z at Microsoft.AspNetCore.Components.Rendering.RendererSynchronizationContext.<>c.<b__10_0>d.MoveNext()
2026-07-15T01:23:54.7139169Z --- End of stack trace from previous location ---
2026-07-15T01:23:54.7161449Z at Bunit.TriggerEventDispatchExtensions.ThrowIfFailedSynchronously(Task result) in /
/src/bunit/EventDispatchExtensions/TriggerEventDispatchExtensions.cs:line 254
2026-07-15T01:23:54.7184689Z at Bunit.TriggerEventDispatchExtensions.TriggerEventAsync(IElement element, String eventName, EventArgs eventArgs) in //src/bunit/EventDispatchExtensions/TriggerEventDispatchExtensions.cs:line 75
2026-07-15T01:23:54.7201742Z at Bunit.EventHandlerDispatchExtensions.ClickAsync(IElement element, MouseEventArgs eventArgs) in /
/src/bunit/obj/Release/net10.0/bunit.generators.internal/Bunit.Blazor.EventDispatcherExtensionGenerator/EventHandlerDispatchExtensions.g.cs:line 1209
2026-07-15T01:23:54.7211689Z at Bunit.EventHandlerDispatchExtensions.Click(IElement element, MouseEventArgs eventArgs) in /_/src/bunit/obj/Release/net10.0/bunit.generators.internal/Bunit.Blazor.EventDispatcherExtensionGenerator/EventHandlerDispatchExtensions.g.cs:line 1200
2026-07-15T01:23:54.7214078Z at HeadlessBlazor.Tests.Dropdown.HBDropdownTriggerTests.Click_DoesNotToggleTheDropdown_WhenPreventDefaultIsSet() in /home/runner/work/HeadlessBlazor/HeadlessBlazor/tests/HeadlessBlazor.Tests/Dropdown/HBDropdownTriggerTests.cs:line 54
2026-07-15T01:23:54.7215597Z at System.Reflection.MethodBaseInvoker.InterpretedInvoke_Method(Object obj, IntPtr
args)
2026-07-15T01:23:54.7216447Z at System.Reflection.MethodBaseInvoker.InvokeWithNoArgs(Object obj, BindingFlags invokeAttr)
2026-07-15T01:23:54.7571785Z [xUnit.net 00:00:01.33] HeadlessBlazor.Tests.Dropdown.HBDropdownTests.OnClickItem_DefaultsToClosingTheDropdown_WhenNoHandlerProvided [FAIL]
2026-07-15T01:23:54.7641354Z Failed HeadlessBlazor.Tests.Dropdown.HBDropdownTests.OnClickItem_DefaultsToClosingTheDropdown_WhenNoHandlerProvided [5 ms]
2026-07-15T01:23:54.7669121Z Error Message:
2026-07-15T01:23:54.7673318Z System.InvalidOperationException : The current thread is not associated with the Dispatcher. Use InvokeAsync() to switch execution to the Dispatcher when triggering rendering or component state.
2026-07-15T01:23:54.7710058Z Stack Trace:
2026-07-15T01:23:54.7720834Z at Microsoft.AspNetCore.Components.Dispatcher.AssertAccess()
2026-07-15T01:23:54.7771140Z at Microsoft.AspNetCore.Components.RenderTree.Renderer.AddToRenderQueue(Int32 componentId, RenderFragment renderFragment)
2026-07-15T01:23:54.7812983Z at Microsoft.AspNetCore.Components.RenderHandle.Render(RenderFragment renderFragment)
2026-07-15T01:23:54.7841222Z at Microsoft.AspNetCore.Components.ComponentBase.StateHasChanged()
2026-07-15T01:23:54.7884236Z at Microsoft.AspNetCore.Components.ComponentBase.Microsoft.AspNetCore.Components.IHandleEvent.HandleEventAsync(EventCallbackWorkItem callback, Object arg)
2026-07-15T01:23:54.7931683Z at Microsoft.AspNetCore.Components.EventCallback`1.InvokeAsync(TValue arg)
2026-07-15T01:23:54.7961741Z at HeadlessBlazor.Tests.Dropdown.HBDropdownTests.OnClickItem_DefaultsToClosingTheDropdown_WhenNoHandlerProvided() in /home/runner/work/HeadlessBlazor/HeadlessBlazor/tests/HeadlessBlazor.Tests/Dropdown/HBDropdownTests.cs:line 66
2026-07-15T01:23:54.7963293Z --- End of stack trace from previous location ---
2026-07-15T01:23:54.9414379Z
2026-07-15T01:23:54.9451484Z Failed! - Failed: 2, Passed: 71, Skipped: 0, Total: 73, Duration: 1 s - HeadlessBlazor.Tests.dll (net10.0)
2026-07-15T01:23:55.0274220Z ##[error]Process completed with exit code 1.

@claude

claude Bot commented Jul 15, 2026 •

Copy link
Copy Markdown

Claude finished @erinnmclaughlin's task in 5m 10s —— View job


Fixing the 2 failing tests

  • Read CI failure logs
  • Investigate HBDropdownTriggerTests.Click_DoesNotToggleTheDropdown_WhenPreventDefaultIsSet (MissingEventHandlerException)
  • Investigate HBDropdownTests.OnClickItem_DefaultsToClosingTheDropdown_WhenNoHandlerProvided (Dispatcher exception)
  • Fix both tests/source
  • Commit and push (bffd5af)

Both failures came from real bugs, not flukes:

  1. HBDropdownTriggerTests.Click_DoesNotToggleTheDropdown_WhenPreventDefaultIsSet — Bunit.MissingEventHandlerException. HBDropdownTrigger.OnParametersSet (src/HeadlessBlazor.Dropdown/HBDropdownTrigger.cs:21-25) only added an "onclick" attribute when OnClickPreventDefault was false. But HBElementBase.BuildRenderTree (src/HeadlessBlazor.Core/HBElementBase.cs:87) unconditionally emits the onclick:preventdefault modifier attribute regardless of whether an actual onclick handler exists. bUnit requires the base event (onclick) to be present for a modifier like onclick:preventdefault to be valid, so cut.Find("button").Click() threw instead of simulating a no-op click. Fixed by always attaching an onclick handler — EventCallback.Empty (a real no-op) when OnClickPreventDefault is set, or the toggle callback otherwise — so the click event has a valid handler to dispatch to, while still not toggling the dropdown.

  2. HBDropdownTests.OnClickItem_DefaultsToClosingTheDropdown_WhenNoHandlerProvided — InvalidOperationException: The current thread is not associated with the Dispatcher. The test called cut.Instance.OnClickItem.InvokeAsync(null!) directly from the xUnit test thread. Unlike HBDropdown.OpenAsync/CloseAsync (which wrap their bodies in ComponentBase.InvokeAsync, marshaling onto the renderer's dispatcher themselves), invoking an EventCallback<T> directly goes through ComponentBase's IHandleEvent.HandleEventAsync, which calls StateHasChanged() assuming it's already running on the dispatcher thread (as it would be during real event dispatch). This is a well-known bUnit gotcha; the fix is to wrap the call in cut.InvokeAsync(...), which dispatches the work item onto the renderer's synchronization context first.

Note: As with the original PR, I don't have dotnet tool access in this sandbox (all dotnet build/dotnet test invocations were blocked pending approval), so this was verified by careful code tracing rather than a local run — please re-run CI to confirm these were the only two failures.

Branch ·

- HBDropdownTrigger always attaches an onclick handler (EventCallback.Empty
  when OnClickPreventDefault is set) so bUnit's Click() has a valid onclick
  handler to dispatch to, since HBElementBase always renders the
  onclick:preventdefault modifier regardless of whether a handler exists.
- HBDropdownTests invokes OnClickItem via cut.InvokeAsync so the callback
  runs on the renderer's dispatcher thread instead of the test thread.

Co-authored-by: Erin McLaughlin <22223146+erinnmclaughlin@users.noreply.github.com>
@erinnmclaughlin
erinnmclaughlin merged commit 12d7886 into main Jul 15, 2026
2 of 3 checks passed
@erinnmclaughlin
erinnmclaughlin deleted the claude/issue-24-20260715-0100 branch July 15, 2026 01:48
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.

Add initial tests for all projects

1 participant