Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUGFIX release] fix router test regression in urlFor and recognize #19733

Merged
merged 1 commit into from
Aug 30, 2021
Merged

[BUGFIX release] fix router test regression in urlFor and recognize #19733

merged 1 commit into from
Aug 30, 2021

Conversation

chriskrycho
Copy link
Contributor

@chriskrycho chriskrycho commented Aug 26, 2021

As part of the improvements made between 3.24 and 3.28, the router microlib is now lazily loaded. When these changes were made, there were a couple cases where it should be possible to access router state in a non-application test (integration etc.) but it currently is not because the router is not necessarily set up. Since setupRouter is idempotent, call it in those functions so that if it is not set up, it gets set up, and otherwise it will continue working as expected.

Besides the change to the tests here, I have verified that this restores the previous behavior in our app.

Related to #19494. (Not marking as "fixes" because I'm not sure this covers 100% of that!)

yarn.lock Outdated Show resolved Hide resolved
As part of the improvements made between 3.24 and 3.28, the router
microlib is now lazily loaded. When these changes were made, there were
a couple cases where it *should* be possible to access router state in
a non-application test (integration etc.) but it currently is not
because the router is not necessarily set up. Since `setupRouter` is
idempotent, call it in those functions so that if it is *not* set up,
it gets set up, and otherwise it will continue working as expected.
@rwjblue rwjblue merged commit f828888 into emberjs:master Aug 30, 2021
@rwjblue rwjblue added the Bug label Aug 30, 2021
@chriskrycho chriskrycho deleted the router-setup-for-tests branch August 30, 2021 20:32
@NullVoxPopuli
Copy link
Contributor

should this apply to isActive as well?

@sly7-7
Copy link
Contributor

sly7-7 commented Sep 15, 2021

@chriskrycho I remember working a bit on #19405 (In fact, I were clumpsy, because I made a similar PR on my own side). The setupRouter() thing, before, was here, https://github.com/emberjs/ember.js/pull/19405/files#diff-bdcd334bfbf30baf672240b941910d9462e59b46fb9091402ee107f214c40045L76, and I think it would be a good move to put that setup at that place again. So that accessing the router the first time, ensure it is set up. In my Pr #19454 I did'nt remove the setupRouter thing, and all tests were green

@chriskrycho
Copy link
Contributor Author

@sly7-7 I only just saw this, sorry—I don't have any particular attachment to the way I implemented this, so if you've got a better one, landing it seems great!

@chriskrycho
Copy link
Contributor Author

@NullVoxPopuli I don't know off the top of my head!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants