MDL-59437 behat: avoid using participants page for tag tests
[moodle.git] / tag / tests / behat / edit_tag.feature
CommitLineData
8e355853
MG
1@core @core_tag
2Feature: Users can edit tags to add description or rename
3 In order to use tags
4 As a manager
5 I need to be able to edit tags
6
7 Background:
8 Given the following "users" exist:
810805da
MG
9 | username | firstname | lastname | email | interests |
10 | manager1 | Manager | 1 | manager1@example.com | |
11 | user1 | User | 1 | user1@example.com | Cat,Dog,Turtle |
12 | editor1 | Editor | 1 | editor1@example.com | |
8e355853
MG
13 Given the following "roles" exist:
14 | name | shortname |
15 | Tag editor | tageditor |
16 And the following "system role assigns" exist:
17 | user | course | role |
18 | manager1 | Acceptance test site | manager |
19 | editor1 | Acceptance test site | tageditor |
20 And the following "tags" exist:
e11d7380
MG
21 | name | isstandard |
22 | Neverusedtag | 1 |
8e355853 23
a27c42ee 24 @javascript
8e355853
MG
25 Scenario: User with tag editing capability can change tag description
26 Given I log in as "admin"
27 And I set the following system permissions of "Tag editor" role:
810805da
MG
28 | capability | permission |
29 | moodle/tag:edit | Allow |
30 | moodle/site:viewparticipants | Allow |
31 | moodle/user:viewdetails | Allow |
8e355853
MG
32 And I log out
33 When I log in as "editor1"
7a12a02d 34 And I press "Customise this page"
d131489e 35 # TODO MDL-57120 site "Tags" link not accessible without navigation block.
7a12a02d 36 And I add the "Navigation" block if not present
d131489e
EL
37 And I navigate to "Tags" node in "Site pages"
38 And I follow "Turtle"
810805da 39 And I follow "User 1"
8e355853
MG
40 And I follow "Cat"
41 And I follow "Edit this tag"
42 And I should not see "Tag name"
e11d7380 43 And I should not see "Standard"
8e355853
MG
44 And I set the following fields to these values:
45 | Description | Description of tag 1 |
46 | Related tags | Dog, Turtle,Fish |
47 And I press "Update"
48 Then "Cat" "text" should exist in the ".breadcrumb-nav" "css_element"
c026a28d
MG
49 And "Description of tag 1" "text" should exist in the ".tag-description" "css_element"
50 And I should see "Related tags:" in the ".tag_list" "css_element"
51 And I should see "Dog" in the ".tag_list" "css_element"
52 And I should see "Turtle" in the ".tag_list" "css_element"
53 And I should see "Fish" in the ".tag_list" "css_element"
8e355853
MG
54 And I log out
55
a27c42ee 56 @javascript
8e355853
MG
57 Scenario: Manager can change tag description, related tags and rename the tag from tag view page
58 When I log in as "manager1"
7a12a02d 59 And I press "Customise this page"
d131489e 60 # TODO MDL-57120 site "Tags" link not accessible without navigation block.
7a12a02d 61 And I add the "Navigation" block if not present
d131489e
EL
62 And I navigate to "Tags" node in "Site pages"
63 And I follow "Turtle"
810805da 64 And I follow "User 1"
8e355853
MG
65 And I follow "Cat"
66 And I follow "Edit this tag"
67 And I set the following fields to these values:
68 | Tag name | Kitten |
69 | Description | Description of tag 1 |
70 | Related tags | Dog, Turtle,Fish |
e11d7380 71 | Standard | 0 |
8e355853
MG
72 And I press "Update"
73 Then "Kitten" "text" should exist in the ".breadcrumb-nav" "css_element"
c026a28d
MG
74 And "Description of tag 1" "text" should exist in the ".tag-description" "css_element"
75 And I should see "Related tags:" in the ".tag_list" "css_element"
76 And I should see "Dog" in the ".tag_list" "css_element"
77 And I should see "Turtle" in the ".tag_list" "css_element"
78 And I should see "Fish" in the ".tag_list" "css_element"
8e355853 79 And I follow "Edit this tag"
a27c42ee 80 And I click on "× Dog" "text"
8e355853
MG
81 And I press "Update"
82 Then "Kitten" "text" should exist in the ".breadcrumb-nav" "css_element"
c026a28d
MG
83 And "Description of tag 1" "text" should exist in the ".tag-description" "css_element"
84 And I should see "Related tags:" in the ".tag_list" "css_element"
85 And I should see "Turtle" in the ".tag_list" "css_element"
86 And I should see "Fish" in the ".tag_list" "css_element"
8e355853
MG
87 And I should not see "Dog"
88 And I log out
89
90 Scenario: Renaming the tag from tag view page
91 When I log in as "manager1"
7a12a02d 92 And I press "Customise this page"
d131489e 93 # TODO MDL-57120 site "Tags" link not accessible without navigation block.
7a12a02d 94 And I add the "Navigation" block if not present
d131489e
EL
95 And I navigate to "Tags" node in "Site pages"
96 And I follow "Turtle"
810805da 97 And I follow "User 1"
8e355853
MG
98 And I follow "Cat"
99 And I follow "Edit this tag"
100 And I set the following fields to these values:
101 | Tag name | DOG |
102 And I press "Update"
c026a28d 103 And I should see "Tag names already being used"
8e355853
MG
104 And I set the following fields to these values:
105 | Tag name | Kitten |
106 And I press "Update"
107 Then "Kitten" "text" should exist in the ".breadcrumb-nav" "css_element"
108 And I follow "Edit this tag"
109 And I set the following fields to these values:
110 | Tag name | KITTEN |
111 And I press "Update"
112 And "KITTEN" "text" should exist in the ".breadcrumb-nav" "css_element"
113 And I log out
114
a27c42ee 115 @javascript
8e355853
MG
116 Scenario: Manager can change tag description and rename the tag from tag manage page
117 When I log in as "manager1"
118 And I navigate to "Manage tags" node in "Site administration > Appearance"
c026a28d 119 And I follow "Default collection"
8e355853
MG
120 And I click on "Edit this tag" "link" in the "Cat" "table_row"
121 And I set the following fields to these values:
122 | Tag name | Kitten |
123 | Description | Description of tag 1 |
124 | Related tags | Dog, Turtle,Fish |
e11d7380 125 | Standard | 0 |
8e355853 126 And I press "Update"
c026a28d 127 Then "Default collection" "link" should exist in the ".breadcrumb-nav" "css_element"
8e355853 128 And I follow "Kitten"
c026a28d
MG
129 And "Description of tag 1" "text" should exist in the ".tag-description" "css_element"
130 And I should see "Related tags:" in the ".tag_list" "css_element"
131 And I should see "Dog" in the ".tag_list" "css_element"
132 And I should see "Turtle" in the ".tag_list" "css_element"
133 And I should see "Fish" in the ".tag_list" "css_element"
8e355853
MG
134 And I log out
135
136 Scenario: Renaming the tag in edit tag form from tag manage page
137 When I log in as "manager1"
138 And I navigate to "Manage tags" node in "Site administration > Appearance"
c026a28d 139 And I follow "Default collection"
8e355853
MG
140 And I click on "Edit this tag" "link" in the "Cat" "table_row"
141 And I set the following fields to these values:
142 | Tag name | DOG |
143 And I press "Update"
c026a28d 144 And I should see "Tag names already being used"
8e355853
MG
145 And I set the following fields to these values:
146 | Tag name | Kitten |
147 And I press "Update"
c026a28d 148 Then "Default collection" "text" should exist in the ".breadcrumb-nav" "css_element"
8e355853
MG
149 And I click on "Edit this tag" "link" in the "Kitten" "table_row"
150 And I set the following fields to these values:
151 | Tag name | KITTEN |
152 And I press "Update"
c026a28d 153 And "Default collection" "text" should exist in the ".breadcrumb-nav" "css_element"
8e355853
MG
154 And I should see "KITTEN"
155 And I should not see "Kitten"
156 And I log out
157
158 @javascript
159 Scenario: Renaming the tag using quick edit field on tag manage page
160 When I log in as "manager1"
161 And I navigate to "Manage tags" node in "Site administration > Appearance"
c026a28d 162 And I follow "Default collection"
8e355853
MG
163 # Renaming tag to a valid name
164 And I click on "Edit tag name" "link" in the "Cat" "table_row"
165 And I set the field "New name for tag Cat" to "Kitten"
166 And I press key "13" in the field "New name for tag Cat"
167 Then I should not see "Cat"
cdc5f978 168 And "New name for tag" "field" should not exist
8e355853 169 And I wait until "Kitten" "link" exists
c026a28d 170 And I follow "Default collection"
8e355853
MG
171 And I should see "Kitten"
172 And I should not see "Cat"
173 # Renaming tag to an invalid name
174 And I click on "Edit tag name" "link" in the "Turtle" "table_row"
175 And I set the field "New name for tag Turtle" to "DOG"
176 And I press key "13" in the field "New name for tag Turtle"
c1d44340 177 And I should see "The tag name is already in use. Do you want to combine these tags?"
0d202789 178 And I press "Cancel"
cdc5f978 179 And "New name for tag" "field" should not exist
8e355853
MG
180 And I should see "Turtle"
181 And I should see "Dog"
182 And I should not see "DOG"
c026a28d 183 And I follow "Default collection"
8e355853
MG
184 And I should see "Turtle"
185 And I should see "Dog"
186 And I should not see "DOG"
187 # Cancel tag renaming
188 And I click on "Edit tag name" "link" in the "Dog" "table_row"
189 And I set the field "New name for tag Dog" to "Penguin"
190 And I press key "27" in the field "New name for tag Dog"
cdc5f978 191 And "New name for tag" "field" should not exist
8e355853
MG
192 And I should see "Turtle"
193 And I should not see "Penguin"
c026a28d 194 And I follow "Default collection"
8e355853
MG
195 And I should see "Turtle"
196 And I should not see "Penguin"
197 And I log out
0d202789
MG
198
199 @javascript
200 Scenario: Combining tags when renaming
201 When I log in as "manager1"
202 And I navigate to "Manage tags" node in "Site administration > Appearance"
203 And I follow "Default collection"
204 And I click on "Edit tag name" "link" in the "Turtle" "table_row"
205 And I set the field "New name for tag Turtle" to "DOG"
206 And I press key "13" in the field "New name for tag Turtle"
c1d44340 207 And I should see "The tag name is already in use. Do you want to combine these tags?"
0d202789
MG
208 And I press "Yes"
209 Then I should not see "Turtle"
210 And I should not see "DOG"
211 And I should see "Dog"
212 And I log out
213
214 @javascript
215 Scenario: Combining multiple tags
216 When I log in as "manager1"
217 And I navigate to "Manage tags" node in "Site administration > Appearance"
218 And I follow "Default collection"
219 And I set the following fields to these values:
220 | Select tag Dog | 1 |
221 | Select tag Neverusedtag | 1 |
222 | Select tag Turtle | 1 |
223 And I press "Combine selected"
224 And I should see "Select the tag that will be used after combining"
225 And I click on "//form[@id='combinetags_form']//input[@type='radio'][3]" "xpath_element"
226 And I press "Continue"
227 Then I should see "Tags are combined"
228 And I should not see "Dog"
229 And I should not see "Neverusedtag"
230 And I should see "Turtle"
231 # Even though Turtle was not standard but at least one of combined tags was (Neverusedtag). Now Turtle is also standard.
232 And "Remove from standard tags" "link" should exist in the "Turtle" "table_row"
233 And I log out
1e34257e
MG
234
235 Scenario: Filtering tags
236 When I log in as "manager1"
237 And I navigate to "Manage tags" node in "Site administration > Appearance"
238 And I follow "Default collection"
239 And I should not see "Reset filter"
240 And I set the field "Search" to "t"
241 And I press "Search"
242 Then the field "Search" matches value "t"
243 And I should not see "Dog"
244 And I should see "Cat"
245 And I should see "Turtle"
246 And I follow "Reset filter"
247 And I should see "Dog"
248 And I should see "Cat"
249 And I should see "Turtle"
250 And I log out