Skip to content

Commit 60745cf

Browse files
author
Amaia Anabitarte
committed
Adding new behat tests for quiz and data for Moodle app
1 parent ddb166e commit 60745cf

File tree

3 files changed

+444
-0
lines changed

3 files changed

+444
-0
lines changed
Lines changed: 199 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,199 @@
1+
@mod @mod_data @app @javascript
2+
Feature: Users can manage entries in database activities
3+
In order to populate databases
4+
As a user
5+
I need to add and manage entries to databases
6+
7+
Background:
8+
Given the following "users" exist:
9+
| username | firstname | lastname | email |
10+
| student1 | Student | 1 | student1@example.com |
11+
| student2 | Student | 2 | student2@example.com |
12+
| teacher1 | Teacher | 1 | teacher1@example.com |
13+
And the following "courses" exist:
14+
| fullname | shortname | category |
15+
| Course 1 | C1 | 0 |
16+
And the following "course enrolments" exist:
17+
| user | course | role |
18+
| teacher1 | C1 | editingteacher |
19+
| student1 | C1 | student |
20+
| student2 | C1 | student |
21+
And the following "activities" exist:
22+
| activity | name | intro | course | idnumber |
23+
| data | Web links | Useful links | C1 | data1 |
24+
And I log in as "teacher1"
25+
And I am on "Course 1" course homepage
26+
And I add a "Text input" field to "Web links" database and I fill the form with:
27+
| Field name | URL |
28+
| Field description | URL link |
29+
And I add a "Text input" field to "Web links" database and I fill the form with:
30+
| Field name | Description |
31+
| Field description | Link description |
32+
And I log out
33+
34+
Scenario: Students can add entries to a database in the app
35+
Given I enter the app
36+
And I log in as "student1"
37+
And I press "Course 1" near "Course overview" in the app
38+
And I press "Web links" near "General" in the app
39+
And I should see "No entries in database"
40+
When I press "Add entries" in the app
41+
And I set the field "URL" to "https://moodle.org/" in the app
42+
And I set the field "Description" to "Moodle community site" in the app
43+
And I press "Save" near "Web links" in the app
44+
Then I should see "https://moodle.org/"
45+
And I should see "Moodle community site"
46+
47+
Scenario: Students can navigate along single entries in the app
48+
Given I enter the app
49+
And I log in as "student1"
50+
And I press "Course 1" near "Course overview" in the app
51+
And I press "Web links" near "General" in the app
52+
And I press "Add entries" in the app
53+
And I set the field "URL" to "https://moodle.org/" in the app
54+
And I set the field "Description" to "Moodle community site" in the app
55+
And I press "Save" near "Web links" in the app
56+
When I enter the app
57+
And I log in as "student2"
58+
And I press "Course 1" near "Course overview" in the app
59+
And I press "Web links" near "General" in the app
60+
And I press "Add entries" in the app
61+
And I set the field "URL" to "https://moodlecloud.com/" in the app
62+
And I set the field "Description" to "Moodle Cloud" in the app
63+
And I press "Save" near "Web links" in the app
64+
And I press "More" near "Moodle community site" in the app
65+
Then I should see "Moodle community site"
66+
And I should not see "Next"
67+
And I should see "Previous"
68+
And I press "Previous" in the app
69+
And I should see "Moodle Cloud"
70+
And I should see "Next"
71+
And I should not see "Previous"
72+
And I press "Next" in the app
73+
And I should see "Moodle community site"
74+
And I should not see "Moodle Cloud"
75+
And I press "back" near "Web links" in the app
76+
And I should see "Moodle community site"
77+
And I should see "Moodle Cloud"
78+
79+
Scenario: Students can not edit or delete other user's entries from list and single view in the app
80+
Given I enter the app
81+
And I log in as "student1"
82+
And I press "Course 1" near "Course overview" in the app
83+
And I press "Web links" near "General" in the app
84+
And I press "Add entries" in the app
85+
And I set the field "URL" to "https://moodle.org/" in the app
86+
And I set the field "Description" to "Moodle community site" in the app
87+
And I press "Save" near "Web links" in the app
88+
When I enter the app
89+
And I log in as "student2"
90+
And I press "Course 1" near "Course overview" in the app
91+
And I press "Web links" near "General" in the app
92+
Then "Edit" "link" should not exist
93+
And "Delete" "link" should not exist
94+
And I press "More" in the app
95+
And "Edit" "link" should not exist
96+
And "Delete" "link" should not exist
97+
98+
Scenario: Students can edit and delete their own entries from list and single view in the app
99+
Given I enter the app
100+
And I log in as "student1"
101+
And I press "Course 1" near "Course overview" in the app
102+
And I press "Web links" near "General" in the app
103+
And I press "Add entries" in the app
104+
And I set the field "URL" to "https://moodle.org/" in the app
105+
And I set the field "Description" to "Moodle community site" in the app
106+
And I press "Save" near "Web links" in the app
107+
When I press "Edit" in the app
108+
And I set the field "URL" to "https://moodlecloud.com/" in the app
109+
And I set the field "Description" to "Moodle Cloud" in the app
110+
And I press "Save" near "Web links" in the app
111+
Then I should not see "https://moodle.org/"
112+
And I should not see "Moodle community site"
113+
And I should see "https://moodlecloud.com/"
114+
And I should see "Moodle Cloud"
115+
And I press "Delete" in the app
116+
And I should see "Are you sure you want to delete this entry?"
117+
And I press "Cancel" in the app
118+
And I should see "Moodle Cloud"
119+
And I press "Delete" in the app
120+
And I should see "Are you sure you want to delete this entry?"
121+
And I press "OK" in the app
122+
And I should not see "Moodle Cloud"
123+
And I press "Add entries" in the app
124+
And I set the field "URL" to "https://moodle.org/" in the app
125+
And I set the field "Description" to "Moodle community site" in the app
126+
And I press "Save" near "Web links" in the app
127+
And I press "More" in the app
128+
And I press "Edit" in the app
129+
And I set the field "URL" to "https://moodlecloud.com/" in the app
130+
And I set the field "Description" to "Moodle Cloud" in the app
131+
And I press "Save" near "Web links" in the app
132+
And I should not see "https://moodle.org/"
133+
And I should not see "Moodle community site"
134+
And I should see "https://moodlecloud.com/"
135+
And I should see "Moodle Cloud"
136+
And I press "Delete" in the app
137+
And I should see "Are you sure you want to delete this entry?"
138+
And I press "Cancel" in the app
139+
And I should see "Moodle Cloud"
140+
And I press "Delete" in the app
141+
And I should see "Are you sure you want to delete this entry?"
142+
And I press "OK" in the app
143+
And I should not see "Moodle Cloud"
144+
And I should see "No entries in database"
145+
146+
Scenario: Teachers can edit and delete students' entries from list view in the app
147+
Given I enter the app
148+
And I log in as "student1"
149+
And I press "Course 1" near "Course overview" in the app
150+
And I press "Web links" near "General" in the app
151+
And I press "Add entries" in the app
152+
And I set the field "URL" to "https://moodle.org/" in the app
153+
And I set the field "Description" to "Moodle community site" in the app
154+
And I press "Save" near "Web links" in the app
155+
And I press "Add entries" in the app
156+
And I set the field "URL" to "https://telegram.org/" in the app
157+
And I set the field "Description" to "Telegram" in the app
158+
And I press "Save" near "Web links" in the app
159+
When I enter the app
160+
And I log in as "teacher1"
161+
And I press "Course 1" near "Course overview" in the app
162+
And I press "Web links" near "General" in the app
163+
Then I should see "https://moodle.org/"
164+
And I should see "Moodle community site"
165+
And I press "Edit" near "Moodle community site" in the app
166+
And I set the field "URL" to "https://moodlecloud.com/" in the app
167+
And I set the field "Description" to "Moodle Cloud" in the app
168+
And I press "Save" near "Web links" in the app
169+
And I should not see "https://moodle.org/"
170+
And I should not see "Moodle community site"
171+
And I should see "https://moodlecloud.com/"
172+
And I should see "Moodle Cloud"
173+
And I press "Delete" near "Moodle Cloud" in the app
174+
And I should see "Are you sure you want to delete this entry?"
175+
And I press "Cancel" in the app
176+
And I should see "Moodle Cloud"
177+
And I press "Delete" near "Moodle Cloud" in the app
178+
And I should see "Are you sure you want to delete this entry?"
179+
And I press "OK" in the app
180+
And I should not see "Moodle Cloud"
181+
And I press "More" in the app
182+
And I should see "https://telegram.org/"
183+
And I should see "Telegram"
184+
And I press "Edit" in the app
185+
And I set the field "URL" to "https://moodlecloud.com/" in the app
186+
And I set the field "Description" to "Moodle Cloud" in the app
187+
And I press "Save" near "Web links" in the app
188+
And I should not see "https://telegram.org/"
189+
And I should not see "Telegram"
190+
And I should see "https://moodlecloud.com/"
191+
And I should see "Moodle Cloud"
192+
And I press "Delete" in the app
193+
And I should see "Are you sure you want to delete this entry?"
194+
And I press "Cancel" in the app
195+
And I should see "Moodle Cloud"
196+
And I press "Delete" in the app
197+
And I should see "Are you sure you want to delete this entry?"
198+
And I press "OK" in the app
199+
And I should not see "Moodle Cloud"
Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
@mod @mod_data @app @javascript
2+
Feature: Users can store entries in database activities when offline and sync when online
3+
In order to populate databases while offline
4+
As a user
5+
I need to add and manage entries to databases and sync then when online
6+
7+
Background:
8+
Given the following "users" exist:
9+
| username | firstname | lastname | email |
10+
| student1 | Student | 1 | student1@example.com |
11+
| student2 | Student | 2 | student2@example.com |
12+
| teacher1 | Teacher | 1 | teacher1@example.com |
13+
And the following "courses" exist:
14+
| fullname | shortname | category |
15+
| Course 1 | C1 | 0 |
16+
And the following "course enrolments" exist:
17+
| user | course | role |
18+
| teacher1 | C1 | editingteacher |
19+
| student1 | C1 | student |
20+
| student2 | C1 | student |
21+
And the following "activities" exist:
22+
| activity | name | intro | course | idnumber |
23+
| data | Web links | Useful links | C1 | data1 |
24+
And I log in as "teacher1"
25+
And I am on "Course 1" course homepage
26+
And I add a "Text input" field to "Web links" database and I fill the form with:
27+
| Field name | URL |
28+
| Field description | URL link |
29+
And I add a "Text input" field to "Web links" database and I fill the form with:
30+
| Field name | Description |
31+
| Field description | Link description |
32+
And I log out
33+
34+
@app_from3.7
35+
Scenario: Students can add entries to a database in the app while offline
36+
Given I enter the app
37+
And I log in as "student1"
38+
And I press "Course 1" near "Course overview" in the app
39+
And I press "Web links" near "General" in the app
40+
And I switch offline mode to "true"
41+
And I should see "No entries in database"
42+
When I press "Add entries" in the app
43+
And I set the field "URL" to "https://moodle.org/" in the app
44+
And I set the field "Description" to "Moodle community site" in the app
45+
And I press "Save" near "Web links" in the app
46+
Then I should see "https://moodle.org/"
47+
And I should see "Moodle community site"
48+
And I should see "This Database has offline data to be synchronised"
49+
And I press "back" near "Web links" in the app
50+
And I switch offline mode to "false"
51+
And I press "Web links" near "General" in the app
52+
And I should see "https://moodle.org/"
53+
And I should see "Moodle community site"
54+
And I should not see "This Database has offline data to be synchronised"
55+
56+
@app_from3.7
57+
Scenario: Students can edit and delete entries to a database in the app while offline
58+
Given I enter the app
59+
And I log in as "student1"
60+
And I press "Course 1" near "Course overview" in the app
61+
And I press "Web links" near "General" in the app
62+
And I should see "No entries in database"
63+
And I press "Add entries" in the app
64+
And I set the field "URL" to "https://moodle.org/" in the app
65+
And I set the field "Description" to "Moodle community site" in the app
66+
And I press "Save" near "Web links" in the app
67+
And I should see "https://moodle.org/"
68+
And I should see "Moodle community site"
69+
And I press "Information" in the app
70+
And I press "Download" in the app
71+
And I wait until the page is ready
72+
And I switch offline mode to "true"
73+
When I press "Edit" in the app
74+
And I set the field "URL" to "https://moodlecloud.com/" in the app
75+
And I set the field "Description" to "Moodle Cloud" in the app
76+
And I press "Save" near "Web links" in the app
77+
Then I should not see "https://moodle.org/"
78+
And I should not see "Moodle community site"
79+
And I should see "https://moodlecloud.com/"
80+
And I should see "Moodle Cloud"
81+
And I should see "This Database has offline data to be synchronised"
82+
And I press "back" near "Web links" in the app
83+
And I switch offline mode to "false"
84+
And I press "Web links" near "General" in the app
85+
And I should not see "https://moodle.org/"
86+
And I should not see "Moodle community site"
87+
And I should see "https://moodlecloud.com/"
88+
And I should see "Moodle Cloud"
89+
And I should not see "This Database has offline data to be synchronised"
90+
And I press "Information" in the app
91+
And I press "Refresh" in the app
92+
And I wait until the page is ready
93+
And I switch offline mode to "true"
94+
And I press "Delete" in the app
95+
And I should see "Are you sure you want to delete this entry?"
96+
And I press "OK" in the app
97+
And I should see "https://moodlecloud.com/"
98+
And I should see "Moodle Cloud"
99+
And I should see "This Database has offline data to be synchronised"
100+
And I press "back" near "Web links" in the app
101+
And I switch offline mode to "false"
102+
And I press "Web links" near "General" in the app
103+
And I should not see "https://moodlecloud.com/"
104+
And I should not see "Moodle Cloud"
105+
And I should not see "This Database has offline data to be synchronised"
106+
107+
@app_from3.7
108+
Scenario: Students can undo deleting entries to a database in the app while offline
109+
Given I enter the app
110+
And I log in as "student1"
111+
And I press "Course 1" near "Course overview" in the app
112+
And I press "Web links" near "General" in the app
113+
And I should see "No entries in database"
114+
And I press "Add entries" in the app
115+
And I set the field "URL" to "https://moodle.org/" in the app
116+
And I set the field "Description" to "Moodle community site" in the app
117+
And I press "Save" near "Web links" in the app
118+
And I should see "https://moodle.org/"
119+
And I should see "Moodle community site"
120+
And I press "Information" in the app
121+
And I press "Download" in the app
122+
And I wait until the page is ready
123+
When I switch offline mode to "true"
124+
And I press "Delete" in the app
125+
And I should see "Are you sure you want to delete this entry?"
126+
And I press "OK" in the app
127+
And I should see "https://moodle.org/"
128+
And I should see "Moodle community site"
129+
And I should see "This Database has offline data to be synchronised"
130+
And I press "Restore" in the app
131+
And I press "back" near "Web links" in the app
132+
And I switch offline mode to "false"
133+
And I press "Web links" near "General" in the app
134+
Then I should see "https://moodle.org/"
135+
And I should see "Moodle community site"
136+
And I should not see "This Database has offline data to be synchronised"

0 commit comments

Comments
 (0)