-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Bad timing routing issue, failing test #16342
base: main
Are you sure you want to change the base?
Conversation
c003bf5
to
2eb6799
Compare
2eb6799
to
490042f
Compare
|
||
this.add('route:dummy', Route.extend({ | ||
redirect() { | ||
return RSVP.resolve() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I understand well, this is specifically what the test is about ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct.
490042f
to
2b206f9
Compare
@wagenet I've updated (locally) this test to highlight the real issue (it needs an expectDeprecation because of the call to this.replaceWith()). |
'route:dummy', | ||
Route.extend({ | ||
redirect() { | ||
return RSVP.resolve().then(() => this.replaceWith('index')); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs something like this:
expectDeprecation(() => {
this.replaceWith('index');
}, 'Calling replaceWith on a route is deprecated. Use the RouterService instead.');
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated.
2b206f9
to
1801921
Compare
@rwjblue @wagenet, Could you guys please explain me the difference in term of behavior using Because for me, they are be the same. The one from Peter's test (somehow makes the test fail)
The one I just tried (the test is green this way).
I was thinking maybe await Promise.resolve() would be somehow synchronous, so I modified resolving the Promise after 500ms, and it's working too: |
I've made some other tiny experiment around redirect() {
return new RSVP.Promise((resolve) => {
count++;
// later(resolve, 1); // pass
// later(resolve, 0); // pass
// next(resolve); // pass
// run(resolve); // fails
// resolve(); // fails
}).then(() => {
assert.equal(count, 1);
expectDeprecation(() => {
this.replaceWith('index');
}, 'Calling replaceWith on a route is deprecated. Use the RouterService instead.');
});
},
async redirect() {
await new RSVP.Promise((resolve) => {
count++;
// later(resolve, 1); // pass
// later(resolve, 0); // pass
// next(resolve); // pass
// run(resolve); // pass
// resolve(); // pass
});
assert.equal(count, 1);
expectDeprecation(() => {
this.replaceWith('index');
}, 'Calling replaceWith on a route is deprecated. Use the RouterService instead.');
}, |
Possibly it has to do with the difference in the code generated by the transpiler. |
@wagenet I've had a discussion with @rwjblue on this thing. From the discord chat:
seems related to: tildeio/router.js#310 and emberjs/ember-test-helpers#332
|
@wagenet is this still relevant? |
1801921
to
e5564cc
Compare
@locks I just rebased. Looks like CI still fails. |
Is this still relevant? |
e5564cc
to
fe99bd9
Compare
Rebased again. If this still fails, it's relevant though if we replace the router then it won't be :D |
Not really sure what to name this, or if this test is in the right area,
but it is an issue!