MOBILE-3947 behat: Fix tab select status check

main
Pau Ferrer Ocaña 2024-01-10 13:42:37 +01:00
parent b313555ebe
commit a90d4bda34
3 changed files with 10 additions and 6 deletions

View File

@ -32,7 +32,7 @@ Feature: Main Menu opens the right page
And "Dashboard" "text" should appear before "Site home" "text" in the ".core-tabs-bar" "css_element"
And "Home" "text" should appear before "My courses" "text" in the ".mainmenu-tabs" "css_element"
@ionic7_failure @lms_from4.0
@lms_from4.0
Scenario: Opens My Courses when defaulthomepage is set to My Courses
Given the following config values are set as admin:
| defaulthomepage | 3 |

View File

@ -76,11 +76,10 @@ export class TestingBehatDomUtilsService {
* Check if an element is selected.
*
* @param element Element.
* @param container Container.
* @param firstCall Whether this is the first call of the function.
* @returns Whether the element is selected or not.
*/
isElementSelected(element: HTMLElement, container: HTMLElement, firstCall = true): boolean {
isElementSelected(element: HTMLElement, firstCall = true): boolean {
const ariaCurrent = element.getAttribute('aria-current');
const ariaSelected = element.getAttribute('aria-selected');
const ariaChecked = element.getAttribute('aria-checked');
@ -96,14 +95,19 @@ export class TestingBehatDomUtilsService {
if (inputElement) {
return inputElement.value === 'on';
}
const tabButtonElement = element.closest('ion-tab-button');
if (tabButtonElement?.classList.contains('tab-selected')) {
return true;
}
}
const parentElement = this.getParentElement(element);
if (!parentElement || parentElement === container) {
if (!parentElement || parentElement.classList.contains('ion-page')) {
return false;
}
return this.isElementSelected(parentElement, container, false);
return this.isElementSelected(parentElement, false);
}
/**

View File

@ -326,7 +326,7 @@ export class TestingBehatRuntimeService {
return 'ERROR: No element matches locator to find.';
}
return TestingBehatDomUtils.isElementSelected(element, document.body) ? 'YES' : 'NO';
return TestingBehatDomUtils.isElementSelected(element) ? 'YES' : 'NO';
} catch (error) {
return 'ERROR: ' + error.message;
}