-
-
Notifications
You must be signed in to change notification settings - Fork 259
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
visit() throws TransitionAborted error #332
Comments
@rwjblue did you have a chance to look at this? I am happy to work on a PR, if we agree what the solution should be. (this is the only remaining issue left for our app's test suite refactoring PR ;)) I am not fully aware of the inner workings, but it puzzles me that clicking on the |
@simonihmig — we've been running into this too. Just opened a PR with a failing test and a place to start: #373 (I'd be curious if it fixes your issue) |
☝️ We're having the same issue when migrating to the new testing API. |
I have some The only way for my test to pass is:
|
I am also experiencing this issue when migrating our test suite ( We are using Based on @NullVoxPopuli guidance, our current workaround has been to implement a wrapper of the
|
@ppcano that's pretty much what I'm doing now (for re-usability) import { visit as dangerousVisit } from '@ember/test-helpers';
async function visit(url: string) {
try {
await dangerousVisit(url);
} catch (e) {
console.error(e);
}
}
// tests omitted I like your explicit checking for the TransitionAborted though |
Also experiencing this when |
Minor addition to @ppcano's solution as the original import { settled, visit as _visit } from '@ember/test-helpers';
export async function visit(url: string) {
try {
await _visit(url);
} catch (e) {
if (e.message !== 'TransitionAborted') {
throw e;
}
}
await settled();
} |
This also includes a new helper (credit to @ppcano here: emberjs/ember-test-helpers#332 (comment)) to work around emberjs/ember-test-helpers#332.
This also includes a new helper (credit to @ppcano here: emberjs/ember-test-helpers#332 (comment)) to work around emberjs/ember-test-helpers#332.
* Convert broadcasts test to new style * Convert home/with-repositories to new testing style * Fix ESLint error * Convert another test * Silence ember-keyboard-shortcuts deprecation * Convert owner not found test * Update another test * Convert enterprise banner test * Convert enterprise/navigation test * Ensure user is signed out in navigation test This causes test flappiness when running all tests together * Convert repo active on org test * Convert automatic sign out test This also includes a new helper (credit to @ppcano here: emberjs/ember-test-helpers#332 (comment)) to work around emberjs/ember-test-helpers#332. * Fix ESLint errors * Convert sign out test * Convert feature flags test * Convert pull requests test * Convert builds restart test * Convert builds view pull request * Convert invalid builds test * Convert build stages test * Convert search flow test * Convert profile not found test * Convert profile redirect test * Convert profile billing test (phew) * Convert no search results test * Convert user settings test * Convert basic layout test * Convert profile filtering test * Conver view token test * Convert test and remove unsightly unless/else * Convert default layout test * Convert header layout test * Convert cta layout test * Convert layout/plans test * Convert job build matrix test * Convert jobs/restart test * Convert repo trigger build * Convert invalid job log test * Convert job test and fix resulting errors * Convert job log error test * Convert job delete test * Convert job debug test * Convert job cancel test * Convert repo/not found test * Convert repo/requests test * Whoops missed the helper file * Convert build list routes test * Convert repo branches test * Convert repo caches test * Fix helper import in page object * Convert repo show test * Convert public pusher test * More conversions * Clear local storage between tests as well * Missed part of the test * Convert first sync test * Add ember-lifeline Hoping based on https://engineering.linkedin.com/blog/2018/01/ember-timer-leaks that it will help us identify some leakage that is causing some annoying test flappiness. * Add data-test attrs to be able to use waitFor helper * Convert sync test and remove unnecessary timeout/corresponding config * Revert "Add ember-lifeline" Was just an experiment, removing for now. This reverts commit 9e434c4. * Fix ESLint errors * Convert skipped test (it is still skipped) * Remove use of custom waitForElement helper This is now built-in as `waitFor` within @ember/test-helpers. * Convert environment instance initializer unit test * Convert pro environment test and fix formatting in another test * Import correct initialize function in test * Skip sync tests temporarily It appears that these tests are very flaky, so need to figure out a way to permanently fix them. I do not want them, however, to hold up this chunk of work. * Remove legacy test helpers * Add space for formatting * Convert "unit" test to integration test This does lose a single assertion that we are calling the auth service correctly, but I would argue that this should be a unit test on the auth service if it is needed at all. * Fix ESLint errors * Add comment regarding slow acceptance test * Move final tests within module block This was causing a super weird error regarding `window.wait`. * Remove unnecessary import We no longer use `withFeature` but rather import `enableFeature` directly in any test that needs it * Remove logging statement from template * Use our own setupApplicationTest helper This will automatically sign a user out and clear browser state, ensuring every test starts off with the same state * Remove unnecessary storage calls This already happens within `setupApplicationTest`. * Remove unnecessary use of signOutUser helper I have left it in place for now (in case it has some use later), but we reset the local/session storage anyway before each acceptance test, and our only uses of it right now were essentially duplicating that work.
Thanks to @ppcano for the visitWithAbortedTransition suggestion here: emberjs/ember-test-helpers#332
Im still having this issue, in my case this happens if i add a |
What is in your |
Make sure you're returning something from an asynchronous |
what would you return? I regularly do this: async beforeModel() {
if (await some condition not met) {
return this.transitionTo('do something');
}
} |
Im returning nothing: async beforeModel() {
if (logic) {
await something;
}
if (!logic2) {
this.replaceWith("/some/url");
}
} Should i put a |
Because otherwise, the |
@rwjblue Hmm in my failing test the problem occurs even with a |
Sadly i cant really debug it since the stack trace is just backburner calls. And stepping through the |
@rwjblue We are running into this as well. The difference is that we are actually returning the abort. Any idea why this is still a problem based on the following code? async beforeModel () {
const user = await this.auth.user,
hints = user.get('shownHints');
if (!hints || !hints.includes('documents')) {
return this.transitionTo('account.documents.intro');
}
} Previously user was a preset val, now it's a promise, so we have to await. Hence the reason we are "running into it". |
just upgraded from 3.5.1 to 3.18.0 and am seeing this on any routes that we redirect in async beforeModel. similar to others, I'm doing something like this.
removing the async will remove the TransitionAborted error in tests. |
Someone want to throw together a small repro repo, might be worth stepping through this again 🤔 |
Thanks for the fast response Robert. |
Awesome, I'll try to poke at the repro this week. I remember looking through @simonihmig's initial repro, but things have changed enough upstream that it seems worth digging through again... |
Fwiw using |
* Handle api explorer routing error - For some reason when routing is done during async process, router transtionTo throws the TransitionAbortedError - As a fix treat this particular error as success since it doesn't interfere in the routing - Reference: emberjs/ember-test-helpers#332 * Added changelog
* Handle api explorer routing error - For some reason when routing is done during async process, router transtionTo throws the TransitionAbortedError - As a fix treat this particular error as success since it doesn't interfere in the routing - Reference: emberjs/ember-test-helpers#332 * Added changelog
* Handle api explorer routing error - For some reason when routing is done during async process, router transtionTo throws the TransitionAbortedError - As a fix treat this particular error as success since it doesn't interfere in the routing - Reference: emberjs/ember-test-helpers#332 * Added changelog
What if you invoke
https://deprecations.emberjs.com/v3.x/#toc_routing-transition-methods |
* Handle api explorer routing error - For some reason when routing is done during async process, router transtionTo throws the TransitionAbortedError - As a fix treat this particular error as success since it doesn't interfere in the routing - Reference: emberjs/ember-test-helpers#332 * Added changelog
* Handle api explorer routing error - For some reason when routing is done during async process, router transtionTo throws the TransitionAbortedError - As a fix treat this particular error as success since it doesn't interfere in the routing - Reference: emberjs/ember-test-helpers#332 * Added changelog
* Handle api explorer routing error - For some reason when routing is done during async process, router transtionTo throws the TransitionAbortedError - As a fix treat this particular error as success since it doesn't interfere in the routing - Reference: emberjs/ember-test-helpers#332 * Added changelog
do we have a resolution here? having I know fixing it would have to be a breaking release... but... that's fine? 🙃 |
is this resolved? |
nope. imo, someone should submit a PR that requires a breaking change of this library (major bump), and catches TransitionAborted errors. |
this Issue is mentioned in 20 different places in our code. with ToDos |
You're welcome 😂 |
Riffing on @NullVoxPopuli, how about an extra key for the |
Is there any updates on this issue? In a test the only way to succede is to catch the exception generated by the |
I discovered a new workaround after not being able to get the other workarounds mentioned above working in Ember 4. I'm not entirely sure why this is working, but doing the transition within a function delayed via
I think this is because it moves the entire transition out of the promise chain, so the rejection is not captured by For context, the transition itself is happening within
The
This works because the second parameter of |
I would love to have this update so we don't have to define our own to workaround this. |
If someone wants to do the Code/PR work, I can advocate for it to the ember core team and write up an RFC if needed, etc |
The previous implementation of `followRedirects()` would catch a transition rejection and check the router for an `activeTransition`. This can become problematic in async situations because the destination transition may have resolved before the `reject` is scheduled on the previous transition. One such case is when redirecting from an async model hook to a destination route with synchronous model hooks. This commit updates the `followRedirects()` logic to explicitly follow the redirect chain rather than relying on the presence of an `activeTransition`. This makes following redirects work correctly regardless of any scheduling concerns. This problem has been noted in the context of the `visit()` test helper: - emberjs/ember-test-helpers#332 - emberjs/ember.js#17150
It looks like this issue extends beyond the I have a failing test case and fix for router.js here: tildeio/router.js#335 And then a tweak to Ember core so that it leans on |
The previous implementation of `followRedirects()` would catch a transition rejection and check the router for an `activeTransition`. This can become problematic in async situations because the destination transition may have resolved before the `reject` is scheduled on the previous transition. One such case is when redirecting from an async model hook to a destination route with synchronous model hooks. This commit updates the `followRedirects()` logic to explicitly follow the redirect chain rather than relying on the presence of an `activeTransition`. This makes following redirects work correctly regardless of any scheduling concerns. This problem has been noted in the context of the `visit()` test helper: - emberjs/ember-test-helpers#332 - emberjs/ember.js#17150
This adds the actual error message from Ember's router to the (too generic) message from `visitable`. This is especially important when your test needs to know what kind of error was triggered. For example some tests might want to handle `TransitionAborted` errors differently, see emberjs/ember-test-helpers#332 (comment).
* Better errors from visitable This adds the actual error message from Ember's router to the (too generic) message from `visitable`. This is especially important when your test needs to know what kind of error was triggered. For example some tests might want to handle `TransitionAborted` errors differently, see emberjs/ember-test-helpers#332 (comment). * Pass original error message from visit as Error#cause * preserve original error instance ...under the `cause.error` * doc: add a brief note about the `cause.error` in the `visitable` error instance --------- Co-authored-by: Ruslan Hrabovyi <kudgo.test@gmail.com>
As discussed in Slack, I was unexpectedly seeing failing tests where a transition was aborted.
ApplicationInstance#visit
is throwing it hereAs I said I cannot share the app, but this is the human readable test spec (we have a rather exotic test setup with
ember-cli-yadda
😉):The
I go to the user profile page
step is throwing the exception, which is callingvisit('/user/profile')
internally.I quickly assembled this little repro, that resembles what we were doing in a very minimal way:
https://github.com/simonihmig/ember-visit-transition-abort
All the acceptance tests are passing, with the exception of this last one:
https://github.com/simonihmig/ember-visit-transition-abort/blob/master/tests/acceptance/auth-test.js#L36-L40
The text was updated successfully, but these errors were encountered: