MDL-52707 core_tag: allow to combine tags
[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"
810805da
MG
34 And I navigate to "Participants" node in "Site pages"
35 And I follow "User 1"
8e355853
MG
36 And I follow "Cat"
37 And I follow "Edit this tag"
38 And I should not see "Tag name"
e11d7380 39 And I should not see "Standard"
8e355853
MG
40 And I set the following fields to these values:
41 | Description | Description of tag 1 |
42 | Related tags | Dog, Turtle,Fish |
43 And I press "Update"
44 Then "Cat" "text" should exist in the ".breadcrumb-nav" "css_element"
c026a28d
MG
45 And "Description of tag 1" "text" should exist in the ".tag-description" "css_element"
46 And I should see "Related tags:" in the ".tag_list" "css_element"
47 And I should see "Dog" in the ".tag_list" "css_element"
48 And I should see "Turtle" in the ".tag_list" "css_element"
49 And I should see "Fish" in the ".tag_list" "css_element"
8e355853
MG
50 And I log out
51
a27c42ee 52 @javascript
8e355853
MG
53 Scenario: Manager can change tag description, related tags and rename the tag from tag view page
54 When I log in as "manager1"
810805da
MG
55 And I navigate to "Participants" node in "Site pages"
56 And I follow "User 1"
8e355853
MG
57 And I follow "Cat"
58 And I follow "Edit this tag"
59 And I set the following fields to these values:
60 | Tag name | Kitten |
61 | Description | Description of tag 1 |
62 | Related tags | Dog, Turtle,Fish |
e11d7380 63 | Standard | 0 |
8e355853
MG
64 And I press "Update"
65 Then "Kitten" "text" should exist in the ".breadcrumb-nav" "css_element"
c026a28d
MG
66 And "Description of tag 1" "text" should exist in the ".tag-description" "css_element"
67 And I should see "Related tags:" in the ".tag_list" "css_element"
68 And I should see "Dog" in the ".tag_list" "css_element"
69 And I should see "Turtle" in the ".tag_list" "css_element"
70 And I should see "Fish" in the ".tag_list" "css_element"
8e355853 71 And I follow "Edit this tag"
a27c42ee 72 And I click on "× Dog" "text"
8e355853
MG
73 And I press "Update"
74 Then "Kitten" "text" should exist in the ".breadcrumb-nav" "css_element"
c026a28d
MG
75 And "Description of tag 1" "text" should exist in the ".tag-description" "css_element"
76 And I should see "Related tags:" 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
MG
79 And I should not see "Dog"
80 And I log out
81
82 Scenario: Renaming the tag from tag view page
83 When I log in as "manager1"
810805da
MG
84 And I navigate to "Participants" node in "Site pages"
85 And I follow "User 1"
8e355853
MG
86 And I follow "Cat"
87 And I follow "Edit this tag"
88 And I set the following fields to these values:
89 | Tag name | DOG |
90 And I press "Update"
c026a28d 91 And I should see "Tag names already being used"
8e355853
MG
92 And I set the following fields to these values:
93 | Tag name | Kitten |
94 And I press "Update"
95 Then "Kitten" "text" should exist in the ".breadcrumb-nav" "css_element"
96 And I follow "Edit this tag"
97 And I set the following fields to these values:
98 | Tag name | KITTEN |
99 And I press "Update"
100 And "KITTEN" "text" should exist in the ".breadcrumb-nav" "css_element"
101 And I log out
102
a27c42ee 103 @javascript
8e355853
MG
104 Scenario: Manager can change tag description and rename the tag from tag manage page
105 When I log in as "manager1"
106 And I navigate to "Manage tags" node in "Site administration > Appearance"
c026a28d 107 And I follow "Default collection"
8e355853
MG
108 And I click on "Edit this tag" "link" in the "Cat" "table_row"
109 And I set the following fields to these values:
110 | Tag name | Kitten |
111 | Description | Description of tag 1 |
112 | Related tags | Dog, Turtle,Fish |
e11d7380 113 | Standard | 0 |
8e355853 114 And I press "Update"
c026a28d 115 Then "Default collection" "link" should exist in the ".breadcrumb-nav" "css_element"
8e355853 116 And I follow "Kitten"
c026a28d
MG
117 And "Description of tag 1" "text" should exist in the ".tag-description" "css_element"
118 And I should see "Related tags:" in the ".tag_list" "css_element"
119 And I should see "Dog" in the ".tag_list" "css_element"
120 And I should see "Turtle" in the ".tag_list" "css_element"
121 And I should see "Fish" in the ".tag_list" "css_element"
8e355853
MG
122 And I log out
123
124 Scenario: Renaming the tag in edit tag form from tag manage page
125 When I log in as "manager1"
126 And I navigate to "Manage tags" node in "Site administration > Appearance"
c026a28d 127 And I follow "Default collection"
8e355853
MG
128 And I click on "Edit this tag" "link" in the "Cat" "table_row"
129 And I set the following fields to these values:
130 | Tag name | DOG |
131 And I press "Update"
c026a28d 132 And I should see "Tag names already being used"
8e355853
MG
133 And I set the following fields to these values:
134 | Tag name | Kitten |
135 And I press "Update"
c026a28d 136 Then "Default collection" "text" should exist in the ".breadcrumb-nav" "css_element"
8e355853
MG
137 And I click on "Edit this tag" "link" in the "Kitten" "table_row"
138 And I set the following fields to these values:
139 | Tag name | KITTEN |
140 And I press "Update"
c026a28d 141 And "Default collection" "text" should exist in the ".breadcrumb-nav" "css_element"
8e355853
MG
142 And I should see "KITTEN"
143 And I should not see "Kitten"
144 And I log out
145
146 @javascript
147 Scenario: Renaming the tag using quick edit field on tag manage page
148 When I log in as "manager1"
149 And I navigate to "Manage tags" node in "Site administration > Appearance"
c026a28d 150 And I follow "Default collection"
8e355853
MG
151 # Renaming tag to a valid name
152 And I click on "Edit tag name" "link" in the "Cat" "table_row"
153 And I set the field "New name for tag Cat" to "Kitten"
154 And I press key "13" in the field "New name for tag Cat"
155 Then I should not see "Cat"
cdc5f978 156 And "New name for tag" "field" should not exist
8e355853 157 And I wait until "Kitten" "link" exists
c026a28d 158 And I follow "Default collection"
8e355853
MG
159 And I should see "Kitten"
160 And I should not see "Cat"
161 # Renaming tag to an invalid name
162 And I click on "Edit tag name" "link" in the "Turtle" "table_row"
163 And I set the field "New name for tag Turtle" to "DOG"
164 And I press key "13" in the field "New name for tag Turtle"
0d202789
MG
165 And I should see "This tag name is already used, do you want to combine these tags?"
166 And I press "Cancel"
cdc5f978 167 And "New name for tag" "field" should not exist
8e355853
MG
168 And I should see "Turtle"
169 And I should see "Dog"
170 And I should not see "DOG"
c026a28d 171 And I follow "Default collection"
8e355853
MG
172 And I should see "Turtle"
173 And I should see "Dog"
174 And I should not see "DOG"
175 # Cancel tag renaming
176 And I click on "Edit tag name" "link" in the "Dog" "table_row"
177 And I set the field "New name for tag Dog" to "Penguin"
178 And I press key "27" in the field "New name for tag Dog"
cdc5f978 179 And "New name for tag" "field" should not exist
8e355853
MG
180 And I should see "Turtle"
181 And I should not see "Penguin"
c026a28d 182 And I follow "Default collection"
8e355853
MG
183 And I should see "Turtle"
184 And I should not see "Penguin"
185 And I log out
0d202789
MG
186
187 @javascript
188 Scenario: Combining tags when renaming
189 When I log in as "manager1"
190 And I navigate to "Manage tags" node in "Site administration > Appearance"
191 And I follow "Default collection"
192 And I click on "Edit tag name" "link" in the "Turtle" "table_row"
193 And I set the field "New name for tag Turtle" to "DOG"
194 And I press key "13" in the field "New name for tag Turtle"
195 And I should see "This tag name is already used, do you want to combine these tags?"
196 And I press "Yes"
197 Then I should not see "Turtle"
198 And I should not see "DOG"
199 And I should see "Dog"
200 And I log out
201
202 @javascript
203 Scenario: Combining multiple tags
204 When I log in as "manager1"
205 And I navigate to "Manage tags" node in "Site administration > Appearance"
206 And I follow "Default collection"
207 And I set the following fields to these values:
208 | Select tag Dog | 1 |
209 | Select tag Neverusedtag | 1 |
210 | Select tag Turtle | 1 |
211 And I press "Combine selected"
212 And I should see "Select the tag that will be used after combining"
213 And I click on "//form[@id='combinetags_form']//input[@type='radio'][3]" "xpath_element"
214 And I press "Continue"
215 Then I should see "Tags are combined"
216 And I should not see "Dog"
217 And I should not see "Neverusedtag"
218 And I should see "Turtle"
219 # Even though Turtle was not standard but at least one of combined tags was (Neverusedtag). Now Turtle is also standard.
220 And "Remove from standard tags" "link" should exist in the "Turtle" "table_row"
221 And I log out