Skip to content

Commit 128f6ae

Browse files
committed
Work around a hard redirect when programmatically clicking an <a> inside a PowserSelect's <li>
1 parent a377569 commit 128f6ae

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

tests/acceptance/header-search-test.js

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { click, fillIn, currentURL } from '@ember/test-helpers';
1+
import { click, fillIn, find, currentURL } from '@ember/test-helpers';
22
import { module, test } from 'qunit';
33
import { setupEmberObserverTest } from '../helpers/setup-ember-observer-test';
44
import { selectChoose } from 'ember-power-select/test-support/helpers';
@@ -122,7 +122,19 @@ module('Acceptance | header search', function (hooks) {
122122

123123
await fillIn('.test-header-search input', 'test');
124124

125-
await click(findByText('.test-search-result-addon-link', 'addon-test'));
125+
/**
126+
* Note: Parent element <li> is being clicked here, whereas in real life user
127+
* clicks <a> inside <li>. The problem is that current implementation of the
128+
* component has an <a> inside PowerSelect that attaches a listener to <li>.
129+
* After upgrading to 3.28, this started producing a hard redirect that breaks
130+
* the flow of test and causes a browser timeout.
131+
* This only happens with programmatic click, while real mouse click behaves
132+
* as expected.
133+
* `.parentElement` should be removed once the hard redirect is figured out.
134+
*/
135+
await click(
136+
findByText('.test-search-result-addon-link', 'addon-test').parentElement
137+
);
126138

127139
assert.equal(
128140
currentURL(),
@@ -132,7 +144,9 @@ module('Acceptance | header search', function (hooks) {
132144

133145
await fillIn('.test-header-search input', 'foo');
134146

135-
await click('.test-search-result-jump-to-full-search-link');
147+
await click(
148+
find('.test-search-result-jump-to-full-search-link').parentElement
149+
);
136150

137151
assert.equal(
138152
currentURL(),

0 commit comments

Comments
 (0)