Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 51 additions & 1 deletion test-app/tests/integration/components/basic-dropdown-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
waitUntil,
find,
settled,
pauseTest
} from '@ember/test-helpers';

let deprecations = [];
Expand Down Expand Up @@ -1397,6 +1398,55 @@ module('Integration | Component | basic-dropdown', function (hooks) {
wormhole.remove();
});

test('Shadow dom: Its `toggle` action opens and closes the dropdown with renderInPlace', async function (assert) {

await render(hbs`
<Shadow>
<BasicDropdown @renderInPlace={{true}} as |dropdown|>
<dropdown.Trigger>Click me</dropdown.Trigger>
<dropdown.Content>
<div style="height: 100px; width: 100px; background: black" id="dropdown-is-opened"></div>
</dropdown.Content>
</BasicDropdown>
</Shadow>
`);

assert
.dom('#dropdown-is-opened', this.element.getRootNode())
.doesNotExist('The dropdown is closed');

const triggerElement = find('[data-shadow]')?.shadowRoot.querySelector(
'.ember-basic-dropdown-trigger',
);

await click(triggerElement);

assert
.dom('.ember-basic-dropdown-content', find('[data-shadow]').shadowRoot)
.exists('The dropdown is rendered');


assert.dom('#dropdown-is-opened', find('[data-shadow]').shadowRoot).exists('The dropdown is opened');

await click(find('[data-shadow]').shadowRoot.getElementById('dropdown-is-opened'));

assert.dom('#dropdown-is-opened', find('[data-shadow]').shadowRoot).exists('The dropdown stays opened when clicking content');

await click(triggerElement);

assert
.dom('#dropdown-is-opened', find('[data-shadow]').shadowRoot)
.doesNotExist('The dropdown is closed again');

await click(triggerElement);

assert.dom('#dropdown-is-opened', find('[data-shadow]').shadowRoot).exists('The dropdown is opened 2d time');

await click(find('[data-shadow]').shadowRoot.getElementById('dropdown-is-opened'));

assert.dom('#dropdown-is-opened', find('[data-shadow]').shadowRoot).exists('The dropdown stays opened when clicking content after 2d open');
});

test('Shadow dom: Its `toggle` action opens and closes the dropdown when wormhole is inside shadow dom', async function (assert) {
await render(hbs`
<Shadow>
Expand All @@ -1406,7 +1456,7 @@ module('Integration | Component | basic-dropdown', function (hooks) {
<div id="dropdown-is-opened"></div>
</dropdown.Content>
</BasicDropdown>

<div id="wormhole-in-shadow-dom"></div>
</Shadow>
`);
Expand Down
Loading