mirror of
https://github.com/moodle/moodle.git
synced 2025-08-09 19:06:41 +02:00
MDL-45320 behat: Step definitions for blocks
This commit is contained in:
parent
e3353f92fc
commit
a33bc20d2e
5 changed files with 24 additions and 38 deletions
|
@ -83,13 +83,13 @@ class behat_blocks extends behat_base {
|
||||||
public function i_open_the_blocks_action_menu($blockname) {
|
public function i_open_the_blocks_action_menu($blockname) {
|
||||||
|
|
||||||
if (!$this->running_javascript()) {
|
if (!$this->running_javascript()) {
|
||||||
throw new DriverException('Blocks action menu not available when Javascript is disabled');
|
// Action menu does not need to be open if Javascript is off.
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If it is already opened we do nothing.
|
// If it is already opened we do nothing.
|
||||||
$blocknode = $this->get_block_node($blockname);
|
$blocknode = $this->get_text_selector_node('block', $blockname);
|
||||||
$classes = array_flip(explode(' ', $blocknode->getAttribute('class')));
|
if ($blocknode->hasClass('action-menu-shown')) {
|
||||||
if (!empty($classes['action-menu-shown'])) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -97,18 +97,18 @@ class behat_blocks extends behat_base {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the DOM node of the block from <div>.
|
* Clicks on Configure block for specified block. Page must be in editing mode.
|
||||||
*
|
*
|
||||||
* @throws ElementNotFoundException Thrown by behat_base::find
|
* Argument block_name may be either the name of the block or CSS class of the block.
|
||||||
* @param string $blockname The block name
|
*
|
||||||
* @return NodeElement
|
* @Given /^I configure the "(?P<block_name_string>(?:[^"]|\\")*)" block$/
|
||||||
|
* @param string $blockname
|
||||||
*/
|
*/
|
||||||
protected function get_block_node($blockname) {
|
public function i_configure_the_block($blockname) {
|
||||||
|
// Note that since $blockname may be either block name or CSS class, we can not use the exact label of "Configure" link.
|
||||||
$blockname = $this->getSession()->getSelectorsHandler()->xpathLiteral($blockname);
|
return array(
|
||||||
$xpath = "//div[contains(concat(' ', normalize-space(@class), ' '), ' block ')][contains(., $blockname)]";
|
new Given('I open the "'.$this->escape($blockname).'" blocks action menu'),
|
||||||
|
new Given('I click on "Configure" "link" in the "'.$this->escape($blockname).'" "block"')
|
||||||
return $this->find('xpath', $xpath);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,6 @@ Feature: Add and configure blocks throughout the site
|
||||||
As a manager
|
As a manager
|
||||||
I need to set and configure blocks throughout the site
|
I need to set and configure blocks throughout the site
|
||||||
|
|
||||||
@javascript
|
|
||||||
Scenario: Add and configure a block throughtout the site
|
Scenario: Add and configure a block throughtout the site
|
||||||
Given the following "courses" exists:
|
Given the following "courses" exists:
|
||||||
| fullname | shortname | category |
|
| fullname | shortname | category |
|
||||||
|
@ -18,8 +17,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 open the "Comments" blocks action menu
|
And I configure the "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 |
|
||||||
And I press "Save changes"
|
And I press "Save changes"
|
||||||
|
@ -27,8 +25,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 open the "Comments" blocks action menu
|
And I configure the "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) |
|
||||||
And I press "Save changes"
|
And I press "Save changes"
|
||||||
|
|
|
@ -39,19 +39,16 @@ 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 configure the "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 |
|
||||||
And I press "Save changes"
|
And I press "Save changes"
|
||||||
|
|
||||||
@javascript
|
|
||||||
Scenario: Block settings can be modified so that a block apprears on any page
|
Scenario: Block settings can be modified so that a block apprears on any page
|
||||||
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 configure the "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 |
|
||||||
And I press "Save changes"
|
And I press "Save changes"
|
||||||
|
@ -59,11 +56,9 @@ Feature: Block appearances
|
||||||
And I follow "Test survey name"
|
And I follow "Test survey name"
|
||||||
And I should not see "Comments"
|
And I should not see "Comments"
|
||||||
|
|
||||||
@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 configure the "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 |
|
||||||
And I press "Save changes"
|
And I press "Save changes"
|
||||||
|
@ -72,8 +67,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 configure the "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 |
|
||||||
| Region | Right |
|
| Region | Right |
|
||||||
|
|
|
@ -15,7 +15,6 @@ Feature: Allowed blocks controls
|
||||||
| user | course | role |
|
| user | course | role |
|
||||||
| teacher1 | C1 | editingteacher |
|
| teacher1 | C1 | editingteacher |
|
||||||
|
|
||||||
@javascript
|
|
||||||
Scenario: Blocks can be added with the default permissions
|
Scenario: Blocks can be added with the default permissions
|
||||||
Given I log in as "teacher1"
|
Given I log in as "teacher1"
|
||||||
And I follow "Course 1"
|
And I follow "Course 1"
|
||||||
|
|
|
@ -4,7 +4,6 @@ Feature: The context of a block can always be returned to it's original state.
|
||||||
As an admin
|
As an admin
|
||||||
I need to be able to return the block to original state
|
I need to be able to return the block to original state
|
||||||
|
|
||||||
@javascript
|
|
||||||
Scenario: Add and configure a block to display on every page and revert back
|
Scenario: Add and configure a block to display on every page and revert back
|
||||||
Given the following "courses" exists:
|
Given the following "courses" exists:
|
||||||
| fullname | shortname | category |
|
| fullname | shortname | category |
|
||||||
|
@ -15,8 +14,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 open the "Tags" blocks action menu
|
And I configure the "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 |
|
||||||
And I press "Save changes"
|
And I press "Save changes"
|
||||||
|
@ -25,8 +23,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 open the "Tags" blocks action menu
|
And I configure the "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 |
|
||||||
And I press "Save changes"
|
And I press "Save changes"
|
||||||
|
@ -41,8 +38,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 open the "Tags" blocks action menu
|
And I configure the "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 |
|
||||||
And I press "Save changes"
|
And I press "Save changes"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue