/admin/tool/behat/tests/behat/get_and_set_fields.feature

https://github.com/markn86/moodle · Gherkin Specification · 210 lines · 187 code · 3 blank · 20 comment · 15 complexity · ca0f0b15d6ba849e90fd19669dc183ec MD5 · raw file

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