From 802ff3e2e3760d570d2015129760ee09cd03d80f Mon Sep 17 00:00:00 2001 From: David Woloszyn Date: Mon, 24 Apr 2023 14:22:20 +1000 Subject: [PATCH] MDL-75913 behat: Use alternatives to Atto in tests --- .../tests/behat/default_value.feature | 28 +-- .../tests/behat/edit_fields_settings.feature | 17 +- .../displayh5p/tests/behat/h5p_filter.feature | 167 +++++------------- .../behat/edit_previous_feedback.feature | 3 +- .../tests/behat/duplicate_lesson_page.feature | 69 ++++---- .../tests/behat/questions_images.feature | 19 +- .../behat/manually_mark_question.feature | 6 +- .../tests/behat/embedded_images.feature | 32 ++-- .../tests/behat/file_update.feature | 51 +++--- .../tests/behat/select_content.feature | 11 +- 10 files changed, 153 insertions(+), 250 deletions(-) diff --git a/customfield/field/textarea/tests/behat/default_value.feature b/customfield/field/textarea/tests/behat/default_value.feature index d10b5e2cee8..ee49d2a14a6 100644 --- a/customfield/field/textarea/tests/behat/default_value.feature +++ b/customfield/field/textarea/tests/behat/default_value.feature @@ -1,5 +1,4 @@ -# This feature has Atto-specific steps. See MDL-75913 for further details. -@customfield @customfield_textarea @javascript @_file_upload @editor_atto +@customfield @customfield_textarea @javascript @editor_tiny Feature: Default value for the textarea custom field can contain images In order to see images on custom fields As a manager @@ -25,21 +24,18 @@ Feature: Default value for the textarea custom field can contain images And the following "blocks" exist: | blockname | contextlevel | reference | pagetypepattern | defaultregion | | private_files | System | 1 | my-index | side-post | - # Upload an image into the private files. + And the following "user private files" exist: + | user | filepath | filename | + | admin | lib/tests/fixtures/gd-logo.png | gd-logo.png | And I log in as "admin" - And I follow "Manage private files" - And I upload "lib/tests/fixtures/gd-logo.png" file to "Files" filemanager - And I click on "Save changes" "button" And I navigate to "Courses > Course custom fields" in site administration And I click on "Add a new custom field" "link" And I click on "Text area" "link" And I set the following fields to these values: | Name | Test field | | Short name | testfield | - | Default value | v | # Embed the image into Default value. - And I select the text in the "Default value" Atto editor - And I click on "Insert or edit image" "button" in the "Default value" "form_row" + And I click on "Image" "button" in the "Default value" "form_row" And I click on "Browse repositories..." "button" And I click on "Private files" "link" in the ".fp-repo-area" "css_element" And I click on "gd-logo.png" "link" @@ -55,17 +51,19 @@ Feature: Default value for the textarea custom field can contain images Scenario: Teacher will see textarea default value when editing a course created before custom field was created # Teacher will see the image when editing existing course. - And I log in as "teacher" + When I log in as "teacher" And I am on "Course 1" course homepage And I navigate to "Settings" in current page administration And I expand all fieldsets - Then "//img[contains(@src, 'draftfile.php') and contains(@src, '/gd-logo.png') and @alt='Example']" "xpath_element" should exist in the "Test field" "form_row" + And I switch to the "Test field" TinyMCE editor iframe + Then "//img[contains(@src, 'draftfile.php') and contains(@src, '/gd-logo.png') and @alt='Example']" "xpath_element" should exist + And I switch to the main frame # Save the course without changing the default value. And I press "Save and display" And I log out # Now the same image is displayed as "value" and not as "defaultvalue". And I am on site homepage - And "//img[contains(@src, '/customfield_textarea/defaultvalue/')]" "xpath_element" should not exist + Then "//img[contains(@src, '/customfield_textarea/defaultvalue/')]" "xpath_element" should not exist And the image at "//*[contains(@class, 'frontpage-course-list-all')]//*[contains(@class, 'customfield_textarea')]//img[contains(@src, 'pluginfile.php') and contains(@src, '/customfield_textarea/value/') and @alt='Example']" "xpath_element" should be identical to "lib/tests/fixtures/gd-logo.png" Scenario: Manager can create a course and the default value for textarea custom field will apply. @@ -76,9 +74,11 @@ Feature: Default value for the textarea custom field can contain images | Course full name | Course 2 | | Course short name | C2 | And I expand all fieldsets - Then "//img[contains(@src, 'draftfile.php') and contains(@src, '/gd-logo.png') and @alt='Example']" "xpath_element" should exist in the "Test field" "form_row" + And I switch to the "Test field" TinyMCE editor iframe + Then "//img[contains(@src, 'draftfile.php') and contains(@src, '/gd-logo.png') and @alt='Example']" "xpath_element" should exist + And I switch to the main frame And I press "Save and display" And I log out # Now the same image is displayed as "value" and not as "defaultvalue". And I am on site homepage - And the image at "//*[contains(@class, 'frontpage-course-list-all')]//*[contains(@class, 'customfield_textarea')]//img[contains(@src, 'pluginfile.php') and contains(@src, '/customfield_textarea/value/') and @alt='Example']" "xpath_element" should be identical to "lib/tests/fixtures/gd-logo.png" + Then the image at "//*[contains(@class, 'frontpage-course-list-all')]//*[contains(@class, 'customfield_textarea')]//img[contains(@src, 'pluginfile.php') and contains(@src, '/customfield_textarea/value/') and @alt='Example']" "xpath_element" should be identical to "lib/tests/fixtures/gd-logo.png" diff --git a/customfield/tests/behat/edit_fields_settings.feature b/customfield/tests/behat/edit_fields_settings.feature index 5854bd6b040..155859393ac 100644 --- a/customfield/tests/behat/edit_fields_settings.feature +++ b/customfield/tests/behat/edit_fields_settings.feature @@ -1,5 +1,5 @@ # This feature has Atto-specific steps. See MDL-75913 for further details. -@core @core_course @core_customfield @javascript @editor_atto +@core @core_course @core_customfield @javascript Feature: Teachers can edit course custom fields In order to have additional data on the course As a teacher @@ -28,6 +28,9 @@ Feature: Teachers can edit course custom fields And the following "blocks" exist: | blockname | contextlevel | reference | pagetypepattern | defaultregion | | private_files | System | 1 | my-index | side-post | + And the following "user private files" exist: + | user | filepath | filename | + | admin | lib/tests/fixtures/gd-logo.png | gd-logo.png | Scenario: Display custom fields on course edit form When I log in as "teacher1" @@ -74,16 +77,12 @@ Feature: Teachers can edit course custom fields | Field 5 | b | And I log out - @javascript @_file_upload + @javascript @editor_tiny Scenario: Use images in the custom field description When I log in as "admin" - And I follow "Manage private files" - And I upload "lib/tests/fixtures/gd-logo.png" file to "Files" filemanager - And I click on "Save changes" "button" And I navigate to "Courses > Course custom fields" in site administration And I click on "Edit" "link" in the "Field 1" "table_row" - And I select the text in the "Description" Atto editor - And I click on "Insert or edit image" "button" in the "Description" "form_row" + And I click on "Image" "button" in the "Description" "form_row" And I click on "Browse repositories..." "button" And I click on "Private files" "link" in the ".fp-repo-area" "css_element" And I click on "gd-logo.png" "link" @@ -111,9 +110,9 @@ Feature: Teachers can edit course custom fields Then I should see "You must supply a value here" in the "Short name" "form_row" And I set the field "Short name" to "short name" And I click on "Save changes" "button" in the "Adding a new Short text" "dialogue" - And I should see "The short name can only contain alphanumeric lowercase characters and underscores (_)." in the "Short name" "form_row" + Then I should see "The short name can only contain alphanumeric lowercase characters and underscores (_)." in the "Short name" "form_row" And I set the field "Short name" to "f1" And I click on "Save changes" "button" in the "Adding a new Short text" "dialogue" - And I should see "Short name already exists" in the "Short name" "form_row" + Then I should see "Short name already exists" in the "Short name" "form_row" And I click on "Cancel" "button" in the "Adding a new Short text" "dialogue" And I log out diff --git a/filter/displayh5p/tests/behat/h5p_filter.feature b/filter/displayh5p/tests/behat/h5p_filter.feature index 3c79d290dbc..f0ab95bec5f 100644 --- a/filter/displayh5p/tests/behat/h5p_filter.feature +++ b/filter/displayh5p/tests/behat/h5p_filter.feature @@ -7,17 +7,13 @@ Feature: Render H5P content using filters | 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 | + | 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 | - | page | PageName2 | PageDesc1 | 1 | C1 | H5Ptest | 1 | 1 | + | user | course | role | + | teacher1 | C1 | editingteacher | + | student1 | C1 | student | And the following "blocks" exist: | blockname | contextlevel | reference | pagetypepattern | defaultregion | | private_files | System | 1 | my-index | side-post | @@ -27,51 +23,36 @@ Feature: Render H5P content using filters @javascript @external Scenario: Render an external H5P content URL. - Given I am on the PageName1 "page activity editing" page logged in as teacher1 - And I set the field "Page content" to "
Go for it
https://moodle.h5p.com/content/1290772960722742119/embed" - When I click on "Save and display" "button" - And I wait until the page is ready + Given the following "activities" exist: + | activity | name | intro | introformat | course | content | contentformat | idnumber | + | page | PageName1 | PageDesc1 | 1 | C1 |
Go for it
https://moodle.h5p.com/content/1290772960722742119/embed | 1 | 1 | + When I am on the PageName1 "page activity" page logged in as teacher1 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 with the URL. Should be rendered. - Given I am on the PageName1 "page activity editing" page logged in as teacher1 -# This content won't be displayed, so this scenario shouldn't be labeled as external. - And I set the field "Page content" to "https://moodle.h5p.com/content/1290772960722742119/embed" - When I click on "Save and display" "button" - And I wait until the page is ready + Given the following "activities" exist: + | activity | name | intro | introformat | course | content | contentformat | idnumber | + | page | PageName1 | PageDesc1 | 1 | C1 | https://moodle.h5p.com/content/1290772960722742119/embed | 1 | 1 | + When I am on the PageName1 "page activity" page logged in as teacher1 And I switch to "h5p-iframe" class iframe Then I should see "Lorum ipsum" Scenario: Add an external H5P content URL in a link with text. Shouldn't be rendered. - Given I am on the PageName1 "page activity editing" page logged in as teacher1 # This content won't be displayed, so this scenario shouldn't be labeled as external. - And I set the field "Page content" to "Here you are the content" - When I click on "Save and display" "button" - And I wait until the page is ready + Given the following "activities" exist: + | activity | name | intro | introformat | course | content | contentformat | idnumber | + | page | PageName1 | PageDesc1 | 1 | C1 | Here you are the content | 1 | 1 | + When I am on the PageName1 "page activity" page logged in as teacher1 Then ".h5p-iframe" "css_element" should not exist - # This scenario has Atto-specific steps. See MDL-75913 for further details. - @javascript @editor_atto + @javascript Scenario: Render a local H5P file as admin - Given I log in as "admin" - 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 "h5p/tests/fixtures/ipsums.h5p" file to "Select files" filemanager - And I press "Save and return to course" - And I am on the PageName1 "page activity editing" page - 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" + Given the following "activities" exist: + | activity | name | intro | introformat | course | content | contentformat | idnumber | [[files::content]] | + | page | PageName1 | PageDesc1 | 1 | C1 |

H5P Activity:

@@PLUGINFILE@@/ipsums.h5p
| 1 | 1 | h5p/tests/fixtures/ipsums.h5p::ipsums.h5p | + When I am on the PageName1 "page activity" page logged in as teacher1 And I should see "PageName1" in the "page-header" "region" # Switch to iframe created by filter And I switch to "h5p-iframe" class iframe @@ -85,88 +66,43 @@ Feature: Render H5P content using filters 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" + Then I should not see "you don't have access" And I should see "Lorum ipsum" - # This scenario has Atto-specific steps. See MDL-75913 for further details. - @javascript @editor_atto + @javascript Scenario: Render a local H5P file as teacher - 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 "h5p/tests/fixtures/ipsums.h5p" file to "Select files" filemanager - And I press "Save and return to course" - And I am on the PageName1 "page activity editing" page - 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" + Given the following "activities" exist: + | activity | name | intro | introformat | course | content | contentformat | idnumber | [[files::content]] | + | page | PageName1 | PageDesc1 | 1 | C1 |

H5P Activity:

@@PLUGINFILE@@/ipsums.h5p
| 1 | 1 | h5p/tests/fixtures/ipsums.h5p::ipsums.h5p::teacher1 | + When I am on the PageName1 "page activity" page logged in as teacher1 And I should see "PageName1" in the "page-header" "region" # Switch to iframe created by filter And I switch to "h5p-iframe" class iframe Then I should see "Note that the libraries may exist in the file you uploaded, but you're not allowed to upload new libraries." And I should see "missing-required-library" - # This scenario has Atto-specific steps. See MDL-75913 for further details. - @javascript @editor_atto + @javascript Scenario: Render a local H5P file with existing libraries - 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 | ipsumFileTeacher | - And I upload "h5p/tests/fixtures/ipsums.h5p" file to "Select files" filemanager - And I press "Save and return to course" - And I am on the PageName1 "page activity editing" page - 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 "ipsumFileTeacher (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 - And I click on "Save and display" "button" + Given the following "activities" exist: + | activity | name | intro | introformat | course | content | contentformat | idnumber | [[files::content]] | + | page | PageName1 | PageDesc1 | 1 | C1 |

