Commit 392367c4 authored by Marina Glancy's avatar Marina Glancy
Browse files

MDL-56586 behat: fix behat tests to work with new add block

parent 0d9d55a3
......@@ -27,6 +27,7 @@ Feature: Import course's contents into another course
| Description | Test forum description |
And I add the "Comments" block
And I add the "Recent blog entries" block
And I turn editing mode off
When I import "Course 1" course into "Course 2" course using this options:
Then I should see "Test database name"
And I should see "Test forum name"
......
......@@ -26,7 +26,6 @@ Feature: Option to include groups and groupings when importing a course to anoth
| Grouping 2 | C1 | GROUPING2 |
And I log in as "teacher1"
And I follow "Course 1"
And I turn editing mode on
Scenario: Include groups and groupings when importing a course to another course
Given I import "Course 1" course into "Course 2" course using this options:
......
......@@ -113,4 +113,24 @@ class behat_blocks extends behat_base {
array("Configure", "link", $this->escape($blockname), "block")
);
}
/**
* Ensures that block can be added to the page but does not actually add it.
*
* @Then /^the add block selector should contain "(?P<block_name_string>(?:[^"]|\\")*)" block$/
* @param string $blockname
*/
public function the_add_block_selector_should_contain_block($blockname) {
$this->execute('behat_forms::the_select_box_should_contain', [get_string('addblock'), $blockname]);
}
/**
* Ensures that block can not be added to the page.
*
* @Then /^the add block selector should not contain "(?P<block_name_string>(?:[^"]|\\")*)" block$/
* @param string $blockname
*/
public function the_add_block_selector_should_not_contain_block($blockname) {
$this->execute('behat_forms::the_select_box_should_not_contain', [get_string('addblock'), $blockname]);
}
}
......@@ -38,5 +38,5 @@ Feature: Allowed blocks controls
When I log in as "teacher1"
And I follow "Course 1"
And I turn editing mode on
Then the "Add a block" select box should not contain "Activities"
And the "Add a block" select box should not contain "Course completion status"
Then the add block selector should not contain "Activities" block
And the add block selector should not contain "Course completion status" block
......@@ -121,7 +121,7 @@ Feature: Test category management actions
And I click on "Back to Category: Cat 1" "link"
# Redirect
And I should see the "Course categories and courses" management page
And I should see "Cat 1" in the "#course-listing h3" "css_element"
And "Cat 1" "link" should exist in the "#category-listing" "css_element"
Scenario: Test I can set access permissions for a category through the management interface.
Given the following "categories" exist:
......
......@@ -20,10 +20,10 @@ Feature: Restrict which blocks can be added to Dashboard
And I log in as "student1"
And I click on "Dashboard" "link" in the "Navigation" "block"
And I press "Customise this page"
Then the "Add a block" select box should contain "Comments"
And the "Add a block" select box should contain "Courses"
And the "Add a block" select box should contain "HTML"
And the "Add a block" select box should contain "Tags"
Then the add block selector should contain "Comments" block
And the add block selector should contain "Courses" block
And the add block selector should contain "HTML" block
And the add block selector should contain "Tags" block
Scenario: Remove the ability to add the comments block to Dashboard
When I log in as "admin"
......@@ -35,7 +35,7 @@ Feature: Restrict which blocks can be added to Dashboard
And I log in as "student1"
And I click on "Dashboard" "link" in the "Navigation" "block"
And I press "Customise this page"
Then the "Add a block" select box should not contain "Comments"
And the "Add a block" select box should not contain "Courses"
And the "Add a block" select box should not contain "HTML"
And the "Add a block" select box should contain "Tags"
Then the add block selector should not contain "Comments" block
And the add block selector should not contain "Courses" block
And the add block selector should not contain "HTML" block
And the add block selector should contain "Tags" block
......@@ -65,4 +65,30 @@ class behat_theme_boost_behat_blocks extends behat_blocks {
);
}
public function the_add_block_selector_should_contain_block($blockname) {
$this->execute('behat_navigation::i_select_from_flat_navigation_drawer', get_string('addblock'));
$cancelstr = get_string('cancel');
if (!$this->running_javascript()) {
$this->execute('behat_general::should_exist_in_the', [$blockname, 'link', '#region-main', 'css_element']);
$this->execute('behat_general::i_click_on_in_the', [$cancelstr, 'link', '#region-main', 'css_element']);
} else {
$this->execute('behat_general::should_exist_in_the', [$blockname, 'link', '.modal-body', 'css_element']);
$this->execute('behat_general::i_click_on_in_the', [$cancelstr, 'link', '.modal-body', 'css_element']);
}
}
public function the_add_block_selector_should_not_contain_block($blockname) {
$this->execute('behat_navigation::i_select_from_flat_navigation_drawer', get_string('addblock'));
$cancelstr = get_string('cancel');
if (!$this->running_javascript()) {
$this->execute('behat_general::should_not_exist_in_the', [$blockname, 'link', '#region-main', 'css_element']);
$this->execute('behat_general::i_click_on_in_the', [$cancelstr, 'link', '#region-main', 'css_element']);
} else {
$this->execute('behat_general::should_not_exist_in_the', [$blockname, 'link', '.modal-body', 'css_element']);
$this->execute('behat_general::i_click_on_in_the', [$cancelstr, 'link', '.modal-body', 'css_element']);
}
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment