From 22afe0801f079e3e05f7d4d28a8f4934a527941f Mon Sep 17 00:00:00 2001 From: Vitalii Elenhaupt <3624712+veelenga@users.noreply.github.com> Date: Sun, 22 Nov 2020 18:05:38 +0200 Subject: [PATCH] Do not warn when selecting a text with comma (#521) --- addon-test-support/-private/helpers.js | 17 +++++++++-------- .../comma-separated-selector-test.js | 16 +++++++++++++++- 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/addon-test-support/-private/helpers.js b/addon-test-support/-private/helpers.js index f521f1df..ee5eab72 100644 --- a/addon-test-support/-private/helpers.js +++ b/addon-test-support/-private/helpers.js @@ -27,6 +27,15 @@ class Selector { scope = this.calculateScope(this.targetNode, this.targetScope); } + deprecate( + 'Usage of comma separated selectors is deprecated in ember-cli-page-object', + `${scope} ${this.targetSelector}`.indexOf(',') === -1, { + id: 'ember-cli-page-object.comma-separated-selectors', + until: "2.0.0", + url: 'https://ember-cli-page-object.js.org/docs/v1.16.x/deprecations/#comma-separated-selectors', + } + ); + filters = this.calculateFilters(this.targetFilters); let selector = $.trim(`${scope} ${this.targetSelector}${filters}`); @@ -37,14 +46,6 @@ class Selector { selector = ':first'; } - deprecate( - 'Usage of comma separated selectors is deprecated in ember-cli-page-object', selector.indexOf(',') === -1, { - id: 'ember-cli-page-object.comma-separated-selectors', - until: "2.0.0", - url: 'https://ember-cli-page-object.js.org/docs/v1.16.x/deprecations/#comma-separated-selectors', - } - ); - return selector; } diff --git a/tests/integration/deprecations/comma-separated-selector-test.js b/tests/integration/deprecations/comma-separated-selector-test.js index af90c97b..b84e70cc 100644 --- a/tests/integration/deprecations/comma-separated-selector-test.js +++ b/tests/integration/deprecations/comma-separated-selector-test.js @@ -2,7 +2,7 @@ import { module, test } from 'qunit'; import { setupRenderingTest } from 'ember-qunit'; import hbs from 'htmlbars-inline-precompile'; -import { create, text } from 'dummy/tests/page-object'; +import { create, text, clickOnText } from 'dummy/tests/page-object'; import require from 'require'; if (require.has('@ember/test-helpers')) { @@ -69,5 +69,19 @@ if (require.has('@ember/test-helpers')) { assert.expectNoDeprecation(); }); + + test('don\'t show deprecation when the selector contains text with comma', async function(assert) { + let page = create({ + clickOnButton: clickOnText('button') + }); + + await render(hbs`
+ +
`); + + page.clickOnButton('Lorem, Ipsum'); + + assert.expectNoDeprecation(); + }); }); }