Skip to content

Commit f075c64

Browse files
committed
MOBILE-3320 behat: Add navigation tests
1 parent c48240f commit f075c64

File tree

3 files changed

+88
-8
lines changed

3 files changed

+88
-8
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
@mod @mod_messages @app @javascript
2+
Feature: Test messages navigation in the app
3+
4+
Background:
5+
Given the following "users" exist:
6+
| username | firstname |
7+
| teacher | Teacher |
8+
| student | Student |
9+
And the following "courses" exist:
10+
| fullname | shortname |
11+
| Course 1 | C1 |
12+
And the following "course enrolments" exist:
13+
| user | course | role |
14+
| teacher | C1 | editingteacher |
15+
| student | C1 | student |
16+
17+
Scenario: Avoid recursive links to profile
18+
When I enter the app
19+
And I log in as "teacher"
20+
And I press "Messages" in the app
21+
And I press "Contacts" in the app
22+
And I press "Search people and messages" in the app
23+
And I set the field "Search" to "student" in the app
24+
And I press "Search" "button" in the app
25+
And I press "Student" in the app
26+
And I set the field "New message" to "Hi there" in the app
27+
And I press "Send" in the app
28+
Then I should find "Hi there" in the app
29+
30+
When I press "Display options" in the app
31+
And I press "User info" in the app
32+
Then I should find "Details" in the app
33+
34+
When I press "Message" in the app
35+
Then I should find "Hi there" in the app
36+
37+
When I press "Display options" in the app
38+
Then I should not find "User info" in the app
39+
40+
When I press the back button in the app
41+
And I press the back button in the app
42+
Then I should find "Hi there" in the app

tests/behat/behat_app.php

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -484,12 +484,12 @@ public function i_press_the_standard_button_in_the_app(string $button) {
484484
}
485485

486486
/**
487-
* Receives push notifications for forum events.
487+
* Receives push notifications.
488488
*
489-
* @Given /^I receive a forum push notification for:$/
489+
* @Given /^I receive a push notification in the app for:$/
490490
* @param TableNode $data
491491
*/
492-
public function i_receive_a_forum_push_notification(TableNode $data) {
492+
public function i_receive_a_push_notification(TableNode $data) {
493493
global $DB, $CFG;
494494

495495
$data = (object) $data->getColumnsHash()[0];
@@ -513,6 +513,23 @@ public function i_receive_a_forum_push_notification(TableNode $data) {
513513
$this->wait_for_pending_js();
514514
}
515515

516+
/**
517+
* Opens a custom link.
518+
*
519+
* @Given /^I open a custom link in the app for:$/
520+
*/
521+
public function i_open_a_custom_link(TableNode $data) {
522+
global $DB, $CFG;
523+
524+
$data = (object) $data->getColumnsHash()[0];
525+
$discussion = $DB->get_record('forum_discussions', ['name' => $data->discussion]);
526+
$pageurl = "{$CFG->behat_wwwroot}/mod/forum/discuss.php?d={$discussion->id}";
527+
$url = "moodlemobile://link=" . urlencode($pageurl);
528+
529+
$this->evaluate_script("return window.urlSchemes.handleCustomURL('$url')");
530+
$this->wait_for_pending_js();
531+
}
532+
516533
/**
517534
* Closes a popup by clicking on the 'backdrop' behind it.
518535
*

tests/behat/navigation_pushnotifications.feature renamed to tests/behat/navigation_deeplinks.feature

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
@app @javascript
2-
Feature: It navigates properly after receiving push notifications.
2+
Feature: It navigates properly using deep links.
33

44
Background:
55
Given the following "users" exist:
@@ -22,7 +22,7 @@ Feature: It navigates properly after receiving push notifications.
2222
And the following config values are set as admin:
2323
| forcelogout | 1 | tool_mobile |
2424

25-
Scenario: Open a forum push notification
25+
Scenario: Receive a push notification
2626
When I enter the app
2727
And I log in as "student2"
2828
And I press the main menu button in the app
@@ -31,12 +31,33 @@ Feature: It navigates properly after receiving push notifications.
3131
And I set the field "Your site" to "$WWWROOT" in the app
3232
And I press "Connect to your site" in the app
3333
And I log in as "student1"
34-
And I receive a forum push notification for:
35-
| username | course | module | discussion |
36-
| student2 | C1 | forum | Forum topic |
34+
And I receive a push notification in the app for:
35+
| username | module | discussion |
36+
| student2 | forum | Forum topic |
3737
Then I should find "Reconnect" in the app
3838

3939
When I set the field "Password" to "student2" in the app
4040
And I press "Log in" in the app
4141
Then I should find "Forum topic" in the app
4242
And I should find "Forum message" in the app
43+
But I should not find "Site home" in the app
44+
45+
When I press the back button in the app
46+
Then I should find "Site home" in the app
47+
But I should not find "Forum topic" in the app
48+
And I should not find "Forum message" in the app
49+
50+
Scenario: Open a link with a custom URL
51+
When I launch the app
52+
And I open a custom link in the app for:
53+
| discussion |
54+
| Forum topic |
55+
And I log in as "student1"
56+
Then I should find "Forum topic" in the app
57+
And I should find "Forum message" in the app
58+
But I should not find "Site home" in the app
59+
60+
When I press the back button in the app
61+
Then I should find "Site home" in the app
62+
But I should not find "Forum topic" in the app
63+
And I should not find "Forum message" in the app

0 commit comments

Comments
 (0)