mirror of
https://github.com/moodle/moodle.git
synced 2025-01-18 05:58:34 +01:00
MDL-82298 navigation: Update behat tests
This commit is contained in:
parent
35fd32ffb4
commit
1cc03ca6b9
@ -1632,7 +1632,7 @@ class behat_navigation extends behat_base {
|
||||
/**
|
||||
* Checks if a navigation menu item is active.
|
||||
*
|
||||
* @Given menu item :navigationmenuitem should be active
|
||||
* @Then menu item :navigationmenuitem should be active
|
||||
* @param string $navigationmenuitem The navigation menu item name.
|
||||
*/
|
||||
public function menu_item_should_be_active(string $navigationmenuitem): void {
|
||||
@ -1644,7 +1644,7 @@ class behat_navigation extends behat_base {
|
||||
/**
|
||||
* Checks if a navigation menu item is not active
|
||||
*
|
||||
* @Given menu item :navigationmenuitem should not be active
|
||||
* @Then menu item :navigationmenuitem should not be active
|
||||
* @param string $navigationmenuitem The navigation menu item name.
|
||||
*/
|
||||
public function menu_item_should_not_be_active(string $navigationmenuitem): void {
|
||||
@ -1656,16 +1656,27 @@ class behat_navigation extends behat_base {
|
||||
/**
|
||||
* Sets a link to no longer navigate when selected.
|
||||
*
|
||||
* @When I update the link with selector :selector to go nowhere
|
||||
* @param string $selector selector for link to go nowhere
|
||||
* @When /^I update the href of the "(?P<locator_string>[^"]*)" "(?P<selector_string>[^"]*)" link to "(?P<href_string>[^"]*)"$/
|
||||
* @param string $locator The locator to use
|
||||
* @param string $selector selector type
|
||||
* @param string $href The value
|
||||
*/
|
||||
public function i_update_the_link_to_go_nowhere(string $selector) {
|
||||
public function i_update_the_link_to_go_nowhere(
|
||||
string $locator,
|
||||
string $selector,
|
||||
string $href,
|
||||
): void {
|
||||
$this->require_javascript();
|
||||
$xpath = $this->find(
|
||||
selector: $selector,
|
||||
locator: $locator,
|
||||
)->getXpath();
|
||||
$script = <<<JS
|
||||
var result = document.evaluate("$selector", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null);
|
||||
var result = document.evaluate("{$xpath}", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null);
|
||||
var link = result.singleNodeValue;
|
||||
|
||||
if (link) {
|
||||
link.setAttribute('href', '#');
|
||||
link.setAttribute('href', '{$href}');
|
||||
} else {
|
||||
throw new Error('No element found with the XPath: ' + "$selector");
|
||||
}
|
||||
|
@ -69,10 +69,10 @@ Feature: Menu navigation has accurate checkmarks in single activity course forma
|
||||
Scenario: Admin should not see checkmark if link is not navigated to in current browser for single activity format quiz
|
||||
Given I log in as "admin"
|
||||
And I am on "Course 1" course homepage
|
||||
And I update the link with selector "//*//a/following-sibling::*//a[contains(text(), 'Participants')]" to go nowhere
|
||||
And I update the href of the "//*//a/following-sibling::*//a[contains(text(), 'Participants')]" "xpath" link to "#"
|
||||
When I navigate to "Participants" in current page administration
|
||||
Then menu item "Participants" should not be active
|
||||
And I update the link with selector "//*//a/following-sibling::*//a[contains(text(), 'Backup')]" to go nowhere
|
||||
And I update the href of the "//*//a/following-sibling::*//a[contains(text(), 'Backup')]" "xpath" link to "#"
|
||||
When I click on "//*//a[contains(text(),'Activity')]" "xpath"
|
||||
And I click on "//*//a/following-sibling::*//a[contains(text(), 'Backup')]" "xpath"
|
||||
Then menu item "Backup" should not be active
|
||||
|
@ -78,7 +78,7 @@ Feature: Menu navigation has accurate checkmarks in topic course format
|
||||
Scenario: Admin should not see checkmark if link is not navigated to in current browser in course view for topics format
|
||||
Given I log in as "admin"
|
||||
And I am on "Course 1" course homepage
|
||||
And I update the link with selector "//*//a/following-sibling::*//a[contains(text(), 'Filters')]" to go nowhere
|
||||
And I update the href of the "//*//a/following-sibling::*//a[contains(text(), 'Filters')]" "xpath" link to "#"
|
||||
And I navigate to "Question bank" in current page administration
|
||||
Then menu item "Filters" should not be active
|
||||
|
||||
@ -87,6 +87,6 @@ Feature: Menu navigation has accurate checkmarks in topic course format
|
||||
Given I log in as "admin"
|
||||
And I am on "Course 1" course homepage
|
||||
And I follow "Quiz 1"
|
||||
And I update the link with selector "//*//a/following-sibling::*//a[contains(text(), 'Backup')]" to go nowhere
|
||||
And I update the href of the "//*//a/following-sibling::*//a[contains(text(), 'Backup')]" "xpath" link to "#"
|
||||
And I navigate to "Backup" in current page administration
|
||||
Then menu item "Backup" should not be active
|
||||
|
Loading…
x
Reference in New Issue
Block a user