From 83db25c3303290902d9f85cc6311b1d8b89fdc86 Mon Sep 17 00:00:00 2001 From: Paul Holden Date: Wed, 17 Jul 2024 13:52:24 +0100 Subject: [PATCH] MDL-82527 h5p: improve editor Behat scenarios for embedding content. * Move the shared drag fixture out of the Atto plugin; * Switch to using faster generators for populating private files; * Clarify required fields for private files generator --- .../atto => h5p}/tests/fixtures/drag.h5p | Bin lib/behat/classes/behat_core_generator.php | 2 +- .../atto/plugins/h5p/tests/behat/h5p.feature | 43 ++++++++---------- .../tiny/plugins/h5p/tests/behat/h5p.feature | 41 +++++++---------- 4 files changed, 36 insertions(+), 50 deletions(-) rename {lib/editor/atto => h5p}/tests/fixtures/drag.h5p (100%) diff --git a/lib/editor/atto/tests/fixtures/drag.h5p b/h5p/tests/fixtures/drag.h5p similarity index 100% rename from lib/editor/atto/tests/fixtures/drag.h5p rename to h5p/tests/fixtures/drag.h5p diff --git a/lib/behat/classes/behat_core_generator.php b/lib/behat/classes/behat_core_generator.php index bc1e0807912..e6f2f3d5741 100644 --- a/lib/behat/classes/behat_core_generator.php +++ b/lib/behat/classes/behat_core_generator.php @@ -290,7 +290,7 @@ class behat_core_generator extends behat_generator_base { 'user private files' => [ 'singular' => 'user private file', 'datagenerator' => 'user_private_files', - 'required' => ['user', 'filepath', 'filename'], + 'required' => ['user', 'filepath'], 'switchids' => ['user' => 'userid'] ], 'badge external backpacks' => [ diff --git a/lib/editor/atto/plugins/h5p/tests/behat/h5p.feature b/lib/editor/atto/plugins/h5p/tests/behat/h5p.feature index fc60fe9abf5..fc884b4f3d9 100644 --- a/lib/editor/atto/plugins/h5p/tests/behat/h5p.feature +++ b/lib/editor/atto/plugins/h5p/tests/behat/h5p.feature @@ -1,5 +1,5 @@ -@editor @editor_atto @atto @atto_h5p @core_h5p @_file_upload @_switch_iframe -Feature: Add h5ps to Atto +@editor @editor_atto @atto @atto_h5p @core_h5p @_switch_iframe +Feature: Use the Atto editor to upload an h5p package To write rich text - I need to add h5ps. Background: @@ -18,9 +18,6 @@ Feature: Add h5ps to Atto And the "displayh5p" filter is "on" And the following config values are set as admin: | allowedsources | https://moodle.h5p.com/content/[id] | filter_displayh5p | - And the following "blocks" exist: - | blockname | contextlevel | reference | pagetypepattern | defaultregion | - | private_files | System | 1 | my-index | side-post | @javascript @external Scenario: Insert an embedded h5p @@ -38,11 +35,10 @@ Feature: Add h5ps to Atto @javascript Scenario: Insert an h5p file - Given I log in as "admin" - And I follow "Manage private files..." - And I upload "h5p/tests/fixtures/guess-the-answer.h5p" file to "Files" filemanager - And I click on "Save changes" "button" - And I am on the PageName1 "page activity editing" page + Given the following "user private file" exists: + | user | admin | + | filepath | h5p/tests/fixtures/guess-the-answer.h5p | + And I am on the "PageName1" "page activity editing" page logged in as "admin" 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" @@ -97,11 +93,10 @@ Feature: Add h5ps to Atto @javascript @external Scenario: Edit H5P content - Given I log in as "admin" - 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 the PageName1 "page activity editing" page + Given the following "user private file" exists: + | user | admin | + | filepath | h5p/tests/fixtures/drag.h5p | + And I am on the "PageName1" "page activity editing" page logged in as "admin" 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" @@ -131,11 +126,10 @@ Feature: Add h5ps to Atto @javascript Scenario: Enable/disable H5P options atto - Given I log in as "admin" - And I follow "Manage private files..." - And I upload "h5p/tests/fixtures/guess-the-answer.h5p" file to "Files" filemanager - And I click on "Save changes" "button" - And I am on the PageName1 "page activity editing" page + Given the following "user private file" exists: + | user | admin | + | filepath | h5p/tests/fixtures/guess-the-answer.h5p | + And I am on the "PageName1" "page activity editing" page logged in as "admin" 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" @@ -207,11 +201,10 @@ Feature: Add h5ps to Atto And the following "course enrolments" exist: | user | course | role | | student1 | C1 | student | - And I log in as "admin" - And I follow "Manage private files..." - And I upload "h5p/tests/fixtures/guess-the-answer.h5p" file to "Files" filemanager - And I click on "Save changes" "button" - And I am on the PageName1 "page activity editing" page + And the following "user private file" exists: + | user | admin | + | filepath | h5p/tests/fixtures/guess-the-answer.h5p | + And I am on the "PageName1" "page activity editing" page logged in as "admin" 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" diff --git a/lib/editor/tiny/plugins/h5p/tests/behat/h5p.feature b/lib/editor/tiny/plugins/h5p/tests/behat/h5p.feature index 81bacb607d5..0c6d6634718 100644 --- a/lib/editor/tiny/plugins/h5p/tests/behat/h5p.feature +++ b/lib/editor/tiny/plugins/h5p/tests/behat/h5p.feature @@ -1,4 +1,4 @@ -@editor @editor_tiny @tiny_h5p @javascript @_file_upload +@editor @editor_tiny @tiny_h5p @javascript Feature: Use the TinyMCE editor to upload an h5p package In order to work with h5p As a content creator @@ -20,9 +20,6 @@ Feature: Use the TinyMCE editor to upload an h5p package And the "displayh5p" filter is "on" And the following config values are set as admin: | allowedsources | https://moodle.h5p.com/content/[id] | filter_displayh5p | - And the following "blocks" exist: - | blockname | contextlevel | reference | pagetypepattern | defaultregion | - | private_files | System | 1 | my-index | side-post | @javascript @external Scenario: TinyMCE can be used to embed an H5P activity @@ -38,12 +35,11 @@ Feature: Use the TinyMCE editor to upload an h5p package @javascript Scenario: TinyMCE can be used to upload and embed an H5P activity - Given I log in as "admin" + Given the following "user private file" exists: + | user | admin | + | filepath | h5p/tests/fixtures/guess-the-answer.h5p | And I change window size to "large" - And I follow "Manage private files..." - And I upload "h5p/tests/fixtures/guess-the-answer.h5p" file to "Files" filemanager - And I click on "Save changes" "button" - And I am on the "PageName1" "page activity editing" page + And I am on the "PageName1" "page activity editing" page logged in as "admin" And I click on the "Configure H5P content" button for the "Page content" TinyMCE editor And I click on "Browse repositories..." "button" in the "Insert H5P content" "dialogue" And I click on "Private files" "link" in the ".fp-repo-area" "css_element" @@ -74,11 +70,10 @@ Feature: Use the TinyMCE editor to upload an h5p package @javascript @external Scenario: A user can edit H5P content embedding with TinyMCE - Given I log in as "admin" - 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 the PageName1 "page activity editing" page + Given the following "user private file" exists: + | user | admin | + | filepath | h5p/tests/fixtures/drag.h5p | + And I am on the "PageName1" "page activity editing" page logged in as "admin" And I click on the "Configure H5P content" button for the "Page content" TinyMCE editor And I click on "Browse repositories..." "button" in the "Insert H5P content" "dialogue" And I click on "Private files" "link" in the ".fp-repo-area" "css_element" @@ -104,11 +99,10 @@ Feature: Use the TinyMCE editor to upload an h5p package @javascript Scenario: Enable/disable H5P options tiny - Given I log in as "admin" - And I follow "Manage private files..." - And I upload "h5p/tests/fixtures/guess-the-answer.h5p" file to "Files" filemanager - And I click on "Save changes" "button" - And I am on the PageName1 "page activity editing" page + Given the following "user private file" exists: + | user | admin | + | filepath | h5p/tests/fixtures/guess-the-answer.h5p | + And I am on the "PageName1" "page activity editing" page logged in as "admin" And I click on the "Configure H5P content" button for the "Page content" TinyMCE editor And I click on "Browse repositories..." "button" in the "Insert H5P content" "dialogue" And I click on "Private files" "link" in the ".fp-repo-area" "css_element" @@ -178,11 +172,10 @@ Feature: Use the TinyMCE editor to upload an h5p package And the following "course enrolments" exist: | user | course | role | | student1 | C1 | student | - And I log in as "admin" - And I follow "Manage private files..." - And I upload "h5p/tests/fixtures/guess-the-answer.h5p" file to "Files" filemanager - And I click on "Save changes" "button" - And I am on the PageName1 "page activity editing" page + And the following "user private file" exists: + | user | admin | + | filepath | h5p/tests/fixtures/guess-the-answer.h5p | + And I am on the "PageName1" "page activity editing" page logged in as "admin" And I click on the "Configure H5P content" button for the "Page content" TinyMCE editor And I click on "Browse repositories..." "button" in the "Insert H5P content" "dialogue" And I click on "Private files" "link" in the ".fp-repo-area" "css_element" -- 2.43.0