Repository navigation
Add initial tests for Toast, Dropdown, OutsideClick, FloatingElement, Forms, and bundle packages - #26
Conversation
… 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>
|
@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 finished @erinnmclaughlin's task in 3m 21s —— View job Fixed the failing build
CI was actually failing with 4 compile errors, not just the one in the trigger comment. Pulled the full list from the
Note: Same as the original PR — I don't have |
- 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>
|
@claude here are the logs now: 2026-07-15T01:23:35.7661526Z ##[group]Run dotnet test tests//*.csproj -c Release |
|
Claude finished @erinnmclaughlin's task in 5m 10s —— View job Fixing the 2 failing tests
Both failures came from real bugs, not flukes:
Note: As with the original PR, I don't have 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>
Adds initial, low-hanging-fruit tests for every remaining
srcpackage (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 testin my sandbox (nodotnettool access) - please run the test suite before merging.Generated with Claude Code