1 |
efrain |
1 |
@mod @mod_data
|
|
|
2 |
Feature: Users can be required to specify certain fields when adding entries to database activities
|
|
|
3 |
In order to constrain user input
|
|
|
4 |
As a teacher
|
|
|
5 |
I need to specify certain fields as required when I add 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 |
| teacher1 | Teacher | 1 | teacher1@example.com |
|
|
|
12 |
And the following "courses" exist:
|
|
|
13 |
| fullname | shortname | category |
|
|
|
14 |
| Course 1 | C1 | 0 |
|
|
|
15 |
And the following "course enrolments" exist:
|
|
|
16 |
| user | course | role |
|
|
|
17 |
| teacher1 | C1 | editingteacher |
|
|
|
18 |
| student1 | C1 | student |
|
|
|
19 |
And the following "activities" exist:
|
|
|
20 |
| activity | name | intro | course | idnumber |
|
|
|
21 |
| data | Test database name | n | C1 | data1 |
|
|
|
22 |
And the following "mod_data > fields" exist:
|
|
|
23 |
| database | type | name | required | description | param1 |
|
|
|
24 |
| data1 | text | Base Text input | 1 | Base Text input | |
|
|
|
25 |
| data1 | checkbox | Required Checkbox | 1 | Base Text input | Required Checkbox Option 1 |
|
|
|
26 |
| data1 | checkbox | Required Two-Option Checkbox | 1 | Required Two-Option Checkbox | RTOC Option 1\nRTOC Option 2 |
|
|
|
27 |
| data1 | latlong | Required Coordinates | 1 | Required Coordinates | |
|
|
|
28 |
| data1 | menu | Required Menu | 1 | Required Menu | Option 1 |
|
|
|
29 |
| data1 | number | Required Number | 1 | Required Number | |
|
|
|
30 |
| data1 | radiobutton | Required Radio | 1 | Required Radio | Required Radio Option 1 |
|
|
|
31 |
| data1 | text | Required Text input | 1 | Required Text input | |
|
|
|
32 |
| data1 | textarea | Required Text area | 1 | Required Text area | |
|
|
|
33 |
| data1 | url | Required URL | 1 | Required URL | |
|
|
|
34 |
| data1 | multimenu | Required Multimenu | 1 | Required Multimenu | Option 1 |
|
|
|
35 |
| data1 | multimenu | Required Two-Option Multimenu | 1 | Required Two-Option Multimenu | Option 1\nOption 2 |
|
|
|
36 |
| data1 | checkbox | Not required Checkbox | 0 | Not required Checkbox | Not required Checkbox Option 1 |
|
|
|
37 |
| data1 | latlong | Not required Coordinates | 0 | Not required Coordinates | |
|
|
|
38 |
| data1 | menu | Not required Menu | 0 | Not required Menu | Option 1 |
|
|
|
39 |
| data1 | number | Not required Number | 0 | Not required Number | |
|
|
|
40 |
| data1 | radiobutton | Not required Radio | 0 | Not required Radio | Not required Radio Option 1 |
|
|
|
41 |
| data1 | text | Not required Text input | 0 | Not required Text input | |
|
|
|
42 |
| data1 | textarea | Not required Text area | 0 | Not required Text area | |
|
|
|
43 |
| data1 | url | Not required URL | 0 | Not required URL | |
|
|
|
44 |
| data1 | multimenu | Not required Multimenu | 0 | Not required Multimenu | Option 1 |
|
|
|
45 |
|
|
|
46 |
Scenario: Students receive errors for empty required fields but not for optional fields
|
|
|
47 |
Given I am on the "Test database name" "data activity" page logged in as student1
|
|
|
48 |
And I click on "Add entry" "button"
|
|
|
49 |
And I set the field "Base Text input" to "Some input to allow us to submit the otherwise empty form"
|
|
|
50 |
When I press "Save"
|
|
|
51 |
# Then ".alert" "css_element" should exist in the "//div[contains(@id,'defaulttemplate-addentry']//div[position()=1]]" "xpath_element"
|
|
|
52 |
Then ".alert" "css_element" should appear after "Checkbox" "text"
|
|
|
53 |
And ".alert" "css_element" should appear before "Required Checkbox" "text"
|
|
|
54 |
And ".alert" "css_element" should appear after "Two-Option Checkbox" "text"
|
|
|
55 |
And ".alert" "css_element" should appear before "Required Two-Option Checkbox" "text"
|
|
|
56 |
And ".alert" "css_element" should appear after "Coordinates" "text"
|
|
|
57 |
And ".alert" "css_element" should appear before "Required Coordinates" "text"
|
|
|
58 |
And ".alert" "css_element" should appear after "Menu" "text"
|
|
|
59 |
And ".alert" "css_element" should appear before "Required Menu" "text"
|
|
|
60 |
And ".alert" "css_element" should appear after "Radio" "text"
|
|
|
61 |
And ".alert" "css_element" should appear before "Required Radio" "text"
|
|
|
62 |
And ".alert" "css_element" should appear after "Text input" "text"
|
|
|
63 |
And ".alert" "css_element" should appear before "Required Text input" "text"
|
|
|
64 |
And ".alert" "css_element" should appear after "Text area" "text"
|
|
|
65 |
And ".alert" "css_element" should appear before "Required Text area" "text"
|
|
|
66 |
And ".alert" "css_element" should appear after "URL" "text"
|
|
|
67 |
And ".alert" "css_element" should appear before "Required URL" "text"
|
|
|
68 |
And ".alert" "css_element" should appear after "Multimenu" "text"
|
|
|
69 |
And ".alert" "css_element" should appear before "Required Multimenu" "text"
|
|
|
70 |
And ".alert" "css_element" should appear after "Two-Option Multimenu" "text"
|
|
|
71 |
And ".alert" "css_element" should appear before "Required Two-Option Multimenu" "text"
|
|
|
72 |
And I am on "Course 1" course homepage
|
|
|
73 |
And I follow "Test database name"
|
|
|
74 |
And I should see "No entries yet"
|
|
|
75 |
|
|
|
76 |
Scenario: Students receive no error for filled in required fields
|
|
|
77 |
Given I am on the "Test database name" "data activity" page logged in as student1
|
|
|
78 |
And I click on "Add entry" "button"
|
|
|
79 |
And I set the following fields to these values:
|
|
|
80 |
| Base Text input | Some input to allow us to submit the otherwise empty form |
|
|
|
81 |
| Required Checkbox Option 1 | 1 |
|
|
|
82 |
| RTOC Option 1 | 1 |
|
|
|
83 |
| Latitude | 0 |
|
|
|
84 |
| Longitude | 0 |
|
|
|
85 |
| Required Menu | 1 |
|
|
|
86 |
| Required Number | 1 |
|
|
|
87 |
| Required Radio Option 1 | 1 |
|
|
|
88 |
| Required Text input | New entry text |
|
|
|
89 |
| Required Text area | More text |
|
|
|
90 |
| Required URL | http://example.com/ |
|
|
|
91 |
| Required Multimenu | 1 |
|
|
|
92 |
| Required Two-Option Multimenu | 1 |
|
|
|
93 |
When I press "Save"
|
|
|
94 |
And I select "List view" from the "jump" singleselect
|
|
|
95 |
Then I should not see "No entries in database"
|
|
|
96 |
And I should see "New entry text"
|
|
|
97 |
|
|
|
98 |
Scenario: Fields refill with data after having an error
|
|
|
99 |
Given I am on the "Test database name" "data activity" page logged in as student1
|
|
|
100 |
And I click on "Add entry" "button"
|
|
|
101 |
And I set the following fields to these values:
|
|
|
102 |
| RTOC Option 1 | 1 |
|
|
|
103 |
| Latitude | 0 |
|
|
|
104 |
| Longitude | 0 |
|
|
|
105 |
| Required Menu | 1 |
|
|
|
106 |
| Required Number | 1 |
|
|
|
107 |
| Required Radio Option 1 | 1 |
|
|
|
108 |
| Required Text input | New entry text |
|
|
|
109 |
| Required Text area | More text |
|
|
|
110 |
| Required URL | http://example.com/ |
|
|
|
111 |
| Required Multimenu | 1 |
|
|
|
112 |
| Required Two-Option Multimenu | 1 |
|
|
|
113 |
When I press "Save"
|
|
|
114 |
Then the following fields match these values:
|
|
|
115 |
| Base Text input | |
|
|
|
116 |
| Latitude | 0 |
|
|
|
117 |
| Longitude | 0 |
|
|
|
118 |
| Required Menu | Option 1 |
|
|
|
119 |
| Required Number | 1 |
|
|
|
120 |
| Required Radio Option 1 | 1 |
|
|
|
121 |
| Required Text input | New entry text |
|
|
|
122 |
| Required Text area | More text |
|
|
|
123 |
| Required URL | http://example.com/ |
|
|
|
124 |
| Required Multimenu | Option 1 |
|
|
|
125 |
| Required Two-Option Multimenu | Option 1 |
|
|
|
126 |
|
|
|
127 |
@javascript
|
|
|
128 |
Scenario: A student fills in Latitude but not Longitude will see an error
|
|
|
129 |
Given I am on the "Test database name" "data activity" page logged in as student1
|
|
|
130 |
And I click on "Add entry" "button"
|
|
|
131 |
And I set the following fields to these values:
|
|
|
132 |
| Base Text input | Some input to allow us to submit the otherwise empty form |
|
|
|
133 |
| Required Checkbox Option 1 | 1 |
|
|
|
134 |
| RTOC Option 1 | 1 |
|
|
|
135 |
| Latitude | 24 |
|
|
|
136 |
| Required Menu | 1 |
|
|
|
137 |
| Required Number | 1 |
|
|
|
138 |
| Required Radio Option 1 | 1 |
|
|
|
139 |
| Required Text input | New entry text |
|
|
|
140 |
| Required Text area | More text |
|
|
|
141 |
| Required URL | http://example.com/ |
|
|
|
142 |
| Required Multimenu | 1 |
|
|
|
143 |
| Required Two-Option Multimenu | 1 |
|
|
|
144 |
| Latitude | 20 |
|
|
|
145 |
When I press "Save"
|
|
|
146 |
Then I should see "Both latitude and longitude are required."
|
|
|
147 |
|
|
|
148 |
Scenario: A student filling in number and text fields with zero will not see an error.
|
|
|
149 |
Scenario: A student fills in Latitude but not Longitude will see an error
|
|
|
150 |
Given I am on the "Test database name" "data activity" page logged in as student1
|
|
|
151 |
And I click on "Add entry" "button"
|
|
|
152 |
And I set the following fields to these values:
|
|
|
153 |
| Base Text input | Some input to allow us to submit the otherwise empty form |
|
|
|
154 |
| Required Checkbox Option 1 | 1 |
|
|
|
155 |
| RTOC Option 1 | 1 |
|
|
|
156 |
| Latitude | 0 |
|
|
|
157 |
| Longitude | 0 |
|
|
|
158 |
| Required Menu | 1 |
|
|
|
159 |
| Required Number | 0 |
|
|
|
160 |
| Required Radio Option 1 | 1 |
|
|
|
161 |
| Required Text input | 0 |
|
|
|
162 |
| Required Text area | 0 |
|
|
|
163 |
| Required URL | http://example.com/ |
|
|
|
164 |
| Required Multimenu | 1 |
|
|
|
165 |
| Required Two-Option Multimenu | 1 |
|
|
|
166 |
When I press "Save"
|
|
|
167 |
And I select "List view" from the "jump" singleselect
|
|
|
168 |
Then I should not see "No entries in database"
|
|
|
169 |
And I should see "Some input to allow us to submit the otherwise empty form"
|