H5P Activity:

@@PLUGINFILE@@/ipsums.h5p
| 1 | 1 | h5p/tests/fixtures/ipsums.h5p::ipsums.h5p::teacher1 | + | page | PageName2 | PageDesc2 | 1 | C1 |

H5P Activity:

@@PLUGINFILE@@/ipsums.h5p
| 1 | 1 | h5p/tests/fixtures/ipsums.h5p::ipsums.h5p::admin | + When I am on the PageName1 "page activity" page logged in as teacher1 And I should see "PageName1" in the "page-header" "region" # Switch to iframe created by filter And I switch to "h5p-iframe" class iframe # Libraries don't exist, so an error should be displayed. - And I should see "missing-required-library" + Then I should see "missing-required-library" And I switch to the main frame - And I log out - And I log in as "admin" - 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 "h5p/tests/fixtures/ipsums.h5p" file to "Select files" filemanager - And I press "Save and return to course" - And I am on the PageName2 "page activity editing" page - 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 - And I click on "Save and display" "button" + And I am on the PageName2 "page activity" page logged in as admin And I should see "PageName2" in the "page-header" "region" # 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 # Libraries have been installed. - And I should see "Lorum ipsum" + Then I should see "Lorum ipsum" And I switch to the main frame - And I log out And I am on the PageName1 "page activity" page logged in as teacher1 # Switch to iframe created by filter And I switch to "h5p-iframe" class iframe @@ -175,29 +111,18 @@ Feature: Render H5P content using filters Then I should not see "missing-required-library" And I should see "Lorum ipsum" - # This scenario has Atto-specific steps. See MDL-75913 for further details. - @javascript @editor_atto + @javascript Scenario: Render local H5P file with a disabled main library - Given I log in as "admin" -# Upload H5P file to private files. - And I follow "Manage private files..." - And I upload "h5p/tests/fixtures/ipsums.h5p" file to "Files" filemanager - And I click on "Save changes" "button" + Given the following "activities" exist: + | activity | name | intro | introformat | course | content | contentformat | idnumber | [[files::content]] | + | page | PageName1 | PageDesc1 | 1 | C1 |

