mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 16:36:37 +02:00
MDL-40975 Behat: Fix test failure with block menus
This commit is contained in:
parent
27e6dce63b
commit
b100c4e3a1
4 changed files with 48 additions and 5 deletions
|
@ -58,4 +58,43 @@ class behat_blocks extends behat_base {
|
||||||
return $steps;
|
return $steps;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Opens a block's actions menu if it is not already opened.
|
||||||
|
*
|
||||||
|
* @Given /^I open the "(?P<block_name_string>(?:[^"]|\\")*)" blocks action menu$/
|
||||||
|
* @throws DriverException The step is not available when Javascript is disabled
|
||||||
|
* @param string $blockname
|
||||||
|
* @return Given
|
||||||
|
*/
|
||||||
|
public function i_open_the_blocks_action_menu($blockname) {
|
||||||
|
|
||||||
|
if (!$this->running_javascript()) {
|
||||||
|
throw new DriverException('Blocks action menu not available when Javascript is disabled');
|
||||||
|
}
|
||||||
|
|
||||||
|
// If it is already opened we do nothing.
|
||||||
|
$blocknode = $this->get_block_node($blockname);
|
||||||
|
$classes = array_flip(explode(' ', $blocknode->getAttribute('class')));
|
||||||
|
if (!empty($classes['action-menu-shown'])) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
return new Given('I click on "a[role=\'menuitem\']" "css_element" in the "' . $this->escape($blockname) . '" "block"');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the DOM node of the block from <div>.
|
||||||
|
*
|
||||||
|
* @throws ElementNotFoundException Thrown by behat_base::find
|
||||||
|
* @param string $blockname The block name
|
||||||
|
* @return NodeElement
|
||||||
|
*/
|
||||||
|
protected function get_block_node($blockname) {
|
||||||
|
|
||||||
|
$blockname = $this->getSession()->getSelectorsHandler()->xpathLiteral($blockname);
|
||||||
|
$xpath = "//div[contains(concat(' ', normalize-space(@class), ' '), ' block ')][contains(., $blockname)]";
|
||||||
|
|
||||||
|
return $this->find('xpath', $xpath);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,7 @@ Feature: Add and configure blocks throughout the site
|
||||||
And I log in as "manager1"
|
And I log in as "manager1"
|
||||||
And I follow "Turn editing on"
|
And I follow "Turn editing on"
|
||||||
And I add the "Comments" block
|
And I add the "Comments" block
|
||||||
And I click on "Actions" "link" in the "Comments" "block"
|
And I open the "Comments" blocks action menu
|
||||||
And I follow "Configure Comments block"
|
And I follow "Configure Comments block"
|
||||||
And I fill the moodle form with:
|
And I fill the moodle form with:
|
||||||
| Page contexts | Display throughout the entire site |
|
| Page contexts | Display throughout the entire site |
|
||||||
|
@ -27,7 +27,7 @@ Feature: Add and configure blocks throughout the site
|
||||||
Then I should see "Comments" in the "Comments" "block"
|
Then I should see "Comments" in the "Comments" "block"
|
||||||
And I should see "Save comment" in the "Comments" "block"
|
And I should see "Save comment" in the "Comments" "block"
|
||||||
And I am on homepage
|
And I am on homepage
|
||||||
And I click on "Actions" "link" in the "Comments" "block"
|
And I open the "Comments" blocks action menu
|
||||||
And I follow "Configure Comments block"
|
And I follow "Configure Comments block"
|
||||||
And I fill the moodle form with:
|
And I fill the moodle form with:
|
||||||
| Default weight | -10 (first) |
|
| Default weight | -10 (first) |
|
||||||
|
|
|
@ -42,6 +42,7 @@ Feature: Block appearances
|
||||||
And I follow "Course 1"
|
And I follow "Course 1"
|
||||||
And I follow "Turn editing on"
|
And I follow "Turn editing on"
|
||||||
And I add the "Comments" block
|
And I add the "Comments" block
|
||||||
|
And I open the "Comments" blocks action menu
|
||||||
And I follow "Configure Comments block"
|
And I follow "Configure Comments block"
|
||||||
And I fill the moodle form with:
|
And I fill the moodle form with:
|
||||||
| Display on page types | Any page |
|
| Display on page types | Any page |
|
||||||
|
@ -52,6 +53,7 @@ Feature: Block appearances
|
||||||
When I follow "Test survey name"
|
When I follow "Test survey name"
|
||||||
Then I should see "Comments" in the "Comments" "block"
|
Then I should see "Comments" in the "Comments" "block"
|
||||||
And I follow "Course 1"
|
And I follow "Course 1"
|
||||||
|
And I open the "Comments" blocks action menu
|
||||||
And I follow "Configure Comments block"
|
And I follow "Configure Comments block"
|
||||||
And I fill the moodle form with:
|
And I fill the moodle form with:
|
||||||
| Display on page types | Any course page |
|
| Display on page types | Any course page |
|
||||||
|
@ -63,6 +65,7 @@ Feature: Block appearances
|
||||||
@javascript
|
@javascript
|
||||||
Scenario: Block settings can be modified so that a block can be hidden or moved
|
Scenario: Block settings can be modified so that a block can be hidden or moved
|
||||||
When I follow "Test book name"
|
When I follow "Test book name"
|
||||||
|
And I open the "Comments" blocks action menu
|
||||||
And I follow "Configure Comments block"
|
And I follow "Configure Comments block"
|
||||||
And I fill the moodle form with:
|
And I fill the moodle form with:
|
||||||
| Visible | No |
|
| Visible | No |
|
||||||
|
@ -72,6 +75,7 @@ Feature: Block appearances
|
||||||
Then I should not see "Comments"
|
Then I should not see "Comments"
|
||||||
And I expand "Course administration" node
|
And I expand "Course administration" node
|
||||||
And I follow "Turn editing on"
|
And I follow "Turn editing on"
|
||||||
|
And I open the "Comments" blocks action menu
|
||||||
And I follow "Configure Comments block"
|
And I follow "Configure Comments block"
|
||||||
And I fill the moodle form with:
|
And I fill the moodle form with:
|
||||||
| Visible | Yes |
|
| Visible | Yes |
|
||||||
|
|
|
@ -15,7 +15,7 @@ Feature: The context of a block can always be returned to it's original state.
|
||||||
And I add the "Tags" block
|
And I add the "Tags" block
|
||||||
Then I should see "Tags" in the "Tags" "block"
|
Then I should see "Tags" in the "Tags" "block"
|
||||||
And I click on "Participants" "link" in the "//li[p/span[contains(normalize-space(string(.)), 'Current course')]]" "xpath_element"
|
And I click on "Participants" "link" in the "//li[p/span[contains(normalize-space(string(.)), 'Current course')]]" "xpath_element"
|
||||||
And I click on "Actions" "link" in the "Tags" "block"
|
And I open the "Tags" blocks action menu
|
||||||
And I follow "Configure Tags block"
|
And I follow "Configure Tags block"
|
||||||
And I fill the moodle form with:
|
And I fill the moodle form with:
|
||||||
| Display on page types | Any page |
|
| Display on page types | Any page |
|
||||||
|
@ -25,7 +25,7 @@ Feature: The context of a block can always be returned to it's original state.
|
||||||
| Assignment name | Assignment1 |
|
| Assignment name | Assignment1 |
|
||||||
| Description | Description |
|
| Description | Description |
|
||||||
And I follow "Assignment1"
|
And I follow "Assignment1"
|
||||||
And I click on "Actions" "link" in the "Tags" "block"
|
And I open the "Tags" blocks action menu
|
||||||
And I follow "Configure Tags block"
|
And I follow "Configure Tags block"
|
||||||
And I fill the moodle form with:
|
And I fill the moodle form with:
|
||||||
| Display on page types | Any assignment module page |
|
| Display on page types | Any assignment module page |
|
||||||
|
@ -41,7 +41,7 @@ Feature: The context of a block can always be returned to it's original state.
|
||||||
| Description | Description |
|
| Description | Description |
|
||||||
And I follow "Assignment2"
|
And I follow "Assignment2"
|
||||||
And I should see "Tags" in the "Tags" "block"
|
And I should see "Tags" in the "Tags" "block"
|
||||||
And I click on "Actions" "link" in the "Tags" "block"
|
And I open the "Tags" blocks action menu
|
||||||
And I follow "Configure Tags block"
|
And I follow "Configure Tags block"
|
||||||
And I fill the moodle form with:
|
And I fill the moodle form with:
|
||||||
| Display on page types | Any page |
|
| Display on page types | Any page |
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue