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

Add failing test case for chained redirects via routeWillChange #20612

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions packages/ember/tests/routing/router_service_test/events_test.js
Original file line number Diff line number Diff line change
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
Loading