MDL-51260 tags: Update the tags form element to use the autocomplete field
[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:
21 | name | tagtype |
22 | Neverusedtag | official |
8e355853
MG
23
24 Scenario: User with tag editing capability can change tag description
25 Given I log in as "admin"
26 And I set the following system permissions of "Tag editor" role:
810805da
MG
27 | capability | permission |
28 | moodle/tag:edit | Allow |
29 | moodle/site:viewparticipants | Allow |
30 | moodle/user:viewdetails | Allow |
8e355853
MG
31 And I log out
32 When I log in as "editor1"
810805da
MG
33 And I navigate to "Participants" node in "Site pages"
34 And I follow "User 1"
8e355853
MG
35 And I follow "Cat"
36 And I follow "Edit this tag"
37 And I should not see "Tag name"
38 And I should not see "Official"
39 And I set the following fields to these values:
40 | Description | Description of tag 1 |
41 | Related tags | Dog, Turtle,Fish |
42 And I press "Update"
43 Then "Cat" "text" should exist in the ".breadcrumb-nav" "css_element"
44 And "Description of tag 1" "text" should exist in the "#tag-description" "css_element"
45 And I should see "Related tags: Dog, Turtle, Fish"
46 And I log out
47
48 Scenario: Manager can change tag description, related tags and rename the tag from tag view page
49 When I log in as "manager1"
810805da
MG
50 And I navigate to "Participants" node in "Site pages"
51 And I follow "User 1"
8e355853
MG
52 And I follow "Cat"
53 And I follow "Edit this tag"
54 And I set the following fields to these values:
55 | Tag name | Kitten |
56 | Description | Description of tag 1 |
57 | Related tags | Dog, Turtle,Fish |
58 | Official | 0 |
59 And I press "Update"
60 Then "Kitten" "text" should exist in the ".breadcrumb-nav" "css_element"
61 And "Description of tag 1" "text" should exist in the "#tag-description" "css_element"
62 And I should see "Related tags: Dog, Turtle, Fish"
63 And I follow "Edit this tag"
64 And I set the following fields to these values:
65 | Related tags | Turtle, Fish |
66 And I press "Update"
67 Then "Kitten" "text" should exist in the ".breadcrumb-nav" "css_element"
68 And "Description of tag 1" "text" should exist in the "#tag-description" "css_element"
69 And I should see "Related tags: Turtle, Fish"
70 And I should not see "Dog"
71 And I log out
72
73 Scenario: Renaming the tag from tag view page
74 When I log in as "manager1"
810805da
MG
75 And I navigate to "Participants" node in "Site pages"
76 And I follow "User 1"
8e355853
MG
77 And I follow "Cat"
78 And I follow "Edit this tag"
79 And I set the following fields to these values:
80 | Tag name | DOG |
81 And I press "Update"
82 And I should see "DOG: Tag names already being used"
83 And I set the following fields to these values:
84 | Tag name | Kitten |
85 And I press "Update"
86 Then "Kitten" "text" should exist in the ".breadcrumb-nav" "css_element"
87 And I follow "Edit this tag"
88 And I set the following fields to these values:
89 | Tag name | KITTEN |
90 And I press "Update"
91 And "KITTEN" "text" should exist in the ".breadcrumb-nav" "css_element"
92 And I log out
93
94 Scenario: Manager can change tag description and rename the tag from tag manage page
95 When I log in as "manager1"
96 And I navigate to "Manage tags" node in "Site administration > Appearance"
97 And I click on "Edit this tag" "link" in the "Cat" "table_row"
98 And I set the following fields to these values:
99 | Tag name | Kitten |
100 | Description | Description of tag 1 |
101 | Related tags | Dog, Turtle,Fish |
102 | Official | 0 |
103 And I press "Update"
104 Then "Manage tags" "link" should exist in the ".breadcrumb-nav" "css_element"
105 And I follow "Kitten"
106 And "Description of tag 1" "text" should exist in the "#tag-description" "css_element"
107 And I should see "Related tags: Dog, Turtle, Fish"
108 And I log out
109
110 Scenario: Renaming the tag in edit tag form from tag manage page
111 When I log in as "manager1"
112 And I navigate to "Manage tags" node in "Site administration > Appearance"
113 And I click on "Edit this tag" "link" in the "Cat" "table_row"
114 And I set the following fields to these values:
115 | Tag name | DOG |
116 And I press "Update"
117 And I should see "DOG: Tag names already being used"
118 And I set the following fields to these values:
119 | Tag name | Kitten |
120 And I press "Update"
121 Then "Manage tags" "text" should exist in the ".breadcrumb-nav" "css_element"
122 And I click on "Edit this tag" "link" in the "Kitten" "table_row"
123 And I set the following fields to these values:
124 | Tag name | KITTEN |
125 And I press "Update"
126 And "Manage tags" "text" should exist in the ".breadcrumb-nav" "css_element"
127 And I should see "KITTEN"
128 And I should not see "Kitten"
129 And I log out
130
131 @javascript
132 Scenario: Renaming the tag using quick edit field on tag manage page
133 When I log in as "manager1"
134 And I navigate to "Manage tags" node in "Site administration > Appearance"
135 # Renaming tag to a valid name
136 And I click on "Edit tag name" "link" in the "Cat" "table_row"
137 And I set the field "New name for tag Cat" to "Kitten"
138 And I press key "13" in the field "New name for tag Cat"
139 Then I should not see "Cat"
140 And "New name for tag" "field" should not be visible
141 And I wait until "Kitten" "link" exists
142 And I follow "Manage tags"
143 And I should see "Kitten"
144 And I should not see "Cat"
145 # Renaming tag to an invalid name
146 And I click on "Edit tag name" "link" in the "Turtle" "table_row"
147 And I set the field "New name for tag Turtle" to "DOG"
148 And I press key "13" in the field "New name for tag Turtle"
149 And I should see "Tag names already being used"
150 And I press "Ok"
151 And "New name for tag" "field" should not be visible
152 And I should see "Turtle"
153 And I should see "Dog"
154 And I should not see "DOG"
155 And I follow "Manage tags"
156 And I should see "Turtle"
157 And I should see "Dog"
158 And I should not see "DOG"
159 # Cancel tag renaming
160 And I click on "Edit tag name" "link" in the "Dog" "table_row"
161 And I set the field "New name for tag Dog" to "Penguin"
162 And I press key "27" in the field "New name for tag Dog"
163 And "New name for tag" "field" should not be visible
164 And I should see "Turtle"
165 And I should not see "Penguin"
166 And I follow "Manage tags"
167 And I should see "Turtle"
168 And I should not see "Penguin"
169 And I log out