-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adds test coverage for back-to-top button.
- Loading branch information
1 parent
b48c427
commit d888930
Showing
2 changed files
with
99 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
<?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/>. | ||
|
||
/** | ||
* Theme UCSF - General custom Behat rules | ||
* | ||
* @package theme_ucsf | ||
* @copyright The Regents of the University of California | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
|
||
require_once(__DIR__.'/../../../../lib/behat/behat_base.php'); | ||
|
||
|
||
/** | ||
* Class behat_theme_ucsf_base_general | ||
* | ||
* @package theme_ucsf | ||
* @copyright The Regents of the University of California | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
class behat_theme_ucsf_base_general extends behat_base { | ||
|
||
/** | ||
* Resets the theme cache. | ||
* @Given /^the theme cache has been reset$/ | ||
*/ | ||
public function theme_reset_all_caches() { | ||
theme_reset_all_caches(); | ||
} | ||
|
||
/** | ||
* Purges theme cache and reloads the theme | ||
* @copyright 2022 Alexander Bias, lern.link GmbH <[email protected]> | ||
* @see https://github.com/moodle-an-hochschulen/moodle-theme_boost_union | ||
* @Given /^the theme cache is purged and the theme is reloaded$/ | ||
*/ | ||
public function purge_theme_cache_and_reload_theme() { | ||
theme_reset_all_caches(); | ||
} | ||
|
||
/** | ||
* Scroll the page to a given coordinate. | ||
* | ||
* @copyright 2016 Shweta Sharma on https://stackoverflow.com/a/39613869. | ||
* @Then /^I scroll page to x "(?P<posx_number>\d+)" y "(?P<posy_number>\d+)"$/ | ||
* @param string $posx The x coordinate to scroll to. | ||
* @param string $posy The y coordinate to scroll to. | ||
* @return void | ||
* @throws Exception | ||
*/ | ||
public function i_scroll_page_to_x_y_coordinates_of_page($posx, $posy) { | ||
try { | ||
$this->getSession()->executeScript("(function(){window.scrollTo($posx, $posy);})();"); | ||
} catch (Exception) { | ||
throw new Exception("Scrolling the page to given coordinates failed"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
@theme @theme_ucsf @theme_ucsf_backtotop | ||
Feature: Back-to-top button | ||
Background: | ||
Given the following "users" exist: | ||
| username | | ||
| student1 | | ||
And the following "courses" exist: | ||
| fullname | shortname | | ||
| Course 1 | C1 | | ||
And the following "course enrolments" exist: | ||
| user | course | role | | ||
| student1 | C1 | student | | ||
|
||
@javascript | ||
Scenario: Back-to-top button - is visible and works | ||
Given the theme cache is purged and the theme is reloaded | ||
When I log in as "student1" | ||
And I am on "Course 1" course homepage | ||
Then "#back-to-top" "css_element" should exist | ||
And "#page-footer" "css_element" should appear before "#back-to-top" "css_element" | ||
And "#back-to-top" "css_element" should not be visible | ||
And I scroll page to x "0" y "250" | ||
And "#back-to-top" "css_element" should be visible | ||
And I click on "#back-to-top" "css_element" | ||
# Then I wait 1 second as the scroll up process is animated | ||
And I wait "1" seconds | ||
And "#back-to-top" "css_element" should not be visible |