Skip to content

Commit

Permalink
WIP behat
Browse files Browse the repository at this point in the history
  • Loading branch information
cameron1729 committed Jul 29, 2024
1 parent 7d9b69e commit ca57348
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
16 changes: 16 additions & 0 deletions lib/tests/behat/behat_navigation.php
Original file line number Diff line number Diff line change
Expand Up @@ -1025,6 +1025,22 @@ protected function open_tab(string $name, string $jstarget): void {
$this->execute('behat_general::switch_to_window', [$name]);
}

/**
* @When I update the link with selector :selector to go nowhere
*/
public function i_update_the_link_to_go_nowhere(string $selector) {
$script = <<<JS
var link = document.querySelector('$selector');
if (link) {
link.setAttribute('href', '#');
} else {
throw new Error('No element found with the selector: $selector');
}
JS;

$this->getSession()->executeScript($script);
}

/**
* Opens the course homepage. (Consider using 'I am on the "shortname" "Course" page' step instead.)
*
Expand Down
15 changes: 15 additions & 0 deletions lib/tests/behat/moremenu.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
@core
Feature: Navigate using the browser back button
In order to easily navigate Moodle
As a user
Pressing the back button in the browser should result in accurate navigation menus

@javascript
Scenario: The active menu item check marks are consistent - topics format course
Given the following "courses" exist:
| fullname | shortname |
| Course 1 | C1 |
When I am on the "Course 1" course page logged in as "admin"
And I update the link with selector 'li[data-key="questionbank"] > a' to go nowhere
And I navigate to "Question bank" in current page administration
Then "li[data-key='questionbank'] > a[aria-current='true']" "css_element" should not exist

0 comments on commit ca57348

Please sign in to comment.