MOBILE-3947 behat: Fix tab select status check
This commit is contained in:
		
							parent
							
								
									b313555ebe
								
							
						
					
					
						commit
						a90d4bda34
					
				@ -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 |
 | 
			
		||||
 | 
			
		||||
@ -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);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
 | 
			
		||||
@ -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;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user