2 Feature: Verify that all form fields values can be get and set
3 In order to use behat steps definitions
5 I need to verify it all works in real moodle forms
8 Given the following "courses" exist:
9 | fullname | shortname | category |
11 And the following "users" exist:
12 | username | email | firstname | lastname |
13 | student1 | s1@example.com | Student | 1 |
14 | student2 | s2@example.com | Student | 2 |
15 | student3 | s3@example.com | Student | 3 |
16 And the following "course enrolments" exist:
17 | user | course | role |
18 | student1 | C1 | student |
19 | student2 | C1 | student |
20 | student3 | C1 | student |
21 | admin | C1 | editingteacher |
22 And the following "groups" exist:
23 | name | description | course | idnumber |
24 | Group 1 | G1 description | C1 | G1 |
25 | Group 2 | G1 description | C1 | G2 |
26 And the following "group members" exist:
32 And the following "activities" exist:
33 | activity | course | idnumber | name | intro | firstpagetitle | wikimode | visible |
34 | wiki | C1 | wiki1 | Test this one | Test this one | Test this one | collaborative | 0 |
35 And I log in as "admin"
36 And I am on "Course 1" course homepage
37 And I navigate to "Reset" node in "Course administration"
38 # Select (multi-select) - Checking "the select box should contain".
39 And I expand all fieldsets
40 And the "Unenrol users" select box should contain "No roles"
41 And the "Unenrol users" select box should contain "Student"
42 And the "Unenrol users" select box should contain "Non-editing teacher"
43 And the "Unenrol users" select box should contain "Teacher"
44 And the "Unenrol users" select box should contain "Manager"
45 And the "Unenrol users" select box should contain "No roles, Student, Non-editing teacher, Teacher, Manager"
46 And the "Unenrol users" select box should contain "Manager, Teacher, Non-editing teacher, Student, No roles"
47 And the "Unenrol users" select box should not contain "President"
48 And the "Unenrol users" select box should not contain "Baker"
49 And the "Unenrol users" select box should not contain "President, Baker"
50 And I am on "Course 1" course homepage with editing mode on
51 And I follow "Test this one"
52 And I press "Create page"
53 # Text (textarea & editor) & Select (multi-select) - Checking "I set the following fields to these values".
54 When I set the following fields to these values:
55 | HTML format | Student page contents |
57 Then I should see "Student page contents" in the "region-main" "region"
58 # Select (multi-select) - Checking "I set the field".
59 And I navigate to "Edit settings" in current page administration
60 And I expand all fieldsets
61 # Checkbox - Checking "I set the field" and "The field matches value" ticked.
62 And I set the field "Force format" to "1"
63 And I press "Save and return to course"
64 And I should see "Test this one"
65 And I follow "Test this one"
66 And I navigate to "Edit settings" in current page administration
67 And I expand all fieldsets
68 And the field "Force format" matches value "1"
69 And the field "Force format" does not match value ""
70 # Checkbox - Checking "I set the field" and "The field matches value" unticked.
71 And I set the field "Force format" to ""
72 And I press "Save and return to course"
73 And I should see "Test this one"
74 And I follow "Test this one"
75 And I navigate to "Edit settings" in current page administration
76 And I expand all fieldsets
77 And the field "Force format" matches value ""
78 And the field "Force format" does not match value "1"
79 # Checkbox - Checking "I set the following fields to these values:" and "The following fields match these values" ticked.
80 And I set the following fields to these values:
82 And I press "Save and return to course"
83 And I should see "Test this one"
84 And I follow "Test this one"
85 And I navigate to "Edit settings" in current page administration
86 And I expand all fieldsets
87 And the following fields match these values:
89 And the following fields do not match these values:
91 # Checkbox - Checking "I set the following fields to these values:" and "The following fields match these values" unticked.
92 And I set the following fields to these values:
94 And I press "Save and return to course"
95 And I should see "Test this one"
96 And I follow "Test this one"
97 And I navigate to "Edit settings" in current page administration
98 And I expand all fieldsets
99 And the following fields match these values:
101 And the following fields do not match these values:
103 # Select (simple) - Checking "I set the following fields to these values:".
104 And I set the following fields to these values:
105 | Default format | NWiki |
106 # Select (simple) - Checking "I set the field".
107 And I set the field "Group mode" to "Separate groups"
108 And I press "Save and display"
109 And I navigate to "Edit settings" in current page administration
110 And the following fields match these values:
111 | Default format | NWiki |
112 | Group mode | Separate groups |
113 # All fields - Checking "the following fields do not match these values".
114 And the following fields do not match these values:
115 | Wiki name | Test this one baby |
116 | Default format | HTML |
118 And I am on "Course 1" course homepage
119 # Radio - Checking "I set the field" and "the field matches value".
120 And I add a "Choice" to section "1" and I fill the form with:
121 | Choice name | Test choice name |
122 | Description | Test choice description |
123 | Allow choice to be updated | Yes |
127 And I follow "Test choice name"
128 And I set the field "one" to "1"
129 And I press "Save my choice"
130 And the field "one" matches value "1"
131 And the field "two" matches value ""
132 # Check if field xpath set/match works.
133 And I am on "Course 1" course homepage
134 And I navigate to "Edit settings" node in "Course administration"
135 And I set the field with xpath "//input[@id='id_idnumber']" to "Course id number"
136 And the field with xpath "//input[@name='idnumber']" matches value "Course id number"
137 And the field with xpath "//input[@name='idnumber']" does not match value ""
138 And I press "Save and display"
139 And I navigate to "Edit settings" node in "Course administration"
140 And the field "Course ID number" matches value "Course id number"
142 Scenario: with JS disabled all form fields getters and setters works as expected
145 Scenario: with JS enabled all form fields getters and setters works as expected
146 Then I am on "Course 1" course homepage
147 And I navigate to "Users > Groups" in current page administration
148 # Select (multi-select & AJAX) - Checking "I set the field" and "select box should contain".
149 And I set the field "groups" to "Group 2"
150 And the "members" select box should contain "Student 2"
151 And the "members" select box should contain "Student 3"
152 And the "members" select box should not contain "Student 1"
153 And I set the field "groups" to "Group 1"
154 And the "members" select box should contain "Student 1"
155 And the "members" select box should contain "Student 2"
156 And the "members" select box should not contain "Student 3"
157 # Checkbox (AJAX) - Checking "I set the field" and "I set the following fields to these values".
158 And I am on "Course 1" course homepage
159 And I add a "Lesson" to section "1"
160 And I set the following fields to these values:
161 | Name | Test lesson |
162 | Description | Test lesson description |
163 | available[enabled] | 1 |
164 And I set the field "deadline[enabled]" to "1"
165 # Checkbox (AJAX) - Checking "the field matches value" before saving.
166 And the field "available[enabled]" matches value "1"
167 And the "available[day]" "field" should be enabled
168 And the field "deadline[enabled]" matches value "1"
169 And I press "Save and display"
170 And I navigate to "Edit settings" in current page administration
171 And the field "available[enabled]" matches value "1"
172 And the "available[day]" "field" should be enabled
173 And the field "deadline[enabled]" matches value "1"
175 # Advanced checkbox requires real browser to allow uncheck to work. MDL-58681. MDL-55386.
176 # Advanced checkbox - Checking "I set the field" and "The field matches value" ticked.
177 And I am on "Course 1" course homepage
178 And I follow "Test this one"
179 And I navigate to "Edit settings" in current page administration
180 And I set the field "Display description on course page" to "1"
181 And I press "Save and return to course"
182 And I should see "Test this one"
183 And I follow "Test this one"
184 And I navigate to "Edit settings" in current page administration
185 And the field "Display description on course page" matches value "1"
186 And the field "Display description on course page" does not match value ""
187 # Advanced checkbox - Checking "I set the field" and "The field matches value" unticked.
188 And I set the field "Display description on course page" to ""
189 And I press "Save and return to course"
190 And I should see "Test this one"
191 And I follow "Test this one"
192 And I navigate to "Edit settings" in current page administration
193 And the field "Display description on course page" matches value ""
194 And the field "Display description on course page" does not match value "1"
195 # Advanced checkbox - Checking "I set the following fields to these values:" and "The following fields match these values" ticked.
196 And I set the following fields to these values:
197 | Display description on course page | 1 |
198 And I press "Save and return to course"
199 And I should see "Test this one"
200 And I follow "Test this one"
201 And I navigate to "Edit settings" in current page administration
202 And the following fields match these values:
203 | Display description on course page | 1 |
204 And the following fields do not match these values:
205 | Display description on course page | |
206 # Advanced checkbox - Checking "I set the following fields to these values:" and "The following fields match these values" unticked.
207 And I set the following fields to these values:
208 | Display description on course page | |
209 And I press "Save and return to course"
210 And I should see "Test this one"
211 And I follow "Test this one"
212 And I navigate to "Edit settings" in current page administration
213 And the following fields match these values:
214 | Display description on course page | |
215 And the following fields do not match these values:
216 | Display description on course page | 1 |