Skip to content

Commit

Permalink
MDL-82596 behat: switch manual private files upload to generator.
Browse files Browse the repository at this point in the history
  • Loading branch information
paulholden committed Jul 28, 2024
1 parent 794115a commit 554ca6c
Show file tree
Hide file tree
Showing 16 changed files with 112 additions and 183 deletions.
Original file line number Diff line number Diff line change
@@ -1,17 1,14 @@
@core @core_contentbank @core_h5p @contenttype_h5p @_file_upload @_switch_iframe @javascript
@core @core_contentbank @core_h5p @contenttype_h5p @_switch_iframe @javascript
Feature: H5P file upload to content bank for admins
In order import new H5P content to content bank
As an admin
I need to be able to upload a new .h5p file to content bank

Background:
Given the following "blocks" exist:
| blockname | contextlevel | reference | pagetypepattern | defaultregion |
| private_files | System | 1 | my-index | side-post |
Given the following "user private file" exists:
| user | admin |
| filepath | h5p/tests/fixtures/filltheblanks.h5p |
And I log in as "admin"
And I follow "Manage private files..."
And I upload "h5p/tests/fixtures/filltheblanks.h5p" file to "Files" filemanager
And I click on "Save changes" "button"
And I turn editing mode on
And the following config values are set as admin:
| unaddableblocks | | theme_boost|
Expand Down Expand Up @@ -99,13 96,11 @@ Feature: H5P file upload to content bank for admins
And I should see "Fill in the Blanks"

Scenario: Uploading invalid packages throws error
Given I follow "Dashboard"
And I follow "Manage private files..."
And I upload "h5p/tests/fixtures/no-json-file.h5p" file to "Files" filemanager
And I click on "Save changes" "button"
And I follow "Manage private files..."
And I upload "h5p/tests/fixtures/unzippable.h5p" file to "Files" filemanager
And I click on "Save changes" "button"
Given the following "user private files" exist:
| user | filepath |
| admin | h5p/tests/fixtures/no-json-file.h5p |
| admin | h5p/tests/fixtures/unzippable.h5p |
And I follow "Dashboard"
And I expand "Site pages" node
And I click on "Content bank" "link"
When I click on "Upload" "link"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 19,10 @@ Feature: H5P file upload to content bank for non admins
| user | course | role |
| teacher1 | C1 | editingteacher |
| teacher2 | C1 | editingteacher |
And the following "blocks" exist:
| blockname | contextlevel | reference | pagetypepattern | defaultregion |
| private_files | System | 1 | my-index | side-post |
And the following "user private file" exists:
| user | teacher1 |
| filepath | h5p/tests/fixtures/filltheblanks.h5p |
And I log in as "teacher1"
And I follow "Manage private files..."
And I upload "h5p/tests/fixtures/filltheblanks.h5p" file to "Files" filemanager
And I click on "Save changes" "button"

Scenario: Teachers can not access system level content bank
Given I turn editing mode on
Expand Down Expand Up @@ -128,11 125,10 @@ Feature: H5P file upload to content bank for non admins
And I should not see "filltheblanks.h5p"

Scenario: Teachers can not see existing contents when libraries are not installed
Given I log out
Given the following "user private file" exists:
| user | admin |
| filepath | h5p/tests/fixtures/filltheblanks.h5p |
And I log in as "admin"
And I follow "Manage private files..."
And I upload "h5p/tests/fixtures/filltheblanks.h5p" file to "Files" filemanager
And I click on "Save changes" "button"
And I navigate to "H5P > Manage H5P content types" in site administration
And I should not see "Fill in the Blanks"
When I upload "h5p/tests/fixtures/filltheblanks.h5p" file to "H5P content type" filemanager
Expand Down
27 changes: 10 additions & 17 deletions contentbank/tests/behat/delete_content.feature
Original file line number Diff line number Diff line change
@@ -1,18 1,14 @@
@core @core_contentbank @core_h5p @contentbank_h5p @_file_upload @javascript
@core @core_contentbank @core_h5p @contentbank_h5p @javascript
Feature: Delete H5P file from the content bank
In order remove H5P content from the content bank
As an admin
I need to be able to delete any H5P content from the content bank

