first commit

This commit is contained in:
CHIEFSOFT\ameye
2024-09-30 18:11:26 -04:00
commit e592ca6823
27270 changed files with 5002257 additions and 0 deletions
+41
View File
@@ -0,0 +1,41 @@
@javascript @theme_boost
Feature: Add a block using boost theme
In order to decide the blocks to display in the Add a block list for a theme
As an administrator
I need to define them using the unaddableblocks setting
Background:
Given the following "courses" exist:
| fullname | shortname |
| Course 1 | C1 |
And I log in as "admin"
Scenario: Default blocks defined in unaddableblocks settings are not displayed in the Add a block list
Given I am on "Course 1" course homepage with editing mode on
When I click on "Add a block" "link"
Then I should not see "Administration"
And I should not see "Navigation"
And I should not see "Courses"
And I should not see "Section links"
And I should see "Online users"
Scenario: Admins can change unaddable blocks using the unaddableblocks setting
Given the following config values are set as admin:
| unaddableblocks | settings,private_files | theme_boost|
And I am on "Course 1" course homepage with editing mode on
When I click on "Add a block" "link"
Then I should not see "Administration"
And I should not see "Private files"
And I should see "Navigation"
And I should see "Courses"
And I should see "Section links"
Scenario: If unaddableblocks settting is empty, no block is excluded from the Add a block list
Given the following config values are set as admin:
| unaddableblocks | | theme_boost|
And I am on "Course 1" course homepage with editing mode on
When I click on "Add a block" "link"
Then I should see "Administration"
And I should see "Navigation"
And I should see "Courses"
And I should see "Section links"
@@ -0,0 +1,103 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
// NOTE: no MOODLE_INTERNAL test here, this file may be required by behat before including /config.php.
// For that reason, we can't even rely on $CFG->admin being available here.
require_once(__DIR__ . '/../../../../lib/tests/behat/behat_navigation.php');
use Behat\Mink\Exception\ElementNotFoundException as ElementNotFoundException;
use Behat\Mink\Exception\ExpectationException as ExpectationException;
/**
* Step definitions related to the navigation in the Boost theme.
*
* @package theme_boost
* @category test
* @copyright 2021 Mihail Geshoski
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class behat_theme_boost_behat_navigation extends behat_navigation {
/**
* Checks whether a node is active in the navbar.
*
* @override i should see :name is active in navigation
*
* @throws ElementNotFoundException
* @param string $element The name of the nav elemnent to look for.
* @return void
*/
public function i_should_see_is_active_in_navigation($element) {
$this->execute("behat_general::assert_element_contains_text",
[$element, '.navbar .nav-link.active', 'css_element']);
}
/**
* Checks whether a node is active in the secondary nav.
*
* @Given i should see :name is active in secondary navigation
* @throws ElementNotFoundException
* @param string $element The name of the nav elemnent to look for.
* @return void
*/
public function i_should_see_is_active_in_secondary_navigation($element) {
$this->execute("behat_general::assert_element_contains_text",
[$element, '.secondary-navigation .nav-link.active', 'css_element']);
}
/**
* Checks whether the language selector menu is present in the navbar.
*
* @Given language selector menu should exist in the navbar
* @Given language selector menu should :not exist in the navbar
*
* @throws ElementNotFoundException
* @param string|null $not Instructs to checks whether the element does not exist in the user menu, if defined
* @return void
*/
public function lang_menu_should_exist($not = null) {
$callfunction = is_null($not) ? 'should_exist' : 'should_not_exist';
$this->execute("behat_general::{$callfunction}", [$this->get_lang_menu_xpath(), 'xpath_element']);
}
/**
* Checks whether an item exists in the language selector menu.
*
* @Given :itemtext :selectortype should exist in the language selector menu
* @Given :itemtext :selectortype should :not exist in the language selector menu
*
* @throws ElementNotFoundException
* @param string $itemtext The menu item to find
* @param string $selectortype The selector type
* @param string|null $not Instructs to checks whether the element does not exist in the user menu, if defined
* @return void
*/
public function should_exist_in_lang_menu($itemtext, $selectortype, $not = null) {
$callfunction = is_null($not) ? 'should_exist_in_the' : 'should_not_exist_in_the';
$this->execute("behat_general::{$callfunction}",
[$itemtext, $selectortype, $this->get_lang_menu_xpath(), 'xpath_element']);
}
/**
* Return the xpath for the language selector menu element.
*
* @return string The xpath
*/
protected function get_lang_menu_xpath() {
return "//nav[contains(concat(' ', @class, ' '), ' navbar ')]" .
"//div[contains(concat(' ', @class, ' '), ' langmenu ')]" .
"//div[contains(concat(' ', @class, ' '), ' dropdown-menu ')]";
}
}
+12
View File
@@ -0,0 +1,12 @@
{
"features": [
"lib/tests/behat/action_menu.feature",
"blocks/tests/behat/hide_blocks.feature",
"blocks/tests/behat/move_blocks.feature",
"course/tests/behat/activity_navigation.feature",
"course/tests/behat/activity_navigation_with_restrictions.feature",
"course/tests/behat/paged_course_navigation.feature",
"course/tests/behat/section_visibility.feature",
"mod/page/tests/behat/page_appearance.feature"
]
}
@@ -0,0 +1,80 @@
@javascript @theme_boost
Feature: Breadcrumbs navigation
To navigate in boost theme
As an admin user
I should see breadcrumbs
Scenario: Admin user navigates to site administrations plugins assignment settings
Given I log in as "admin"
When I navigate to "Plugins > Activity modules > Assignment > Assignment settings" in site administration
Then I should see "Activity modules" in the ".breadcrumb" "css_element"
And I should see "Assignment" in the ".breadcrumb" "css_element"
And I should see "Assignment settings" in the ".breadcrumb" "css_element"
Scenario: Admin user navigates to site adminsitrations plugins assignment feedback offline grading worksheet
Given I log in as "admin"
When I navigate to "Plugins > Activity modules > Assignment > Feedback plugins > Offline grading worksheet" in site administration
Then I should see "Activity modules" in the ".breadcrumb" "css_element"
And I should see "Assignment" in the ".breadcrumb" "css_element"
And I should see "Feedback plugins" in the ".breadcrumb" "css_element"
And I should see "Offline grading worksheet" in the ".breadcrumb" "css_element"
Scenario: Admin user navigates to site adminsitrations plugins badges manage backpacks page
Given I log in as "admin"
When I navigate to "Badges > Manage backpacks" in site administration
Then I should see "Badges" in the ".breadcrumb" "css_element"
And I should see "Manage backpacks" in the ".breadcrumb" "css_element"
Scenario: Admin user changes the default home page and navigates to 'course category management' page
Given the following config values are set as admin:
| defaulthomepage | 3 |
And the following "categories" exist:
| name | category | idnumber |
| Cat 1 | 0 | CAT1 |
And I log in as "admin"
And I navigate to "Courses > Manage courses and categories" in site administration
When I follow "Cat 1"
Then I should not see "My courses" in the ".breadcrumb" "css_element"
And I should see "Cat 1" in the ".breadcrumb" "css_element"
And I should see "Manage courses and categories" in the ".breadcrumb" "css_element"
Scenario: Admin user sets the default home page to 'Site' and navigates to its 'Preferences' and 'Private files' page
Given the following config values are set as admin:
| defaulthomepage | 0 |
And I log in as "admin"
When I follow "Preferences" in the user menu
# There should be no breadcrumbs on this page.
Then ".breadcrumb-item" "css_element" should not exist in the ".breadcrumb" "css_element"
Scenario: Admin user sets the default home page to 'Dashboard' and navigates to its 'Preferences' and 'Private files' page
Given the following config values are set as admin:
| defaulthomepage | 1 |
And I log in as "admin"
When I follow "Preferences" in the user menu
# There should be no breadcrumbs on this page.
Then ".breadcrumb-item" "css_element" should not exist in the ".breadcrumb" "css_element"
And I follow "Private files" in the user menu
# There should be no breadcrumbs on this page.
And ".breadcrumb-item" "css_element" should not exist in the ".breadcrumb" "css_element"
Scenario: Admin user sets the default home page to 'User preference' and navigates to its 'Preferences' and 'Private files' page
Given the following config values are set as admin:
| defaulthomepage | 2 |
And I log in as "admin"
When I follow "Preferences" in the user menu
# There should be no breadcrumbs on this page.
Then ".breadcrumb-item" "css_element" should not exist in the ".breadcrumb" "css_element"
And I follow "Private files" in the user menu
# There should be no breadcrumbs on this page.
And ".breadcrumb-item" "css_element" should not exist in the ".breadcrumb" "css_element"
Scenario: Admin user sets the default home page to 'My courses' and navigates to its 'Preferences' and 'Private files' page
Given the following config values are set as admin:
| defaulthomepage | 3 |
And I log in as "admin"
When I follow "Preferences" in the user menu
# There should be no breadcrumbs on this page.
Then ".breadcrumb-item" "css_element" should not exist in the ".breadcrumb" "css_element"
And I follow "Private files" in the user menu
# There should be no breadcrumbs on this page.
And ".breadcrumb-item" "css_element" should not exist in the ".breadcrumb" "css_element"
@@ -0,0 +1,44 @@
@core @core_course @theme_boost
Feature: Role assignments can be made at the category level
In order to grant a user different capabilities
As a user
I can assign roles in categories
Background:
Given the following "users" exist:
| username | firstname | lastname |
| manager | Manager | Manager |
And the following "categories" exist:
| name | category | idnumber |
| Cat 1 | 0 | CAT1 |
And the following "role assigns" exist:
| user | role | contextlevel | reference |
| manager | manager | Category | CAT1 |
And I log in as "admin"
@javascript
Scenario: A user with a category role can assign roles
Given I define the allowed role assignments for the "Manager" role as:
| Teacher | Assignable |
And I log out
And I log in as "manager"
And I am on course index
When I follow "Cat 1"
And I navigate to "Permissions" in current page administration
Then "Assign roles" "text" should exist in the ".tertiary-navigation" "css_element"
@javascript
Scenario: A user with a category role cannot assign roles if there are no roles to assign
Given I define the allowed role assignments for the "Manager" role as:
| Manager | Not assignable |
| Course creator | Not assignable |
| Teacher | Not assignable |
| Non-editing teacher | Not assignable |
| Student | Not assignable |
And I change window size to "large"
And I log out
And I log in as "manager"
And I am on course index
When I follow "Cat 1"
And I navigate to "Permissions" in current page administration
Then "Assign roles" "text" should not exist in the ".tertiary-navigation" "css_element"
@@ -0,0 +1,29 @@
@javascript @theme_boost
Feature: Context settings menu
To navigate in boost theme I need to use the context settings menu
Background:
Given the following "courses" exist:
| fullname | shortname |
| Course 1 | C1 |
And the following "users" exist:
| username | firstname | lastname | email |
| teacher1 | Teacher | 1 | teacher1@example.com |
| student1 | Student | 1 | student1@example.com |
And the following "course enrolments" exist:
| user | course | role |
| teacher1 | C1 | editingteacher |
| student1 | C1 | student |
Scenario: Teacher can use the context settings menu
And I log in as "teacher1"
And I am on "Course 1" course homepage
And I navigate to "Settings" in current page administration
And I should see "Edit course settings"
And I log out
Scenario: Student cannot use the context settings menu
And I log in as "student1"
And I am on "Course 1" course homepage
And ".context-header-settings-menu [role=button]" "css_element" should not exist
And I log out
@@ -0,0 +1,46 @@
@javascript @theme_boost
Feature: Course reuse navigation
As a teacher
I can navigate to course reuse pages
Background:
Given the following "courses" exist:
| fullname | shortname | newsitems |
| Course 1 | C1 | 5 |
And the following "users" exist:
| username | firstname | lastname | email |
| teacher1 | Teacher | 1 | teacher1@example.com |
And the following "course enrolments" exist:
| user | course | role |
| teacher1 | C1 | editingteacher |
Scenario: A Teacher can navigate to the course Import page.
Given I log in as "teacher1"
When I am on "Course 1" course homepage
And I navigate to "Course reuse" in current page administration
Then I should not see "Find a course to import data from:"
And I should see "Import"
And I should see "Backup"
And I should see "Restore"
And I should not see "Copy course"
Scenario Outline: A Teacher can navigate to other Course reuse pages.
Given I log in as "teacher1"
When I am on "Course 1" course homepage
And I navigate to "Course reuse" in current page administration
And I follow "<adminpage>"
Then I should see "<content>"
Examples:
| adminpage | content |
| Backup | Backup settings |
| Restore | Upload a backup file |
| Import | Find a course to import data from: |
| Reset | Delete all user data and reset this course to its original state |
Scenario: An Administrator can view the course copy page.
Given I log in as "admin"
When I am on "Course 1" course homepage
And I navigate to "Course reuse" in current page administration
And I follow "Copy course"
Then I should see "Create a copy of this course in any course category"
@@ -0,0 +1,27 @@
@javascript @theme_boost
Feature: Form errors only display after submit or change in Boost theme
In order to have a more accessible way to display form errors
As anyone
I need to see errors only after I submit the form or change a field
Background:
Given the following "courses" exist:
| fullname | shortname |
| Course 1 | C1 |
Scenario: Form error appears after submit, but not after just tabbing through
When I log in as "admin"
And I navigate to "Courses > Add a new course" in site administration
And I click on "Course full name" "field"
And I press the tab key
Then I should not see "Missing full name"
And I press "Save and display"
And I should see "Missing full name"
And the focused element is "Course full name" "field"
Scenario: Form error appears immediately after change
When I am on the "C1" "course editing" page logged in as "admin"
And I set the field "Course full name" to ""
And I press the tab key
Then I should see "Missing full name"
And the focused element is "Course full name" "field"
@@ -0,0 +1,76 @@
@javascript @theme_boost
Feature: Language selector menu
To be able to set the preferred language for the site
As a user
I need to be presented with a language selector menu
Background:
Given remote langimport tests are enabled
And the following "courses" exist:
| fullname | shortname |
| Course 1 | C1 |
And the following "users" exist:
| username | firstname | lastname | email |
| teacher1 | Teacher | 1 | teacher1@example.com |
And the following "course enrolments" exist:
| user | course | role |
| teacher1 | C1 | editingteacher |
And the following "language pack" exists:
| language | en_ar |
Scenario: Logged user is presented with a language selector which is placed within the user menu
Given I log in as "teacher1"
And I am on site homepage
# The language selector menu is not present in the navbar when a user is logged in.
And language selector menu should not exist in the navbar
# The language selector is present within the user menu.
And "Language" "link" should exist in the user menu
When I follow "Language" in the user menu
Then I should see "Language selector" user submenu
And "English (en)" "link" should exist in the "Language selector" user submenu
And "English (pirate) (en_ar)" "link" should exist in the "Language selector" user submenu
Scenario: Non-logged user is presented with a language selector which is placed within the navbar
Given I am on site homepage
# The language selector menu is present in the navbar when a user is not logged in.
And language selector menu should exist in the navbar
And "English (en)" "link" should exist in the language selector menu
And "English (pirate) (en_ar)" "link" should exist in the language selector menu
Scenario: Logged user is not presented with a language selector in a course if a language is forced in that context
Given I log in as "teacher1"
And I am on "Course 1" course homepage
And I navigate to "Settings" in current page administration
And I expand all fieldsets
And I set the following fields to these values:
| id_lang | en |
And I press "Save and display"
# The language selector is not present within the user menu in the course context when a language is enforced.
When I am on "Course 1" course homepage
And "Language" "link" should not exist in the user menu
# The language selector is present within the user menu in other contexts.
And I am on site homepage
And "Language" "link" should exist in the user menu
Scenario: Logged user is not presented with a language selector if there is less than two installed languages
Given I log in as "admin"
And I navigate to "Language > Language packs" in site administration
And I set the field "Installed language packs" to "en_ar"
And I press "Uninstall selected language pack(s)"
And I click on "Yes" "button" in the "Uninstall selected language pack(s)" "dialogue"
And the "Installed language packs" select box should not contain "en_ar"
When I am on site homepage
# The language selector is not present within the user menu.
And "Language" "link" should not exist in the user menu
Scenario: Non-logged user is not presented with a language selector if there is less than two installed languages
Given I log in as "admin"
And I navigate to "Language > Language packs" in site administration
And I set the field "Installed language packs" to "en_ar"
And I press "Uninstall selected language pack(s)"
And I click on "Yes" "button" in the "Uninstall selected language pack(s)" "dialogue"
And the "Installed language packs" select box should not contain "en_ar"
And I log out
When I am on site homepage
# The language selector menu is not present in the navbar.
Then language selector menu should not exist in the navbar
@@ -0,0 +1,30 @@
@javascript @theme_boost
Feature: My courses page block layout in Boost theme
In order to have a clear and consistent view on the my courses page
As a student
I need to see the blocks in the expected placement
Background:
Given the following "users" exist:
| username | firstname | lastname | email |
| student1 | Student | 1 | student@example.com |
And I log in as "admin"
And I am on site homepage
And I turn editing mode on
And I add the "Text" block to the default region with:
| Text block title | Text on all pages |
| Content | This is visible on all pages |
And I configure the "Text on all pages" block
And I set the following fields to these values:
| Page contexts | Display throughout the entire site |
| Default region | Right |
And I click on "Save changes" "button" in the "Configure Text on all pages block" "dialogue"
Scenario: Student can see relevant blocks with correct placement on my courses page
When I log in as "student1"
And I am on the "My courses" page
Then "Course overview" "text" should exist in the "region-main" "region"
And I should see "This is visible on all pages"
And I press "Close block drawer"
And "Course overview" "text" should exist in the "region-main" "region"
And I should not see "This is visible on all pages"
+120
View File
@@ -0,0 +1,120 @@
@javascript @theme_boost
Feature: Primary navigation
To navigate in boost theme
As a user
I need to use the primary navigation
Background:
Given the following "users" exist:
| username | firstname | lastname | email |
| user1 | User | One | user1@example.com |
@javascript @theme_boost
Scenario Outline: Admin sets defaulthomepage and verify the landing page and site home link
Given I log in as "admin"
And the following config values are set as admin:
| defaulthomepage | <defaulthomepageset> |
And I am on homepage
And I should see "<homepage>" in the "a.nav-link.active:not([tabindex])" "css_element"
And I should see "<sitehome>" in the "<linkelement>" "css_element"
Examples:
| defaulthomepageset | homepage | sitehome | linkelement |
| 0 | Home | Home | a.nav-link.active:not([tabindex]):not([href*='redirect=0']) |
| 1 | Dashboard | Home | a.nav-link[tabindex='-1'][href$='redirect=0'] |
| 3 | My courses | Home | a.nav-link[tabindex='-1'][href$='redirect=0'] |
@javascript @theme_boost
Scenario Outline: Admin sets defaulthomepage to user preference and verifies the landing page based on it
Given I log in as "admin"
And I navigate to "Appearance > Navigation" in site administration
And I set the field "Start page for users" to "User preference"
And I press "Save changes"
And I follow "Preferences" in the user menu
And I follow "Start page"
And I set the field "Start page" to "<userpreference>"
And I press "Save changes"
And the following config values are set as admin:
| defaulthomepage | 2 |
And I log out
And I log in as "admin"
And I should see "<homepage>" in the "a.nav-link.active:not([tabindex])" "css_element"
Examples:
| userpreference | homepage |
| Home | Home |
| Dashboard | Dashboard |
| My courses | My courses |
@javascript @theme_boost
Scenario: Users could use primary nav menu on mobile size screens
Given I change window size to "mobile"
And I am on the "My courses" page logged in as "user1"
Then "Home" "link" should not be visible
And "Side panel" "button" should exist
And I click on "Side panel" "button"
And I should see "Home" in the "theme_boost-drawers-primary" "region"
@theme_boost
Scenario: Guest users can only see the Home item in the primary navigation menu
Given I log in as "guest"
When I am on site homepage
Then I should see "Home" in the ".primary-navigation" "css_element"
And I should not see "Dashboard" in the ".primary-navigation" "css_element"
And I should not see "My courses" in the ".primary-navigation" "css_element"
And I should not see "Site administration" in the ".primary-navigation" "css_element"
Scenario: Dashboard is not displayed in the primary navigation when it is disabled
Given the following config values are set as admin:
| enabledashboard | 0 |
When I am on the "My courses" page logged in as "user1"
Then I should not see "Dashboard"
And the following config values are set as admin:
| enabledashboard | 1 |
# We need to reload the page to skip the "Welcome, xxxx!" and display the real page title.
And I reload the page
And I should see "Dashboard"
Scenario: Start page when default home is dashboard but dashboard is disabled
Given the following config values are set as admin:
| enabledashboard | 0 |
# 1 = Dashboard.
| defaulthomepage | 1 |
When I log in as "admin"
# We need to reload the page to skip the "Welcome, xxxx!" and display the real page title.
And I reload the page
Then I should not see "Dashboard" in the "page-header" "region"
And I should see "My courses" in the "page-header" "region"
And I log out
# Check dashboard is displayed when it's re-enabled.
And the following config values are set as admin:
| enabledashboard | 1 |
And I log in as "admin"
# We need to reload the page to skip the "Welcome, xxxx!" and display the real page title.
And I reload the page
And I should see "Dashboard" in the "page-header" "region"
And I should not see "My courses" in the "page-header" "region"
Scenario: Start page when default home is user preference set to dashboard but dashboard is disabled
Given the following config values are set as admin:
| enabledashboard | 0 |
# 2 = User preference.
| defaulthomepage | 2 |
# 1 = Dashboard.
And the following "user preferences" exist:
| user | preference | value |
| admin | user_home_page_preference | 1 |
When I log in as "admin"
# We need to reload the page to skip the "Welcome, xxxx!" and display the real page title.
And I reload the page
Then I should not see "Dashboard"
And I should see "My courses" in the "page-header" "region"
And I log out
# Check dashboard is displayed when it's re-enabled.
And the following config values are set as admin:
| enabledashboard | 1 |
And I log in as "admin"
# We need to reload the page to skip the "Welcome, xxxx!" and display the real page title.
And I reload the page
And I should see "Dashboard" in the "page-header" "region"
And I should not see "My courses" in the "page-header" "region"
@@ -0,0 +1,26 @@
@javascript @theme_boost
Feature: Region main settings menu
To navigate in boost theme I need to use the region main settings menu
Background:
Given the following "courses" exist:
| fullname | shortname | newsitems |
| Course 1 | C1 | 5 |
And the following "users" exist:
| username | firstname | lastname | email |
| teacher1 | Teacher | 1 | teacher1@example.com |
| student1 | Student | 1 | student1@example.com |
And the following "course enrolments" exist:
| user | course | role |
| teacher1 | C1 | editingteacher |
| student1 | C1 | student |
And the following "activities" exist:
| activity | name | intro | course | idnumber | option |
| choice | Choice name | Test choice description | C1 | choice1 | Option 1, Option 2, Option 3 |
Scenario: Student cannot use all options in the region main settings menu
Given I log in as "student1"
When I am on "Course 1" course homepage
Then "#region-main-settings-menu [role=button]" "css_element" should not exist
And I am on the "Choice name" "Choice activity" page
And "#region-main-settings-menu [role=button]" "css_element" should not exist
@@ -0,0 +1,30 @@
@tool @tool_usertours @theme_boost
Feature: Reset a tour for Boost
In order to test a tour
As an administrator
I can reset the tour to force it to display again
Background:
Given I log in as "admin"
And I add a new user tour with:
| Name | First tour |
| Description | My first tour |
| Apply to URL match | FRONTPAGE |
| Tour is enabled | 1 |
| Show with backdrop | 1 |
And I add steps to the "First tour" tour:
| targettype | Title | id_content | Content type |
| Display in middle of page | Welcome | Welcome tour. | Manual |
@javascript
Scenario: Reset the tour with desktop view
# Changing the window size to large so we will have the footer button.
Given I change window size to "large"
And I am on site homepage
And I should see "Welcome"
And I press "Got it"
And I should not see "Welcome"
When I click on ".btn-footer-popover" "css_element" in the "#page-footer" "css_element"
Then I should see "Reset user tour on this page"
And I click on "Reset user tour on this page" "link"
And I should see "Welcome"
@@ -0,0 +1,23 @@
@javascript @theme_boost
Feature: Administration nav tabs
Scenario: See last opened tab in site admin when returning to the page
Given I log in as "admin"
And I am on site homepage
And I click on "Site administration" "link"
And I click on "Users" "link"
And I click on "Browse list of users" "link"
And I should see "Add a new user"
When I press the "back" button in the browser
Then I should see "Cohorts"
Scenario: Navigate back to specific tab after search
Given I log in as "admin"
And I am on site homepage
And I click on "Site administration" "link"
And I set the field "Search" to "assignment"
And I press "Search"
# I should be redirected to the site admin tab with the complete list under it.
# Testing the existence of at least one of the options in the node is sufficient.
When I select "Users" from secondary navigation
Then I should see "Browse list of users"
@@ -0,0 +1,32 @@
@core @core_admin @theme_boost
Feature: Select a theme in Boost theme
In order to choose a theme
As an admin
I need to preview the theme and make a selection
Background:
Given I log in as "admin"
And I navigate to "Appearance > Themes" in site administration
@javascript
Scenario: I am able to preview a theme using a modal window
When I click on "Preview theme 'Boost'" "button"
Then I should see "Boost" in the "Boost" "dialogue"
And I should see "Boost is a modern highly-customisable theme." in the "Boost" "dialogue"
And I should see "Current theme" in the "Boost" "dialogue"
@javascript
Scenario: I am able to change the theme using the modal window select button
Given I should see "Current theme" in the "#theme-card-boost" "css_element"
When I click on "Preview theme 'Classic'" "button"
And I click on "Select theme" "button" in the "Classic" "dialogue"
Then I should see "Current theme" in the "#theme-card-classic" "css_element"
Scenario: I am able to change the theme using the normal select button
Given I should see "Current theme" in the "#theme-card-boost" "css_element"
When I click on "Select theme 'Classic'" "button"
Then I should see "Current theme" in the "#theme-card-classic" "css_element"
Scenario: I am able to view a theme's settings page
Given I click on "Edit theme settings 'Boost'" "link"
Then I should see "Boost"
@@ -0,0 +1,35 @@
@tool @tool_usertours @theme_boost
Feature: Apply tour filters to a tour for Classic
In order to give more directed tours
As an administrator
I need to create a user tour specific to theme Classic
@javascript
Scenario: Add a tour for theme Classic
Given I log in as "admin"
And I add a new user tour with:
| Name | First tour |
| Description | My first tour |
| Apply to URL match | /my/% |
| Tour is enabled | 1 |
| Theme | Classic |
And I add steps to the "First tour" tour:
| targettype | Title | id_content | Content type |
| Display in middle of page | Welcome | Welcome to your personal learning space. We'd like to give you a quick tour to show you some of the areas you may find helpful | Manual |
When I am on homepage
Then I should not see "Welcome to your personal learning space. We'd like to give you a quick tour to show you some of the areas you may find helpful"
@javascript
Scenario: Add a tour for theme Boost
Given I log in as "admin"
And I add a new user tour with:
| Name | First tour |
| Description | My first tour |
| Apply to URL match | /my/% |
| Tour is enabled | 1 |
| Theme | Boost |
And I add steps to the "First tour" tour:
| targettype | Title | id_content | Content type |
| Display in middle of page | Welcome | Welcome to your personal learning space. We'd like to give you a quick tour to show you some of the areas you may find helpful | Manual |
When I am on homepage
Then I should see "Welcome to your personal learning space. We'd like to give you a quick tour to show you some of the areas you may find helpful"
@@ -0,0 +1,35 @@
@javascript @theme_boost
Feature: Welcome message on boost
To be welcome in moodle
As a User
I need to see a welcome message on the first page
Scenario: Login and be welcomed on the homepage
Given the following config values are set as admin:
| defaulthomepage | 0 |
When I log in as "admin"
Then I should not see "Acceptance test site" in the "page-header" "region"
And I should see "Welcome, Admin!" in the "page-header" "region"
And I reload the page
And I should not see "Welcome, Admin!" in the "page-header" "region"
And I should see "Acceptance test site" in the "page-header" "region"
Scenario: Login and be welcomed on the dashboard
Given the following config values are set as admin:
| defaulthomepage | 1 |
When I log in as "admin"
Then I should not see "Dashboard" in the "page-header" "region"
And I should see "Welcome, Admin!" in the "page-header" "region"
And I reload the page
And I should not see "Welcome, Admin!" in the "page-header" "region"
And I should see "Dashboard" in the "page-header" "region"
Scenario: Login and be welcomed on the my courses page
Given the following config values are set as admin:
| defaulthomepage | 3 |
When I log in as "admin"
Then I should not see "My courses" in the "page-header" "region"
And I should see "Welcome, Admin!" in the "page-header" "region"
And I reload the page
And I should not see "Welcome, Admin!" in the "page-header" "region"
And I should see "My courses" in the "page-header" "region"
+540
View File
@@ -0,0 +1,540 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
namespace theme_boost;
/**
* Test the boostnavbar file
*
* @package theme_boost
* @covers \theme_boost\boostnavbar
* @copyright 2021 Peter Dias
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class boostnavbar_test extends \advanced_testcase {
/**
* Provider for test_remove_no_link_items
* The setup and expected arrays are defined as an array of 'nodekey' => $hasaction
*
* @return array
*/
public function remove_no_link_items_provider(): array {
return [
'All nodes have links links including leaf node. Set to remove section nodes.' => [
[
'node1' => ['hasaction' => true, 'issection' => false],
'node2' => ['hasaction' => true, 'issection' => false],
'node3' => ['hasaction' => true, 'issection' => false],
],
true,
[
'Home' => true,
'Courses' => true,
'tc_1' => true,
'node1' => true,
'node2' => true,
'node3' => true,
]
],
'Only some parent nodes have links. Leaf node has a link. Set to remove section nodes.' => [
[
'node1' => ['hasaction' => false, 'issection' => false],
'node2' => ['hasaction' => true, 'issection' => false],
'node3' => ['hasaction' => true, 'issection' => false],
],
true,
[
'Home' => true,
'Courses' => true,
'tc_1' => true,
'node2' => true,
'node3' => true,
]
],
'All parent nodes do not have links. Leaf node has a link. Set to remove section nodes.' => [
[
'node1' => ['hasaction' => false, 'issection' => false],
'node2' => ['hasaction' => false, 'issection' => false],
'node3' => ['hasaction' => true, 'issection' => false],
],
true,
[
'Home' => true,
'Courses' => true,
'tc_1' => true,
'node3' => true,
]
],
'All parent nodes have links. Leaf node does not has a link. Set to remove section nodes.' => [
[
'node1' => ['hasaction' => true, 'issection' => false],
'node2' => ['hasaction' => true, 'issection' => false],
'node3' => ['hasaction' => false, 'issection' => false],
],
true,
[
'Home' => true,
'Courses' => true,
'tc_1' => true,
'node1' => true,
'node2' => true,
'node3' => false,
]
],
'All parent nodes do not have links. Leaf node does not has a link. Set to remove section nodes.' => [
[
'node1' => ['hasaction' => false, 'issection' => false],
'node2' => ['hasaction' => false, 'issection' => false],
'node3' => ['hasaction' => false, 'issection' => false],
],
true,
[
'Home' => true,
'Courses' => true,
'tc_1' => true,
'node3' => false,
]
],
'Some parent nodes do not have links. Leaf node does not has a link. Set to remove section nodes.' => [
[
'node1' => ['hasaction' => true, 'issection' => false],
'node2' => ['hasaction' => false, 'issection' => false],
'node3' => ['hasaction' => false, 'issection' => false],
],
true,
[
'Home' => true,
'Courses' => true,
'tc_1' => true,
'node1' => true,
'node3' => false,
]
],
'All nodes have links links including leaf node and section nodes. Set to remove section nodes.' => [
[
'node1' => ['hasaction' => true, 'issection' => false],
'node2' => ['hasaction' => true, 'issection' => false],
'sectionnode1' => ['hasaction' => true, 'issection' => true],
'node3' => ['hasaction' => true, 'issection' => false],
],
true,
[
'Home' => true,
'Courses' => true,
'tc_1' => true,
'node1' => true,
'node2' => true,
'node3' => true,
]
],
'All nodes have links links including leaf node and section nodes. Set to not remove section nodes.' => [
[
'node1' => ['hasaction' => true, 'issection' => false],
'node2' => ['hasaction' => true, 'issection' => false],
'sectionnode1' => ['hasaction' => true, 'issection' => true],
'node3' => ['hasaction' => true, 'issection' => false],
],
false,
[
'Home' => true,
'Courses' => true,
'tc_1' => true,
'node1' => true,
'node2' => true,
'sectionnode1' => true,
'node3' => true,
]
],
'Only some parent nodes have links. Section node does not have a link. Set to not remove section nodes.' => [
[
'node1' => ['hasaction' => false, 'issection' => false],
'node2' => ['hasaction' => true, 'issection' => false],
'sectionnode1' => ['hasaction' => false, 'issection' => true],
'node3' => ['hasaction' => true, 'issection' => false],
],
true,
[
'Home' => true,
'Courses' => true,
'tc_1' => true,
'node2' => true,
'node3' => true,
]
]
];
}
/**
* Test the remove_no_link_items function
*
* @dataProvider remove_no_link_items_provider
* @param array $setup
* @param bool $removesectionnodes Whether to remove the section nodes with an associated action.
* @param array $expected
* @throws \ReflectionException
*/
public function test_remove_no_link_items(array $setup, bool $removesectionnodes, array $expected): void {
global $PAGE;
$this->resetAfterTest();
// Unfortunate hack needed because people use global $PAGE around the place.
$PAGE->set_url('/');
$course = $this->getDataGenerator()->create_course();
$page = new \moodle_page();
$page->set_course($course);
$page->set_url(new \moodle_url('/course/view.php', array('id' => $course->id)));
// A dummy url to use. We don't care where it's pointing to.
$url = new \moodle_url('/');
foreach ($setup as $key => $value) {
$page->navbar->add($key, $value['hasaction'] ? $url : null,
$value['issection'] ? \navigation_node::TYPE_SECTION : null);
}
$boostnavbar = $this->getMockBuilder(boostnavbar::class)
->disableOriginalConstructor()
->onlyMethods([])
->getMock();
$rc = new \ReflectionClass(boostnavbar::class);
$rcp = $rc->getProperty('items');
$rcp->setValue($boostnavbar, $page->navbar->get_items());
// Make the call to the function.
$rcm = $rc->getMethod('remove_no_link_items');
$rcm->invoke($boostnavbar, $removesectionnodes);
// Get the value for the class variable that the function modifies.
$values = $rcp->getValue($boostnavbar);
$actual = [];
foreach ($values as $value) {
$actual[$value->text] = $value->has_action();
}
$this->assertEquals($expected, $actual);
}
/**
* Provider for test_remove_duplicate_items.
*
* @return array
*/
public function remove_duplicate_items_provider(): array {
global $CFG;
return [
'Breadcrumb items with identical text and action url (actions of same type moodle_url).' => [
[
[
'text' => 'Node 1',
'action' => new \moodle_url('/page1.php')
],
[
'text' => 'Node 2',
'action' => new \moodle_url('/page2.php', ['id' => 1])
],
[
'text' => 'Node 4',
'action' => new \moodle_url('/page4.php', ['id' => 1])
],
[
'text' => 'Node 2',
'action' => new \moodle_url('/page2.php', ['id' => 1])
],
],
['Home', 'Node 1', 'Node 4', 'Node 2']
],
'Breadcrumb items with identical text and action url (actions of different type moodle_url/text).' => [
[
[
'text' => 'Node 1',
'action' => new \moodle_url('/page1.php')
],
[
'text' => 'Node 2',
'action' => new \moodle_url('/page2.php', ['id' => 1])
],
[
'text' => 'Node 4',
'action' => new \moodle_url('/page4.php', ['id' => 1])
],
[
'text' => 'Node 2',
'action' => "{$CFG->wwwroot}/page2.php?id=1"
],
],
['Home', 'Node 1', 'Node 4', 'Node 2']
],
'Breadcrumb items with identical text and action url (actions of different type moodle_url/action_link).' => [
[
[
'text' => 'Node 1',
'action' => new \moodle_url('/page1.php')
],
[
'text' => 'Node 2',
'action' => new \moodle_url('/page2.php', ['id' => 1])
],
[
'text' => 'Node 4',
'action' => new \moodle_url('/page4.php', ['id' => 1])
],
[
'text' => 'Node 2',
'action' => new \action_link(new \moodle_url('/page2.php', ['id' => 1]), 'Action link')
],
],
['Home', 'Node 1', 'Node 4', 'Node 2']
],
'Breadcrumbs items with identical text but not identical action url.' => [
[
[
'text' => 'Node 1',
'action' => new \moodle_url('/page1.php')
],
[
'text' => 'Node 2',
'action' => new \moodle_url('/page2.php', ['id' => 1])
],
[
'text' => 'Node 2',
'action' => new \moodle_url('/page2.php', ['id' => 2])
],
[
'text' => 'Node 4',
'action' => new \moodle_url('/page4.php', ['id' => 1])
],
],
['Home', 'Node 1', 'Node 2', 'Node 2', 'Node 4']
],
'Breadcrumb items with identical action url but not identical text.' => [
[
[
'text' => 'Node 1',
'action' => new \moodle_url('/page1.php')
],
[
'text' => 'Node 2',
'action' => new \moodle_url('/page2.php', ['id' => 1])
],
[
'text' => 'Node 3',
'action' => new \moodle_url('/page2.php', ['id' => 1])
],
[
'text' => 'Node 4',
'action' => new \moodle_url('/page4.php', ['id' => 1])
],
],
['Home', 'Node 1', 'Node 2', 'Node 3', 'Node 4']
],
'Breadcrumb items without any identical action url or text.' => [
[
[
'text' => 'Node 1',
'action' => new \moodle_url('/page1.php')
],
[
'text' => 'Node 2',
'action' => new \moodle_url('/page2.php', ['id' => 1])
],
[
'text' => 'Node 3',
'action' => new \moodle_url('/page3.php', ['id' => 1])
],
[
'text' => 'Node 4',
'action' => new \moodle_url('/page4.php', ['id' => 1])
],
],
['Home', 'Node 1', 'Node 2', 'Node 3', 'Node 4']
],
];
}
/**
* Test the remove_duplicate_items function.
*
* @dataProvider remove_duplicate_items_provider
* @param array $navbarnodes The array containing the text and action of the nodes to be added to the navbar
* @param array $expected The array containing the text of the expected navbar nodes
*/
public function test_remove_duplicate_items(array $navbarnodes, array $expected): void {
$this->resetAfterTest();
$page = new \moodle_page();
$page->set_url('/');
// Add the navbar nodes.
foreach ($navbarnodes as $node) {
$page->navbar->add($node['text'], $node['action'], \navigation_node::TYPE_CUSTOM);
}
$boostnavbar = $this->getMockBuilder(boostnavbar::class)
->disableOriginalConstructor()
->onlyMethods([])
->getMock();
$rc = new \ReflectionClass(boostnavbar::class);
$rcp = $rc->getProperty('items');
$rcp->setValue($boostnavbar, $page->navbar->get_items());
// Make the call to the function.
$rcm = $rc->getMethod('remove_duplicate_items');
$rcm->invoke($boostnavbar);
// Get the value for the class variable that the function modifies.
$values = $rcp->getValue($boostnavbar);
$actual = [];
foreach ($values as $value) {
$actual[] = $value->text;
}
$this->assertEquals($expected, $actual);
}
/**
* Provider for test_remove_items_that_exist_in_navigation.
*
* @return array
*/
public function remove_items_that_exist_in_navigation_provider(): array {
global $CFG;
return [
'Item with identical action url and text exists in the primary navigation menu.' => [
'primary',
[
[
'text' => 'Node 1',
'action' => new \moodle_url('/page1.php')
],
],
[
'Node 1' => new \moodle_url('/page1.php'),
'Node 2' => new \moodle_url('/page2.php'),
'Node 3' => new \moodle_url('/page1.php'),
],
['Node 2', 'Node 3']
],
'Item with identical action url and text exists in the secondary navigation menu.' => [
'secondary',
[
[
'text' => 'Node 2',
'action' => new \moodle_url('/page2.php')
],
],
[
'Node 1' => new \moodle_url('/page1.php'),
'Node 2' => new \moodle_url('/page2.php'),
'Node 3' => new \moodle_url('/page1.php'),
],
['Home', 'Node 1', 'Node 3']
],
'Multiple items with identical action url and text exist in the secondary navigation menu.' => [
'secondary',
[
[
'text' => 'Node 2',
'action' => new \moodle_url('/page2.php')
],
[
'text' => 'Node 3',
'action' => new \moodle_url('/page3.php')
],
],
[
'Node 1' => new \moodle_url('/page1.php'),
'Node 2' => "{$CFG->wwwroot}/page2.php",
'Node 3' => new \action_link(new \moodle_url('/page3.php'), 'Action link'),
],
['Home', 'Node 1']
],
'No items with identical action url and text in the secondary navigation menu.' => [
'secondary',
[
[
'text' => 'Node 4',
'action' => new \moodle_url('/page4.php')
],
],
[
'Node 1' => new \moodle_url('/page1.php'),
'Node 2' => new \moodle_url('/page2.php'),
'Node 3' => new \moodle_url('/page1.php'),
],
['Home', 'Node 1', 'Node 2', 'Node 3']
],
];
}
/**
* Test the remove_items_that_exist_in_navigation function.
*
* @dataProvider remove_items_that_exist_in_navigation_provider
* @param string $navmenu The name of the navigation menu we would like to use (primary or secondary)
* @param array $navmenunodes The array containing the text and action of the nodes to be added to the navigation menu
* @param array $navbarnodes Array containing the text => action of the nodes to be added to the navbar
* @param array $expected Array containing the text of the expected navbar nodes after the filtering
*/
public function test_remove_items_that_exist_in_navigation(string $navmenu, array $navmenunodes, array $navbarnodes,
array $expected): void {
global $PAGE;
// Unfortunate hack needed because people use global $PAGE around the place.
$PAGE->set_url('/');
$this->resetAfterTest();
$page = new \moodle_page();
$page->set_url('/');
switch ($navmenu) {
case 'primary':
$navigationmenu = new \core\navigation\views\primary($page);
break;
case 'secondary':
$navigationmenu = new \core\navigation\views\secondary($page);
}
$navigationmenu->initialise();
// Add the additional nodes to the navigation menu.
foreach ($navmenunodes as $navmenunode) {
$navigationmenu->add($navmenunode['text'], $navmenunode['action'], \navigation_node::TYPE_CUSTOM);
}
// Add the additional navbar nodes.
foreach ($navbarnodes as $text => $action) {
$page->navbar->add($text, $action, \navigation_node::TYPE_CUSTOM);
}
$boostnavbar = $this->getMockBuilder(boostnavbar::class)
->disableOriginalConstructor()
->onlyMethods([])
->getMock();
$rc = new \ReflectionClass(boostnavbar::class);
$rcp = $rc->getProperty('items');
$rcp->setValue($boostnavbar, $page->navbar->get_items());
// Make the call to the function.
$rcm = $rc->getMethod('remove_items_that_exist_in_navigation');
$rcm->invoke($boostnavbar, $navigationmenu);
// Get the value for the class variable that the function modifies.
$values = $rcp->getValue($boostnavbar);
$actual = [];
foreach ($values as $value) {
$actual[] = $value->text;
}
$this->assertEquals($expected, $actual);
}
}
@@ -0,0 +1,76 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
namespace theme_boost\privacy;
use context_user;
use core_privacy\local\request\writer;
/**
* Privacy tests for theme_boost.
*
* @package theme_boost
* @category test
* @covers \theme_boost\privacy\provider
* @copyright 2018 Adrian Greeve <adriangreeve.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class provider_test extends \core_privacy\tests\provider_testcase {
/**
* Data provider for {@see test_export_user_preferences}
*
* @return array[]
*/
public function export_user_preference_provider(): array {
return [
'Index drawer open' => [provider::DRAWER_OPEN_INDEX, true, 'privacy:drawerindexopen'],
'Index drawer closed' => [provider::DRAWER_OPEN_INDEX, false, 'privacy:drawerindexclosed'],
'Block drawer open' => [provider::DRAWER_OPEN_BLOCK, true, 'privacy:drawerblockopen'],
'Block drawer closed' => [provider::DRAWER_OPEN_BLOCK, false, 'privacy:drawerblockclosed'],
];
}
/**
* Test for provider::test_export_user_preferences().
*
* @param string $preference
* @param bool $value
* @param string $expectdescription
*
* @dataProvider export_user_preference_provider
*/
public function test_export_user_preferences(string $preference, bool $value, string $expectdescription): void {
$this->resetAfterTest();
// Test setup.
$user = $this->getDataGenerator()->create_user();
$this->setUser($user);
// Add a user home page preference for the User.
set_user_preference($preference, $value, $user);
// Test the user preferences export contains 1 user preference record for the User.
provider::export_user_preferences($user->id);
$writer = writer::with_context(context_user::instance($user->id));
$this->assertTrue($writer->has_any_data());
$exportedpreferences = $writer->get_user_preferences('theme_boost');
$this->assertCount(1, (array) $exportedpreferences);
$this->assertEquals($value, (bool) $exportedpreferences->{$preference}->value);
$this->assertEquals(get_string($expectdescription, 'theme_boost'), $exportedpreferences->{$preference}->description);
}
}
+42
View File
@@ -0,0 +1,42 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
namespace theme_boost;
/**
* Unit tests for scss compilation.
*
* @package theme_boost
* @copyright 2016 onwards Ankit Agarwal
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class scss_test extends \advanced_testcase {
/**
* Test that boost can be compiled using SassC (the defacto implemention).
*/
public function test_scss_compilation_with_sassc(): void {
if (!defined('PHPUNIT_PATH_TO_SASSC')) {
$this->markTestSkipped('Path to SassC not provided');
}
$this->resetAfterTest();
set_config('pathtosassc', PHPUNIT_PATH_TO_SASSC);
$this->assertNotEmpty(
\theme_config::load('boost')->get_css_content_debug('scss', null, null)
);
}
}