Skip to content

Commit 98d8185

Browse files
authored
Merge pull request #4683 from crazyserver/MOBILE-4974-behat
MOBILE-4974 behat: Allow to listen when the app is ready
2 parents 126f3e2 + 36c4e38 commit 98d8185

File tree

38 files changed

+57
-9
lines changed

38 files changed

+57
-9
lines changed

local_moodleappbehat/tests/behat/behat_app.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,11 @@ class behat_app extends behat_app_helper {
5252
protected $scenariolaststep;
5353

5454
/**
55-
* @BeforeScenario
55+
* @BeforeScenario @app
5656
*/
5757
public function before_scenario(ScenarioScope $scope) {
5858
$feature = $scope->getFeature();
5959

60-
if (!$feature->hasTag('app')) {
61-
return;
62-
}
63-
6460
$steps = $scope->getScenario()->getSteps();
6561

6662
$this->scenarioslug = $this->get_scenario_slug($scope);

local_moodleappbehat/tests/behat/behat_app_helper.php

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@ interface behat_app_listener {
3333
*/
3434
function on_app_load(): void;
3535

36+
/**
37+
* Called when the app is ready.
38+
*/
39+
function on_app_ready(): void;
40+
3641
/**
3742
* Called before the app is unloaded.
3843
*/
@@ -43,7 +48,7 @@ function on_app_unload(): void;
4348
/**
4449
* A trait containing functionality used by the behat app context.
4550
*
46-
* @package core
51+
* @package local_moodleappbehat
4752
* @category test
4853
* @copyright 2018 The Open University
4954
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
@@ -234,6 +239,8 @@ protected function prepare_browser() {
234239
throw new DriverException('Moodle App not found in browser');
235240
}, false, 60);
236241

242+
$this->notify_ready();
243+
237244
try {
238245
// Init Behat JavaScript runtime.
239246
$initoptions = json_encode([
@@ -351,6 +358,17 @@ protected function notify_load(): void {
351358
}
352359
}
353360

361+
/**
362+
* Notify to listeners that the app is ready.
363+
*/
364+
protected function notify_ready(): void {
365+
foreach (self::$listeners as $listener) {
366+
if (method_exists($listener, 'on_app_ready')) {
367+
$listener->on_app_ready();
368+
}
369+
}
370+
}
371+
354372
/**
355373
* Notify to listeners that the app is about to be unloaded.
356374
*/

src/addons/block/activitymodules/tests/behat/block_activitymodules.feature

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ Feature: Basic tests of activity modules block
4848
When I press "Test forum name 1" in the app
4949
Then the header should be "Test forum name 1" in the app
5050

51+
@disabled_features
5152
Scenario: Block is included in disabled features
5253
# Add another block just to ensure there is something in the block region and the drawer is displayed.
5354
Given the following "blocks" exist:

src/addons/block/activityresults/tests/behat/block_activityresults.feature

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ Feature: Basic tests of activity results block
2121
Then I should find "Activity results" in the app
2222
And I should find "Please configure this block" in the app
2323

24+
@disabled_features
2425
Scenario: Block is included in disabled features
2526
# Add another block just to ensure there is something in the block region and the drawer is displayed.
2627
Given the following "blocks" exist:

src/addons/block/badges/tests/behat/block_badges.feature

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ Feature: Basic tests of badges block
2121
Then I should find "Latest badges" in the app
2222
And I should find "You have no badges to display" in the app
2323

24+
@disabled_features
2425
Scenario: Block is included in disabled features
2526
# Add another block just to ensure there is something in the block region and the drawer is displayed.
2627
Given the following "blocks" exist:

src/addons/block/blogmenu/tests/behat/block_blogmenu.feature

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ Feature: Basic tests of blog menu block
2121
Then I should find "Blog menu" in the app
2222
And I should find "Blog entries" in the app
2323

24+
@disabled_features
2425
Scenario: Block is included in disabled features
2526
# Add another block just to ensure there is something in the block region and the drawer is displayed.
2627
Given the following "blocks" exist:

src/addons/block/blogrecent/tests/behat/block_blogrecent.feature

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ Feature: Basic tests of blog recent block
2121
Then I should find "Recent blog entries" in the app
2222
And I should find "No recent entries" in the app
2323

24+
@disabled_features
2425
Scenario: Block is included in disabled features
2526
# Add another block just to ensure there is something in the block region and the drawer is displayed.
2627
Given the following "blocks" exist:

src/addons/block/blogtags/tests/behat/block_blogtags.feature

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ Feature: Basic tests of blog tags block
5151
And I should find "T1" in the app
5252
And I should find "T2" in the app
5353

54+
@disabled_features
5455
Scenario: Block is included in disabled features
5556
# Add another block just to ensure there is something in the block region and the drawer is displayed.
5657
Given the following "blocks" exist:

src/addons/block/calendarmonth/tests/behat/block_calendar_month.feature

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ Feature: View the calendar block and check it links to the calendar page
2222
When I press "Calendar" in the app
2323
Then the header should be "Calendar" in the app
2424

25+
@disabled_features
2526
Scenario: Block is included in disabled features
2627
# Add another block just to ensure there is something in the block region and the drawer is displayed.
2728
Given the following "blocks" exist:

src/addons/block/calendarupcoming/tests/behat/block_calendar_upcoming.feature

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ Feature: View the calendar upcoming block and check
2424
Then the header should be "Calendar" in the app
2525
And I should find "There are no events" in the app
2626

27+
@disabled_features
2728
Scenario: Block is included in disabled features
2829
# Add another block just to ensure there is something in the block region and the drawer is displayed.
2930
Given the following "blocks" exist:

0 commit comments

Comments
 (0)