From 614b6eef515821f5c2a20dd45e424145b53bf44b Mon Sep 17 00:00:00 2001 From: Richard Livsey Date: Tue, 18 Sep 2018 14:13:25 +0100 Subject: [PATCH] Failing test to demonstrate query params bug If there's: 1. a dynamic segment 2. a loading template 3. a route with a model hook that returns a promise 4. a query param defined then the query param is not sticky on link-tos Possibly related to https://github.com/emberjs/ember.js/issues/12107 --- .../link_to_with_query_params_test.js | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/packages/ember/tests/helpers/link_to_test/link_to_with_query_params_test.js b/packages/ember/tests/helpers/link_to_test/link_to_with_query_params_test.js index ae5eed0fc94..a716afe6e1d 100644 --- a/packages/ember/tests/helpers/link_to_test/link_to_with_query_params_test.js +++ b/packages/ember/tests/helpers/link_to_test/link_to_with_query_params_test.js @@ -605,6 +605,49 @@ moduleFor( }); } + ['@test link-to with dynamic segment and loading route regression test'](assert) { + this.router.map(function() { + this.route('foo', { path: ':foo' }, function() { + this.route('bar', function() { + this.route('baz'); + }); + }); + }); + + this.addTemplate( + 'foo.bar', + ` + {{link-to 'Baz' 'foo.bar.baz' id='baz-link'}} + ` + ); + + this.addTemplate('foo.bar.loading', 'Loading'); + + this.add( + 'controller:foo.bar', + Controller.extend({ + queryParams: ['qux'], + qux: null, + }) + ); + + this.add( + 'route:foo.bar.baz', + Route.extend({ + model() { + return new RSVP.Promise(resolve => { + setTimeout(resolve, 1); + }); + }, + }) + ); + + return this.visit('/foo/bar/baz?qux=abc').then(() => { + let bazLink = this.$('#baz-link'); + assert.equal(bazLink.attr('href'), '/foo/bar/baz?qux=abc'); + }); + } + ['@test link-to default query params while in active transition regression test'](assert) { this.router.map(function() { this.route('foos');