Skip to content

Commit

Permalink
Work around a hard redirect when programmatically clicking an <a> ins…
Browse files Browse the repository at this point in the history
…ide a PowserSelect's <li>
  • Loading branch information
lolmaus committed Oct 5, 2023
1 parent a377569 commit 128f6ae
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions tests/acceptance/header-search-test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { click, fillIn, currentURL } from '@ember/test-helpers';
import { click, fillIn, find, currentURL } from '@ember/test-helpers';
import { module, test } from 'qunit';
import { setupEmberObserverTest } from '../helpers/setup-ember-observer-test';
import { selectChoose } from 'ember-power-select/test-support/helpers';
Expand Down Expand Up @@ -122,7 +122,19 @@ module('Acceptance | header search', function (hooks) {

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

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

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

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

await click('.test-search-result-jump-to-full-search-link');
await click(
find('.test-search-result-jump-to-full-search-link').parentElement
);

assert.equal(
currentURL(),
Expand Down

0 comments on commit 128f6ae

Please sign in to comment.