Merge pull request #3299 from alfonso-salces/MOBILE-4021-tests
MOBILE-4021 notifications: Create notification acceptance testsmain
commit
a1dc1ec631
|
@ -420,30 +420,42 @@ class behat_app extends behat_app_helper {
|
||||||
/**
|
/**
|
||||||
* Receives push notifications.
|
* Receives push notifications.
|
||||||
*
|
*
|
||||||
* @When /^I receive a push notification in the app for:$/
|
* @When /^I click a push notification in the app for:$/
|
||||||
* @param TableNode $data Table data
|
* @param TableNode $data Table data
|
||||||
*/
|
*/
|
||||||
public function i_receive_a_push_notification(TableNode $data) {
|
public function i_click_a_push_notification(TableNode $data) {
|
||||||
global $DB, $CFG;
|
global $DB, $CFG;
|
||||||
|
|
||||||
$data = (object) $data->getColumnsHash()[0];
|
$data = (object) $data->getColumnsHash()[0];
|
||||||
$module = $DB->get_record('course_modules', ['idnumber' => $data->module]);
|
|
||||||
$discussion = $DB->get_record('forum_discussions', ['name' => $data->discussion]);
|
if (isset($data->module, $data->discussion)) {
|
||||||
|
$module = $DB->get_record('course_modules', ['idnumber' => $data->module]);
|
||||||
|
$discussion = $DB->get_record('forum_discussions', ['name' => $data->discussion]);
|
||||||
|
$data->name = 'posts';
|
||||||
|
$data->component = 'mod_forum';
|
||||||
|
}
|
||||||
|
|
||||||
$notification = json_encode([
|
$notification = json_encode([
|
||||||
'site' => md5($CFG->behat_wwwroot . $data->username),
|
'site' => md5($CFG->behat_wwwroot . $data->username),
|
||||||
'courseid' => $discussion->course,
|
'subject' => $data->subject ?? null,
|
||||||
'moodlecomponent' => 'mod_forum',
|
'userfrom' => $data->userfrom ?? null,
|
||||||
'name' => 'posts',
|
'userto' => $data->username ?? null,
|
||||||
|
'message' => $data->message ?? '',
|
||||||
|
'title' => $data->title ?? '',
|
||||||
|
'image' => $data->image ?? null,
|
||||||
|
'courseid' => $discussion->course ?? null,
|
||||||
|
'moodlecomponent' => $data->component ?? null,
|
||||||
|
'name' => $data->name ?? null,
|
||||||
'contexturl' => '',
|
'contexturl' => '',
|
||||||
'notif' => 1,
|
'notif' => 1,
|
||||||
'customdata' => [
|
'customdata' => isset($discussion->id, $module->id, $discussion->forum)
|
||||||
'discussionid' => $discussion->id,
|
? ['discussionid' => $discussion->id, 'cmid' => $module->id, 'instance' => $discussion->forum]
|
||||||
'cmid' => $module->id,
|
: null,
|
||||||
'instance' => $discussion->forum,
|
'additionalData' => isset($data->subject) || isset($data->userfrom)
|
||||||
],
|
? ['foreground' => true, 'notId' => 23, 'notif' => 1] : null,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$this->zone_js("pushNotifications.notificationClicked($notification)", true);
|
$this->evaluate_script("pushNotifications.notificationClicked($notification)", true);
|
||||||
$this->wait_for_pending_js();
|
$this->wait_for_pending_js();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,114 @@
|
||||||
|
@app @javascript
|
||||||
|
Feature: Notifications
|
||||||
|
|
||||||
|
Background:
|
||||||
|
Given the following "users" exist:
|
||||||
|
| username | firstname | lastname |
|
||||||
|
| student1 | First | Student |
|
||||||
|
| student2 | Second | Student |
|
||||||
|
And the following "notifications" exist:
|
||||||
|
| subject | userfrom | userto | timecreated | timeread |
|
||||||
|
| Test 01 | student2 | student1 | 1649766600 | null |
|
||||||
|
| Test 02 | student2 | student1 | 1649766601 | null |
|
||||||
|
| Test 03 | student2 | student1 | 1649766602 | 1649766602 |
|
||||||
|
| Test 04 | student2 | student1 | 1649766603 | 1649766602 |
|
||||||
|
| Test 05 | student2 | student1 | 1649766604 | null |
|
||||||
|
| Test 06 | student2 | student1 | 1649766605 | null |
|
||||||
|
| Test 07 | student2 | student1 | 1649766606 | 1649766602 |
|
||||||
|
| Test 08 | student2 | student1 | 1649766607 | 1649766602 |
|
||||||
|
| Test 09 | student2 | student1 | 1649766608 | null |
|
||||||
|
| Test 10 | student2 | student1 | 1649766609 | 1649766602 |
|
||||||
|
| Test 11 | student2 | student1 | 1649766610 | 1649766602 |
|
||||||
|
| Test 12 | student2 | student1 | 1649766611 | 1649766602 |
|
||||||
|
| Test 13 | student2 | student1 | 1649766612 | 1649766602 |
|
||||||
|
| Test 14 | student2 | student1 | 1649766613 | 1649766602 |
|
||||||
|
| Test 15 | student2 | student1 | 1649766614 | 1649766602 |
|
||||||
|
| Test 16 | student2 | student1 | 1649766615 | 1649766602 |
|
||||||
|
| Test 17 | student2 | student1 | 1649766616 | 1649766602 |
|
||||||
|
| Test 18 | student2 | student1 | 1649766617 | 1649766602 |
|
||||||
|
| Test 19 | student2 | student1 | 1649766618 | 1649766602 |
|
||||||
|
| Test 20 | student2 | student1 | 1649766619 | 1649766602 |
|
||||||
|
| Test 21 | student2 | student1 | 1649766620 | null |
|
||||||
|
| Test 22 | student2 | student1 | 1649766621 | 1649766602 |
|
||||||
|
| Test 23 | student2 | student1 | 1649766622 | 1649766602 |
|
||||||
|
| Test 24 | student2 | student1 | 1649766623 | 1649766602 |
|
||||||
|
| Test 25 | student2 | student1 | 1649766624 | 1649766602 |
|
||||||
|
| Test 26 | student2 | student1 | 1649766625 | null |
|
||||||
|
| Test 27 | student2 | student1 | 1649766626 | 1649766602 |
|
||||||
|
| Test 28 | student2 | student1 | 1649766627 | 1649766602 |
|
||||||
|
| Test 29 | student2 | student1 | 1649766628 | 1649766602 |
|
||||||
|
| Test 30 | student2 | student1 | 1649766629 | null |
|
||||||
|
|
||||||
|
Scenario: Mobile navigation
|
||||||
|
Given I enter the app
|
||||||
|
And I log in as "student1"
|
||||||
|
And I press "Notifications" in the app
|
||||||
|
Then I should find "Test 30" in the app
|
||||||
|
But I should not find "Test 10" in the app
|
||||||
|
When I load more items in the app
|
||||||
|
Then I should find "Test 10" in the app
|
||||||
|
And I should find "Test 01" in the app
|
||||||
|
|
||||||
|
# Receive a push notification
|
||||||
|
And the following "notifications" exist:
|
||||||
|
| subject | userfrom | userto | timecreated | timeread |
|
||||||
|
| Test 31 | student2 | student1 | 1649766631 | null |
|
||||||
|
When I click a push notification in the app for:
|
||||||
|
| username | message | title | subject | userfrom |
|
||||||
|
| student1 | Test push | Test 31 | Push 01 | student2 |
|
||||||
|
Then I should find "Push 01" in the app
|
||||||
|
|
||||||
|
# Open notification detail
|
||||||
|
When I press the back button in the app
|
||||||
|
And I press "Test 30" in the app
|
||||||
|
Then I should find "Test 30 description" in the app
|
||||||
|
|
||||||
|
# Go back and open other notification
|
||||||
|
When I press the back button in the app
|
||||||
|
Then I should find "Test 10" in the app
|
||||||
|
When I press "Test 10" in the app
|
||||||
|
Then I should find "Test 10 description" in the app
|
||||||
|
|
||||||
|
# Swipe to next notification
|
||||||
|
When I swipe to the right in the app
|
||||||
|
Then I should find "Test 11 description" in the app
|
||||||
|
But I should not find "Test 10 description" in the app
|
||||||
|
|
||||||
|
# Swipe to previous notification
|
||||||
|
When I swipe to the left in the app
|
||||||
|
Then I should find "Test 10 description" in the app
|
||||||
|
But I should not find "Test 09 description" in the app
|
||||||
|
|
||||||
|
Scenario: Tablet navigation
|
||||||
|
Given I enter the app
|
||||||
|
And I change viewport size to "1200x640"
|
||||||
|
And I log in as "student1"
|
||||||
|
And I press "Notifications" in the app
|
||||||
|
Then I should find "Test 30" in the app
|
||||||
|
But I should not find "Test 10" in the app
|
||||||
|
|
||||||
|
# Load more notifications
|
||||||
|
When I load more items in the app
|
||||||
|
Then I should find "Test 10" in the app
|
||||||
|
And I should find "Test 01" in the app
|
||||||
|
And I should find "Test 30 description" inside the split-view content in the app
|
||||||
|
And "Test 30" near "Test 29" should be selected in the app
|
||||||
|
|
||||||
|
# Open loaded items after load more notifications
|
||||||
|
When I press "Test 10" in the app
|
||||||
|
Then I should find "Test 10 description" inside the split-view content in the app
|
||||||
|
And "Test 10" near "Test 11" should be selected in the app
|
||||||
|
|
||||||
|
# Mark as read notification
|
||||||
|
When I press "Test 01" in the app
|
||||||
|
Then I should not find "Unread notification: Test 01" in the app
|
||||||
|
But I should find "Test 01" in the app
|
||||||
|
And I should find "Unread notification: Test 26" in the app
|
||||||
|
|
||||||
|
# Mark all notifications as read
|
||||||
|
When I press "Mark all as read" in the app
|
||||||
|
Then I should not find "Unread notification" in the app
|
||||||
|
|
||||||
|
# Pull to refresh
|
||||||
|
When I pull to refresh in the app
|
||||||
|
Then I should not find "Unread notification" in the app
|
|
@ -30,7 +30,7 @@ Feature: It navigates properly using deep links.
|
||||||
And I set the field "Your site" to "$WWWROOT" in the app
|
And I set the field "Your site" to "$WWWROOT" in the app
|
||||||
And I press "Connect to your site" in the app
|
And I press "Connect to your site" in the app
|
||||||
And I log in as "student1"
|
And I log in as "student1"
|
||||||
And I receive a push notification in the app for:
|
And I click a push notification in the app for:
|
||||||
| username | module | discussion |
|
| username | module | discussion |
|
||||||
| student2 | forum | Forum topic |
|
| student2 | forum | Forum topic |
|
||||||
And I wait the app to restart
|
And I wait the app to restart
|
||||||
|
|
Loading…
Reference in New Issue