diff --git a/.travis.yml b/.travis.yml index 7166a133dff7ba80658b69ac70c31785988874fe..3707df32e0448acc8fc7a9c4b3b57421c8e79187 100644 --- a/.travis.yml +++ b/.travis.yml @@ -51,4 +51,4 @@ script: - moodle-plugin-ci grunt - moodle-plugin-ci phpdoc - moodle-plugin-ci phpunit - - moodle-plugin-ci behat --dump + - moodle-plugin-ci behat --dump --suite=boost_campus diff --git a/CHANGES.md b/CHANGES.md index f28f204c0c39a712ff34d8cd591a54ad824a8953..069f2d2701a2d94fba0125ae74f374401fb9cf86 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -6,6 +6,8 @@ Changes ### Unreleased +* 2019-12-20 - Added Behat tests. + PLEASE NOTE: For all scenarios to pass, the Moodle version 3.7.3+ (Build: 20191212) is needed. * 2019-12-17 - Fixed bug for the selection of block regions when 2 block columns in footer are enabled. * 2019-11-29 - Moved the variable output.standard_end_of_body_html from footer.mustache to solve Javascript issues with behat tests. diff --git a/tests/behat/theme_boost_campus_additional_layout_settings.feature b/tests/behat/theme_boost_campus_additional_layout_settings.feature new file mode 100644 index 0000000000000000000000000000000000000000..e4e75fc6033827a097366dd5d8985f4713031675 --- /dev/null +++ b/tests/behat/theme_boost_campus_additional_layout_settings.feature @@ -0,0 +1,82 @@ +@theme @theme_boost_campus @theme_boost_campus_additional_layout_settings +Feature: Configuring the theme_boost_campus plugin for the "Additional Layout Settings" tab + In order to use the features + As admin + I need to be able to configure the theme Boost Campus plugin + + Background: + Given the following "users" exist: + | username | + | teacher1 | + And the following "courses" exist: + | fullname | shortname | + | Course 1 | C1 | + And the following "course enrolments" exist: + | user | course | role | + | teacher1 | C1 | editingteacher | + # There is a nasty bug with Behat-testing this theme that the footer is not displayed until the settings + # of the theme are stored manually. It seems not to be sufficient to just rely on the default settings being + # stored during the installation of the theme. Until we find the root of this bug, we circumvent it by setting the + # brand color manually and within this process making sure that all settings are really stored to the database. + And I log in as "admin" + And I navigate to "Appearance > Boost Campus" in site administration + And I click on "General settings" "link" + And I set the field "id_s_theme_boost_campus_brandcolor" to "#7a99ac" + And I press "Save changes" + And I log out + + @javascript @_file_upload + Scenario: Add "Image area items" + When I log in as "admin" + And I navigate to "Appearance > Boost Campus" in site administration + And I click on "Additional Layout Settings" "link" + And I upload "theme/boost_campus/tests/fixtures/moodle_logo.jpg" file to "Image area items" filemanager + And I press "Save changes" + Then ".imagearea img" "css_element" should exist + + # Dependent on setting "Image area items" + @javascript @_file_upload + Scenario: Add "Image area item links" + When I log in as "admin" + And I navigate to "Appearance > Boost Campus" in site administration + And I click on "Additional Layout Settings" "link" + And I upload "theme/boost_campus/tests/fixtures/moodle_logo.jpg" file to "Image area items" filemanager + And I set the field "id_s_theme_boost_campus_imageareaitemslink" to "moodle_logo.jpg|http://moodle.org" + And I press "Save changes" + Then ".imagearea img" "css_element" should exist + And "//div[contains(concat(' ',normalize-space(@class),' '),' imagearea ')]//a[contains(@href, 'http://moodle.org')]" "xpath_element" should exist + + # Dependent on setting "Image area items" + # This is not testable with behat. + # Scenario: Set "Image area items maximal height" + + Scenario: Use Footnote setting + Given the following config values are set as admin: + | config | value | plugin | + | footnote | <a href="/login/logout.php">Logout Footnote</a> | theme_boost_campus | + When I log in as "teacher1" + Then ".footnote" "css_element" should exist + Then I should see "Logout Footnote" in the ".footnote" "css_element" + And I click on "Logout Footnote" "link" + Then I should see "Do you really want to log out?" + + Scenario: Enable "Dashboard menu item on top" + Given the following config values are set as admin: + | config | value | plugin | + | defaulthomepageontop | yes | theme_boost_campus | + When I log in as "teacher1" + Then "//div[@id='nav-drawer']//span[contains(text(),'Dashboard')]" "xpath_element" should appear before "//div[@id='nav-drawer']//span[contains(text(),'Site home')]" "xpath_element" + When I am on "Course 1" course homepage + Then "//div[@id='nav-drawer']//span[contains(text(),'Dashboard')]" "xpath_element" should appear before "//div[@id='nav-drawer']//span[contains(text(),'C1')]" "xpath_element" + + Scenario: Counter check: Disable "Dashboard menu item on top" + Given the following config values are set as admin: + | config | value | plugin | + | defaulthomepageontop | no | theme_boost_campus | + When I log in as "teacher1" + Then "//div[@id='nav-drawer']//span[contains(text(),'Dashboard')]" "xpath_element" should appear before "//div[@id='nav-drawer']//span[contains(text(),'Site home')]" "xpath_element" + When I am on "Course 1" course homepage + Then "//div[@id='nav-drawer']//span[contains(text(),'Dashboard')]" "xpath_element" should appear before "//div[@id='nav-drawer']//span[contains(text(),'Site home')]" "xpath_element" + + # This is not testable with Behat + # Scenario: Enable "Nav drawer full width on small screens" diff --git a/tests/behat/theme_boost_campus_advanced_settings.feature b/tests/behat/theme_boost_campus_advanced_settings.feature new file mode 100644 index 0000000000000000000000000000000000000000..6df8b0d48369629d5ac42c7eebbc3a1b72bee296 --- /dev/null +++ b/tests/behat/theme_boost_campus_advanced_settings.feature @@ -0,0 +1,63 @@ +@theme @theme_boost_campus @theme_boost_campus_advanced_settings +Feature: Configuring the theme_boost_campus plugin for the "Advanced settings" tab + In order to use the features + As admin + I need to be able to configure the theme Boost Campus plugin + + Background: + Given the following "users" exist: + | username | + | student1 | + | teacher1 | + And the following "courses" exist: + | fullname | shortname | + | Course 1 | C1 | + And the following "course enrolments" exist: + | user | course | role | + | teacher1 | C1 | editingteacher | + | student1 | C1 | student | + # There is a nasty bug with Behat-testing this theme that the footer is not displayed until the settings + # of the theme are stored manually. It seems not to be sufficient to just rely on the default settings being + # stored during the installation of the theme. Until we find the root of this bug, we circumvent it by setting the + # brand color manually and within this process making sure that all settings are really stored to the database. + And I log in as "admin" + And I navigate to "Appearance > Boost Campus" in site administration + And I click on "General settings" "link" + And I set the field "id_s_theme_boost_campus_brandcolor" to "#7a99ac" + And I press "Save changes" + And I log out + + # This is derivated from theme Boost and should be covered there with tests + # Scenario: Add "Raw initial SCSS" + + # This is derivated from theme Boost and should be covered there with tests + # Scenario: Add "Raw SCSS" + + # This is not testable with Behat + # Scenario: "Catch keyboard commands" + + Scenario: Set "Position of "Add a block" widget" to "At the bottom of the default block region" + Given the following config values are set as admin: + | config | value | plugin | + | addablockposition | positionblockregion | theme_boost_campus | + And I log in as "admin" + And I navigate to "Development > Purge caches" in site administration + And I press "Purge all caches" + And I log out + When I log in as "teacher1" + And I am on "Course 1" course homepage with editing mode on + Then I should see "Add a block" in the "#block-region-side-pre" "css_element" + And I should not see "Add a block" in the "#nav-drawer" "css_element" + + Scenario: Set "Position of "Add a block" widget" to "At the bottom of the nav drawer" + Given the following config values are set as admin: + | config | value | plugin | + | addablockposition | positionnavdrawer | theme_boost_campus | + And I log in as "admin" + And I navigate to "Development > Purge caches" in site administration + And I press "Purge all caches" + And I log out + When I log in as "teacher1" + And I am on "Course 1" course homepage with editing mode on + Then I should see "Add a block" in the "#nav-drawer" "css_element" + And "#block-region-side-pre" "css_element" should not exist diff --git a/tests/behat/theme_boost_campus_course_layout_settings.feature b/tests/behat/theme_boost_campus_course_layout_settings.feature new file mode 100644 index 0000000000000000000000000000000000000000..d293b4a22969e9ac85f828caf38dfb892ed23127 --- /dev/null +++ b/tests/behat/theme_boost_campus_course_layout_settings.feature @@ -0,0 +1,231 @@ +@theme @theme_boost_campus @theme_boost_campus_course_layout_settings +Feature: Configuring the theme_boost_campus plugin for the "Course Layout settings" tab + In order to use the features + As admin + I need to be able to configure the theme Boost Campus plugin + + Background: + Given the following "users" exist: + | username | + | student1 | + | teacher1 | + And the following "courses" exist: + | fullname | shortname | + | Course 1 | C1 | + And the following "course enrolments" exist: + | user | course | role | + | teacher1 | C1 | editingteacher | + | student1 | C1 | student | + # There is a nasty bug with Behat-testing this theme that the footer is not displayed until the settings + # of the theme are stored manually. It seems not to be sufficient to just rely on the default settings being + # stored during the installation of the theme. Until we find the root of this bug, we circumvent it by setting the + # brand color manually and within this process making sure that all settings are really stored to the database. + And I log in as "admin" + And I navigate to "Appearance > Boost Campus" in site administration + And I click on "General settings" "link" + And I set the field "id_s_theme_boost_campus_brandcolor" to "#7a99ac" + And I press "Save changes" + And I log out + + Scenario: Enable "Section 0: Title" + Given the following config values are set as admin: + | config | value | plugin | + | section0title | yes | theme_boost_campus | + When I log in as "teacher1" + And I am on "Course 1" course homepage with editing mode on + Then I should see "General" in the "li#section-0" "css_element" + When I edit the section "0" and I fill the form with: + | Custom | 1 | + | New value for Section name | This is the general section | + Then I should see "This is the general section" in the "li#section-0" "css_element" + + @javascript + Scenario: Counter check: Disable "Section 0: Title" + Given the following config values are set as admin: + | config | value | plugin | + | section0title | no | theme_boost_campus | + When I log in as "teacher1" + And I am on "Course 1" course homepage with editing mode on + Then I should not see "General" in the "li#section-0" "css_element" + When I edit the section "0" and I fill the form with: + | Custom | 1 | + | New value for Section name | This is the general section | + Then I should see "This is the general section" in the "li#section-0" "css_element" + + Scenario: Enable "Course edit button" + Given the following config values are set as admin: + | config | value | plugin | + | courseeditbutton | 1 | theme_boost_campus | + When I log in as "teacher1" + And I am on "Course 1" course homepage + Then I should see "Turn editing on" in the "#page-header .singlebutton" "css_element" + When I click on "Turn editing on" "button" + Then I should see "Turn editing off" in the "#page-header .singlebutton" "css_element" + And I should see "Add an activity or resource" + + Scenario: Enable "Position of switch role information" + Given the following config values are set as admin: + | config | value | plugin | + | showswitchedroleincourse | yes | theme_boost_campus | + When I log in as "teacher1" + And I am on "Course 1" course homepage + And I follow "Switch role to..." in the user menu + And I click on "Student" "button" + Then I should see "You are viewing this course currently with the role:" in the ".switched-role-infobox" "css_element" + When I click on "Return to my normal role" "link" in the ".switched-role-infobox" "css_element" + Then I should not see "You are viewing this course currently with the role:" + And ".switched-role-infobox" "css_element" should not exist + + Scenario: Enable "Show hint in hidden courses" + Given the following config values are set as admin: + | config | value | plugin | + | showhintcoursehidden | yes | theme_boost_campus | + When I log in as "teacher1" + And I am on "Course 1" course homepage + When I navigate to "Edit settings" in current page administration + And I set the following fields to these values: + | Course visibility | Hide | + And I click on "Save and display" "button" + Then I should see "This course is currently hidden. Only enrolled teachers can access this course when hidden." in the ".course-hidden-infobox" "css_element" + When I am on "Course 1" course homepage + When I navigate to "Edit settings" in current page administration + And I set the following fields to these values: + | Course visibility | Show | + And I click on "Save and display" "button" + Then I should not see "This course is currently hidden. Only enrolled teachers can access this course when hidden." + And ".course-hidden-infobox" "css_element" should not exist + + Scenario: Enable "Show hint for guest access" + Given the following config values are set as admin: + | config | value | plugin | + | showhintcourseguestaccess | yes | theme_boost_campus | + And the following "users" exist: + | username | + | student2 | + When I log in as "teacher1" + And I am on "Course 1" course homepage + And I navigate to "Users > Enrolment methods" in current page administration + And I click on "Edit" "link" in the "Guest access" "table_row" + And I set the following fields to these values: + | Allow guest access | Yes | + And I press "Save changes" + And I log out + When I log in as "student2" + And I am on "Course 1" course homepage + Then I should see "You are currently viewing this course as Guest." in the ".course-guestaccess-infobox" "css_element" + And I log out + And I log in as "teacher1" + And I am on "Course 1" course homepage + And I navigate to "Users > Enrolment methods" in current page administration + And I click on "Enable" "link" in the "Self enrolment (Student)" "table_row" + And I log out + When I log in as "student2" + And I am on "Course 1" course homepage + Then I should see "To have full access to the course, you can self enrol into this course." in the ".course-guestaccess-infobox" "css_element" + And I click on "self enrol into this course" "link" in the ".course-guestaccess-infobox" "css_element" + And I click on "Enrol me" "button" + Then I should not see "You are currently viewing this course as Guest." + And ".course-guestaccess-infobox" "css_element" should not exist + And I log out + When I log in as "teacher1" + And I am on "Course 1" course homepage + And I navigate to "Users > Enrolment methods" in current page administration + And I click on "Edit" "link" in the "Guest access" "table_row" + And I set the following fields to these values: + | Allow guest access | No | + And I press "Save changes" + And I log out + When I log in as "student2" + And I am on "Course 1" course homepage + Then I should not see "You are currently viewing this course as Guest." + And ".course-guestaccess-infobox" "css_element" should not exist + + @javascript + Scenario: Enable "In course settings menu" + Given the following config values are set as admin: + | config | value | plugin | + | showsettingsincourse | yes | theme_boost_campus | + When I log in as "teacher1" + And I am on "Course 1" course homepage + Then "#boost-campus-course-settings" "css_element" should not be visible + When I click on ".context-header-settings-menu [role=button]" "css_element" + Then "#boost-campus-course-settings" "css_element" should be visible + And I should see "Course administration" in the "#boost-campus-course-settings" "css_element" + And I should see "Backup" in the "#course-settings-courseadmin" "css_element" + And I should see "Users" in the "#boost-campus-course-settings" "css_element" + When I click on "Users" "link" + Then "#course-settings-users" "css_element" should be visible + And I should see "Enrolment methods" in the "#course-settings-users" "css_element" + And I should see "Reports" in the "#boost-campus-course-settings" "css_element" + When I click on "Reports" "link" + Then "#course-settings-coursereports" "css_element" should be visible + And I should see "Activity report" in the "#course-settings-coursereports" "css_element" + And I should see "Badges" in the "#boost-campus-course-settings" "css_element" + When I click on "Badges" "link" + Then "#course-settings-coursebadges" "css_element" should be visible + And I should see "Manage badges" in the "#course-settings-coursebadges" "css_element" + And I should see "Question bank" in the "#boost-campus-course-settings" "css_element" + When I click on "Question bank" "link" + Then "#course-settings-questionbank" "css_element" should be visible + And I should see "Questions" in the "#course-settings-questionbank" "css_element" + + # Dependent on setting showsettingsincourse + @javascript + Scenario: Set "Switch role to..." location(s) to "Just in the user menu" + Given the following config values are set as admin: + | config | value | plugin | + | showsettingsincourse | yes | theme_boost_campus | + | incoursesettingsswitchtoroleposition | no | theme_boost_campus | + # Purging caches is needed because the theme's SCSS must be rewritten based on the new settings + And I log in as "admin" + And I navigate to "Development > Purge caches" in site administration + And I press "Purge all caches" + And I log out + When I log in as "teacher1" + And I am on "Course 1" course homepage + And I click on ".context-header-settings-menu [role=button]" "css_element" + Then I should not see "Switch role to" in the "#boost-campus-course-settings" "css_element" + When I click on ".usermenu" "css_element" + Then I should see "Switch role to..." in the ".usermenu" "css_element" + + # Dependent on setting showsettingsincourse + @javascript + Scenario: Set "Switch role to..." location(s) to "Just in the course settings" + Given the following config values are set as admin: + | config | value | plugin | + | showsettingsincourse | yes | theme_boost_campus | + | incoursesettingsswitchtoroleposition | yes | theme_boost_campus | + # Purging caches is needed because the theme's SCSS must be rewritten based on the new settings + And I log in as "admin" + And I navigate to "Development > Purge caches" in site administration + And I press "Purge all caches" + And I log out + When I log in as "teacher1" + And I am on "Course 1" course homepage + And I click on ".context-header-settings-menu [role=button]" "css_element" + Then I should see "Switch role to" in the "#boost-campus-course-settings" "css_element" + When I click on "Switch role to" "link" in the "#boost-campus-course-settings" "css_element" + Then I should see "Student" in the "#course-settings-switchroletotab" "css_element" + When I click on ".usermenu" "css_element" + Then I should not see "Switch role to..." in the ".usermenu" "css_element" + + # Dependent on setting showsettingsincourse + @javascript + Scenario: Set "Switch role to..." location(s) to "In both places: in the user menu and in the course settings" + Given the following config values are set as admin: + | config | value | plugin | + | showsettingsincourse | yes | theme_boost_campus | + | incoursesettingsswitchtoroleposition | both | theme_boost_campus | + # Purging caches is needed because the theme's SCSS must be rewritten based on the new settings + And I log in as "admin" + And I navigate to "Development > Purge caches" in site administration + And I press "Purge all caches" + And I log out + When I log in as "teacher1" + And I am on "Course 1" course homepage + And I click on ".context-header-settings-menu [role=button]" "css_element" + Then I should see "Switch role to" in the "#boost-campus-course-settings" "css_element" + When I click on "Switch role to" "link" in the "#boost-campus-course-settings" "css_element" + Then I should see "Student" in the "#course-settings-switchroletotab" "css_element" + When I click on ".usermenu" "css_element" + Then I should see "Switch role to..." in the ".usermenu" "css_element" diff --git a/tests/behat/theme_boost_campus_design_settings.feature b/tests/behat/theme_boost_campus_design_settings.feature new file mode 100644 index 0000000000000000000000000000000000000000..c55cb8dc5457c609baaf6833995982cbdf5eaebb --- /dev/null +++ b/tests/behat/theme_boost_campus_design_settings.feature @@ -0,0 +1,129 @@ +@theme @theme_boost_campus @theme_boost_campus_design_settings +Feature: Configuring the theme_boost_campus plugin for the "Design Settings" tab + In order to use the features + As admin + I need to be able to configure the theme Boost Campus plugin + + Background: + Given the following "users" exist: + | username | + | teacher1 | + And the following "courses" exist: + | fullname | shortname | + | Course 1 | C1 | + And the following "course enrolments" exist: + | user | course | role | + | teacher1 | C1 | editingteacher | + # There is a nasty bug with Behat-testing this theme that the footer is not displayed until the settings + # of the theme are stored manually. It seems not to be sufficient to just rely on the default settings being + # stored during the installation of the theme. Until we find the root of this bug, we circumvent it by setting the + # brand color manually and within this process making sure that all settings are really stored to the database. + And I log in as "admin" + And I navigate to "Appearance > Boost Campus" in site administration + And I click on "General settings" "link" + And I set the field "id_s_theme_boost_campus_brandcolor" to "#7a99ac" + And I press "Save changes" + And I log out + + @javascript @_file_upload + # The setting is designed to display multiple login background images in a random order. + # The randomness is the reason why we cannot test it here with more than one image. + Scenario: Use Login page background images + When I log in as "admin" + And I navigate to "Appearance > Boost Campus" in site administration + And I click on "Design Settings" "link" + And I upload "theme/boost_campus/tests/fixtures/login_bg.jpg" file to "Login page background images" filemanager + And I press "Save changes" + And I log out + And I click on "Log in" "link" + Then the "class" attribute of "body" "css_element" should contain "loginbackgroundimage1" + + # Dependent on setting "Use Login page background images" + @javascript @_file_upload + Scenario: Display text for login background images + When I log in as "admin" + And I navigate to "Appearance > Boost Campus" in site administration + And I click on "Design Settings" "link" + And I upload "theme/boost_campus/tests/fixtures/login_bg.jpg" file to "Login page background images" filemanager + And I set the field "id_s_theme_boost_campus_loginbackgroundimagetext" to "login_bg.jpg|Copyright by SplitShire on pexels.com" + And I press "Save changes" + And I log out + And I click on "Log in" "link" + Then I should see "Copyright by SplitShire on pexels.com" in the "#loginbackgroundimagetext" "css_element" + + # This is not testable with Behat + # Scenario: Enable "Login form" + + # This is not testable with Behat + # Scenario: Add "Font files" + + # This is not testable with Behat + # Scenario: Enable "Block icon" + + # This is not testable with Behat + # Scenario: Change "Block column width on Dashboard" + + # This is not testable with Behat + # Scenario: Change "Block column width on all other pages" + + Scenario: Enable "Dark navbar" + Given the following config values are set as admin: + | config | value | plugin | + | darknavbar | yes | theme_boost_campus | + When I log in as "teacher1" + Then the "class" attribute of "nav" "css_element" should contain "bg-dark" + + Scenario: Counter check: Disable "Dark navbar" + Given the following config values are set as admin: + | config | value | plugin | + | darknavbar | no | theme_boost_campus | + When I log in as "teacher1" + Then the "class" attribute of "nav" "css_element" should not contain "bg-dark" + + @javascript + Scenario: Enable "Show help texts in a modal dialogue" + # This scenario does not work with the settings short notation + # Given the following config values are set as admin: + # | config | value | plugin | + # | helptextmodal | 1 | theme_boost_campus | + When I log in as "admin" + And I navigate to "Appearance > Boost Campus" in site administration + And I click on "Design Settings" "link" + And I set the field "s_theme_boost_campus_helptextmodal" to "1" + And I press "Save changes" + And I log out + And I log in as "teacher1" + And I am on "Course 1" course homepage with editing mode on + And I add a "Assignment" to section "1" and I fill the form with: + | Assignment name | Test assign | + | Description | Test | + And I open "Test assign" actions menu + And I click on "Edit settings" "link" in the "Test assign" activity + And I click on "Help with Additional files" "icon" + Then ".modal-dialog" "css_element" should exist + And I should see "Help with Additional files" in the "#assign-introattachments-modal-dialogue .modal-title" "css_element" + And I should see "Additional files for use in the assignment" in the "#assign-introattachments-modal-dialogue .modal-body" "css_element" + And I should see "Close" in the "#assign-introattachments-modal-dialogue .modal-footer" "css_element" + And I click on "//div[@id='assign-introattachments-modal-dialogue']//div[@class='modal-footer']//button" "xpath_element" + Then ".modal-dialog" "css_element" should not be visible + + # This is not testable with Behat # + # Scenario: Change breakpoint + + @javascript @_file_upload + Scenario: Add additional resources + When I log in as "admin" + And I navigate to "Appearance > Boost Campus" in site administration + And I click on "Design Settings" "link" + And I upload "theme/boost_campus/tests/fixtures/login_bg.jpg" file to "Add additional resources" filemanager + # Moodle core step "And I add the "HTML" block relies on the fact that the widget is in the nav drawer + And I click on "Advanced settings" "link" + And I set the field "id_s_theme_boost_campus_addablockposition" to "positionnavdrawer" + And I press "Save changes" + And I follow "Dashboard" in the user menu + When I press "Customise this page" + And I add the "HTML" block + And I configure the "(new HTML block)" block + And I set the field "Content" to "<p><img src='/pluginfile.php/1/theme_boost_campus/additionalresources/0/moodle_logo.jpg'><br></p>" + And I press "Save changes" + Then "//section[contains(concat(' ',normalize-space(@class),' '),' block_html ')]//img[contains(@src, 'moodle_logo.jpg')]" "xpath_element" should exist diff --git a/tests/behat/theme_boost_campus_footer_layout_settings.feature b/tests/behat/theme_boost_campus_footer_layout_settings.feature new file mode 100644 index 0000000000000000000000000000000000000000..cecaa9ae082a7f3e08d7b626976e9fc8b972ccbb --- /dev/null +++ b/tests/behat/theme_boost_campus_footer_layout_settings.feature @@ -0,0 +1,296 @@ +@theme @theme_boost_campus @theme_boost_campus_footer_layout_settings +Feature: Configuring the theme_boost_campus plugin for the "Footer Layout Settings" tab + In order to use the features + As admin + I need to be able to configure the theme Boost Campus plugin + + Background: + Given the following "users" exist: + | username | + | teacher1 | + And the following "courses" exist: + | fullname | shortname | + | Course 1 | C1 | + And the following "course enrolments" exist: + | user | course | role | + | teacher1 | C1 | editingteacher | + # There is a nasty bug with Behat-testing this theme that the footer is not displayed until the settings + # of the theme are stored manually. It seems not to be sufficient to just rely on the default settings being + # stored during the installation of the theme. Until we find the root of this bug, we circumvent it by setting the + # brand color manually and within this process making sure that all settings are really stored to the database. + And I log in as "admin" + And I navigate to "Appearance > Boost Campus" in site administration + And I click on "General settings" "link" + And I set the field "id_s_theme_boost_campus_brandcolor" to "#7a99ac" + And I press "Save changes" + And I log out + + # This scenario needs full browser support only for this Behat test to pass, otherwise javascript would not be needed. + @javascript + Scenario: Setting "Footer blocks" to "One block columns in footer" + # Position of "Add a block" widget must be set to "At the bottom of the nav drawer" because the Moodle + # Behat step to add a block does not work with the position "At the bottom of the default block region" + Given the following config values are set as admin: + | config | value | plugin | + | footerblocks | 1columns | theme_boost_campus | + | addablockposition | positionnavdrawer | theme_boost_campus | + And I log in as "admin" + And I navigate to "Development > Purge caches" in site administration + And I press "Purge all caches" + And I follow "Dashboard" in the user menu + When I press "Customise this page" + And I add the "Latest announcements" block + And I configure the "Latest announcements" block + And I set the following fields to these values: + | id_bui_region | footer-left | + And I press "Save changes" + Then I should see "Latest announcements" in the "#block-region-footer-left" "css_element" + + # This scenario needs full browser support only for this Behat test to pass, otherwise javascript would not be needed. + @javascript + Scenario: Setting "Footer blocks" to "Two block columns in footer" + # Position of "Add a block" widget must be set to "At the bottom of the nav drawer" because the Moodle + # Behat step to add a block does not work with the position "At the bottom of the default block region" + Given the following config values are set as admin: + | config | value | plugin | + | footerblocks | 2columns | theme_boost_campus | + | addablockposition | positionnavdrawer | theme_boost_campus | + And I log in as "admin" + And I navigate to "Development > Purge caches" in site administration + And I press "Purge all caches" + And I follow "Dashboard" in the user menu + When I press "Customise this page" + And I add the "Latest announcements" block + And I configure the "Latest announcements" block + And I set the following fields to these values: + | id_bui_region | footer-left | + And I press "Save changes" + And I add the "Comments" block + And I configure the "Comments" block + And I set the following fields to these values: + | id_bui_region | footer-right | + And I press "Save changes" + Then I should see "Latest announcements" in the "#block-region-footer-left" "css_element" + And I should see "Comments" in the "#block-region-footer-right" "css_element" + + # This scenario needs full browser support only for this Behat test to pass, otherwise javascript would not be needed. + @javascript + Scenario: Setting "Footer blocks" to "Three block columns in footer" + # Position of "Add a block" widget must be set to "At the bottom of the nav drawer" because the Moodle + # Behat step to add a block does not work with the position "At the bottom of the default block region" + Given the following config values are set as admin: + | config | value | plugin | + | footerblocks | 3columns | theme_boost_campus | + | addablockposition | positionnavdrawer | theme_boost_campus | + And I log in as "admin" + And I navigate to "Development > Purge caches" in site administration + And I press "Purge all caches" + And I follow "Dashboard" in the user menu + When I press "Customise this page" + And I add the "Latest announcements" block + And I configure the "Latest announcements" block + And I set the following fields to these values: + | id_bui_region | footer-left | + And I press "Save changes" + And I add the "Comments" block + And I configure the "Comments" block + And I set the following fields to these values: + | id_bui_region | footer-middle | + And I press "Save changes" + And I add the "Tags" block + And I configure the "Tags" block + And I set the following fields to these values: + | id_bui_region | footer-right | + And I press "Save changes" + Then I should see "Latest announcements" in the "#block-region-footer-left" "css_element" + And I should see "Comments" in the "#block-region-footer-middle" "css_element" + And I should see "Tags" in the "#block-region-footer-right" "css_element" + + # This scenario needs full browser support only for this Behat test to pass, otherwise javascript would not be needed. + @javascript + Scenario: Setting "Footer blocks" to "No blocks in footer" + # Position of "Add a block" widget must be set to "At the bottom of the nav drawer" because the Moodle + # Behat step to add a block does not work with the position "At the bottom of the default block region" + Given the following config values are set as admin: + | config | value | plugin | + | footerblocks | 0columns | theme_boost_campus | + | addablockposition | positionnavdrawer | theme_boost_campus | + And I log in as "admin" + And I navigate to "Development > Purge caches" in site administration + And I press "Purge all caches" + And I follow "Dashboard" in the user menu + When I press "Customise this page" + And I add the "Latest announcements" block + And I configure the "Latest announcements" block + Then I should not see "Footer (left)" in the "#id_bui_region" "css_element" + And I should not see "Footer (middle)" in the "#id_bui_region" "css_element" + Then I should not see "Footer (right)" in the "#id_bui_region" "css_element" + And I set the following fields to these values: + | id_bui_region | side-pre | + And I press "Save changes" + Then "#block-region-footer-left" "css_element" should not exist + And "#block-region-footer-middle" "css_element" should not exist + And "#block-region-footer-right" "css_element" should not exist + And I should not see "Latest announcements" in the "#page-footer" "css_element" + + # This scenario needs full browser support only for this Behat test to pass, otherwise javascript would not be needed. + @javascript + # This scenario does not work with the settings short notation + # Given the following config values are set as admin: + # | config | value | plugin | + # | footerhidehelplink | 1 | theme_boost_campus | + Scenario: Enable Hide link to the Moodle docs" + When I log in as "admin" + And I navigate to "Appearance > Boost Campus" in site administration + And I click on "Footer Layout Settings" "link" + And I set the field "s_theme_boost_campus_footerhidehelplink" to "1" + And I press "Save changes" + And I log out + When I log in as "teacher1" + And I am on "Course 1" course homepage + Then I should not see "Moodle Docs for this page" in the "page-footer" "region" + + # This scenario needs full browser support only for this Behat test to pass, otherwise javascript would not be needed. + @javascript + # This scenario does not work with the settings short notation + # Given the following config values are set as admin: + # | config | value | plugin | + # | footerhidehelplink | 0 | theme_boost_campus | + Scenario: Counter check: Disable "Hide link to the Moodle docs" + When I log in as "admin" + And I navigate to "Appearance > Boost Campus" in site administration + And I click on "Footer Layout Settings" "link" + And I set the field "s_theme_boost_campus_footerhidehelplink" to "0" + And I press "Save changes" + And I log out + When I log in as "teacher1" + And I am on "Course 1" course homepage + Then I should see "Moodle Docs for this page" in the "page-footer" "region" + + # This scenario needs full browser support only for this Behat test to pass, otherwise javascript would not be needed. + @javascript + Scenario: Enable "Hide login information" + # This scenario does not work with the settings short notation + # Given the following config values are set as admin: + # | config | value | plugin | + # | footerhidelogininfo | 1 | theme_boost_campus | + When I log in as "admin" + And I navigate to "Appearance > Boost Campus" in site administration + And I click on "Footer Layout Settings" "link" + And I set the field "s_theme_boost_campus_footerhidelogininfo" to "1" + And I press "Save changes" + Then I should not see "You are logged in as Admin User" in the "page-footer" "region" + + # This scenario needs full browser support only for this Behat test to pass, otherwise javascript would not be needed. + @javascript + Scenario: Counter check: Disable "Hide login information" + # This scenario does not work with the settings short notation + # Given the following config values are set as admin: + # | config | value | plugin | + # | footerhidelogininfo | 0 | theme_boost_campus | + When I log in as "admin" + And I navigate to "Appearance > Boost Campus" in site administration + And I click on "Footer Layout Settings" "link" + And I set the field "s_theme_boost_campus_footerhidelogininfo" to "0" + And I press "Save changes" + Then I should see "You are logged in as Admin User" in the "page-footer" "region" + + # This scenario needs full browser support only for this Behat test to pass, otherwise javascript would not be needed. + @javascript + # This scenario does not work with the settings short notation + # Given the following config values are set as admin: + # | config | value | plugin | + # | footerhidehomelink | 1 | theme_boost_campus | + Scenario: Enable "Hide link to the webpage start" + When I log in as "admin" + And I navigate to "Appearance > Boost Campus" in site administration + And I click on "Footer Layout Settings" "link" + And I set the field "s_theme_boost_campus_footerhidehomelink" to "1" + And I press "Save changes" + Then I should not see "Home" in the "page-footer" "region" + + # This scenario needs full browser support only for this Behat test to pass, otherwise javascript would not be needed. + @javascript + # This scenario does not work with the settings short notation + # Given the following config values are set as admin: + # | config | value | plugin | + # | footerhidehomelink | 0 | theme_boost_campus | + Scenario: Counter check: Disable"Hide link to the webpage start" + When I log in as "admin" + And I navigate to "Appearance > Boost Campus" in site administration + And I click on "Footer Layout Settings" "link" + And I set the field "s_theme_boost_campus_footerhidehomelink" to "0" + And I press "Save changes" + Then I should see "Home" in the "page-footer" "region" + + # This scenario needs full browser support only for this Behat test to pass, otherwise javascript would not be needed. + @javascript + # This scenario does not work with the settings short notation + # Given the following config values are set as admin: + # | config | value | plugin | + # | footerhideusertourslink | 1 | theme_boost_campus | + Scenario: Enable "Hide link to reset the user tour" + When I log in as "admin" + And I navigate to "Appearance > Boost Campus" in site administration + And I click on "Footer Layout Settings" "link" + And I set the field "s_theme_boost_campus_footerhideusertourslink" to "1" + And I press "Save changes" + # As both provided user tours are disabled in the testing environment, we need to enable one + # (the Dashboard tour) first. + And I navigate to "Appearance > User tours" in site administration + And I click on "//td[@id='tours_r0_c3']//a[contains(concat(' ',normalize-space(@class),' '),'quickeditlink')]" "xpath_element" + And I log out + When I log in as "teacher1" + Then I should not see "Reset user tour on this page" in the "page-footer" "region" + + # This scenario needs full browser support only for this Behat test to pass, otherwise javascript would not be needed. + @javascript + # This scenario does not work with the settings short notation + # Given the following config values are set as admin: + # | config | value | plugin | + # | footerhideusertourslink | 0 | theme_boost_campus | + Scenario: Counter check: Disable "Hide link to reset the user tour" + When I log in as "admin" + And I navigate to "Appearance > Boost Campus" in site administration + And I click on "Footer Layout Settings" "link" + And I set the field "s_theme_boost_campus_footerhideusertourslink" to "0" + And I press "Save changes" + # As both provided user tours are disabled in the testing environment, we need to enable one + # (the Dashboard tour) first. + And I navigate to "Appearance > User tours" in site administration + And I click on "//td[@id='tours_r0_c3']//a[contains(concat(' ',normalize-space(@class),' '),'quickeditlink')]" "xpath_element" + And I log out + When I log in as "teacher1" + Then I should see "Reset user tour on this page" in the "page-footer" "region" + + # This scenario needs full browser support only for this Behat test to pass, otherwise javascript would not be needed. + @javascript + # This scenario does not work with the settings short notation + # Given the following config values are set as admin: + # | config | value | plugin | + # | hidefooteronloginpage | 1 | theme_boost_campus | + Scenario: Enable "Hiding the footer on the login page" + When I log in as "admin" + And I navigate to "Appearance > Boost Campus" in site administration + And I click on "Footer Layout Settings" "link" + And I set the field "s_theme_boost_campus_hidefooteronloginpage" to "1" + And I press "Save changes" + And I log out + And I click on "Log in" "link" + Then I should not see "You are not logged in." + + # This scenario needs full browser support only for this Behat test to pass, otherwise javascript would not be needed. + @javascript + # This scenario does not work with the settings short notation + # Given the following config values are set as admin: + # | config | value | plugin | + # | hidefooteronloginpage | 0 | theme_boost_campus | + Scenario: Counter check: Disable "Hiding the footer on the login page" + When I log in as "admin" + And I navigate to "Appearance > Boost Campus" in site administration + And I click on "Footer Layout Settings" "link" + And I set the field "s_theme_boost_campus_hidefooteronloginpage" to "0" + And I press "Save changes" + And I log out + And I click on "Log in" "link" + Then I should see "You are not logged in." diff --git a/tests/behat/theme_boost_campus_general_settings.feature b/tests/behat/theme_boost_campus_general_settings.feature new file mode 100644 index 0000000000000000000000000000000000000000..40b68f48bf9c5247465fb687b4d4c5354c0f6c89 --- /dev/null +++ b/tests/behat/theme_boost_campus_general_settings.feature @@ -0,0 +1,50 @@ +@theme @theme_boost_campus @theme_boost_campus_general_settings +Feature: Configuring the theme_boost_campus plugin for the "General settings" tab + In order to use the features + As admin + I need to be able to configure the theme Boost Campus plugin + + Background: + # There is a nasty bug with Behat-testing this theme that the footer is not displayed until the settings + # of the theme are stored manually. It seems not to be sufficient to just rely on the default settings being + # stored during the installation of the theme. Until we find the root of this bug, we circumvent it by setting the + # brand color manually and within this process making sure that all settings are really stored to the database. + And I log in as "admin" + And I navigate to "Appearance > Boost Campus" in site administration + And I click on "General settings" "link" + And I set the field "id_s_theme_boost_campus_brandcolor" to "#7a99ac" + And I press "Save changes" + And I log out + + # This is derivated from theme Boost and should be covered there with tests + # Scenario: Change "Theme preset" + + # This is derivated from theme Boost and should be covered there with tests + # Scenario: Upload "Additional theme preset files" + + # This is derivated from theme Boost and should be covered there with tests + # Scenario: Add "Background image" + + # This is derivated from theme Boost and should be covered there with tests + # Scenario: Set "Brand colour" + + # This is not testable with behat + # Scenario: Set "Brand success colour" + + # This is not testable with behat + # Scenario: Set "Brand info colour" + + # This is not testable with behat + # Scenario: Set "Brand warning colour" + + # This is not testable with behat + # Scenario: Set "Brand danger colour" + + @javascript @_file_upload + Scenario: Add "Favicon" + When I log in as "admin" + And I navigate to "Appearance > Boost Campus" in site administration + And I click on "General settings" "link" + And I upload "theme/boost_campus/tests/fixtures/favicon.ico" file to "Favicon" filemanager + And I press "Save changes" + Then "//head//link[contains(@href, 'favicon.ico')]" "xpath_element" should exist diff --git a/tests/fixtures/favicon.ico b/tests/fixtures/favicon.ico new file mode 100644 index 0000000000000000000000000000000000000000..a06710ebc2f7e09cba8b452ba7719a80da9237b2 Binary files /dev/null and b/tests/fixtures/favicon.ico differ diff --git a/tests/fixtures/login_bg.jpg b/tests/fixtures/login_bg.jpg new file mode 100644 index 0000000000000000000000000000000000000000..7082377f13a2f32a74090fed9215f2d5f64d7be5 Binary files /dev/null and b/tests/fixtures/login_bg.jpg differ diff --git a/tests/fixtures/moodle_logo.jpg b/tests/fixtures/moodle_logo.jpg new file mode 100644 index 0000000000000000000000000000000000000000..b010a89c5e57462d770200374c55e6011c0ebc39 Binary files /dev/null and b/tests/fixtures/moodle_logo.jpg differ