MDL-67810 core_contentbank: contenttype_h5p editor integrated
[moodle.git] / contentbank / tests / behat / edit_content.feature
CommitLineData
c49d8663
VDF
1@core @core_contentbank @contentbank_h5p @_file_upload @javascript
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