AutorÃa | Ultima modificación | Ver Log |
@core @core_contentbank @core_h5p @contenttype_h5p @_file_upload @_switch_iframe @javascriptFeature: Replace H5P file from an existing content requires special capabilitiesIn order replace an H5P content from the content bankAs a teacherI need to be able to replace the content only if certain capabilities are allowedBackground:Given I log in as "admin"And I navigate to "H5P > Manage H5P content types" in site administrationAnd I upload "h5p/tests/fixtures/ipsums.h5p" file to "H5P content type" filemanagerAnd I click on "Upload H5P content types" "button" in the "#fitem_id_uploadlibraries" "css_element"And I upload "h5p/tests/fixtures/filltheblanks.h5p" file to "H5P content type" filemanagerAnd I click on "Upload H5P content types" "button" in the "#fitem_id_uploadlibraries" "css_element"And the following "users" exist:| username | firstname | lastname | email || teacher1 | Teacher | 1 | teacher1@example.com |And the following "categories" exist:| name | category | idnumber || Cat 1 | 0 | CAT1 |And the following "courses" exist:| fullname | shortname | category || Course 1 | C1 | CAT1 |And the following "course enrolments" exist:| user | course | role || teacher1 | C1 | editingteacher |And the following "contentbank content" exist:| contextlevel | reference | contenttype | user | contentname | filepath || Course | C1 | contenttype_h5p | admin | admincontent | /h5p/tests/fixtures/ipsums.h5p || Course | C1 | contenttype_h5p | teacher1 | teachercontent | /h5p/tests/fixtures/filltheblanks.h5p |And I log outAnd I log in as "teacher1"And I am on "Course 1" course homepage with editing mode onAnd the following config values are set as admin:| unaddableblocks | | theme_boost|And I add the "Navigation" block if not presentAnd I expand "Site pages" nodeAnd I click on "Content bank" "link"# Force the content deployAnd I click on "admincontent" "link"And I am on "Course 1" course homepageAnd I expand "Site pages" nodeAnd I click on "Content bank" "link"Scenario: Teacher can replace its own H5P filesGiven I click on "teachercontent" "link"When I click on "More" "button"And I click on "Replace with file" "link"And I upload "h5p/tests/fixtures/ipsums.h5p" file to "Upload content" filemanagerAnd I click on "Save changes" "button"Then I switch to "h5p-player" class iframeAnd I switch to "h5p-iframe" class iframeAnd I should see "Lorum ipsum"And I switch to the main frameScenario: Teacher cannot replace another user's H5P filesWhen I click on "admincontent" "link"And I click on "More" "button"Then I should not see "Replace with file"Scenario: Teacher cannot replace a content without having upload capabilityGiven the following "permission overrides" exist:| capability | permission | role | contextlevel | reference || moodle/contentbank:upload | Prevent | editingteacher | Course | C1 |When I click on "teachercontent" "link"And I click on "More" "button"Then I should not see "Replace with file"Scenario: Teacher cannot replace a content without having the H5P upload capabilityGiven the following "permission overrides" exist:| capability | permission | role | contextlevel | reference || contenttype/h5p:upload | Prevent | editingteacher | Course | C1 |When I click on "teachercontent" "link"And I click on "More" "button"Then I should not see "Replace with file"Scenario: Teacher cannot replace a content without having the manage own content capabilityGiven the following "permission overrides" exist:| capability | permission | role | contextlevel | reference || moodle/contentbank:manageowncontent | Prevent | editingteacher | Course | C1 |When I click on "teachercontent" "link"And I click on "More" "button"Then I should not see "Replace with file"Scenario: Replacing with invalid packages throws errorGiven I log in as "admin"And I navigate to "H5P > Manage H5P content types" in site administrationAnd I upload "h5p/tests/fixtures/no-json-file.h5p" file to "H5P content type" filemanagerAnd I upload "h5p/tests/fixtures/unzippable.h5p" file to "H5P content type" filemanagerAnd I log outAnd I log in as "teacher1"And I am on "Course 1" course homepageAnd I expand "Site pages" nodeAnd I click on "Content bank" "link"And I click on "teachercontent" "link"When I click on "More" "button"And I click on "Replace with file" "link"And I upload "h5p/tests/fixtures/no-json-file.h5p" file to "Upload content" filemanagerAnd I click on "Save changes" "button"And I wait until the page is readyThen I should see "A valid main h5p.json file is missing"And I should see "Only files with the following extensions are allowed"And I should not see "Sorry, this file is not valid"And I click on "More" "button"And I click on "Replace with file" "link"And I upload "h5p/tests/fixtures/unzippable.h5p" file to "Upload content" filemanagerAnd I click on "Save changes" "button"And I wait until the page is readyAnd I should see "It is not possible to unzip it"And I should not see "Sorry, this file is not valid"