MOBILE-3153 behat: Test User Tours

main
Noel De Martin 2022-03-10 12:07:15 +01:00
parent 462e868582
commit 82fa21f76b
3 changed files with 74 additions and 1 deletions

View File

@ -415,9 +415,12 @@
case 'popover':
containers = document.querySelectorAll('ion-app ion-popover.hydrated');
break;
case 'user-tour':
containers = document.querySelectorAll('core-user-tours-user-tour.is-active');
break;
default:
// Other containerName or not implemented.
const containerSelector = 'ion-alert, ion-popover, ion-action-sheet, ion-modal, page-core-mainmenu, ion-app';
const containerSelector = 'ion-alert, ion-popover, ion-action-sheet, ion-modal, core-user-tours-user-tour.is-active, page-core-mainmenu, ion-app';
containers = document.querySelectorAll(containerSelector);
}

View File

@ -69,6 +69,9 @@ class behat_app extends behat_base {
/** @var bool Whether the app is running or not */
protected $apprunning = false;
/** @var array Config overrides */
protected $appconfig = ['disableUserTours' => true];
/**
* Register listener.
*
@ -540,6 +543,11 @@ class behat_app extends behat_base {
}, false, 60);
}
// Prepare testing config.
$configoverrides = json_encode($this->appconfig);
$this->evaluate_script("configProvider.patchEnvironment($configoverrides)");
// Continue only after JS finishes.
$this->wait_for_pending_js();
}
@ -691,6 +699,7 @@ class behat_app extends behat_base {
* Opens a custom link.
*
* @Given /^I open a custom link in the app for:$/
* @param TableNode $data
*/
public function i_open_a_custom_link(TableNode $data) {
global $DB, $CFG;
@ -742,6 +751,18 @@ class behat_app extends behat_base {
$this->wait_for_pending_js();
}
/**
* Override app config.
*
* @Given /^the app has the following config:$/
* @param TableNode $data
*/
public function the_app_has_the_following_config(TableNode $data) {
foreach ($data->getRows() as $configrow) {
$this->appconfig[$configrow[0]] = json_decode($configrow[1]);
}
}
/**
* Clicks on / touches something that is visible in the app.
*

View File

@ -0,0 +1,49 @@
@app @javascript
Feature: User Tours work properly.
Background:
Given the following "users" exist:
| username | firstname | lastname |
| student1 | Student | First |
| student2 | Student | Second |
And the following "courses" exist:
| fullname | shortname |
| Course 1 | C1 |
And the following "course enrolments" exist:
| user | course | role |
| student1 | C1 | student |
| student2 | C1 | student |
And the app has the following config:
| disableUserTours | false |
Scenario: Acknowledge User Tours
When I enter the app
And I log in as "student1"
Then I should find "Explore your personal area" in the app
But I should not find "Expand to explore" in the app
When I press "Got it" in the app
Then I should find "Expand to explore" in the app
But I should not find "Explore your personal area" in the app
When I press "Got it" in the app
Then I should not find "Expand to explore" in the app
And I should not find "Explore your personal area" in the app
When I press "My courses" in the app
And I press "Course 1" in the app
Then I should find "Find your way around" in the app
When I press "Got it" in the app
Then I should not find "Find your way around" in the app
When I press "Participants" in the app
And I press "Student First" in the app
Then I should find "Swipe left and right to navigate around" in the app
When I press "Got it" in the app
Then I should not find "Swipe left and right to navigate around" in the app
When I press the back button in the app
And I press "Student First" in the app
Then I should not find "Swipe left and right to navigate around" in the app