From c6ae97a79f962b97d9d95e38e15c1884abac82fc Mon Sep 17 00:00:00 2001 From: Alon Bukai Date: Sat, 16 Nov 2019 13:16:38 +0200 Subject: [PATCH 1/3] tests: Add failing test for QP helper with let --- .../link-to/query-params-curly-test.js | 21 ++++++++----------- 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/packages/@ember/-internals/glimmer/tests/integration/components/link-to/query-params-curly-test.js b/packages/@ember/-internals/glimmer/tests/integration/components/link-to/query-params-curly-test.js index bae22cde460..3067609a974 100644 --- a/packages/@ember/-internals/glimmer/tests/integration/components/link-to/query-params-curly-test.js +++ b/packages/@ember/-internals/glimmer/tests/integration/components/link-to/query-params-curly-test.js @@ -68,22 +68,19 @@ moduleFor( }); } - async ['@feature(ember-glimmer-angle-bracket-built-ins) `(query-params)` must be used in conjunction with `{{link-to}}']( - assert - ) { + ['@test `(query-params)` can be used outside of `{{link-to}}']() { this.addTemplate( 'index', - `{{#let (query-params foo='456' bar='NAW') as |qp|}}{{link-to 'Index' 'index' qp}}{{/let}}` + `{{#let (query-params foo='456' alon='BUKAI') as |qp|}}{{link-to 'Index' 'index' qp}}{{/let}}` ); - // TODO If we visit this page at all in production mode, it'll fail for - // entirely different reasons than what this test is trying to test. - let promise = DEBUG ? this.visit('/') : null; - - await assert.rejectsAssertion( - promise, - /The `\(query-params\)` helper can only be used when invoking the `{{link-to}}` component\./ - ); + return this.visit('/').then(async () => { + this.assertComponentElement(this.firstChild, { + tagName: 'a', + attrs: { href: '/?alon=BUKAI&foo=456', class: classMatcher('ember-view') }, + content: 'Index', + }); + }); } } ); From 676b8edd565f9a2e7ecd08961c2d6cfb068548b9 Mon Sep 17 00:00:00 2001 From: Alon Bukai Date: Sat, 16 Nov 2019 13:16:45 +0200 Subject: [PATCH 2/3] fix: Fixed link-to assert with (qp) helper --- .../-internals/glimmer/lib/components/link-to.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/@ember/-internals/glimmer/lib/components/link-to.ts b/packages/@ember/-internals/glimmer/lib/components/link-to.ts index ae3b034d57b..af5af9ff757 100644 --- a/packages/@ember/-internals/glimmer/lib/components/link-to.ts +++ b/packages/@ember/-internals/glimmer/lib/components/link-to.ts @@ -864,14 +864,14 @@ if (EMBER_GLIMMER_ANGLE_BRACKET_BUILT_INS) { ) ); - if (DEBUG && this.query === UNDEFINED) { - let { _models: models } = this; - let lastModel = models.length > 0 && models[models.length - 1]; + let { _models: models } = this; + if (models.length > 0) { + let lastModel = models[models.length - 1]; - assert( - 'The `(query-params)` helper can only be used when invoking the `{{link-to}}` component.', - !(lastModel && lastModel.isQueryParams) - ); + if (typeof lastModel === 'object' && lastModel !== null && lastModel.isQueryParams) { + this.query = lastModel.values; + models.pop(); + } } return; From e45ee5da523e630472259a73698f1136b1eb459e Mon Sep 17 00:00:00 2001 From: Alon Bukai Date: Sat, 16 Nov 2019 13:24:55 +0200 Subject: [PATCH 3/3] fix: Readd DEBUG in tests --- .../components/link-to/query-params-curly-test.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/@ember/-internals/glimmer/tests/integration/components/link-to/query-params-curly-test.js b/packages/@ember/-internals/glimmer/tests/integration/components/link-to/query-params-curly-test.js index 3067609a974..a5df75c22f0 100644 --- a/packages/@ember/-internals/glimmer/tests/integration/components/link-to/query-params-curly-test.js +++ b/packages/@ember/-internals/glimmer/tests/integration/components/link-to/query-params-curly-test.js @@ -68,7 +68,11 @@ moduleFor( }); } - ['@test `(query-params)` can be used outside of `{{link-to}}']() { + ['@test `(query-params)` can be used outside of `{{link-to}}'](assert) { + if (!DEBUG) { + assert.expect(0); + return; + } this.addTemplate( 'index', `{{#let (query-params foo='456' alon='BUKAI') as |qp|}}{{link-to 'Index' 'index' qp}}{{/let}}`