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".
62 And I set the field "Display description on course page" to "1"
63 # Checkbox - Checking "I set the following fields to these values:".
64 And I set the following fields to these values:
66 # Checkbox - Checking "the field matches value" and "the field does not match value".
67 And the field "Display description on course page" matches value "1"
68 And the field "Display description on course page" does not match value ""
69 And I press "Save and return to course"
70 And I should see "Test this one"
71 And I follow "Test this one"
72 And I navigate to "Edit settings" in current page administration
73 # Checkbox - Checking "the field matches value" and "the following fields match these values".
74 And the following fields match these values:
75 | Display description on course page | 1 |
76 | Default format | HTML |
77 | Wiki name | Test this one |
78 And the field "Force format" matches value "1"
79 # Select (simple) - Checking "I set the following fields to these values:".
80 And I set the following fields to these values:
81 | Default format | NWiki |
82 | Display description on course page | |
83 # Checkbox - Checking "I set the field" to uncheck.
84 And I set the field "Force format" to ""
85 # Select (simple) - Checking "I set the field".
86 And I set the field "Group mode" to "Separate groups"
87 And I press "Save and display"
88 And I navigate to "Edit settings" in current page administration
89 And the following fields match these values:
90 | Default format | NWiki |
91 | Group mode | Separate groups |
92 | Display description on course page | |
94 # All fields - Checking "the following fields do not match these values".
95 And the following fields do not match these values:
96 | Wiki name | Test this one baby |
97 | Default format | HTML |
100 And I am on "Course 1" course homepage
101 # Radio - Checking "I set the field" and "the field matches value".
102 And I add a "Choice" to section "1" and I fill the form with:
103 | Choice name | Test choice name |
104 | Description | Test choice description |
105 | Allow choice to be updated | Yes |
109 And I follow "Test choice name"
110 And I set the field "one" to "1"
111 And I press "Save my choice"
112 And the field "one" matches value "1"
113 And the field "two" matches value ""
114 # Check if field xpath set/match works.
115 And I am on "Course 1" course homepage
116 And I navigate to "Edit settings" node in "Course administration"
117 And I set the field with xpath "//input[@id='id_idnumber']" to "Course id number"
118 And the field with xpath "//input[@name='idnumber']" matches value "Course id number"
119 And the field with xpath "//input[@name='idnumber']" does not match value ""
120 And I press "Save and display"
121 And I navigate to "Edit settings" node in "Course administration"
122 And the field "Course ID number" matches value "Course id number"
124 Scenario: with JS disabled all form fields getters and setters works as expected
127 Scenario: with JS enabled all form fields getters and setters works as expected
128 Then I am on "Course 1" course homepage
129 And I navigate to "Users > Groups" in current page administration
130 # Select (multi-select & AJAX) - Checking "I set the field" and "select box should contain".
131 And I set the field "groups" to "Group 2"
132 And the "members" select box should contain "Student 2"
133 And the "members" select box should contain "Student 3"
134 And the "members" select box should not contain "Student 1"
135 And I set the field "groups" to "Group 1"
136 And the "members" select box should contain "Student 1"
137 And the "members" select box should contain "Student 2"
138 And the "members" select box should not contain "Student 3"
139 # Checkbox (AJAX) - Checking "I set the field" and "I set the following fields to these values".
140 And I am on "Course 1" course homepage
141 And I add a "Lesson" to section "1"
142 And I set the following fields to these values:
143 | Name | Test lesson |
144 | Description | Test lesson description |
145 | available[enabled] | 1 |
146 And I set the field "deadline[enabled]" to "1"
147 # Checkbox (AJAX) - Checking "the field matches value" before saving.
148 And the field "available[enabled]" matches value "1"
149 And the "available[day]" "field" should be enabled
150 And the field "deadline[enabled]" matches value "1"
151 And I press "Save and display"
152 And I navigate to "Edit settings" in current page administration
153 And the field "available[enabled]" matches value "1"
154 And the "available[day]" "field" should be enabled
155 And the field "deadline[enabled]" matches value "1"