From 90170ae82a90816be31cfd8b3428a74c9f6fd51f Mon Sep 17 00:00:00 2001 From: Ruslan Hrabovyi Date: Fri, 27 Oct 2023 00:07:58 +0200 Subject: [PATCH] fix ember-classic scenario --- test-app/tests/unit/-private/query-test.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/test-app/tests/unit/-private/query-test.js b/test-app/tests/unit/-private/query-test.js index 9424e178..73b3bf8a 100644 --- a/test-app/tests/unit/-private/query-test.js +++ b/test-app/tests/unit/-private/query-test.js @@ -4,6 +4,7 @@ import { Query } from 'ember-cli-page-object/-private/query'; import { setupRenderingTest } from '../../helpers'; // @ts-expect-error test-only private import import Locator from 'ember-cli-page-object/-private/query/locator'; +import { getRootElement } from '@ember/test-helpers'; const renderList = (testContext, options) => { return testContext.createTemplate( @@ -33,9 +34,14 @@ module('Unit | -private/query', function (hooks) { `); assert.equal(q.toString(), ':first-child:eq(0)'); + + // due to ember-classic scenario to enable the application-template-wrapper + // we have one extra element in the DOM, which prevents us from using the hard-coded expected selector + const firstChild = getRootElement().querySelector(':first-child'); assert.deepEqual( q.all().map((e) => e.id), - ['root'] + // for all the scenarios, but ember-classic it must be ['root'] + [firstChild.id] ); }); @@ -165,9 +171,13 @@ module('Unit | -private/query', function (hooks) { await renderPlayground(this); + // due to ember-classic scenario to enable the application-template-wrapper + // we have one extra element in the DOM, which prevents us from using the hard-coded expected selector + const firstChild = getRootElement().querySelector(':first-child'); assert.deepEqual( q.all().map((el) => el.id), - ['root1'] + // for all the scenarios, but ember-classic it must be ['root'] + [firstChild.id] ); assert.equal(q.toString(), ':first-child:eq(0)'); });