Skip to content

Commit

Permalink
Failing test for chained redirects via routeWillChange
Browse files Browse the repository at this point in the history
When there is a chain of two redirects triggered via a routeWillChange hook, the destination route model() hook is called twice, and is called with the wrong parameters.

Failing test for emberjs#20611
  • Loading branch information
davidtaylorhq committed Dec 28, 2023
1 parent cc4eaf4 commit 04f2de4
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions packages/ember/tests/routing/router_service_test/events_test.js
Expand Up @@ -299,6 +299,44 @@ moduleFor(
});
}

'@test chained redirection with `transitionTo` and url params'(assert) {
this.add(
`route:dynamic`,
Route.extend({
router: service(),
model(params) {
assert.step(`loaded-${params.dynamic_id}`);
},
})
);

return this.visit('/').then(() => {
this.routerService.on('routeWillChange', (transition) => {
let to = transition.to;
if (to.name === 'dynamic') {
assert.step(`willchange-to-${to.params.dynamic_id}`);
if (to.params.dynamic_id === '1') {
this.routerService.transitionTo('dynamic', '2');
} else if (to.params.dynamic_id === '2') {
this.routerService.transitionTo('dynamic', '3');
}
}
});

return this.routerService
.transitionTo('/dynamic/1')
.followRedirects()
.then(() => {
assert.verifySteps([
'willchange-to-1',
'willchange-to-2',
'willchange-to-3',
'loaded-3',
]);
});
});
}

'@test nested redirection with `replaceWith`'(assert) {
assert.expect(11);
let toChild = false;
Expand Down

0 comments on commit 04f2de4

Please sign in to comment.