MOBILE-3947 behat: Fix isSelected function
parent
d912d9d9af
commit
2335ff8010
|
@ -77,16 +77,25 @@ export class TestingBehatDomUtilsService {
|
||||||
*
|
*
|
||||||
* @param element Element.
|
* @param element Element.
|
||||||
* @param container Container.
|
* @param container Container.
|
||||||
|
* @param firstCall Whether this is the first call of the function.
|
||||||
* @returns Whether the element is selected or not.
|
* @returns Whether the element is selected or not.
|
||||||
*/
|
*/
|
||||||
isElementSelected(element: HTMLElement, container: HTMLElement): boolean {
|
isElementSelected(element: HTMLElement, container: HTMLElement, firstCall = true): boolean {
|
||||||
const ariaCurrent = element.getAttribute('aria-current');
|
const ariaCurrent = element.getAttribute('aria-current');
|
||||||
if (
|
const ariaSelected = element.getAttribute('aria-selected');
|
||||||
(ariaCurrent && ariaCurrent !== 'false') ||
|
const ariaChecked = element.getAttribute('aria-checked');
|
||||||
(element.getAttribute('aria-selected') === 'true') ||
|
|
||||||
(element.getAttribute('aria-checked') === 'true')
|
if (ariaCurrent || ariaSelected || ariaChecked) {
|
||||||
) {
|
return (!!ariaCurrent && ariaCurrent !== 'false') ||
|
||||||
return true;
|
(!!ariaSelected && ariaSelected === 'true') ||
|
||||||
|
(!!ariaChecked && ariaChecked === 'true');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (firstCall) {
|
||||||
|
const inputElement = element.closest('ion-checkbox, ion-radio, ion-toggle')?.querySelector('input');
|
||||||
|
if (inputElement) {
|
||||||
|
return inputElement.value === 'on';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const parentElement = this.getParentElement(element);
|
const parentElement = this.getParentElement(element);
|
||||||
|
@ -94,7 +103,7 @@ export class TestingBehatDomUtilsService {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.isElementSelected(parentElement, container);
|
return this.isElementSelected(parentElement, container, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue