commit
549b0ce096
|
@ -133,9 +133,10 @@ Feature: Test basic usage of choice activity in app
|
|||
| choice | Test single choice name | Test single choice description | C1 | choice1 | Option 1, Option 2, Option 3 | 0 | 0 | 1 |
|
||||
When I enter the course "Course 1" as "student1" in the app
|
||||
And I press "Display options" in the app
|
||||
And I press "Show download options" in the app
|
||||
And I press "Download" near "Test single choice name" in the app
|
||||
Then I should find "Downloaded" near "Test single choice name" in the app
|
||||
And I press "Manage course storage" in the app
|
||||
And I press "Download" within "Test single choice name" "ion-item" in the app
|
||||
Then I should find "Downloaded" within "Test single choice name" "ion-item" in the app
|
||||
And I press the back button in the app
|
||||
|
||||
When I switch offline mode to "true"
|
||||
And I press "Test multi choice name" in the app
|
||||
|
|
|
@ -183,8 +183,9 @@ Feature: Test basic usage of forum activity in app
|
|||
|
||||
When I press the back button in the app
|
||||
And I press "Display options" in the app
|
||||
And I press "Show download options" in the app
|
||||
And I press "Download" near "Test forum name" in the app
|
||||
And I press "Manage course storage" in the app
|
||||
And I press "Download" within "Test forum name" "ion-item" in the app
|
||||
And I press the back button in the app
|
||||
And I press "Test forum name" in the app
|
||||
And I press "Auto-test" near "Sort by last post creation date in descending order" in the app
|
||||
Then I should find "Reply" in the app
|
||||
|
@ -209,8 +210,9 @@ Feature: Test basic usage of forum activity in app
|
|||
|
||||
When I press the back button in the app
|
||||
And I press "Display options" in the app
|
||||
And I press "Show download options" in the app
|
||||
And I press "Download" near "Test forum name" in the app
|
||||
And I press "Manage course storage" in the app
|
||||
And I press "Download" within "Test forum name" "ion-item" in the app
|
||||
And I press the back button in the app
|
||||
And I press "Test forum name" in the app
|
||||
And I press "Auto-test" near "Sort by last post creation date in descending order" in the app
|
||||
Then I should find "Reply" in the app
|
||||
|
@ -287,8 +289,9 @@ Feature: Test basic usage of forum activity in app
|
|||
And I press "Post to forum" in the app
|
||||
And I press the back button in the app
|
||||
And I press "Display options" in the app
|
||||
And I press "Show download options" in the app
|
||||
And I press "Download" near "Test forum name" in the app
|
||||
And I press "Manage course storage" in the app
|
||||
And I press "Download" within "Test forum name" "ion-item" in the app
|
||||
And I press the back button in the app
|
||||
And I press "Test forum name" in the app
|
||||
And I press "DiscussionSubject" in the app
|
||||
And I switch offline mode to "true"
|
||||
|
@ -365,9 +368,10 @@ Feature: Test basic usage of forum activity in app
|
|||
|
||||
When I press the back button in the app
|
||||
And I press "Display options" in the app
|
||||
And I press "Show download options" in the app
|
||||
And I press "Download" near "Test forum name" in the app
|
||||
Then I should find "Downloaded" near "Test forum name" in the app
|
||||
And I press "Manage course storage" in the app
|
||||
And I press "Download" within "Test forum name" "ion-item" in the app
|
||||
Then I should find "Downloaded" within "Test forum name" "ion-item" in the app
|
||||
And I press the back button in the app
|
||||
|
||||
When I press "Test forum name" in the app
|
||||
And I press "Add a new discussion topic" in the app
|
||||
|
|
|
@ -375,8 +375,9 @@ Feature: Test basic usage of survey activity in app
|
|||
| survey | Test survey critical incidents | Test survey1 | 5 | C1 | survey1 | 0 |
|
||||
When I enter the course "Course 1" as "student1" in the app
|
||||
And I press "Display options" in the app
|
||||
And I press "Show download options" in the app
|
||||
And I press "Manage course storage" in the app
|
||||
And I press "cloud download" near "Test survey critical incidents" in the app
|
||||
And I press the back button in the app
|
||||
And I switch offline mode to "true"
|
||||
And I press "Test survey name" in the app
|
||||
Then I should see "There was a problem connecting to the site. Please check your connection and try again."
|
||||
|
|
|
@ -345,6 +345,26 @@
|
|||
return element.parentElement || (element.getRootNode() && element.getRootNode().host) || null;
|
||||
};
|
||||
|
||||
/**
|
||||
* Get closest element matching a selector, without traversing up a given container.
|
||||
*
|
||||
* @param {HTMLElement} element Element.
|
||||
* @param {string} selector Selector.
|
||||
* @param {HTMLElement} container Topmost container to search within.
|
||||
* @return {HTMLElement} Closest matching element.
|
||||
*/
|
||||
const getClosestMatching = function(element, selector, container) {
|
||||
if (element.matches(selector)) {
|
||||
return element;
|
||||
}
|
||||
|
||||
if (element === container || !element.parentElement) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return getClosestMatching(element.parentElement, selector, container);
|
||||
};
|
||||
|
||||
/**
|
||||
* Function to find elements based on their text or Aria label.
|
||||
*
|
||||
|
@ -361,6 +381,24 @@
|
|||
|
||||
let container = topContainer;
|
||||
|
||||
if (locator.within) {
|
||||
const withinElements = findElementsBasedOnText(locator.within);
|
||||
|
||||
if (withinElements.length === 0) {
|
||||
throw new Error('There was no match for within text')
|
||||
} else if (withinElements.length > 1) {
|
||||
const withinElementsAncestors = getTopAncestors(withinElements);
|
||||
|
||||
if (withinElementsAncestors.length > 1) {
|
||||
throw new Error('Too many matches for within text');
|
||||
}
|
||||
|
||||
topContainer = container = withinElementsAncestors[0];
|
||||
} else {
|
||||
topContainer = container = withinElements[0];
|
||||
}
|
||||
}
|
||||
|
||||
if (topContainer && locator.near) {
|
||||
const nearElements = findElementsBasedOnText(locator.near);
|
||||
|
||||
|
@ -382,7 +420,7 @@
|
|||
do {
|
||||
const elements = findElementsBasedOnTextWithin(container, locator.text);
|
||||
const filteredElements = locator.selector
|
||||
? elements.filter(element => element.matches(locator.selector))
|
||||
? elements.map(element => getClosestMatching(element, locator.selector, container)).filter(element => !!element)
|
||||
: elements;
|
||||
|
||||
if (filteredElements.length > 0) {
|
||||
|
|
|
@ -1020,7 +1020,7 @@ class behat_app extends behat_base {
|
|||
* @return object
|
||||
*/
|
||||
public function parse_element_locator(string $text): object {
|
||||
preg_match('/^"((?:[^"]|\\")*?)"(?: "([^"]*?)")?(?: near "((?:[^"]|\\")*?)"(?: "([^"]*?)")?)?$/', $text, $matches);
|
||||
preg_match('/^"((?:[^"]|\\")*?)"(?: "([^"]*?)")?(?: (near|within) "((?:[^"]|\\")*?)"(?: "([^"]*?)")?)?$/', $text, $matches);
|
||||
|
||||
$locator = [
|
||||
'text' => str_replace('\\"', '"', $matches[1]),
|
||||
|
@ -1028,9 +1028,9 @@ class behat_app extends behat_base {
|
|||
];
|
||||
|
||||
if (!empty($matches[3])) {
|
||||
$locator['near'] = (object) [
|
||||
'text' => str_replace('\\"', '"', $matches[3]),
|
||||
'selector' => $matches[4] ?? null,
|
||||
$locator[$matches[3]] = (object) [
|
||||
'text' => str_replace('\\"', '"', $matches[4]),
|
||||
'selector' => $matches[5] ?? null,
|
||||
];
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue