Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 1
@tool_behat
2
Feature: Verify that all form fields values can be get and set
3
  In order to use behat steps definitions
4
  As a test writer
5
  I need to verify it all works in real moodle forms
6
 
7
  Background:
8
    Given the following "courses" exist:
9
      | fullname | shortname | category |
10
      | Course 1 | C1 | 0 |
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:
27
      | user | group |
28
      | student1 | G1 |
29
      | student2 | G1 |
30
      | student2 | G2 |
31
      | student3 | G2 |
32
    And the following "activities" exist:
33
      | activity | course | idnumber | name          | firstpagetitle | wikimode      | visible |
34
      | wiki     | C1     | wiki1    | Test this one | Test this one  | collaborative | 0       |
35
    And I am on the "Course 1" "reset" page logged in as admin
36
    # Select (multi-select) - Checking "the select box should contain".
37
    And I expand all fieldsets
38
    And the "Unenrol users" select box should contain "No roles"
39
    And the "Unenrol users" select box should contain "Student"
40
    And the "Unenrol users" select box should contain "Non-editing teacher"
41
    And the "Unenrol users" select box should contain "Teacher"
42
    And the "Unenrol users" select box should contain "Manager"
43
    And the "Unenrol users" select box should contain "No roles, Student, Non-editing teacher, Teacher, Manager"
44
    And the "Unenrol users" select box should contain "Manager, Teacher, Non-editing teacher, Student, No roles"
45
    And the "Unenrol users" select box should not contain "President"
46
    And the "Unenrol users" select box should not contain "Baker"
47
    And the "Unenrol users" select box should not contain "President, Baker"
48
    And I am on "Course 1" course homepage with editing mode on
49
    And I am on the "Test this one" "wiki activity" page
50
    And I press "Create page"
51
    # Text (textarea & editor) & Select (multi-select) - Checking "I set the following fields to these values".
52
    When I set the following fields to these values:
53
      | HTML format | Student page contents |
54
    And I press "Save"
55
    Then I should see "Student page contents" in the "region-main" "region"
56
    # Select (multi-select) - Checking "I set the field".
57
    And I navigate to "Settings" in current page administration
58
    And I expand all fieldsets
59
    # Checkbox - Checking "I set the field" and "The field matches value" ticked.
60
    And I set the field "Force format" to "1"
61
    And I press "Save and return to course"
62
    And I am on the "Test this one" "wiki activity editing" page
63
    And I expand all fieldsets
64
    And the field "Force format" matches value "1"
65
    And the field "Force format" does not match value ""
66
    # Checkbox - Checking "I set the field" and "The field matches value" unticked.
67
    And I set the field "Force format" to ""
68
    And I press "Save and return to course"
69
    And I am on the "Test this one" "wiki activity editing" page
70
    And I expand all fieldsets
71
    And the field "Force format" matches value ""
72
    And the field "Force format" does not match value "1"
73
    # Checkbox - Checking "I set the following fields to these values:" and "The following fields match these values" ticked.
74
    And I set the following fields to these values:
75
      | Force format | 1 |
76
    And I press "Save and return to course"
77
    And I am on the "Test this one" "wiki activity editing" page
78
    And I expand all fieldsets
79
    And the following fields match these values:
80
      | Force format | 1 |
81
    And the following fields do not match these values:
82
      | Force format | |
83
    # Checkbox - Checking "I set the following fields to these values:" and "The following fields match these values" unticked.
84
    And I set the following fields to these values:
85
      | Force format | |
86
    And I press "Save and return to course"
87
    And I am on the "Test this one" "wiki activity editing" page
88
    And I expand all fieldsets
89
    And the following fields match these values:
90
      | Force format | |
91
    And the following fields do not match these values:
92
      | Force format | 1 |
93
    # Select (simple) - Checking "I set the following fields to these values:".
94
    And I set the following fields to these values:
95
      | Default format | NWiki |
96
    # Select (simple) - Checking "I set the field".
97
    And I set the field "Group mode" to "Separate groups"
98
    And I press "Save and display"
99
    And I navigate to "Settings" in current page administration
100
    And the following fields match these values:
101
      | Default format | NWiki |
102
      | Group mode | Separate groups |
103
    # All fields - Checking "the following fields do not match these values".
104
    And the following fields do not match these values:
105
      | Wiki name | Test this one baby |
106
      | Default format | HTML |
107
    And I press "Cancel"
108
    # Radio - Checking "I set the field" and "the field matches value".
109
    And the following "activity" exists:
110
      | activity         | choice                       |
111
      | course           | C1                           |