Background:
Given the following "blocks" exist:
| blockname | contextlevel | reference | pagetypepattern | defaultregion |
| private_files | System | 1 | my-index | side-post |
And I log in as "admin"
And I follow "Manage private files..."
And I upload "h5p/tests/fixtures/filltheblanks.h5p" file to "Files" filemanager
And I click on "Save changes" "button"
And I am on the "Content bank" page
Given the following "user private file" exists:
| user | admin |
| filepath | h5p/tests/fixtures/filltheblanks.h5p |
And I am on the "Content bank" page logged in as "admin"
And I click on "Upload" "link"
And I click on "Choose a file..." "button"
And I click on "Private files" "link" in the ".fp-repo-area" "css_element"
Expand Down Expand Up @@ -48,12 44,10 @@ Feature: Delete H5P file from the content bank
And the following "role assigns" exist:
| user | role | contextlevel | reference |
| manager | manager | System | |
And I log out
And I log in as "manager"
And I follow "Manage private files..."
And I upload "h5p/tests/fixtures/find-the-words.h5p" file to "Files" filemanager
And I click on "Save changes" "button"
When I am on the "Content bank" page
And the following "user private file" exists:
| user | manager |
| filepath | h5p/tests/fixtures/find-the-words.h5p |
When I am on the "Content bank" page logged in as "manager"
And I should see "content2delete.h5p"
And I follow "content2delete.h5p"
And I wait "2" seconds
Expand All @@ -71,8 65,7 @@ Feature: Delete H5P file from the content bank
And I should see "Delete"

Scenario: The number of times a content is used is displayed before removing it
Given I follow "Dashboard"
And I follow "Manage private files..."
Given I am on the "My private files" page
And I click on "Add..." "button"
And I select "Content bank" repository in file picker
And I click on "content2delete.h5p" "file" in repository content area
Expand Down
19 changes: 7 additions & 12 deletions contentbank/tests/behat/edit_content.feature
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 5,7 @@ Feature: Content bank use editor feature
I need to be able to access the edition options

Background:
Given the following "blocks" exist:
| blockname | contextlevel | reference | pagetypepattern | defaultregion |
| private_files | System | 1 | my-index | side-post |
And I log in as "admin"
Given I log in as "admin"
And I am on site homepage
And I turn editing mode on
And the following config values are set as admin:
Expand All @@ -25,10 22,9 @@ Feature: Content bank use editor feature
Then the "[data-action=Add-content]" "css_element" should be disabled

Scenario: Users can see the Add button if there is content type available for creation
Given I follow "Dashboard"
And I follow "Manage private files..."
And I upload "h5p/tests/fixtures/filltheblanks.h5p" file to "Files" filemanager
And I click on "Save changes" "button"
Given the following "user private file" exists:
| user | admin |
| filepath | h5p/tests/fixtures/filltheblanks.h5p |
And I click on "Site pages" "list_item" in the "Navigation" "block"
And I click on "Content bank" "link" in the "Navigation" "block"
And I click on "Upload" "link"
Expand All @@ -44,10 40,9 @@ Feature: Content bank use editor feature
And I should see "Fill in the Blanks"

