Skip to content

Commit e8b3fcb

Browse files
committed
MOBILE-4770 overview: Add some behat tests
The tests for the rest of activities will be added in follow up issues.
1 parent ca9bfb1 commit e8b3fcb

File tree

14 files changed

+735
-4
lines changed

14 files changed

+735
-4
lines changed

local_moodleappbehat/tests/behat/behat_app_helper.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -327,10 +327,13 @@ protected function replace_arguments(string $text): string {
327327
preg_match_all("/\\$\\{([^:}]+):([^}]+)\\}/", $text, $matches);
328328

329329
foreach ($matches[0] as $index => $match) {
330-
if ($matches[2][$index] == 'cmid') {
331-
$coursemodule = $DB->get_record('course_modules', ['idnumber' => $matches[1][$index]]);
332-
$text = str_replace($match, $coursemodule->id, $text);
330+
$coursemodule = (array) $DB->get_record('course_modules', ['idnumber' => $matches[1][$index]]);
331+
$property = $matches[2][$index] === 'cmid' ? 'id' : $matches[2][$index];
332+
if (!isset($coursemodule[$property])) {
333+
throw new DriverException("Property '$matches[2][$index]' not found in activity '$matches[1][$index]'.");
333334
}
335+
336+
$text = str_replace($match, $coursemodule[$property], $text);
334337
}
335338

336339
return $text;

src/addons/coursecompletion/tests/behat/navigation.feature

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ Feature: Course completion navigation
5858
Then I should find "Course completion status" in the app
5959
And I should find "Self completion" in the app
6060
When I press "Close" in the app
61+
And I press "Next" within "Course" "ion-tab-bar" in the app
6162
And I press "Completion" in the app
6263
Then I should find "Status" in the app
6364

@@ -66,6 +67,7 @@ Feature: Course completion navigation
6667
Then I should not find "Course completion status" in the app
6768
And I should not find "Self completion" in the app
6869
When I press "Close" in the app
70+
And I press "Next" within "Course" "ion-tab-bar" in the app
6971
Then I should not find "Completion" in the app
7072

7173
Given the following config values are set as admin:
@@ -76,4 +78,5 @@ Feature: Course completion navigation
7678
Then I should not find "Course completion status" in the app
7779
And I should not find "Self completion" in the app
7880
When I press "Close" in the app
81+
And I press "Next" within "Course" "ion-tab-bar" in the app
7982
Then I should not find "Completion" in the app

src/addons/coursecompletion/tests/behat/selfcompletion.feature

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ Feature: Student should be able to complete a course with self completion enable
2323

2424
Scenario: Manually complete the course
2525
Given I entered the course "Course 1" as "student1" in the app
26-
When I press "Completion" in the app
26+
And I press "Next" within "Course" "ion-tab-bar" in the app
27+
And I press "Completion" in the app
2728
Then I should find "Not yet started" within "Status" "ion-item" in the app
2829
And I should find "Marking yourself complete" in the app
2930
And I should find "No" within "Self completion" "ion-item" in the app
Lines changed: 158 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,158 @@
1+
@addon_mod_assign @app @mod @mod_assign @javascript @lms_from5.1
2+
Feature: Activities overview for assign activity
3+
4+
Background:
5+
Given the Moodle site is compatible with this feature
6+
And the following "users" exist:
7+
| username | firstname | lastname |
8+
| student1 | Username | 1 |
9+
| student2 | Username | 2 |
10+
| student3 | Username | 3 |
11+
| student4 | Username | 4 |
12+
| student5 | Username | 5 |
13+
| student6 | Username | 6 |
14+
| student7 | Username | 7 |
15+
| student8 | Username | 8 |
16+
| teacher1 | Teacher | T |
17+
And the following "courses" exist:
18+
| fullname | shortname | groupmode |
19+
| Course 1 | C1 | 1 |
20+
And the following "course enrolments" exist:
21+
| user | course | role |
22+
| student1 | C1 | student |
23+
| student2 | C1 | student |
24+
| student3 | C1 | student |
25+
| student4 | C1 | student |
26+
| student5 | C1 | student |
27+
| student6 | C1 | student |
28+
| student7 | C1 | student |
29+
| student8 | C1 | student |
30+
| teacher1 | C1 | editingteacher |
31+
And the following "activities" exist:
32+
| activity | name | course | idnumber | duedate | assignsubmission_onlinetext_enabled | assignsubmission_file_enabled | submissiondrafts |
33+
| assign | Date assign | C1 | assign1 | ##1 Jan 2040 08:00## | 1 | 0 | 0 |
34+
| assign | No submissions | C1 | assign2 | ##tomorrow noon## | 1 | 0 | 0 |
35+
| assign | Pending grades | C1 | assign3 | | 1 | 0 | 0 |
36+
And the following "mod_assign > submissions" exist:
37+
| assign | user | onlinetext |
38+
| Date assign | student1 | This is a submission for assignment |
39+
| Pending grades | student1 | This is a submission for assignment |
40+
| Pending grades | student2 | This is a submission for assignment |
41+
And the following "grade grades" exist:
42+
| gradeitem | user | grade |
43+
| Pending grades | student1 | 50 |
44+
45+
Scenario: Teachers can see relevant columns in the assign overview
46+
Given I entered the course "Course 1" as "teacher1" in the app
47+
When I press "Activities" in the app
48+
And I press "Assignments" in the app
49+
And I press "Date assign" "ion-item" in the app
50+
Then I should find "1 January 2040" within "Due date" "ion-item" in the app
51+
And I should find "1 of 8" within "Submissions" "ion-item" in the app
52+
53+
When I press "Grade" within "Actions" "ion-item" in the app
54+
Then the header should be "Date assign" in the app
55+
56+
When I go back in the app
57+
And I press "No submissions" "ion-item" in the app
58+
Then I should find "Tomorrow" within "Due date" "ion-item" in the app
59+
And I should find "0 of 8" within "Submissions" "ion-item" in the app
60+
And I should be able to press "View" within "Actions" "ion-item" in the app
61+
62+
When I press "Pending grades" "ion-item" in the app
63+
Then I should find "-" within "Due date" "ion-item" in the app
64+
And I should find "2 of 8" within "Submissions" "ion-item" in the app
65+
And I should be able to press "Grade" within "Actions" "ion-item" in the app
66+
67+
Scenario: The assign overview actions has information about the number of pending elements to grade
68+
Given I entered the course "Course 1" as "teacher1" in the app
69+
When I press "Activities" in the app
70+
And I press "Assignments" in the app
71+
And I press "Date assign" "ion-item" in the app
72+
Then I should find "Grade" within "Actions" "ion-item" in the app
73+
And I should find "1" within "Grade" "ion-button" in the app
74+
75+
When I press "Pending grades" "ion-item" in the app
76+
Then I should find "Grade" within "Actions" "ion-item" in the app
77+
And I should find "2" within "Grade" "ion-button" in the app
78+
79+
# Validate alert badge updates.
80+
When the following "grade grades" exist:
81+
| gradeitem | user | grade |
82+
| Date assign | student1 | 50 |
83+
| Pending grades | student1 | 50 |
84+
And I pull to refresh in the app
85+
And I press "Assignments" in the app
86+
And I press "Date assign" "ion-item" in the app
87+
Then I should find "View" within "Actions" "ion-item" in the app
88+
And I should not find "Grade" within "Actions" "ion-item" in the app
89+
And I should not find "1" within "Actions" "ion-item" in the app
90+
91+
When I press "Pending grades" "ion-item" in the app
92+
Then I should find "Grade" within "Actions" "ion-item" in the app
93+
And I should find "1" within "Grade" "ion-button" in the app
94+
95+
Scenario: The assign overview actions has different label action based on assignment configuration
96+
Given the following "activity" exists:
97+
| course | C1 |
98+
| activity | assign |
99+
| name | Feedback only |
100+
| idnumber | assign4 |
101+
| submissiondrafts | 0 |
102+
| assignsubmission_onlinetext_enabled | 1 |
103+
| assignfeedback_comments_enabled | 1 |
104+
| assignfeedback_editpdf_enabled | 1 |
105+
And the following "activity" exists:
106+
| course | C1 |
107+
| activity | assign |
108+
| name | Neither grading nor feedback |
109+
| idnumber | assign5 |
110+
| submissiondrafts | 0 |
111+
| assignsubmission_onlinetext_enabled | 1 |
112+
| assignfeedback_comments_enabled | 0 |
113+
| assignfeedback_editpdf_enabled | 0 |
114+
And the following "mod_assign > submissions" exist:
115+
| assign | user | onlinetext |
116+
| Feedback only | student1 | Feedback only assignment |
117+
| Neither grading nor feedback | student1 | Neither grading nor feedback submission |
118+
And I am on the "Feedback only" "assign activity editing" page logged in as "teacher1"
119+
And I expand all fieldsets
120+
And I set the field "grade[modgrade_type]" to "None"
121+
And I press "Save and return to course"
122+
And I am on the "Neither grading nor feedback" "assign activity editing" page
123+
And I expand all fieldsets
124+
And I set the field "grade[modgrade_type]" to "None"
125+
And I press "Save and return to course"
126+
And I entered the course "Course 1" as "teacher1" in the app
127+
128+
When I press "Activities" in the app
129+
And I press "Assignments" in the app
130+
And I press "Date assign" "ion-item" in the app
131+
Then I should find "Grade" within "Actions" "ion-item" in the app
132+
133+
When I press "Feedback only" "ion-item" in the app
134+
Then I should find "View" within "Actions" "ion-item" in the app
135+
And I should find "1 of 8" within "Submissions" "ion-item" in the app
136+
137+
When I press "Neither grading nor feedback" "ion-item" in the app
138+
Then I should find "View" within "Actions" "ion-item" in the app
139+
And I should find "1 of 8" within "Submissions" "ion-item" in the app
140+
141+
Scenario: Students can see relevant columns in the assign overview
142+
Given I entered the course "Course 1" as "student1" in the app
143+
When I press "Activities" in the app
144+
And I press "Assignments" in the app
145+
And I press "Date assign" "ion-item" in the app
146+
Then I should find "1 January 2040" within "Due date" "ion-item" in the app
147+
And I should find "Submitted for grading" within "Submission status" "ion-item" in the app
148+
And I should find "-" within "Grade" "ion-item" in the app
149+
150+
When I press "No submissions" "ion-item" in the app
151+
Then I should find "Tomorrow" within "Due date" "ion-item" in the app
152+
And I should find "No submission" within "Submission status" "ion-item" in the app
153+
And I should find "-" within "Grade" "ion-item" in the app
154+
155+
When I press "Pending grades" "ion-item" in the app
156+
Then I should find "-" within "Due date" "ion-item" in the app
157+
And I should find "Submitted for grading" within "Submission status" "ion-item" in the app
158+
And I should find "50.00" within "Grade" "ion-item" in the app
546 Bytes
Loading
442 Bytes
Loading
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
@addon_mod_choice @app @mod @mod_choice @javascript @lms_from5.1
2+
Feature: Activities overview for choice activity
3+
4+
Background:
5+
Given the Moodle site is compatible with this feature
6+
And the following "users" exist:
7+
| username | firstname | lastname |
8+
| student1 | Student | 1 |
9+
| student2 | Student | 2 |
10+
| student3 | Student | 3 |
11+
| teacher1 | Teacher | T |
12+
And the following "courses" exist:
13+
| fullname | shortname | enablecompletion |
14+
| Course 1 | C1 | 1 |
15+
And the following "course enrolments" exist:
16+
| user | course | role |
17+
| student1 | C1 | student |
18+
| student2 | C1 | student |
19+
| student3 | C1 | student |
20+
| teacher1 | C1 | editingteacher |
21+
And the following "activities" exist:
22+
| activity | name | intro | course | idnumber | option | section | completion | allowmultiple | timeclose |
23+
| choice | Choice 1 | Choice Description 1 | C1 | choice1 | Option 1, Option 2 | 1 | 1 | 1 | 1 January 2040 |
24+
| choice | Choice 2 | Choice Description 2 | C1 | choice2 | Option A, Option B | 1 | 0 | 0 | |
25+
| choice | Choice 3 | Choice Description 3 | C1 | choice3 | Option A | 1 | 0 | 0 | |
26+
And the following "mod_choice > responses" exist:
27+
| choice | user | responses |
28+
| choice1 | student1 | Option 1, Option 2 |
29+
| choice1 | student3 | Option 2 |
30+
| choice2 | student2 | Option A |
31+
32+
Scenario: Students can see relevant columns and content in the choice overview
33+
Given I entered the course "Course 1" as "student1" in the app
34+
When I press "Activities" in the app
35+
And I press "Choices" in the app
36+
And I press "Choice 1" "ion-item" in the app
37+
Then I should find "1 January 2040" within "Due date" "ion-item" in the app
38+
And I should find "Answered" "ion-icon" within "Responded" "ion-item" in the app
39+
40+
When I press "Choice 2" "ion-item" in the app
41+
Then I should find "-" within "Due date" "ion-item" in the app
42+
And I should find "-" within "Responded" "ion-item" in the app
43+
And I should not find "Answered" within "Responded" "ion-item" in the app
44+
45+
When I press "Choice 3" "ion-item" in the app
46+
Then I should find "-" within "Due date" "ion-item" in the app
47+
And I should find "-" within "Responded" "ion-item" in the app
48+
And I should not find "Answered" "ion-icon" within "Responded" "ion-item" in the app
49+
50+
Scenario: Teachers can see relevant columns and content in the choice overview
51+
Given I entered the course "Course 1" as "teacher1" in the app
52+
When I press "Activities" in the app
53+
And I press "Choices" in the app
54+
And I press "Choice 1" "ion-item" in the app
55+
Then I should find "1 January 2040" within "Due date" "ion-item" in the app
56+
And I should find "2" within "Students who responded" "ion-item" in the app
57+
And I should find "View" within "Actions" "ion-item" in the app
58+
59+
When I press "View" within "Actions" "ion-item" in the app
60+
Then the header should be "Choice 1" in the app
61+
62+
When I go back in the app
63+
And I press "Choice 2" "ion-item" in the app
64+
Then I should find "-" within "Due date" "ion-item" in the app
65+
And I should find "1" within "Students who responded" "ion-item" in the app
66+
And I should find "View" within "Actions" "ion-item" in the app
67+
68+
When I press "Choice 3" "ion-item" in the app
69+
Then I should find "-" within "Due date" "ion-item" in the app
70+
And I should find "0" within "Students who responded" "ion-item" in the app
71+
And I should find "View" within "Actions" "ion-item" in the app

0 commit comments

Comments
 (0)