112
      | idnumber         | choice1                      |
113
      | intro            | Test choice description      |
114
      | name             | Test choice name             |
115
      | choice1          | Option 1, Option 2, Option 3 |
116
      | section          | 1                            |
117
      | allowupdate      | 1                            |
118
    And I am on "Course 1" course homepage
119
    And I am on the "Test choice name" "choice activity editing" page
120
    And I set the field "Option 1" to "one"
121
    And I set the field "Option 2" to "two"
122
    And I set the field "Option 3" to "three"
123
    And I press "Save and return to course"
124
    And I am on "Course 1" course homepage
125
    And I am on the "Test choice name" "choice activity" page
126
    And I set the field "one" to "1"
127
    And I press "Save my choice"
128
    And the field "one" matches value "1"
129
    And the field "two" matches value ""
130
    # Check if field xpath set/match works.
131
    And I am on "Course 1" course homepage
132
    And I navigate to "Settings" in current page administration
133
    And I set the field with xpath "//input[@id='id_idnumber']" to "Course id number"
134
    And the field with xpath "//input[@name='idnumber']" matches value "Course id number"
135
    And the field with xpath "//input[@name='idnumber']" does not match value ""
136
    And I press "Save and display"
137
    And I navigate to "Settings" in current page administration
138
    And the field "Course ID number" matches value "Course id number"
139
 
140
  @javascript
141
  Scenario: with JS enabled all form fields getters and setters works as expected
142
    Given the following "activities" exist:
143
      | activity | course | name        |
144
      | lesson   | C1     | Test lesson |
145
    Then I am on the "Course 1" "groups" page
146
    # Select (multi-select & AJAX) - Checking "I set the field" and "select box should contain".
147
    And I set the field "groups" to "Group 2"
148
    And the "members" select box should contain "Student 2 (s2@example.com)"
149
    And the "members" select box should contain "Student 3 (s3@example.com)"
150
    And the "members" select box should not contain "Student 1 (s1@example.com)"
151
    And I set the field "groups" to "Group 1"
152
    And the "members" select box should contain "Student 1 (s1@example.com)"
153
    And the "members" select box should contain "Student 2 (s2@example.com)"
154
    And the "members" select box should not contain "Student 3 (s3@example.com)"
155
    # Checkbox (AJAX) - Checking "I set the field" and "I set the following fields to these values".
156
    And I am on the "Test lesson" "lesson activity editing" page
157
    And I set the following fields to these values:
158
      | available[enabled] | 1 |
159
    And I set the field "deadline[enabled]" to "1"
160
    # Checkbox (AJAX) - Checking "the field matches value" before saving.
161
    And the field "available[enabled]" matches value "1"
162
    And the "available[day]" "field" should be enabled
163
    And the field "deadline[enabled]" matches value "1"
164
    And I press "Save and display"
165
    And I navigate to "Settings" in current page administration
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 "Cancel"
170
    # Advanced checkbox requires real browser to allow uncheck to work. MDL-58681. MDL-55386.
171
    # Advanced checkbox - Checking "I set the field" and "The field matches value" ticked.
172
    And I am on the "Test choice name" "choice activity editing" page
173
    And I set the field "Display description on course page" to "1"
174
    And I press "Save and return to course"
175
    And I am on the "Test choice name" "choice activity editing" page
176
    And the field "Display description on course page" matches value "1"
177
    And the field "Display description on course page" does not match value ""
178
    # Advanced checkbox - Checking "I set the field" and "The field matches value" unticked.
179
    And I set the field "Display description on course page" to ""
180
    And I press "Save and return to course"
181
    And I am on the "Test choice name" "choice activity editing" page
182
    And the field "Display description on course page" matches value ""
183
    And the field "Display description on course page" does not match value "1"
184
    # Advanced checkbox - Checking "I set the following fields to these values:" and "The following fields match these values" ticked.
185
    And I set the following fields to these values:
186
      | Display description on course page | 1 |
187
    And I press "Save and return to course"
188
    And I am on the "Test choice name" "choice activity editing" page
189
    And the following fields match these values:
190
      | Display description on course page | 1 |
191
    And the following fields do not match these values:
192
      | Display description on course page | |
193
    # Advanced checkbox - Checking "I set the following fields to these values:" and "The following fields match these values" unticked.
194
    And I set the following fields to these values:
195
      | Display description on course page | |
196
    And I press "Save and return to course"
197
    And I am on the "Test choice name" "choice activity editing" page
198
    And the following fields match these values:
199
      | Display description on course page | |
200
    And the following fields do not match these values:
201
      | Display description on course page | 1 |