Scenario: Users can edit content if they have the required permission
Given I follow "Dashboard"
And I follow "Manage private files..."
And I upload "h5p/tests/fixtures/filltheblanks.h5p" file to "Files" filemanager
And I click on "Save changes" "button"
Given the following "user private file" exists:
| user | admin |
| filepath | h5p/tests/fixtures/filltheblanks.h5p |
And I click on "Site pages" "list_item" in the "Navigation" "block"
And I click on "Content bank" "link" in the "Navigation" "block"
And I click on "Upload" "link"
Expand Down
21 changes: 7 additions & 14 deletions contentbank/tests/behat/events.feature
Original file line number Diff line number Diff line change
@@ -1,30 1,23 @@
@core @core_contentbank @core_h5p @contentbank_h5p @_file_upload @_switch_iframe @javascript
@core @core_contentbank @core_h5p @contentbank_h5p @_switch_iframe @javascript
Feature: Confirm content bank events are triggered
In order to log content bank actions
As an admin
I need to be able to check triggered events

Background:
Given the following "blocks" exist:
| blockname | contextlevel | reference | pagetypepattern | defaultregion |
| private_files | System | 1 | my-index | side-post |
And I log in as "admin"
And I navigate to "H5P > Manage H5P content types" in site administration
And I upload "h5p/tests/fixtures/filltheblanks.h5p" file to "H5P content type" filemanager
And I click on "Upload H5P content types" "button" in the "#fitem_id_uploadlibraries" "css_element"
And the following "courses" exist:
Given the following "courses" exist:
| fullname | shortname | category |
| Course 1 | C1 | 0 |
And the following "contentbank content" exist:
| contextlevel | reference | contenttype | user | contentname | filepath |
| Course | C1 | contenttype_h5p | admin | Existing | /h5p/tests/fixtures/filltheblanks.h5p |
And I follow "Dashboard"
And I follow "Manage private files..."
And I upload "h5p/tests/fixtures/filltheblanks.h5p" file to "Files" filemanager
And I click on "Save changes" "button"
And I am on "Course 1" course homepage with editing mode on
And the following "user private file" exists:
| user | admin |
| filepath | h5p/tests/fixtures/filltheblanks.h5p |
And the following config values are set as admin:
| unaddableblocks | | theme_boost|
And I log in as "admin"
And I am on "Course 1" course homepage with editing mode on
And I add the "Navigation" block if not present

Scenario: Content created and uploaded events when uploading a content file
Expand Down
16 changes: 6 additions & 10 deletions contentbank/tests/behat/view_preferences.feature
Original file line number Diff line number Diff line change
@@ -1,18 1,15 @@
@core @core_contentbank @core_h5p @contentbank_h5p @_file_upload @javascript
@core @core_contentbank @core_h5p @contentbank_h5p @javascript
Feature: Store the content bank view preference
In order to consistantly view the content bank in icons or details view
As an admin
I need to be able to store my view preference

Background:
Given the following "blocks" exist:
| blockname | contextlevel | reference | pagetypepattern | defaultregion |
| private_files | System | 1 | my-index | side-post |
Given the following "user private files" exist:
| user | filepath |
| admin | h5p/tests/fixtures/filltheblanks.h5p |
| admin | h5p/tests/fixtures/greeting-card.h5p |
And I log in as "admin"
And I follow "Manage private files..."
And I upload "h5p/tests/fixtures/filltheblanks.h5p" file to "Files" filemanager
And I upload "h5p/tests/fixtures/greeting-card.h5p" file to "Files" filemanager
And I click on "Save changes" "button"
And I am on site homepage
And I turn editing mode on
And the following config values are set as admin:
Expand Down Expand Up @@ -55,8 52,7 @@ Feature: Store the content bank view preference
And I should not see "Last modified"