H5P Activity:

@@PLUGINFILE@@/ipsums.h5p
| 1 | 1 | h5p/tests/fixtures/ipsums.h5p::ipsums.h5p | + When I am logged in as "admin" # Upload manually the H5P content-type library and disable it. And I navigate to "H5P > Manage H5P content types" in site administration And I upload "h5p/tests/fixtures/ipsums.h5p" file to "H5P content type" filemanager And I click on "Upload H5P content types" "button" in the "#fitem_id_uploadlibraries" "css_element" And I click on "Disable" "link" in the "Accordion" "table_row" -# Add H5P content to the page. - And I am on "Course 1" course homepage - And I am on the PageName1 "page activity editing" page - When 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 "Select this file" "button" - And I click on "Insert H5P" "button" in the "Insert H5P" "dialogue" - And I click on "Save and display" "button" + And I am on the PageName1 "page activity" page logged in as admin And I should see "PageName1" in the "page-header" "region" And I switch to "h5p-iframe" class iframe # Library is disabled, so an error should be displayed. @@ -212,7 +137,7 @@ Feature: Render H5P content using filters 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 see "Lorum ipsum" + Then I should see "Lorum ipsum" And I should not see "This file can't be displayed because its content type is disabled." And I switch to the main frame And I navigate to "H5P > Manage H5P content types" in site administration @@ -220,6 +145,6 @@ Feature: Render H5P content using filters # Library is disabled again, so an error should be displayed. And I am on the PageName1 "page activity" page And I switch to "h5p-iframe" class iframe - And I should see "This file can't be displayed because its content type is disabled." + Then I should see "This file can't be displayed because its content type is disabled." And I should not see "Lorum ipsum" And I switch to the main frame diff --git a/mod/assign/tests/behat/edit_previous_feedback.feature b/mod/assign/tests/behat/edit_previous_feedback.feature index 204fe5605d1..68d398ee264 100644 --- a/mod/assign/tests/behat/edit_previous_feedback.feature +++ b/mod/assign/tests/behat/edit_previous_feedback.feature @@ -4,7 +4,8 @@ Feature: In an assignment, teachers can edit feedback for a students previous su As a teacher I need to be able to edit the feedback for a students previous submission attempt. - # This scenario has Atto-specific steps. See MDL-75913 for further details. + # Atto is necessary to use in this test to circumvent an error in Firefox when using Tiny. + # See issue MDL-77740 for more context, although that implementation does not fix it here. @javascript @editor_atto Scenario: Edit feedback for a students previous attempt. Given the following "courses" exist: diff --git a/mod/lesson/tests/behat/duplicate_lesson_page.feature b/mod/lesson/tests/behat/duplicate_lesson_page.feature index df2501c0a88..0c646fc1c62 100644 --- a/mod/lesson/tests/behat/duplicate_lesson_page.feature +++ b/mod/lesson/tests/behat/duplicate_lesson_page.feature @@ -1,5 +1,4 @@ -# This feature has Atto-specific steps. See MDL-75913 for further details. -@mod @mod_lesson @editor_atto +@mod @mod_lesson @javascript @editor_tiny Feature: In a lesson activity, a teacher can duplicate a lesson page In order to duplicate a lesson page As a teacher @@ -24,14 +23,13 @@ Feature: In a lesson activity, a teacher can duplicate a lesson page And the following "blocks" exist: | blockname | contextlevel | reference | pagetypepattern | defaultregion | | private_files | System | 1 | my-index | side-post | + And the following "user private files" exist: + | user | filepath | filename | + | teacher1 | mod/lesson/tests/fixtures/moodle_logo.jpg | moodle_logo.jpg | And I log in as "teacher1" - And I follow "Manage private files" - And I upload "mod/lesson/tests/fixtures/moodle_logo.jpg" file to "Files" filemanager - And I click on "Save changes" "button" - @javascript @_file_upload Scenario: Duplicate content page with an image. - Given I am on the "Test lesson name" "lesson activity" page + When I am on the "Test lesson name" "lesson activity" page And I follow "Add a content page" And I set the following fields to these values: | Page title | First page name | @@ -40,9 +38,7 @@ Feature: In a lesson activity, a teacher can duplicate a lesson page | id_jumpto_0 | Next page | | id_answer_editor_1 | Previous page | | id_jumpto_1 | Previous page | - # Atto needs focus to add image, select empty p tag to do so. - And I select the text in the "id_contents_editor" Atto editor - And I click on "Insert or edit image" "button" in the "[data-fieldtype=editor]" "css_element" + And I click on "Image" "button" in the "Page contents" "form_row" And I click on "Browse repositories..." "button" And I click on "Private files" "link" in the ".fp-repo-area" "css_element" And I click on "moodle_logo.jpg" "link" @@ -51,24 +47,24 @@ Feature: In a lesson activity, a teacher can duplicate a lesson page And I click on "Save image" "button" And I press "Save page" And I follow "Duplicate page: First page name" - And I should see "Inserted page: First page name" + Then I should see "Inserted page: First page name" And I follow "Update page: First page name" And I set the field "Page title" to "Introduction page" And I press "Save page" - When I follow "Update page: First page name" - And I should see "First page name" - Then "//*[contains(@id, 'id_contents_editor')]//img[contains(@src, 'moodle_logo.jpg')]" "xpath_element" should exist + And I follow "Update page: First page name" + Then I should see "First page name" + And I switch to the "Page contents" TinyMCE editor iframe + Then "//*[contains(@data-id, 'id_contents_editor')]//img[contains(@src, 'moodle_logo.jpg')]" "xpath_element" should exist - @javascript @_file_upload Scenario: Duplicate question page with image in answer. - Given I am on the "Test lesson name" "lesson activity" page + When I am on the "Test lesson name" "lesson activity" page And I follow "Add a question page" And I set the field "Select a question type" to "True/false" And I press "Add a question page" And I set the following fields to these values: | Page title | True false with an image in the answer | | Page contents | Select the picture | - | id_answer_editor_0 | To be replaced | + | id_answer_editor_0 | Answer text | | id_response_editor_0 | Correct answer | | id_jumpto_0 | End of lesson | | id_score_0 | 1 | @@ -76,9 +72,7 @@ Feature: In a lesson activity, a teacher can duplicate a lesson page | id_response_editor_1 | Incorrect answer | | id_jumpto_1 | This page | | id_score_1 | 0 | - # Atto needs focus to add image, select empty p tag to do so. - And I select the text in the "id_answer_editor_0" Atto editor - And I click on "Insert or edit image" "button" in the "//*[@id='id_answer_editor_0']/ancestor::*[@data-fieldtype='editor']" "xpath_element" + And I click on "Image" "button" in the "//*[@id='id_answer_editor_0']/ancestor::*[@data-fieldtype='editor']" "xpath_element" And I click on "Browse repositories..." "button" And I click on "Private files" "link" in the ".fp-repo-area" "css_element" And I click on "moodle_logo.jpg" "link" @@ -87,25 +81,27 @@ Feature: In a lesson activity, a teacher can duplicate a lesson page And I click on "Save image" "button" And I press "Save page" And I follow "Duplicate page: True false with an image in the answer" - And I should see "Inserted page: True false with an image in the answer" + Then I should see "Inserted page: True false with an image in the answer" And I follow "Update page: True false with an image in the answer" And I set the field "Page title" to "First true false" And I press "Save page" - When I follow "Update page: True false with an image in the answer" - And I should see "True false with an image in the answer" - And I should see "Select the picture" - Then "//*[contains(@id, 'id_answer_editor_0')]//img[contains(@src, 'moodle_logo.jpg')]" "xpath_element" should exist + And I follow "Update page: True false with an image in the answer" + Then I should see "True false with an image in the answer" + And I switch to the "Page contents" TinyMCE editor iframe + Then I should see "Select the picture" + And I switch to the main frame + And I switch to the "Answer" TinyMCE editor iframe + Then "//*[contains(@data-id, 'id_answer_editor_0')]//img[contains(@src, 'moodle_logo.jpg')]" "xpath_element" should exist - @javascript @_file_upload Scenario: Duplicate question page with image in feedback. - Given I am on the "Test lesson name" "lesson activity" page + When I am on the "Test lesson name" "lesson activity" page And I follow "Add a question page" And I set the field "Select a question type" to "True/false" And I press "Add a question page" And I set the following fields to these values: | Page title | True false with an image in the feedback | | Page contents | Select the picture | - | id_answer_editor_0 | To be replaced | + | id_answer_editor_0 | Answer text | | id_response_editor_0 | Correct answer | | id_jumpto_0 | End of lesson | | id_score_0 | 1 | @@ -113,9 +109,7 @@ Feature: In a lesson activity, a teacher can duplicate a lesson page | id_response_editor_1 | Incorrect answer | | id_jumpto_1 | This page | | id_score_1 | 0 | - # Atto needs focus to add image, select empty p tag to do so. - And I select the text in the "id_response_editor_0" Atto editor - And I click on "Insert or edit image" "button" in the "//*[@id='id_response_editor_0']/ancestor::*[@data-fieldtype='editor']" "xpath_element" + And I click on "Image" "button" in the "//*[@id='id_response_editor_0']/ancestor::*[@data-fieldtype='editor']" "xpath_element" And I click on "Browse repositories..." "button" And I click on "Private files" "link" in the ".fp-repo-area" "css_element" And I click on "moodle_logo.jpg" "link" @@ -124,11 +118,14 @@ Feature: In a lesson activity, a teacher can duplicate a lesson page And I click on "Save image" "button" And I press "Save page" And I follow "Duplicate page: True false with an image in the feedback" - And I should see "Inserted page: True false with an image in the feedback" + Then I should see "Inserted page: True false with an image in the feedback" And I follow "Update page: True false with an image in the feedback" And I set the field "Page title" to "First true false" And I press "Save page" - When I follow "Update page: True false with an image in the feedback" - And I should see "True false with an image in the feedback" - And I should see "Select the picture" - Then "//*[contains(@id, 'id_response_editor_0')]//img[contains(@src, 'moodle_logo.jpg')]" "xpath_element" should exist + And I follow "Update page: True false with an image in the feedback" + Then I should see "True false with an image in the feedback" + And I switch to the "Page contents" TinyMCE editor iframe + Then I should see "Select the picture" + And I switch to the main frame + And I switch to the "Response" TinyMCE editor iframe + Then "//*[contains(@data-id, 'id_response_editor_0')]//img[contains(@src, 'moodle_logo.jpg')]" "xpath_element" should exist diff --git a/mod/lesson/tests/behat/questions_images.feature b/mod/lesson/tests/behat/questions_images.feature index c461f9f6fd7..291753e4f59 100644 --- a/mod/lesson/tests/behat/questions_images.feature +++ b/mod/lesson/tests/behat/questions_images.feature @@ -3,9 +3,8 @@ Feature: In a lesson activity, teacher can add embedded images in questions answ As a teacher I need to add questions with images in answers and responses - # This scenario has Atto-specific steps. See MDL-75913 for further details. - @javascript @_file_upload @editor_atto - Scenario: questions with images in answers and responses + @javascript @editor_tiny + Scenario: Questions with images in answers and responses Given the following "users" exist: | username | firstname | lastname | email | | teacher1 | Teacher | 1 | teacher1@example.com | @@ -24,10 +23,10 @@ Feature: In a lesson activity, teacher can add embedded images in questions answ And the following "blocks" exist: | blockname | contextlevel | reference | pagetypepattern | defaultregion | | private_files | System | 1 | my-index | side-post | + And the following "user private files" exist: + | user | filepath | filename | + | teacher1 | mod/lesson/tests/fixtures/moodle_logo.jpg | moodle_logo.jpg | And I log in as "teacher1" - And I follow "Manage private files" - And I upload "mod/lesson/tests/fixtures/moodle_logo.jpg" file to "Files" filemanager - And I click on "Save changes" "button" When I am on the "Test lesson name" "lesson activity" page And I follow "Add a question page" And I set the field "Select a question type" to "Multichoice" @@ -47,9 +46,7 @@ Feature: In a lesson activity, teacher can add embedded images in questions answ | id_response_editor_2 | Incorrect answer | | id_jumpto_2 | This page | | id_score_2 | 0 | - # Atto needs focus to add image, select empty p tag to do so. - And I select the text in the "id_answer_editor_2" Atto editor - And I click on "Insert or edit image" "button" in the "//*[@data-fieldtype='editor']/*[descendant::*[@id='id_answer_editor_2']]" "xpath_element" + And I click on "Image" "button" in the "//*[@data-fieldtype='editor']/*[descendant::*[@id='id_answer_editor_2']]" "xpath_element" And I click on "Browse repositories..." "button" And I click on "Private files" "link" in the ".fp-repo-area" "css_element" And I click on "moodle_logo.jpg" "link" @@ -69,9 +66,7 @@ Feature: In a lesson activity, teacher can add embedded images in questions answ | id_answer_editor_1 | False | | id_response_editor_1 | Wrong | | id_jumpto_1 | This page | - # Atto needs focus to add image, select empty p tag to do so. - And I select the text in the "id_response_editor_0" Atto editor - And I click on "Insert or edit image" "button" in the "//*[@data-fieldtype='editor']/*[descendant::*[@id='id_response_editor_0']]" "xpath_element" + And I click on "Image" "button" in the "//*[@data-fieldtype='editor']/*[descendant::*[@id='id_response_editor_0']]" "xpath_element" And I click on "Browse repositories..." "button" And I click on "Private files" "link" in the ".fp-repo-area" "css_element" And I click on "moodle_logo.jpg" "link" diff --git a/mod/quiz/tests/behat/manually_mark_question.feature b/mod/quiz/tests/behat/manually_mark_question.feature index d8bc6e80ae6..aab1436f20c 100644 --- a/mod/quiz/tests/behat/manually_mark_question.feature +++ b/mod/quiz/tests/behat/manually_mark_question.feature @@ -31,6 +31,9 @@ Feature: Teachers can override the grade for any question And the following "blocks" exist: | blockname | contextlevel | reference | pagetypepattern | defaultregion | | private_files | System | 1 | my-index | side-post | + And the following "user private files" exist: + | user | filepath | filename | + | teacher1 | mod/quiz/tests/fixtures/moodle_logo.jpg | moodle_logo.jpg | And I am on the "Quiz 1" "mod_quiz > View" page logged in as "student1" And I press "Attempt quiz" And I follow "Finish attempt ..." @@ -59,9 +62,6 @@ Feature: Teachers can override the grade for any question @javascript @_switch_window @_file_upload @_bug_phantomjs @editor_tiny Scenario: Comment on a response to an essay question attempt. When I log in as "teacher1" - And I follow "Manage private files" - And I upload "mod/quiz/tests/fixtures/moodle_logo.jpg" file to "Files" filemanager - And I click on "Save changes" "button" And I am on the "Quiz 1 > student1 > Attempt 1" "mod_quiz > Attempt review" page And I follow "Make comment or override mark" And I switch to "commentquestion" window diff --git a/mod/workshop/tests/behat/embedded_images.feature b/mod/workshop/tests/behat/embedded_images.feature index 43aa46ee460..031b0553b17 100644 --- a/mod/workshop/tests/behat/embedded_images.feature +++ b/mod/workshop/tests/behat/embedded_images.feature @@ -1,15 +1,17 @@ -@mod @mod_workshop @javascript @_file_upload +@mod @mod_workshop @javascript Feature: Teachers can embed images into instructions and conclusion fields In order to display images as a part of instructions or conclusions in the workshop As a teacher I need to be able to embed images into the fields and they should display correctly - # This scenario has Atto-specific steps. See MDL-75913 for further details. - @editor_atto + @editor_tiny Scenario: Embedding the image into the instructions and conclusions fields Given the following "users" exist: | username | firstname | lastname | email | | teacher1 | Teacher | One | teacher1@example.com | + And the following "user private files" exist: + | user | filepath | filename | + | teacher1 | mod/workshop/tests/fixtures/moodlelogo.png | moodlelogo.png | And the following "courses" exist: | fullname | shortname | | Course 1 | C1 | @@ -29,17 +31,11 @@ Feature: Teachers can embed images into instructions and conclusion fields | Conclusion format | 1 | And I press "Save and display" And I log out - And I log in as "teacher1" - # Upload an image into the private files. - And I follow "Manage private files" - And I upload "mod/workshop/tests/fixtures/moodlelogo.png" file to "Files" filemanager - And I click on "Save changes" "button" + When I log in as "teacher1" # Edit the workshop. - When I am on the "Workshop with embedded images" "workshop activity editing" page + And I am on the "Workshop with embedded images" "workshop activity editing" page And I expand all fieldsets - And I set the field "Instructions for submission" to "

