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 expand "Site administration" node
37 And I expand "Appearance" node
38 And I am on site homepage
39 And I follow "Course 1"
41 # Select (multi-select) - Checking "the select box should contain".
42 And I expand all fieldsets
43 And the "Unenrol users" select box should contain "No roles"
44 And the "Unenrol users" select box should contain "Student"
45 And the "Unenrol users" select box should contain "Non-editing teacher"
46 And the "Unenrol users" select box should contain "Teacher"
47 And the "Unenrol users" select box should contain "Manager"
48 And the "Unenrol users" select box should contain "No roles, Student, Non-editing teacher, Teacher, Manager"
49 And the "Unenrol users" select box should contain "Manager, Teacher, Non-editing teacher, Student, No roles"
50 And the "Unenrol users" select box should not contain "President"
51 And the "Unenrol users" select box should not contain "Baker"
52 And the "Unenrol users" select box should not contain "President, Baker"
53 And I am on site homepage
54 And I follow "Course 1"
55 And I turn editing mode on
56 And I follow "Test this one"
57 And I press "Create page"
58 # Text (textarea & editor) & Select (multi-select) - Checking "I set the following fields to these values".
59 When I set the following fields to these values:
60 | HTML format | Student page contents |
62 Then I should see "Student page contents" in the "region-main" "region"
64 # Select (multi-select) - Checking "I set the field".
65 And I follow "Edit settings"
66 And I expand all fieldsets
67 # Checkbox - Checking "I set the field".
68 And I set the field "Display description on course page" to "1"
69 # Checkbox - Checking "I set the following fields to these values:".
70 And I set the following fields to these values:
72 # Checkbox - Checking "the field matches value" and "the field does not match value".
73 And the field "Display description on course page" matches value "1"
74 And the field "Display description on course page" does not match value ""
75 And I press "Save and return to course"
76 And I should see "Test this one"
77 And I follow "Test this one"
78 And I follow "Edit settings"
79 # Checkbox - Checking "the field matches value" and "the following fields match these values".
80 And the following fields match these values:
81 | Display description on course page | 1 |
82 | Default format | HTML |
83 | Wiki name | Test this one |
84 And the field "Force format" matches value "1"
85 # Select (simple) - Checking "I set the following fields to these values:".
86 And I set the following fields to these values:
87 | Default format | NWiki |
88 | Display description on course page | |
89 # Checkbox - Checking "I set the field" to uncheck.
90 And I set the field "Force format" to ""
91 # Select (simple) - Checking "I set the field".
92 And I set the field "Group mode" to "Separate groups"
93 And I press "Save and display"
94 And I follow "Edit settings"
95 And the following fields match these values:
96 | Default format | NWiki |
97 | Group mode | Separate groups |
98 | Display description on course page | |
100 # All fields - Checking "the following fields do not match these values".
101 And the following fields do not match these values:
102 | Wiki name | Test this one baby |
103 | Default format | HTML |
106 And I follow "Course 1"
107 # Radio - Checking "I set the field" and "the field matches value".
108 And I add a "Choice" to section "1" and I fill the form with:
109 | Choice name | Test choice name |
110 | Description | Test choice description |
111 | Allow choice to be updated | Yes |
115 And I follow "Test choice name"
116 And I set the field "one" to "1"
117 And I press "Save my choice"
118 And the field "one" matches value "1"
119 And the field "two" matches value ""
120 # Check if field xpath set/match works.
121 And I am on site homepage
122 And I follow "Course 1"
123 And I navigate to "Edit settings" node in "Course administration"
124 And I set the field with xpath "//input[@id='id_idnumber']" to "Course id number"
125 And the field with xpath "//input[@name='idnumber']" matches value "Course id number"
126 And the field with xpath "//input[@name='idnumber']" does not match value ""
127 And I press "Save and display"
128 And I navigate to "Edit settings" node in "Course administration"
129 And the field "Course ID number" matches value "Course id number"
132 Scenario: with JS disabled all form fields getters and setters works as expected
135 Scenario: with JS enabled all form fields getters and setters works as expected
136 Then I follow "Course 1"
137 And I expand "Users" node
138 And I follow "Groups"
139 # Select (multi-select & AJAX) - Checking "I set the field" and "select box should contain".
140 And I set the field "groups" to "Group 2"
141 And the "members" select box should contain "Student 2"
142 And the "members" select box should contain "Student 3"
143 And the "members" select box should not contain "Student 1"
144 And I set the field "groups" to "Group 1"
145 And the "members" select box should contain "Student 1"
146 And the "members" select box should contain "Student 2"
147 And the "members" select box should not contain "Student 3"
148 # Checkbox (AJAX) - Checking "I set the field" and "I set the following fields to these values".
149 And I follow "Course 1"
150 And I add a "Lesson" to section "1"
151 And I set the following fields to these values:
152 | Name | Test lesson |
153 | Description | Test lesson description |
154 | available[enabled] | 1 |
155 And I set the field "deadline[enabled]" to "1"
156 # Checkbox (AJAX) - Checking "the field matches value" before saving.
157 And the field "available[enabled]" matches value "1"
158 And the "available[day]" "field" should be enabled
159 And the field "deadline[enabled]" matches value "1"
160 And I press "Save and display"
161 And I follow "Edit settings"
162 And the field "available[enabled]" matches value "1"
163 And the "available[day]" "field" should be enabled
164 And the field "deadline[enabled]" matches value "1"