Scenario: Display the number of times a content is used in file details view
Given I follow "Dashboard"
And I follow "Manage private files..."
Given I am on the "My private files" page
And I click on "Add..." "button"
And I select "Content bank" repository in file picker
And I click on "fib.h5p" "file" in repository content area
Expand Down
16 changes: 5 additions & 11 deletions filter/displayh5p/tests/behat/inline_editing_content.feature
Original file line number Diff line number Diff line change
@@ -1,4 1,4 @@
@editor @editor_atto @atto @atto_h5p @filter @filter_displayh5p @core_h5p @_file_upload @_switch_iframe
@editor @editor_atto @atto @atto_h5p @filter @filter_displayh5p @core_h5p @_switch_iframe
Feature: Inline editing H5P content anywhere
In order to edit an existing H5P content
As a user
Expand Down Expand Up @@ -30,23 30,17 @@ Feature: Inline editing H5P content anywhere
| capability | permission | role | contextlevel | reference |
| moodle/course:update | Allow | teacher | System | |
| moodle/course:update | Allow | student | System | |
And the following "blocks" exist:
| blockname | contextlevel | reference | pagetypepattern | defaultregion |
| private_files | System | 1 | my-index | side-post |

@javascript @mod @mod_page
Scenario: Edit H5P content from a page using link to private file
Given the following "permission overrides" exist:
| capability | permission | role | contextlevel | reference |
| moodle/h5p:updatelibraries | Allow | editingteacher | System | |
And I log in as "teacher1"
# Upload the H5P to private user files.
And I follow "Manage private files..."
And I upload "h5p/tests/fixtures/greeting-card.h5p" file to "Files" filemanager
And I click on "Save changes" "button"
And the following "user private file" exists:
| user | teacher1 |
| filepath | h5p/tests/fixtures/greeting-card.h5p |
# Add H5P content to the page.
And I am on "Course 1" course homepage
And I am on the "PageName1" "page activity" page
And I am on the "PageName1" "page activity" page logged in as "teacher1"
And I navigate to "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"
Expand Down
11 changes: 4 additions & 7 deletions lib/editor/atto/plugins/image/tests/behat/image.feature
Original file line number Diff line number Diff line change
@@ -1,16 1,13 @@
@editor @editor_atto @atto @atto_image @_file_upload
@editor @editor_atto @atto @atto_image
Feature: Add images to Atto
To write rich text - I need to add images.

@javascript
Scenario: Insert an image
Given the following "blocks" exist:
| blockname | contextlevel | reference | pagetypepattern | defaultregion |
| private_files | System | 1 | my-index | side-post |
Given the following "user private file" exists:
| user | admin |
| filepath | lib/editor/atto/tests/fixtures/moodle-logo.png |
And I log in as "admin"
And I follow "Manage private files..."
And I upload "lib/editor/atto/tests/fixtures/moodle-logo.png" file to "Files" filemanager
And I click on "Save changes" "button"
And I open my profile in edit mode
When I set the field "Description" to "<p>Image test</p>"
And I select the text in the "Description" Atto editor
Expand Down
19 changes: 8 additions & 11 deletions lib/editor/atto/plugins/link/tests/behat/link.feature
Original file line number Diff line number Diff line change
@@ -1,16 1,13 @@
@editor @editor_atto @atto @atto_link @_file_upload
@editor @editor_atto @atto @atto_link
Feature: Add links to Atto
To write rich text - I need to add links.

@javascript
Scenario: Insert a links
Given the following "blocks" exist:
| blockname | contextlevel | reference | pagetypepattern | defaultregion |
| private_files | System | 1 | my-index | side-post |
Given the following "user private file" exists:
| user | admin |
| filepath | lib/editor/atto/tests/fixtures/moodle-logo.png |
And I log in as "admin"
And I follow "Manage private files..."
And I upload "lib/editor/atto/tests/fixtures/moodle-logo.png" file to "Files" filemanager
And I click on "Save changes" "button"
When I open my profile in edit mode
And I set the field "Description" to "Super cool"
And I select the text in the "Description" Atto editor
Expand Down Expand Up @@ -85,10 82,10 @@ Feature: Add links to Atto

