Skip to content
Merged
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
25 changes: 6 additions & 19 deletions components/button/test/button-mixin.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,27 +101,14 @@ describe('ButtonMixin', () => {

describe('disabled button events', () => {

let documentClickHandler;

beforeEach(() => {
documentClickHandler = () => {
throw new Error('click event propagated to document');
};
document.addEventListener('click', documentClickHandler, { once: true });
});

afterEach(() => {
document.removeEventListener('click', documentClickHandler, { once: true });
});

it('should stop propagation of click events if button is disabled', async() => {
const el = await fixture(`<${tagName} disabled></${tagName}>`);
expect(() => clickElem(el)).to.not.throw();
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The switch from elem.click() (synchronous) to clickElem(elem) (asynchronous) means that instead of an exception (not) getting thrown, it was doing nothing since it became a Promise.

What I suspect happened is that the test then ended and the actual click would then happen sometime later... but occasionally that happened after the whole test suite was done and the browser was closed. That seems to have made Firefox quite upset which then caused any subsequent test that tries to click to also fail, hence the 130 failures.

});
const el = await fixture(`<div><${tagName} disabled></${tagName}></div>`);
let dispatched = false;
el.addEventListener('click', () => dispatched = true);

await clickElem(el.querySelector(tagName));

it('should stop propagation of click events if button is disabled with disabled-tooltip', async() => {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

disabled-tooltip has no impact on the event propagation, only disabled does. So removing this test.

const el = await fixture(`<${tagName} disabled disabled-tooltip="tooltip text"></${tagName}>`);
expect(() => clickElem(el)).to.not.throw();
expect(dispatched).to.be.false;
});

});
Expand Down
Loading