mirror of
https://github.com/moodle/moodle.git
synced 2025-01-29 19:50:14 +01:00
Merge branch 'MDL-66405-master' of git://github.com/aanabit/moodle
This commit is contained in:
commit
a1e0f47fe9
@ -146,8 +146,8 @@ class filter_displayh5p extends moodle_text_filter {
|
||||
$sourceurl .= $urlmodifier;
|
||||
}
|
||||
|
||||
$h5piframesrc = $sourceurl.
|
||||
'" class="h5p-iframe" style="height:230px; width: 100%; border: 0;" allowfullscreen="allowfullscreen">';
|
||||
$h5piframesrc = $sourceurl . '" class="h5p-iframe" name="h5pcontent"' .
|
||||
' style="height:230px; width: 100%; border: 0;" allowfullscreen="allowfullscreen">';
|
||||
|
||||
// We want to request the resizing script only once.
|
||||
if (self::$loadresizerjs) {
|
||||
|
81
filter/displayh5p/tests/behat/h5p_filter.feature
Normal file
81
filter/displayh5p/tests/behat/h5p_filter.feature
Normal file
@ -0,0 +1,81 @@
|
||||
@editor @filter @filter_displayh5p @core_h5p @_file_upload @_switch_iframe
|
||||
Feature: Render H5P content using filters
|
||||
To write rich text - I need to render H5P content.
|
||||
|
||||
Background:
|
||||
Given the following "courses" exist:
|
||||
| shortname | fullname |
|
||||
| C1 | Course 1 |
|
||||
And the following "users" exist:
|
||||
| username | firstname | lastname | email |
|
||||
| teacher1 | Teacher | 1 | teacher1@example.com |
|
||||
| student1 | Student | 1 | student1@example.com |
|
||||
And the following "course enrolments" exist:
|
||||
| user | course | role |
|
||||
| teacher1 | C1 | editingteacher |
|
||||
| student1 | C1 | student |
|
||||
And the following "activities" exist:
|
||||
| activity | name | intro | introformat | course | content | contentformat | idnumber |
|
||||
| page | PageName1 | PageDesc1 | 1 | C1 | H5Ptest | 1 | 1 |
|
||||
And the "displayh5p" filter is "on"
|
||||
|
||||
@javascript
|
||||
Scenario: Render an external H5P content URL.
|
||||
Given I log in as "teacher1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I follow "PageName1"
|
||||
And I navigate to "Edit settings" in current page administration
|
||||
And I set the field "Page content" to "<div>Go for it</div>https://h5p.org/h5p/embed/576651"
|
||||
When I click on "Save and display" "button"
|
||||
And I wait until the page is ready
|
||||
And I switch to "h5p-iframe" class iframe
|
||||
Then I should see "Lorum ipsum"
|
||||
|
||||
@javascript
|
||||
Scenario: Add an external H5P content URL in a link. Shouldn't be rendered.
|
||||
Given I log in as "teacher1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I follow "PageName1"
|
||||
And I navigate to "Edit settings" in current page administration
|
||||
And I set the field "Page content" to "<a href='https://h5p.org/h5p/embed/576651'>Go to https://h5p.org/h5p/embed/576651</a>"
|
||||
When I click on "Save and display" "button"
|
||||
And I wait until the page is ready
|
||||
Then ".h5p-iframe" "css_element" should not exist
|
||||
|
||||
@javascript
|
||||
Scenario: Render a server H5P file
|
||||
Given I log in as "teacher1"
|
||||
And I am on "Course 1" course homepage with editing mode on
|
||||
And I add a "File" to section "1"
|
||||
And I set the following fields to these values:
|
||||
| Name | ipsumFile |
|
||||
And I upload "filter/displayh5p/tests/fixtures/ipsums.h5p" file to "Select files" filemanager
|
||||
And I press "Save and return to course"
|
||||
And I follow "PageName1"
|
||||
And I navigate to "Edit settings" in current page administration
|
||||
And I click on "Insert H5P" "button" in the "#fitem_id_page" "css_element"
|
||||
And I click on "Browse repositories..." "button" in the "Insert H5P" "dialogue"
|
||||
And I click on "Server files" "link" in the ".fp-repo-area" "css_element"
|
||||
And I click on "ipsumFile (File)" "link"
|
||||
And I click on "ipsums.h5p" "link"
|
||||
And I click on "Select this file" "button"
|
||||
And I click on "Insert H5P" "button" in the "Insert H5P" "dialogue"
|
||||
And I wait until the page is ready
|
||||
When I click on "Save and display" "button"
|
||||
# Switch to iframe created by filter
|
||||
And I switch to "h5p-iframe" class iframe
|
||||
# Switch to iframe created by embed.php page
|
||||
And I switch to "h5p-iframe" class iframe
|
||||
Then I should see "Lorum ipsum"
|
||||
And I switch to the main frame
|
||||
And I log out
|
||||
And I log in as "student1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I follow "PageName1"
|
||||
# Switch to iframe created by filter
|
||||
And I switch to "h5p-iframe" class iframe
|
||||
# Switch to iframe created by embed.php page
|
||||
And I switch to "h5p-iframe" class iframe
|
||||
And I should not see "you don't have access"
|
||||
And I should see "Lorum ipsum"
|
||||
|
@ -78,6 +78,7 @@ class behat_partial_named_selector extends \Behat\Mink\Selector\PartialNamedSele
|
||||
'group_message_header' => 'group_message_header',
|
||||
'group_message' => 'group_message',
|
||||
'autocomplete' => 'autocomplete',
|
||||
'iframe' => 'iframe',
|
||||
);
|
||||
|
||||
/**
|
||||
@ -121,6 +122,7 @@ class behat_partial_named_selector extends \Behat\Mink\Selector\PartialNamedSele
|
||||
'autocomplete_selection' => 'autocomplete_selection',
|
||||
'autocomplete_suggestions' => 'autocomplete_suggestions',
|
||||
'autocomplete' => 'autocomplete',
|
||||
'iframe' => 'iframe',
|
||||
);
|
||||
|
||||
/**
|
||||
@ -229,6 +231,9 @@ XPATH
|
||||
XPATH
|
||||
, 'autocomplete' => <<<XPATH
|
||||
.//descendant::input[@id = //label[contains(normalize-space(string(.)), %locator%)]/@for]/ancestor::*[@data-fieldtype = 'autocomplete']
|
||||
XPATH
|
||||
, 'iframe' => <<<XPATH
|
||||
.//iframe[contains(concat(' ', normalize-space(@class), ' '), %locator% )]
|
||||
XPATH
|
||||
);
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
@editor @editor_atto @atto @atto_h5p @_file_upload @_switch_iframe
|
||||
@editor @editor_atto @atto @atto_h5p @core_h5p @_file_upload @_switch_iframe
|
||||
Feature: Add h5ps to Atto
|
||||
To write rich text - I need to add h5ps.
|
||||
|
||||
@ -15,6 +15,7 @@ Feature: Add h5ps to Atto
|
||||
And the following "activities" exist:
|
||||
| activity | name | intro | introformat | course | content | contentformat | idnumber |
|
||||
| page | PageName1 | PageDesc1 | 1 | C1 | H5Ptest | 1 | 1 |
|
||||
And the "displayh5p" filter is "on"
|
||||
|
||||
@javascript
|
||||
Scenario: Insert an embedded h5p
|
||||
@ -33,9 +34,8 @@ Feature: Add h5ps to Atto
|
||||
@javascript
|
||||
Scenario: Insert an h5p file
|
||||
Given I log in as "admin"
|
||||
And I change window size to "large"
|
||||
And I follow "Manage private files..."
|
||||
And I upload "lib/editor/atto/tests/fixtures/ipsums.h5p" file to "Files" filemanager
|
||||
And I upload "lib/editor/atto/tests/fixtures/guess-the-answer.h5p" file to "Files" filemanager
|
||||
And I click on "Save changes" "button"
|
||||
And I am on "Course 1" course homepage
|
||||
And I follow "PageName1"
|
||||
@ -43,7 +43,7 @@ Feature: Add h5ps to Atto
|
||||
And I click on "Insert H5P" "button" in the "#fitem_id_page" "css_element"
|
||||
And I click on "Browse repositories..." "button" in the "Insert H5P" "dialogue"
|
||||
And I click on "Private files" "link" in the ".fp-repo-area" "css_element"
|
||||
And I click on "ipsums.h5p" "link"
|
||||
And I click on "guess-the-answer.h5p" "link"
|
||||
And I click on "Select this file" "button"
|
||||
And I click on "Insert H5P" "button" in the "Insert H5P" "dialogue"
|
||||
And I wait until the page is ready
|
||||
@ -98,3 +98,127 @@ Feature: Add h5ps to Atto
|
||||
When I navigate to "Edit settings" in current page administration
|
||||
And I click on "Insert H5P" "button"
|
||||
Then I should not see "H5P file upload" in the "Insert H5P" "dialogue"
|
||||
|
||||
@javascript
|
||||
Scenario: Edit H5P content
|
||||
Given I log in as "teacher1"
|
||||
And I follow "Manage private files..."
|
||||
And I upload "lib/editor/atto/tests/fixtures/drag.h5p" file to "Files" filemanager
|
||||
And I click on "Save changes" "button"
|
||||
And I am on "Course 1" course homepage
|
||||
And I follow "PageName1"
|
||||
And I navigate to "Edit settings" in current page administration
|
||||
And I click on "Insert H5P" "button" in the "#fitem_id_page" "css_element"
|
||||
# H5P file content
|
||||
And I click on "Browse repositories..." "button" in the "Insert H5P" "dialogue"
|
||||
And I click on "Private files" "link" in the ".fp-repo-area" "css_element"
|
||||
And I click on "drag" "link"
|
||||
And I click on "Select this file" "button"
|
||||
And I click on "Insert H5P" "button" in the "Insert H5P" "dialogue"
|
||||
And I wait until the page is ready
|
||||
When I click on "Save and display" "button"
|
||||
And I switch to "h5pcontent" iframe
|
||||
And I switch to "h5p-iframe" class iframe
|
||||
Then I should not see "reveal"
|
||||
And I should see "Cloudberries"
|
||||
And I switch to the main frame
|
||||
And I navigate to "Edit settings" in current page administration
|
||||
And I click on ".h5p-placeholder" "css_element"
|
||||
And I click on "Insert H5P" "button" in the "#fitem_id_page" "css_element"
|
||||
# External URL
|
||||
And I set the field with xpath "//textarea[@data-region='h5purl']" to "https://h5p.org/h5p/embed/576651"
|
||||
And I click on "Insert H5P" "button" in the "Insert H5P" "dialogue"
|
||||
And I wait until the page is ready
|
||||
And I click on "Save and display" "button"
|
||||
And I switch to "h5pcontent" iframe
|
||||
And I should see "Lorum ipsum"
|
||||
And I should not see "Cloudberries"
|
||||
|
||||
@javascript
|
||||
Scenario: Enable/disable H5P options
|
||||
Given I log in as "teacher1"
|
||||
And I follow "Manage private files..."
|
||||
And I upload "lib/editor/atto/tests/fixtures/guess-the-answer.h5p" file to "Files" filemanager
|
||||
And I click on "Save changes" "button"
|
||||
And I am on "Course 1" course homepage
|
||||
And I follow "PageName1"
|
||||
And I navigate to "Edit settings" in current page administration
|
||||
And I click on "Insert H5P" "button" in the "#fitem_id_page" "css_element"
|
||||
And I click on "Browse repositories..." "button" in the "Insert H5P" "dialogue"
|
||||
And I click on "Private files" "link" in the ".fp-repo-area" "css_element"
|
||||
And I click on "guess-the-answer.h5p" "link"
|
||||
And I click on "Select this file" "button"
|
||||
# No display option button displayed
|
||||
And I click on "Insert H5P" "button" in the "Insert H5P" "dialogue"
|
||||
And I wait until the page is ready
|
||||
When I click on "Save and display" "button"
|
||||
And I wait until the page is ready
|
||||
And I switch to "h5pcontent" iframe
|
||||
And I switch to "h5p-iframe" class iframe
|
||||
Then I should not see "Reuse"
|
||||
And I should not see "Embed"
|
||||
And I should not see "Rights of use"
|
||||
And I switch to the main frame
|
||||
And I navigate to "Edit settings" in current page administration
|
||||
And I click on ".h5p-placeholder" "css_element"
|
||||
And I click on "Insert H5P" "button" in the "#fitem_id_page" "css_element"
|
||||
And I click on "H5P options" "link"
|
||||
# Only Allow Download button displayed
|
||||
And I click on "Allow download" "checkbox"
|
||||
And I click on "Insert H5P" "button" in the "Insert H5P" "dialogue"
|
||||
And I wait until the page is ready
|
||||
And I click on "Save and display" "button"
|
||||
And I wait until the page is ready
|
||||
And I switch to "h5pcontent" iframe
|
||||
And I switch to "h5p-iframe" class iframe
|
||||
And I should see "Reuse"
|
||||
And I should not see "Embed"
|
||||
And I should not see "Rights of use"
|
||||
And I switch to the main frame
|
||||
And I navigate to "Edit settings" in current page administration
|
||||
And I click on ".h5p-placeholder" "css_element"
|
||||
And I click on "Insert H5P" "button" in the "#fitem_id_page" "css_element"
|
||||
# Embed and copyright buttons displayed. Download not displayed
|
||||
And I click on "Allow download" "checkbox"
|
||||
And I click on "Embed button" "checkbox"
|
||||
And I click on "Copyright button" "checkbox"
|
||||
And I click on "Insert H5P" "button" in the "Insert H5P" "dialogue"
|
||||
And I wait until the page is ready
|
||||
And I click on "Save and display" "button"
|
||||
And I wait until the page is ready
|
||||
And I switch to "h5pcontent" iframe
|
||||
And I switch to "h5p-iframe" class iframe
|
||||
And I should not see "Reuse"
|
||||
And I should see "Embed"
|
||||
And I should see "Rights of use"
|
||||
|
||||
@javascript
|
||||
Scenario: Private H5P files are shown to students
|
||||
Given the following "users" exist:
|
||||
| username | firstname | lastname | email |
|
||||
| student1 | Student | 1 | student1@example.com |
|
||||
And the following "course enrolments" exist:
|
||||
| user | course | role |
|
||||
| student1 | C1 | student |
|
||||
And I log in as "teacher1"
|
||||
And I follow "Manage private files..."
|
||||
And I upload "lib/editor/atto/tests/fixtures/guess-the-answer.h5p" file to "Files" filemanager
|
||||
And I click on "Save changes" "button"
|
||||
And I am on "Course 1" course homepage
|
||||
And I follow "PageName1"
|
||||
And I navigate to "Edit settings" in current page administration
|
||||
And I click on "Insert H5P" "button" in the "#fitem_id_page" "css_element"
|
||||
And I click on "Browse repositories..." "button" in the "Insert H5P" "dialogue"
|
||||
And I click on "Private files" "link" in the ".fp-repo-area" "css_element"
|
||||
And I click on "guess-the-answer.h5p" "link"
|
||||
And I click on "Select this file" "button"
|
||||
And I click on "Insert H5P" "button" in the "Insert H5P" "dialogue"
|
||||
And I wait until the page is ready
|
||||
And I click on "Save and display" "button"
|
||||
And I log out
|
||||
When I log in as "student1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I follow "PageName1"
|
||||
Then I switch to "h5pcontent" iframe
|
||||
And I switch to "h5p-iframe" class iframe
|
||||
And I should see "reveal"
|
||||
|
BIN
lib/editor/atto/tests/fixtures/drag.h5p
vendored
Normal file
BIN
lib/editor/atto/tests/fixtures/drag.h5p
vendored
Normal file
Binary file not shown.
BIN
lib/editor/atto/tests/fixtures/guess-the-answer.h5p
vendored
Normal file
BIN
lib/editor/atto/tests/fixtures/guess-the-answer.h5p
vendored
Normal file
Binary file not shown.
@ -178,6 +178,34 @@ class behat_general extends behat_base {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Switches to the iframe containing specified class.
|
||||
*
|
||||
* @Given /^I switch to "(?P<iframe_name_string>(?:[^"]|\\")*)" class iframe$/
|
||||
* @param string $classname
|
||||
*/
|
||||
public function switch_to_class_iframe($classname) {
|
||||
// We spin to give time to the iframe to be loaded.
|
||||
// Using extended timeout as we don't know about which
|
||||
// kind of iframe will be loaded.
|
||||
$this->spin(
|
||||
function($context, $classname) {
|
||||
$iframe = $this->find('iframe', $classname);
|
||||
if (!empty($iframe->getAttribute('id'))) {
|
||||
$iframename = $iframe->getAttribute('id');
|
||||
} else {
|
||||
$iframename = $iframe->getAttribute('name');
|
||||
}
|
||||
$context->getSession()->switchToIFrame($iframename);
|
||||
|
||||
// If no exception we are done.
|
||||
return true;
|
||||
},
|
||||
$classname,
|
||||
behat_base::get_extended_timeout()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Switches to the main Moodle frame.
|
||||
*
|
||||
|
Loading…
x
Reference in New Issue
Block a user