Skip to content

Commit

Permalink
[BUGFIX release] Add regression test for QP only link-to inside error…
Browse files Browse the repository at this point in the history
… route.

Reproduce failure in #17963: `<LinkTo>` without `@route` param but with
`@query` breaks when navigating to error route.

Co-authored-by: Robert Jackson <me@rwjblue.com>
(cherry picked from commit efbc937)
  • Loading branch information
dgeb authored and rwjblue committed Jun 17, 2019
1 parent 39bb1c3 commit e647112
Showing 1 changed file with 71 additions and 0 deletions.
Expand Up @@ -239,6 +239,77 @@ if (EMBER_GLIMMER_ANGLE_BRACKET_BUILT_INS) {
});
}

['@test generates proper href for `LinkTo` with no @route after transitioning to an error route GH#17963'](
assert
) {
this.router.map(function() {
this.route('bad');
});

this.add(
'controller:application',
Controller.extend({
queryParams: ['baz'],
})
);

this.add(
'route:bad',
Route.extend({
model() {
throw new Error('bad!');
},
})
);

this.addTemplate('error', `Error: {{model.message}}`);

this.addTemplate(
'application',
`
<LinkTo id="bad-link" @route="bad">
Bad
</LinkTo>
<LinkTo id="good-link" @query={{hash baz='lol'}}>
Good
</LinkTo>
{{outlet}}
`
);

return this.visit('/')
.then(async () => {
assert.equal(this.$('#good-link').length, 1, 'good-link should be in the DOM');
assert.equal(this.$('#bad-link').length, 1, 'bad-link should be in the DOM');

let goodLink = this.$('#good-link');
assert.equal(goodLink.attr('href'), '/?baz=lol');

return this.visit('/bad');
})
.then(() => {
assert.equal(this.$('#good-link').length, 1, 'good-link should be in the DOM');
assert.equal(this.$('#bad-link').length, 1, 'bad-link should be in the DOM');

let goodLink = this.$('#good-link');
// should still be / because we never entered /bad (it errored before being fully entered)
// and error states do not get represented in the URL, so we are _effectively_ still
// on /
assert.equal(goodLink.attr('href'), '/?baz=lol');

runTask(() => this.click('#good-link'));

let applicationController = this.getController('application');
assert.deepEqual(
applicationController.getProperties('baz'),
{ baz: 'lol' },
'index controller QP properties updated'
);
});
}

['@test supplied QP properties can be bound'](assert) {
this.addTemplate(
'index',
Expand Down

0 comments on commit e647112

Please sign in to comment.