on-demand release 4.0dev+
[moodle.git] / contentbank / tests / behat / edit_content.feature
CommitLineData
39263ddb 1@core @core_contentbank @core_h5p @contentbank_h5p @_file_upload @javascript
c49d8663
VDF
2Feature: Content bank use editor feature
3 In order to add/edit content
4 As a user
5 I need to be able to access the edition options
6
7 Background:
8 Given I log in as "admin"
9 And I am on site homepage
10 And I turn editing mode on
11 And I add the "Navigation" block if not present
12 And I configure the "Navigation" block
13 And I set the following fields to these values:
14 | Page contexts | Display throughout the entire site |
15 And I press "Save changes"
16
17 Scenario: Users see the Add button disabled if there is no content type available for creation
18 Given I click on "Site pages" "list_item" in the "Navigation" "block"
19 When I click on "Content bank" "link"
20 Then the "[data-action=Add-content]" "css_element" should be disabled
21
22 Scenario: Users can see the Add button if there is content type available for creation
23 Given I follow "Dashboard" in the user menu
24 And I follow "Manage private files..."
25 And I upload "h5p/tests/fixtures/filltheblanks.h5p" file to "Files" filemanager
26 And I click on "Save changes" "button"
27 And I click on "Site pages" "list_item" in the "Navigation" "block"
28 And I click on "Content bank" "link" in the "Navigation" "block"
29 And I click on "Upload" "link"
30 And I click on "Choose a file..." "button"
31 And I click on "Private files" "link" in the ".fp-repo-area" "css_element"
32 And I click on "filltheblanks.h5p" "link"
33 And I click on "Select this file" "button"
34 And I click on "Save changes" "button"
35 When I click on "Content bank" "link"
36 And I click on "filltheblanks.h5p" "link"
37 And I click on "Close" "link"
38 Then I click on "[data-action=Add-content]" "css_element"
39 And I should see "Fill in the Blanks"
40
41 Scenario: Users can edit content if they have the required permission
42 Given I follow "Dashboard" in the user menu
43 And I follow "Manage private files..."
44 And I upload "h5p/tests/fixtures/filltheblanks.h5p" file to "Files" filemanager
45 And I click on "Save changes" "button"
46 And I click on "Site pages" "list_item" in the "Navigation" "block"
47 And I click on "Content bank" "link" in the "Navigation" "block"
48 And I click on "Upload" "link"
49 And I click on "Choose a file..." "button"
50 And I click on "Private files" "link" in the ".fp-repo-area" "css_element"
51 And I click on "filltheblanks.h5p" "link"
52 And I click on "Select this file" "button"
53 And I click on "Save changes" "button"
54 When I click on "Content bank" "link"
55 And I click on "filltheblanks.h5p" "link"
56 Then I click on "Edit" "link"
57 And I switch to "h5p-editor-iframe" class iframe
58 And I switch to the main frame
59 And I click on "Cancel" "button"
60 And I should see "filltheblanks.h5p" in the "h1" "css_element"
61
62 Scenario: Users can create new content if they have the required permission
63 Given I navigate to "H5P > Manage H5P content types" in site administration
64 And I upload "h5p/tests/fixtures/filltheblanks.h5p" file to "H5P content type" filemanager
65 And I click on "Upload H5P content types" "button" in the "#fitem_id_uploadlibraries" "css_element"
66 And I should see "H5P content types uploaded successfully"
67 And I click on "Site pages" "list_item" in the "Navigation" "block"
68 When I click on "Content bank" "link" in the "Navigation" "block"
69 And I click on "[data-action=Add-content]" "css_element"
70 Then I click on "Fill in the Blanks" "link"
71 And I switch to "h5p-editor-iframe" class iframe
72 And I switch to the main frame
73 And I click on "Cancel" "button"
74
75 Scenario: Users can't edit content if they don't have the required permission
76 Given the following "users" exist:
77 | username | firstname | lastname | email |
78 | teacher1 | Teacher | 1 | user1@example.com |
79 And the following "courses" exist:
80 | fullname | shortname | category |
81 | Course 1 | C1 | 0 |
82 And the following "course enrolments" exist:
83 | user | course | role |
84 | teacher1 | C1 | editingteacher |
85 And I navigate to "H5P > Manage H5P content types" in site administration
86 And I upload "h5p/tests/fixtures/filltheblanks.h5p" file to "H5P content type" filemanager
87 And I click on "Upload H5P content types" "button" in the "#fitem_id_uploadlibraries" "css_element"
88 And I should see "H5P content types uploaded successfully"
89 And I log out
90 And I log in as "teacher1"
91 And I am on "Course 1" course homepage
92 And I click on "Site pages" "list_item" in the "Navigation" "block"
93 And I click on "Content bank" "link"
94 And "[data-action=Add-content]" "css_element" should exist
95 When the following "permission overrides" exist:
96 | capability | permission | role | contextlevel | reference |
97 | moodle/contentbank:useeditor | Prohibit | editingteacher | System | |
98 And I reload the page
99 Then "[data-action=Add-content]" "css_element" should not exist
45bff7f9
AA
100
101 Scenario: Users can edit content and save changes
102 Given the following "contentbank content" exist:
103 | contextlevel | reference | contenttype | user | contentname | filepath |
104 | System | | contenttype_h5p | admin | filltheblanks.h5p | /h5p/tests/fixtures/filltheblanks.h5p |
105 And I click on "Site pages" "list_item" in the "Navigation" "block"
106 And I click on "Content bank" "link" in the "Navigation" "block"
107 And I click on "filltheblanks.h5p" "link"
108 And I click on "Edit" "link"
109 And I switch to "h5p-editor-iframe" class iframe
110 And the field "Title" matches value "Geography"
111 And I set the field "Title" to "New title"
112 And I switch to the main frame
113 When I click on "Save" "button"
114 And I should see "filltheblanks.h5p" in the "h1" "css_element"
115 And I click on "Edit" "link"
116 And I switch to "h5p-editor-iframe" class iframe
117 Then the field "Title" matches value "New title"
7be38070
AA
118
119 Scenario: Teachers can edit their own content in the content bank
f3d43c76
SA
120 Given I navigate to "H5P > Manage H5P content types" in site administration
121 And I upload "h5p/tests/fixtures/filltheblanks.h5p" file to "H5P content type" filemanager
122 And I click on "Upload H5P content types" "button" in the "#fitem_id_uploadlibraries" "css_element"
123 And I upload "h5p/tests/fixtures/ipsums.h5p" file to "H5P content type" filemanager
124 And I click on "Upload H5P content types" "button" in the "#fitem_id_uploadlibraries" "css_element"
125 And the following "users" exist:
7be38070
AA
126 | username | firstname | lastname | email |
127 | teacher1 | Teacher | 1 | teacher1@example.com |
128 And the following "courses" exist:
129 | fullname | shortname | category |
130 | Course 1 | C1 | 0 |
131 And the following "course enrolments" exist:
132 | user | course | role |
133 | teacher1 | C1 | editingteacher |
134 And the following "contentbank content" exist:
135 | contextlevel | reference | contenttype | user | contentname | filepath |
136 | Course | C1 | contenttype_h5p | admin | filltheblanks.h5p | /h5p/tests/fixtures/filltheblanks.h5p |
137 | Course | C1 | contenttype_h5p | teacher1 | ipsums.h5p | /h5p/tests/fixtures/ipsums.h5p |
138 When I log out
139 And I log in as "teacher1"
140 And I am on "Course 1" course homepage
141 And I expand "Site pages" node
142 And I click on "Content bank" "link"
143 And I follow "ipsums.h5p"
144 Then "Edit" "link" should exist in the "region-main" "region"
145
146 Scenario: Teachers can't edit content created by other users in the content bank
147 Given the following "users" exist:
148 | username | firstname | lastname | email |
149 | teacher1 | Teacher | 1 | teacher1@example.com |
150 And the following "courses" exist:
151 | fullname | shortname | category |
152 | Course 1 | C1 | 0 |
153 And the following "course enrolments" exist:
154 | user | course | role |
155 | teacher1 | C1 | editingteacher |
156 And the following "contentbank content" exist:
157 | contextlevel | reference | contenttype | user | contentname | filepath |
158 | Course | C1 | contenttype_h5p | admin | filltheblanks.h5p | /h5p/tests/fixtures/filltheblanks.h5p |
159 | Course | C1 | contenttype_h5p | teacher1 | ipsums.h5p | /h5p/tests/fixtures/ipsums.h5p |
160 When I log out
161 And I log in as "teacher1"
162 And I am on "Course 1" course homepage
163 And I expand "Site pages" node
164 And I click on "Content bank" "link"
165 And I follow "filltheblanks.h5p"
166 Then "Edit" "link" should not exist in the "region-main" "region"
33fed53a
AA
167
168 Scenario: Teachers keep their content authoring in copied courses
169 Given the following "users" exist:
170 | username | firstname | lastname | email |
171 | teacher1 | Teacher | 1 | teacher1@example.com |
172 And the following "courses" exist:
173 | fullname | shortname | category |
174 | Course 1 | C1 | 0 |
175 And the following "course enrolments" exist:
176 | user | course | role |
177 | teacher1 | C1 | editingteacher |
178 And the following "contentbank content" exist:
179 | contextlevel | reference | contenttype | user | contentname | filepath |
180 | Course | C1 | contenttype_h5p | admin | filltheblanks.h5p | /h5p/tests/fixtures/filltheblanks.h5p |
181 | Course | C1 | contenttype_h5p | teacher1 | ipsums.h5p | /h5p/tests/fixtures/ipsums.h5p |
182 And I am on "Course 1" course homepage
183 And I navigate to "Copy course" in current page administration
184 And I set the following fields to these values:
185 | Course full name | Copy |
186 | Course short name | Copy |
187 | Teacher | 1 |
188 When I press "Copy and view"
189 And I trigger cron
190 And I am on homepage
191 And I log out
192 And I log in as "teacher1"
193 And I am on "Copy" course homepage
194 And I expand "Site pages" node
195 And I click on "Content bank" "link"
196 And I follow "ipsums.h5p"
197 Then "Edit" "link" should exist in the "region-main" "region"
b983003e 198 And I navigate to "Content bank" in current page administration
33fed53a
AA
199 And I follow "filltheblanks.h5p"
200 Then "Edit" "link" should not exist in the "region-main" "region"