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