Skip to content

Fix FakeNavigationManager when navigating to Uri without absolute path.#952

Merged
linkdotnet merged 5 commits intobUnit-dev:mainfrom
joelmandell:main
Jan 4, 2023
Merged

Fix FakeNavigationManager when navigating to Uri without absolute path.#952
linkdotnet merged 5 commits intobUnit-dev:mainfrom
joelmandell:main

Conversation

@joelmandell
Copy link
Contributor

Fix FakeNavigationManager when navigating to Uri without absolute path.

Pull request description

I run some unit tests of a component today that navigates without problem to a path without absolute path.
But in unit test it throws. I did some unit test of bUnit and found out that FakeNavigationManager could not handle that case.
So this is a PR, that seems to fix it.

PR meta checklist

  • Pull request is targeted at main branch for code
    or targeted at stable branch for documentation that is live on bunit.dev.
  • Pull request is linked to all related issues, if any.
  • I have read the CONTRIBUTING.md document.

Code PR specific checklist

  • My code follows the code style of this project and AspNetCore coding guidelines.
  • My change requires a change to the documentation.
    • I have updated the documentation accordingly.
  • I have updated the appropriate sub section in the CHANGELOG.md.
  • I have added, updated or removed tests to according to my changes.
    • All tests passed.

In the real implementation this works fine. But not when unit-testing. This fixes that issue.
@linkdotnet
Copy link
Collaborator

Hey @joelmandell,

thanks for reaching out to us and filing a PR for the issue you are encountering. Let me level here with you to find a common denominator.

The issue you are seeing is solely because of umlauts in the URL not because they are relative or whatnot. If you remove the ä with a it works as expected. The reason lies in how IsWellFormedUriString and ToAbsoluteUri handles that situation (for some reason bad). Well, that and later the Uri = absoluteUri.OriginalString; which throws in an exception in the current state.

We just swallowed that exception which is why it gave the impression this behavior is more or less expected.

Anyway back on track. I do think your change looks good. There is a smaller nitpick with the test - but I'll put the comment directly at the appropriate place.

Fixes according to comments on PR.
@joelmandell
Copy link
Contributor Author

Thanks @linkdotnet for your comments and I made changes according to them 👍

@linkdotnet
Copy link
Collaborator

Thanks @linkdotnet for your comments and I made changes according to them 👍

One small thing in the changelog.md and we are there! Great job so far!

@linkdotnet
Copy link
Collaborator

Perfect. Looking good and ready for main.

Thanks again @joelmandell!

@linkdotnet linkdotnet enabled auto-merge (squash) January 4, 2023 18:42
@linkdotnet linkdotnet merged commit 26b8e97 into bUnit-dev:main Jan 4, 2023
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