MOBILE-3905 behat: Test swipe navigation
parent
67ec08edea
commit
1ead9612a3
|
@ -352,7 +352,7 @@
|
|||
}
|
||||
}
|
||||
|
||||
return [...uniqueElements];
|
||||
return Array.from(uniqueElements);
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -793,6 +793,23 @@
|
|||
return 'OK';
|
||||
};
|
||||
|
||||
/**
|
||||
* Get an Angular component instance.
|
||||
*
|
||||
* @param {string} selector Element selector
|
||||
* @param {string} className Constructor class name
|
||||
* @return {object} Component instance
|
||||
*/
|
||||
var behatGetComponentInstance = function(selector, className) {
|
||||
const activeElement = Array.from(document.querySelectorAll(`.ion-page:not(.ion-page-hidden) ${selector}`)).pop();
|
||||
|
||||
if (!activeElement || !activeElement.__ngContext__) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return activeElement.__ngContext__.find(node => node?.constructor?.name === className);
|
||||
};
|
||||
|
||||
// Make some functions publicly available for Behat to call.
|
||||
window.behat = {
|
||||
pressStandard : behatPressStandard,
|
||||
|
@ -802,5 +819,6 @@
|
|||
press : behatPress,
|
||||
setField : behatSetField,
|
||||
getHeader : behatGetHeader,
|
||||
getComponentInstance: behatGetComponentInstance,
|
||||
};
|
||||
})();
|
||||
|
|
|
@ -182,6 +182,18 @@ class behat_app extends behat_base {
|
|||
$this->wait_for_pending_js();
|
||||
}
|
||||
|
||||
/**
|
||||
* Trigger swipe gesture.
|
||||
*
|
||||
* @When /^I swipe to the (left|right) in the app$/
|
||||
* @param string $direction
|
||||
*/
|
||||
public function i_swipe_in_the_app(string $direction) {
|
||||
$method = 'swipe' . ucwords($direction);
|
||||
|
||||
$this->evaluate_script("behat.getComponentInstance('core-swipe-navigation', 'CoreSwipeNavigationComponent').$method()");
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if elements are selected in the app.
|
||||
*
|
||||
|
|
|
@ -0,0 +1,63 @@
|
|||
@app @javascript
|
||||
Feature: It navigates using gestures.
|
||||
|
||||
Background:
|
||||
Given the following "users" exist:
|
||||
| username | firstname | lastname |
|
||||
| student1 | Student | First |
|
||||
| teacher1 | Teacher | First |
|
||||
| student2 | Student | Second |
|
||||
| teacher2 | Teacher | Second |
|
||||
| student3 | Student | Third |
|
||||
And the following "courses" exist:
|
||||
| fullname | shortname |
|
||||
| Course 1 | C1 |
|
||||
And the following "course enrolments" exist:
|
||||
| user | course | role |
|
||||
| student1 | C1 | student |
|
||||
| teacher1 | C1 | teacher |
|
||||
| student2 | C1 | student |
|
||||
| teacher2 | C1 | teacher |
|
||||
| student3 | C1 | student |
|
||||
|
||||
Scenario: Swipe between participants
|
||||
When I enter the app
|
||||
And I log in as "student1"
|
||||
And I press "Course 1" near "Course overview" in the app
|
||||
And I press "Participants" in the app
|
||||
And I press "Student First" in the app
|
||||
And I swipe to the left in the app
|
||||
Then I should find "Teacher First" in the app
|
||||
|
||||
When I swipe to the left in the app
|
||||
Then I should find "Student Second" in the app
|
||||
|
||||
When I swipe to the right in the app
|
||||
Then I should find "Teacher First" in the app
|
||||
|
||||
When I swipe to the right in the app
|
||||
Then I should find "Student First" in the app
|
||||
|
||||
When I swipe to the right in the app
|
||||
Then I should find "Student First" in the app
|
||||
|
||||
Scenario: Swipe between filtered participants
|
||||
When I enter the app
|
||||
And I log in as "student1"
|
||||
And I press "Course 1" near "Course overview" in the app
|
||||
And I press "Participants" in the app
|
||||
And I press "Search" in the app
|
||||
And I set the field "Search" to "student" in the app
|
||||
And I press "Search" "button" near "Clear search" in the app
|
||||
And I press "Student First" in the app
|
||||
And I swipe to the left in the app
|
||||
Then I should find "Student Second" in the app
|
||||
|
||||
When I swipe to the left in the app
|
||||
Then I should find "Student Third" in the app
|
||||
|
||||
When I swipe to the right in the app
|
||||
Then I should find "Student Second" in the app
|
||||
|
||||
When I swipe to the right in the app
|
||||
Then I should find "Student First" in the app
|
Loading…
Reference in New Issue