Skip to content

Upgrade bUnit to v2 and migrate test interactions to async event handlers#83

Closed
Copilot wants to merge 7 commits intomainfrom
copilot/upgrade-bunit-to-v2-yet-again
Closed

Upgrade bUnit to v2 and migrate test interactions to async event handlers#83
Copilot wants to merge 7 commits intomainfrom
copilot/upgrade-bunit-to-v2-yet-again

Conversation

Copy link
Contributor

Copilot AI commented Mar 3, 2026

  • Investigate failing CI run and collect actionable compiler warnings/errors from logs
  • Update bUnit v2 migration issues in tests (RenderComponent -> Render, remove deprecated API usage)
  • Update test context base type and disposal to remove bUnit v2 warnings
  • Run targeted dotnet test for JournalApp.Tests (or capture sandbox workload limitation)
  • Address remaining warning(s) directly related to this change set with minimal edits
  • Run code review and CodeQL checks
  • Reply to PR comment with commit hash once fixes are pushed

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Co-authored-by: danielchalmers <7112040+danielchalmers@users.noreply.github.com>
Copilot AI changed the title [WIP] Upgrade bunit to latest v2 package and improve async handling Upgrade bUnit to v2 and migrate test interactions to async event handlers Mar 3, 2026
@danielchalmers danielchalmers marked this pull request as ready for review March 3, 2026 21:39
@danielchalmers
Copy link
Owner

@copilot Fix warnings and errors:

Run dotnet test
  Determining projects to restore...
  Restored D:\a\JournalApp\JournalApp\JournalApp.Tests\JournalApp.Tests.csproj (in 51.48 sec).
  Restored D:\a\JournalApp\JournalApp\JournalApp\JournalApp.csproj (in 1.55 min).
Warning: D:\a\JournalApp\JournalApp\JournalApp\MauiProgram.cs(17,23): warning CA1416: This call site is reachable on all platforms. 'AppBuilderExtensions.UseMauiCommunityToolkit(MauiAppBuilder, Action<Options>?)' is only supported on: 'Android' 21.0 and later, 'iOS' 15.0 and later, 'maccatalyst' 15.0 and later, 'Tizen' 6.5 and later, 'Windows' 10.0.17763 and later. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1416) [D:\a\JournalApp\JournalApp\JournalApp\JournalApp.csproj::TargetFramework=net10.0]
  JournalApp -> D:\a\JournalApp\JournalApp\JournalApp\bin\Debug\net10.0\JournalApp.dll
  JournalApp -> D:\a\JournalApp\JournalApp\JournalApp\bin\Debug\net10.0-android\JournalApp.dll