Image test

" - And I select the text in the "Instructions for submission" Atto editor - And I click on "Insert or edit image" "button" in the "//*[@data-fieldtype='editor']/*[descendant::*[@id='id_instructauthorseditor']]" "xpath_element" + And I click on "Image" "button" in the "Instructions for submission" "form_row" And I click on "Browse repositories..." "button" And I click on "Private files" "link" in the ".fp-repo-area" "css_element" And I click on "moodlelogo.png" "link" @@ -50,9 +46,7 @@ Feature: Teachers can embed images into instructions and conclusion fields # Embed the image into Instructions for assessment. And I navigate to "Settings" in current page administration And I expand all fieldsets - And I set the field "Instructions for assessment" to "

Image test

" - And I select the text in the "Instructions for assessment" Atto editor - And I click on "Insert or edit image" "button" in the "//*[@data-fieldtype='editor']/*[descendant::*[@id='id_instructreviewerseditor']]" "xpath_element" + And I click on "Image" "button" in the "Instructions for assessment" "form_row" And I click on "Browse repositories..." "button" And I click on "Private files" "link" in the ".fp-repo-area" "css_element" And I click on "moodlelogo.png" "link" @@ -63,9 +57,7 @@ Feature: Teachers can embed images into instructions and conclusion fields # Embed the image into Conclusion. And I navigate to "Settings" in current page administration And I expand all fieldsets - And I set the field "Conclusion" to "