@javascript
Scenario: Insert a link for an image
Given I log in as "admin"
And I follow "Private files" in the user menu
And I upload "lib/editor/atto/tests/fixtures/moodle-logo.png" file to "Files" filemanager
And I click on "Save changes" "button"
Given the following "user private file" exists:
| user | admin |
| filepath | lib/editor/atto/tests/fixtures/moodle-logo.png |
And I log in as "admin"
And I open my profile in edit mode
And I click on "Insert or edit image" "button"
And I click on "Browse repositories..." "button"
Expand Down
19 changes: 8 additions & 11 deletions lib/editor/atto/plugins/media/tests/behat/media.feature
Original file line number Diff line number Diff line change
@@ -1,20 1,17 @@
@editor @editor_atto @atto @atto_media @_file_upload
@editor @editor_atto @atto @atto_media
Feature: Add media to Atto
To write rich text - I need to add media.

Background:
Given the following "blocks" exist:
| blockname | contextlevel | reference | pagetypepattern | defaultregion |
| private_files | System | 1 | my-index | side-post |
Given the following "user private files" exist:
| user | filepath |
| admin | lib/editor/atto/tests/fixtures/moodle-logo.webm |
| admin | lib/editor/atto/tests/fixtures/moodle-logo.mp4 |
| admin | lib/editor/atto/tests/fixtures/moodle-logo.png |
| admin | lib/editor/atto/tests/fixtures/pretty-good-en.vtt |
| admin | lib/editor/atto/tests/fixtures/pretty-good-sv.vtt |
And 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/moodle-logo.webm" file to "Files" filemanager
And I upload "lib/editor/atto/tests/fixtures/moodle-logo.mp4" file to "Files" filemanager
And I upload "lib/editor/atto/tests/fixtures/moodle-logo.png" file to "Files" filemanager
And I upload "lib/editor/atto/tests/fixtures/pretty-good-en.vtt" file to "Files" filemanager
And I upload "lib/editor/atto/tests/fixtures/pretty-good-sv.vtt" file to "Files" filemanager
And I click on "Save changes" "button"
And I follow "Profile" in the user menu
And I follow "Blog entries"
And I follow "Add a new entry"
Expand Down
17 changes: 6 additions & 11 deletions lib/editor/atto/tests/behat/autosave.feature
Original file line number Diff line number Diff line change
@@ -1,4 1,4 @@
@editor @editor_atto @atto @_file_upload
@editor @editor_atto @atto
Feature: Atto Autosave
To reduce frustration, atto should save drafts of my work.

Expand All @@ -14,9 14,6 @@ Feature: Atto Autosave
| user | course | role |
| teacher1 | C1 | editingteacher |
| teacher2 | C1 | editingteacher |
And the following "blocks" exist:
| blockname | contextlevel | reference | pagetypepattern | defaultregion |
| private_files | System | 1 | my-index | side-post |
And I log in as "admin"
And I navigate to "Plugins > Text editors > Atto HTML editor > Atto toolbar settings" in site administration
And I set the field "Autosave frequency" to "3"
Expand Down Expand Up @@ -46,18 43,16 @@ Feature: Atto Autosave

@javascript
Scenario: Do not restore a draft if files have been modified
Given I log in as "teacher1"
And I am on "Course 1" course homepage
Given the following "user private file" exists:
| user | teacher2 |
| filepath | lib/editor/atto/tests/fixtures/moodle-logo.png |
And I am on the "Course 1" course page logged in as teacher1
And I navigate to "Settings" in current page administration
And I set the field "Course summary" to "This is my draft"
# Wait for the autosave
And I wait "5" seconds
And I log out
And I log in as "teacher2"
And I follow "Manage private files..."
And I upload "lib/editor/atto/tests/fixtures/moodle-logo.png" file to "Files" filemanager
And I click on "Save changes" "button"
And I am on "Course 1" course homepage
And I am on the "Course 1" course page logged in as teacher2
And I navigate to "Settings" in current page administration
And I set the field "Course summary" to "<p>Image test</p>"
And I select the text in the "Course summary" Atto editor
Expand Down
Loading

0 comments on commit 554ca6c

Please sign in to comment.