Skip to content

make THEN step for visibility ignore irrelevant invisible elements #66

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
5 changes: 3 additions & 2 deletions addon-test-support/-private/steps/power-select.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,10 @@ const steps = {
const trigger = powerSelectFindTrigger(element);
assert('Trigger not found', trigger);

const hasAriaDisabled = trigger.getAttribute('aria-disabled');
not
? expect(trigger).not.to.have.attr('aria-disabled')
: expect(trigger).to.have.attr('aria-disabled');
? expect(hasAriaDisabled).not.be.oneOf([null, false])
: expect(hasAriaDisabled).to.be.truthy;
},

async "Then there should be (NO|no )?(?:(\\d+) )items? in the dropdown $opinionatedElement"(no, countStr, [collection/* , label, selector */]) {
Expand Down
25 changes: 13 additions & 12 deletions addon-test-support/-private/steps/then.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,20 +64,21 @@ const steps = {
},

"Then (?:(\\d+) )?$opinionatedElement should (not |NOT )?be visible"(countRaw, [collection/* , label, selector */], no) {
assert(`Don't use NOT and number at the same time`, !(no && countRaw));

let count =
no ? 0 :
const count =
countRaw ? parseInt(countRaw, 10) :
1;

let m = `Element count`;
expect(collection, m).to.have.length(count);

collection.forEach((element, i) => {
m = `Element #${i} (zero-indexed) visibility`;
expect(isVisible(element), m).to.be.true;
});
const countVisible = collection.filter(element => isVisible(element)).length;
if (no) {
if (countRaw !== undefined) {
// check exact match of invisible elements
expect(collection.length - countVisible, 'Invisible element count').to.equal(count);
} else {
// check no element is visible
expect(countVisible, 'Visible element count').to.equal(0);
}
} else {
expect(countVisible, 'Visible element count').to.equal(count);
}
},

"Then I should see (NO |no )?(?:(\\d+) )?$opinionatedElement"(no, countRaw, [collection, label, selector]) {
Expand Down