Warning: D:\a\JournalApp\JournalApp\JournalApp.Tests\JaTestContext.cs(7,39): warning CS0618: 'TestContext' is obsolete: 'Use BunitContext instead. TestContext will be removed in a future release.' (https://bunit.dev/docs/migrations) [D:\a\JournalApp\JournalApp\JournalApp.Tests\JournalApp.Tests.csproj::TargetFramework=net10.0]
Warning: D:\a\JournalApp\JournalApp\JournalApp.Tests\JaTestContext.cs(24,31): warning CS0108: 'JaTestContext.DisposeAsync()' hides inherited member 'BunitContext.DisposeAsync()'. Use the new keyword if hiding was intended. [D:\a\JournalApp\JournalApp\JournalApp.Tests\JournalApp.Tests.csproj::TargetFramework=net10.0]
Error: D:\a\JournalApp\JournalApp\JournalApp.Tests\SafetyPlanTests.razor(16,19): error CS0619: 'BunitContext.RenderComponent<TComponent>()' is obsolete: 'Use Render instead.' (https://bunit.dev/docs/migrations) [D:\a\JournalApp\JournalApp\JournalApp.Tests\JournalApp.Tests.csproj::TargetFramework=net10.0]
Error: D:\a\JournalApp\JournalApp\JournalApp.Tests\SafetyPlanTests.razor(34,19): error CS0619: 'BunitContext.RenderComponent<TComponent>()' is obsolete: 'Use Render instead.' (https://bunit.dev/docs/migrations) [D:\a\JournalApp\JournalApp\JournalApp.Tests\JournalApp.Tests.csproj::TargetFramework=net10.0]
Error: D:\a\JournalApp\JournalApp\JournalApp.Tests\SafetyPlanTests.razor(45,9): error CS0103: The name 'DisposeComponents' does not exist in the current context [D:\a\JournalApp\JournalApp\JournalApp.Tests\JournalApp.Tests.csproj::TargetFramework=net10.0]
Error: D:\a\JournalApp\JournalApp\JournalApp.Tests\SafetyPlanTests.razor(46,15): error CS0619: 'BunitContext.RenderComponent<TComponent>()' is obsolete: 'Use Render instead.' (https://bunit.dev/docs/migrations) [D:\a\JournalApp\JournalApp\JournalApp.Tests\JournalApp.Tests.csproj::TargetFramework=net10.0]
Error: D:\a\JournalApp\JournalApp\JournalApp.Tests\CalendarTests.razor(23,19): error CS0619: 'BunitContext.RenderComponent<TComponent>(Action<ComponentParameterCollectionBuilder<TComponent>>?)' is obsolete: 'Use Render instead.' (https://bunit.dev/docs/migrations) [D:\a\JournalApp\JournalApp\JournalApp.Tests\JournalApp.Tests.csproj::TargetFramework=net10.0]
Error: D:\a\JournalApp\JournalApp\JournalApp.Tests\CalendarTests.razor(54,19): error CS0619: 'BunitContext.RenderComponent<TComponent>(Action<ComponentParameterCollectionBuilder<TComponent>>?)' is obsolete: 'Use Render instead.' (https://bunit.dev/docs/migrations) [D:\a\JournalApp\JournalApp\JournalApp.Tests\JournalApp.Tests.csproj::TargetFramework=net10.0]
Error: D:\a\JournalApp\JournalApp\JournalApp.Tests\DataPointViewTests.razor(90,19): error CS0619: 'BunitContext.RenderComponent<TComponent>(Action<ComponentParameterCollectionBuilder<TComponent>>?)' is obsolete: 'Use Render instead.' (https://bunit.dev/docs/migrations) [D:\a\JournalApp\JournalApp\JournalApp.Tests\JournalApp.Tests.csproj::TargetFramework=net10.0]
Error: D:\a\JournalApp\JournalApp\JournalApp.Tests\CalendarTests.razor(84,19): error CS0619: 'BunitContext.RenderComponent<TComponent>(Action<ComponentParameterCollectionBuilder<TComponent>>?)' is obsolete: 'Use Render instead.' (https://bunit.dev/docs/migrations) [D:\a\JournalApp\JournalApp\JournalApp.Tests\JournalApp.Tests.csproj::TargetFramework=net10.0]
Error: D:\a\JournalApp\JournalApp\JournalApp.Tests\DataPointViewTests.razor(125,19): error CS0619: 'BunitContext.RenderComponent<TComponent>(Action<ComponentParameterCollectionBuilder<TComponent>>?)' is obsolete: 'Use Render instead.' (https://bunit.dev/docs/migrations) [D:\a\JournalApp\JournalApp\JournalApp.Tests\JournalApp.Tests.csproj::TargetFramework=net10.0]
Error: D:\a\JournalApp\JournalApp\JournalApp.Tests\ManageCategoriesTests.razor(249,19): error CS0619: 'BunitContext.RenderComponent<TComponent>()' is obsolete: 'Use Render instead.' (https://bunit.dev/docs/migrations) [D:\a\JournalApp\JournalApp\JournalApp.Tests\JournalApp.Tests.csproj::TargetFramework=net10.0]
Error: D:\a\JournalApp\JournalApp\JournalApp.Tests\DataPointViewTests.razor(153,19): error CS0619: 'BunitContext.RenderComponent<TComponent>(Action<ComponentParameterCollectionBuilder<TComponent>>?)' is obsolete: 'Use Render instead.' (https://bunit.dev/docs/migrations) [D:\a\JournalApp\JournalApp\JournalApp.Tests\JournalApp.Tests.csproj::TargetFramework=net10.0]
Error: D:\a\JournalApp\JournalApp\JournalApp.Tests\DataPointViewTests.razor(190,19): error CS0619: 'BunitContext.RenderComponent<TComponent>(Action<ComponentParameterCollectionBuilder<TComponent>>?)' is obsolete: 'Use Render instead.' (https://bunit.dev/docs/migrations) [D:\a\JournalApp\JournalApp\JournalApp.Tests\JournalApp.Tests.csproj::TargetFramework=net10.0]
Error: D:\a\JournalApp\JournalApp\JournalApp.Tests\DataPointViewTests.razor(211,19): error CS0619: 'BunitContext.RenderComponent<TComponent>(Action<ComponentParameterCollectionBuilder<TComponent>>?)' is obsolete: 'Use Render instead.' (https://bunit.dev/docs/migrations) [D:\a\JournalApp\JournalApp\JournalApp.Tests\JournalApp.Tests.csproj::TargetFramework=net10.0]
  JournalApp -> D:\a\JournalApp\JournalApp\JournalApp\bin\Debug\net10.0-windows10.0.19041.0\win-x64\JournalApp.dll
Error: Process completed with exit code 1.

Copilot AI and others added 2 commits March 3, 2026 21:55
Co-authored-by: danielchalmers <7112040+danielchalmers@users.noreply.github.com>
Co-authored-by: danielchalmers <7112040+danielchalmers@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Mar 3, 2026

@copilot Fix warnings and errors:

...

Fixed in fff62b3 (plus prior migration fixes in f851259). I updated remaining bUnit v2 API usages (RenderComponent -> Render), replaced DisposeComponents() with component disposal in SafetyPlanTests, moved JaTestContext to BunitContext with explicit IAsyncLifetime.DisposeAsync, and narrowed CA1416 suppression to just the UseMauiCommunityToolkit call.

…propagated before page disposal/navigation.

- Changed [`SafetyPlanItem.razor`](/mnt/f/source/repos/JournalApp/JournalApp/Pages/SafetyPlanning/SafetyPlanItem.razor#L6) to use `Value` + `ValueChanged` with an awaited handler instead of setter-side `TextChanged.InvokeAsync(...)`.
- This removes the fire-and-forget callback race that could leave `Plan.Purpose` unchanged when the test disposes/re-renders quickly (the exact `PlanPersists` scenario).

I couldn’t run the test locally because `dotnet` is not available in this environment (`dotnet: command not found`).

Next step:
1. Run `dotnet test JournalApp.Tests/JournalApp.Tests.csproj --filter "FullyQualifiedName~SafetyPlanTests.PlanPersists"` in your CI/dev environment to confirm the fix.
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