source: moodle/trunk/fuentes/admin/tool/behat/tests/behat/get_and_set_fields.feature @ 136

Last change on this file since 136 was 136, checked in by mabarracus, 4 years ago

Ported code to xenial

File size: 8.2 KB
Line 
1@tool_behat
2Feature: 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@asd.com | Student | 1 |
14      | student2 | s2@asd.com | Student | 2 |
15      | student3 | s3@asd.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 | 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 follow "Manage tags"
39    # Select (multi-select) - We will check "I set the field...".
40    And I set the field "otagsadd" to "OT1, OT2, OT3, OT4, OT5"
41    And I press "Add official tags"
42    And I am on homepage
43    And I follow "Course 1"
44    And I turn editing mode on
45    And I follow "Test this one"
46    And I press "Create page"
47    # Select (multi-select) - Checking "the select box should contain".
48    And the "tags[officialtags][]" select box should contain "OT1"
49    And the "tags[officialtags][]" select box should contain "OT2"
50    And the "tags[officialtags][]" select box should contain "OT3"
51    And the "tags[officialtags][]" select box should contain "OT4"
52    And the "tags[officialtags][]" select box should contain "OT5"
53    And the "tags[officialtags][]" select box should contain "OT1, OT2, OT3, OT4, OT5"
54    And the "tags[officialtags][]" select box should contain "OT5, OT4, OT3, OT2, OT1"
55    And the "tags[officialtags][]" select box should not contain "OT6"
56    And the "tags[officialtags][]" select box should not contain "OT7"
57    And the "tags[officialtags][]" select box should not contain "OT6, OT7"
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 to be tagged |
61      | tags[officialtags][] | OT1, OT3, OT5 |
62    And I press "Save"
63    Then I should see "Student page contents to be tagged" in the "region-main" "region"
64    And I should see "OT1" in the ".wiki-tags" "css_element"
65    And I should see "OT3" in the ".wiki-tags" "css_element"
66    And I should see "OT5" in the ".wiki-tags" "css_element"
67    And I should not see "OT2" in the ".wiki-tags" "css_element"
68    And I should not see "OT4" in the ".wiki-tags" "css_element"
69    And I follow "Edit"
70    # Select (multi-select) - Checking "I set the field".
71    And I set the field "tags[officialtags][]" to "OT2, OT4"
72    And I press "Save"
73    And I should see "OT2" in the ".wiki-tags" "css_element"
74    And I should see "OT4" in the ".wiki-tags" "css_element"
75    And I should not see "OT1" in the ".wiki-tags" "css_element"
76    And I should not see "OT3" in the ".wiki-tags" "css_element"
77    And I should not see "OT5" in the ".wiki-tags" "css_element"
78    And I follow "Edit"
79    # Select (multi-select) - Checking "the field matches value" and "the field does not match value".
80    And the field "tags[officialtags][]" matches value "OT2, OT4"
81    And the field "tags[officialtags][]" does not match value "OT4"
82    And the field "tags[officialtags][]" does not match value "OT2"
83    And the field "tags[officialtags][]" does not match value "OT1, OT3, OT5"
84    And I press "Cancel"
85    And I follow "Edit settings"
86    And I expand all fieldsets
87    # Checkbox - Checking "I set the field".
88    And I set the field "Display description on course page" to "1"
89    # Checkbox - Checking "I set the following fields to these values:".
90    And I set the following fields to these values:
91      | Force format | 1 |
92    # Checkbox - Checking "the field matches value" and "the field does not match value".
93    And the field "Display description on course page" matches value "1"
94    And the field "Display description on course page" does not match value ""
95    And I press "Save and return to course"
96    And I should see "Test this one"
97    And I follow "Test this one"
98    And I follow "Edit settings"
99    # Checkbox - Checking "the field matches value" and "the following fields match these values".
100    And the following fields match these values:
101      | Display description on course page | 1 |
102      | Default format | HTML |
103      | Wiki name | Test this one |
104    And the field "Force format" matches value "1"
105    # Select (simple) - Checking "I set the following fields to these values:".
106    And I set the following fields to these values:
107      | Default format | NWiki |
108      | Display description on course page | |
109    # Checkbox - Checking "I set the field" to uncheck.
110    And I set the field "Force format" to ""
111    # Select (simple) - Checking "I set the field".
112    And I set the field "Group mode" to "Separate groups"
113    And I press "Save and display"
114    And I follow "Edit settings"
115    And the following fields match these values:
116      | Default format | NWiki |
117      | Group mode | Separate groups |
118      | Display description on course page | |
119      | Force format | |
120    # All fields - Checking "the following fields do not match these values".
121    And the following fields do not match these values:
122      | Wiki name | Test this one baby |
123      | Default format | HTML |
124      | Force format | 1 |
125    And I press "Cancel"
126    And I follow "Course 1"
127    # Radio - Checking "I set the field" and "the field matches value".
128    And I add a "Choice" to section "1" and I fill the form with:
129      | Choice name | Test choice name |
130      | Description | Test choice description |
131      | Allow choice to be updated | Yes |
132      | Option 1 | one |
133      | Option 2 | two |
134      | Option 3 | three |
135    And I follow "Test choice name"
136    And I set the field "one" to "1"
137    And I press "Save my choice"
138    And the field "one" matches value "1"
139    And the field "two" matches value ""
140
141  Scenario: with JS disabled all form fields getters and setters works as expected
142
143  @javascript
144  Scenario: with JS enabled all form fields getters and setters works as expected
145    Then I follow "Course 1"
146    And I expand "Users" node
147    And I follow "Groups"
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 follow "Course 1"
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 follow "Edit settings"
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"
174    And I press "Cancel"
Note: See TracBrowser for help on using the repository browser.