Image test

" - And I select the text in the "Conclusion" Atto editor - And I click on "Insert or edit image" "button" in the "//*[@data-fieldtype='editor']/*[descendant::*[@id='id_conclusioneditor']]" "xpath_element" + And I click on "Image" "button" in the "Conclusion" "form_row" And I click on "Browse repositories..." "button" And I click on "Private files" "link" in the ".fp-repo-area" "css_element" And I click on "moodlelogo.png" "link" @@ -77,6 +69,6 @@ Feature: Teachers can embed images into instructions and conclusion fields And I change phase in workshop "Workshop with embedded images" to "Submission phase" Then "//*[contains(@class, 'instructions')]//img[contains(@src, 'pluginfile.php') and contains(@src, '/mod_workshop/instructauthors/moodlelogo.png') and @alt='How to submit']" "xpath_element" should exist And I change phase in workshop "Workshop with embedded images" to "Assessment phase" - And "//*[contains(@class, 'instructions')]//img[contains(@src, 'pluginfile.php') and contains(@src, '/mod_workshop/instructreviewers/moodlelogo.png') and @alt='How to assess']" "xpath_element" should exist + Then "//*[contains(@class, 'instructions')]//img[contains(@src, 'pluginfile.php') and contains(@src, '/mod_workshop/instructreviewers/moodlelogo.png') and @alt='How to assess']" "xpath_element" should exist And I change phase in workshop "Workshop with embedded images" to "Closed" - And "//*[contains(@class, 'conclusion')]//img[contains(@src, 'pluginfile.php') and contains(@src, '/mod_workshop/conclusion/moodlelogo.png') and @alt='Well done']" "xpath_element" should exist + Then "//*[contains(@class, 'conclusion')]//img[contains(@src, 'pluginfile.php') and contains(@src, '/mod_workshop/conclusion/moodlelogo.png') and @alt='Well done']" "xpath_element" should exist diff --git a/repository/contentbank/tests/behat/file_update.feature b/repository/contentbank/tests/behat/file_update.feature index 4a4a38f0077..89692c34483 100644 --- a/repository/contentbank/tests/behat/file_update.feature +++ b/repository/contentbank/tests/behat/file_update.feature @@ -14,25 +14,21 @@ Feature: Updating a file in the content bank after using in a course And the following "contentbank content" exist: | contextlevel | reference | contenttype | user | contentname | filepath | | Course | C1 | contenttype_h5p | admin | package.h5p | /h5p/tests/fixtures/guess-the-answer.h5p | - And the following "activities" exist: - | activity | name | intro | introformat | course | content | contentformat | idnumber | - | page | PageName1 | PageDesc1 | 1 | C1 | H5Ptest | 1 | 1 | - # This scenario has Atto-specific steps. See MDL-75913 for further details. - @editor_atto Scenario: Referenced files is the default option and updates alias as well - Given 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" + When I log in as "admin" + And I am on "Course1" course homepage with editing mode on + And I add a "H5P" to section "1" + And I set the following fields to these values: + | Name | guessFile | + And I click on "Add..." "link" in the ".fp-toolbar" "css_element" And I select "Content bank" repository in file picker And I click on "package.h5p" "file" in repository content area 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 switch to "h5p-player" class iframe And I switch to "h5p-iframe" class iframe - And I switch to "h5p-iframe" class iframe - And I should see "Press here to reveal answer" + Then I should see "Press here to reveal answer" And I switch to the main frame # Now edit the content in the content bank. When I am on "Course1" course homepage with editing mode on @@ -51,31 +47,31 @@ Feature: Updating a file in the content bank after using in a course And I click on "Save" "button" And I switch to "h5p-player" class iframe And I switch to "h5p-iframe" class iframe - And I should see "This is a new text" + Then I should see "This is a new text" And I switch to the main frame # Check the course page is updated. - When I am on the PageName1 "Page activity" page - And I switch to "h5p-iframe" class iframe + When I am on "Course1" course homepage with editing mode on + And I click on "guessFile" "link" in the "page-content" "region" + And I switch to "h5p-player" class iframe And I switch to "h5p-iframe" class iframe Then I should see "This is a new text" And I switch to the main frame - # This scenario has Atto-specific steps. See MDL-75913 for further details. - @editor_atto Scenario: Copied files should not be updated if the original is edited - Given 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" + When I log in as "admin" + And I am on "Course1" course homepage with editing mode on + And I add a "H5P" to section "1" + And I set the following fields to these values: + | Name | guessFile | + And I click on "Add..." "link" in the ".fp-toolbar" "css_element" And I select "Content bank" repository in file picker And I click on "package.h5p" "file" in repository content area And I click on "Make a copy of the file" "radio" 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 switch to "h5p-player" class iframe And I switch to "h5p-iframe" class iframe - And I switch to "h5p-iframe" class iframe - And I should see "Press here to reveal answer" + Then I should see "Press here to reveal answer" And I switch to the main frame # Now edit the content in the content bank. When I am on "Course1" course homepage with editing mode on @@ -94,11 +90,12 @@ Feature: Updating a file in the content bank after using in a course And I click on "Save" "button" And I switch to "h5p-player" class iframe And I switch to "h5p-iframe" class iframe - And I should see "This is a new text" + Then I should see "This is a new text" And I switch to the main frame # Check the course page is not updated. - When I am on the PageName1 "Page activity" page - And I switch to "h5p-iframe" class iframe + When I am on "Course1" course homepage with editing mode on + And I click on "guessFile" "link" in the "page-content" "region" + And I switch to "h5p-player" class iframe And I switch to "h5p-iframe" class iframe Then I should see "Press here to reveal answer" And I switch to the main frame diff --git a/repository/contentbank/tests/behat/select_content.feature b/repository/contentbank/tests/behat/select_content.feature index 0b4920851fc..f3278915577 100644 --- a/repository/contentbank/tests/behat/select_content.feature +++ b/repository/contentbank/tests/behat/select_content.feature @@ -128,21 +128,18 @@ Feature: Select content bank files using the content bank files repository Then I should see "1" elements in "Files" filemanager And I should see "filltheblanks.h5p" in the ".fp-content .fp-file" "css_element" - # This scenario has Atto-specific steps. See MDL-75913 for further details. - @editor_atto Scenario: Non-editing teacher can not see the content bank repository Given I am on the Forum "Forum activity" page logged in as teacher2 And I click on "Add discussion topic" "link" - And I click on "Link" "button" - When I click on "Browse repositories..." "button" + And I click on "Advanced" "button" + When I click on "Add..." "button" Then I should not see "Content bank" in the ".fp-repo-area" "css_element" - @editor_atto Scenario: Student can not see the content bank repository Given I am on the Forum "Forum activity" page logged in as student And I click on "Add discussion topic" "link" - And I click on "Link" "button" - When I click on "Browse repositories..." "button" + And I click on "Advanced" "button" + When I click on "Add..." "button" Then I should not see "Content bank" in the ".fp-repo-area" "css_element" Scenario: Both content name and file name are shown when a content is selected