bUnit
bUnit copied to clipboard
Allow cancellation of navigation with bUnits NavigationManager
With the recent merge of this PR: https://github.com/dotnet/aspnetcore/pull/42638 (here the issue which tracks the topic: https://github.com/dotnet/aspnetcore/issues/42877) users can intercept the NavigationManager
and prevent redirects. To make it work we have to add some logic in the NavigateToCore
function.
Here is an inspiration how it is done in the PR for the RemoteNavigationManager
: https://github.com/dotnet/aspnetcore/blob/d1558107b97d2471e9a0aa5d008b511ead908fa7/src/Components/Server/src/Circuits/RemoteNavigationManager.cs#L84
Goal
The user should have means to simulate the cancellation behaviour in a bUnit test. That said if he has a NavigationLock
component which would prevent the navigation, we should have the same behaviour in bUnit. That includes also no new item on the NavigationHistory
stack. No change of BaseUri
or Uri
.
Analysis
I tried to use the feature as it is already merged to main, but unfortunately the nightly builds don't include this function at the moment.