MDL-42403 course: Added behat to check visibility of bluk move action

This commit is contained in:
Rajesh Taneja
2013-11-19 10:52:33 +08:00
parent a5888fb591
commit 3ea677e39a
2 changed files with 141 additions and 13 deletions
+43 -12
View File
@@ -946,7 +946,7 @@ class behat_course extends behat_base {
protected function get_management_category_listing_node_by_name($name, $link = false) {
$selector = "//div[@id='category-listing']//li[contains(concat(' ', normalize-space(@class), ' '), ' listitem-category ')]//a[text()='{$name}']";
if ($link === false) {
$selector .= "/ancestor::li[@data-id]";
$selector .= "/ancestor::li[@data-id][1]";
}
return $this->find('xpath', $selector);
}
@@ -1001,39 +1001,70 @@ class behat_course extends behat_base {
}
/**
* Clicks on a category checkbox in the management interface.
* Clicks on a category checkbox in the management interface, if not checked.
*
* @Given /^I select category "(?P<name>[^"]*)" in the management interface$/
* @param string $name
*/
public function i_select_category_in_the_management_interface($name) {
$node = $this->get_management_category_listing_node_by_name($name);
$node->checkField('bcat[]');
$node = $node->findField('bcat[]');
if (!$node->isChecked()) {
$node->click();
}
}
/**
* Clicks course checkbox in the management interface.
* Clicks on a category checkbox in the management interface, if checked.
*
* @Given /^I unselect category "(?P<name>[^"]*)" in the management interface$/
* @param string $name
*/
public function i_unselect_category_in_the_management_interface($name) {
$node = $this->get_management_category_listing_node_by_name($name);
$node = $node->findField('bcat[]');
if ($node->isChecked()) {
$node->click();
}
}
/**
* Clicks course checkbox in the management interface, if not checked.
*
* @Given /^I select course "(?P<name>[^"]*)" in the management interface$/
* @param string $name
*/
public function i_select_course_in_the_management_interface($name) {
$node = $this->get_management_course_listing_node_by_name($name);
$node->checkField('bc[]');
$node = $node->findField('bc[]');
if (!$node->isChecked()) {
$node->click();
}
}
/**
* Clicks course checkbox in the management interface, if checked.
*
* @Given /^I unselect course "(?P<name>[^"]*)" in the management interface$/
* @param string $name
*/
public function i_unselect_course_in_the_management_interface($name) {
$node = $this->get_management_course_listing_node_by_name($name);
$node = $node->findField('bc[]');
if ($node->isChecked()) {
$node->click();
}
}
/**
* Move selected categories to top level in the management interface.
*
* @Given /^I move category "(?P<idnumber>[^"]*)" to top level in the management interface$/
* @param string $idnumber
* @Given /^I move category "(?P<name>[^"]*)" to top level in the management interface$/
* @param string $name
* @return Given[]
*/
public function i_move_category_to_top_level_in_the_management_interface($idnumber) {
$id = $this->get_category_id($idnumber);
$selector = sprintf('.listitem-category[data-id="%d"] > div', $id);
$node = $this->find('css', $selector);
$node->checkField('bcat[]');
public function i_move_category_to_top_level_in_the_management_interface($name) {
$this->i_select_category_in_the_management_interface($name);
return array(
new Given('I select "' . coursecat::get(0)->get_formatted_name() . '" from "menumovecategoriesto"'),
new Given('I press "bulkmovecategories"'),
+98 -1
View File
@@ -231,7 +231,104 @@ Feature: Test category management actions
And I click on category "Cat 1" in the management interface
# Redirect
Then I should see category "CAT3" as subcategory of "CAT1" in the management interface
And I move category "CAT3" to top level in the management interface
And I move category "Cat 3" to top level in the management interface
# Redirect
And I should not see category "CAT3" as subcategory of "CAT1" in the management interface
Then I should see category "CAT2" as subcategory of "CAT1" in the management interface
@javascript
Scenario: Test bulk action is shown only when some category/course is selected
Given the following "categories" exists:
| name | category | idnumber |
| Cat 1 | 0 | CAT1 |
| Cat 2 | 0 | CAT2 |
| Cat 3 | 0 | CAT3 |
And the following "courses" exists:
| category | fullname | shortname | idnumber |
| CAT3 | Course 1 | Course 1 | C1 |
| CAT3 | Course 2 | Course 2 | C2 |
And I log in as "admin"
And I go to the courses management page
And I should see the "Course categories" management page
And I should see "Cat 1" in the "#category-listing ul.ml" "css_element"
And I should see "Cat 2" in the "#category-listing ul.ml" "css_element"
And I should see "Cat 3" in the "#category-listing ul.ml" "css_element"
And the "movecategoriesto" "select" should be disabled
And the "resortcategoriesby" "select" should be disabled
And the "resortcoursesby" "select" should be disabled
When I select "allcategories" from "selectsortby"
Then the "resortcategoriesby" "select" should be enabled
And the "resortcoursesby" "select" should be enabled
And the "movecategoriesto" "select" should be disabled
And I select category "Cat 2" in the management interface
And the "movecategoriesto" "select" should be enabled
And the "resortcategoriesby" "select" should be enabled
And the "resortcoursesby" "select" should be enabled
And I select "selectedcategories" from "selectsortby"
And the "movecategoriesto" "select" should be enabled
And the "resortcategoriesby" "select" should be enabled
And the "resortcoursesby" "select" should be enabled
And I unselect category "Cat 2" in the management interface
And the "movecategoriesto" "select" should be disabled
And the "resortcategoriesby" "select" should be disabled
And the "resortcoursesby" "select" should be disabled
And I select category "Cat 3" in the management interface
And the "movecategoriesto" "select" should be enabled
And the "resortcategoriesby" "select" should be enabled
And the "resortcoursesby" "select" should be enabled
And I select category "Cat 2" in the management interface
And the "movecategoriesto" "select" should be enabled
And the "resortcategoriesby" "select" should be enabled
And the "resortcoursesby" "select" should be enabled
And I unselect category "Cat 2" in the management interface
And I unselect category "Cat 3" in the management interface
And the "movecategoriesto" "select" should be disabled
And the "resortcategoriesby" "select" should be disabled
And the "resortcoursesby" "select" should be disabled
And I click on category "Cat 1" in the management interface
# Redirect.
And I should see the "Course categories and courses" management page
And the "movecategoriesto" "select" should be disabled
And the "resortcategoriesby" "select" should be disabled
And the "resortcoursesby" "select" should be disabled
And the "movecoursesto" "select" should be disabled
And I click on category "Cat 3" in the management interface
#Redirect
And I should see the "Course categories and courses" management page
And I should see "Course 1" in the "#course-listing ul.ml" "css_element"
And I should see "Course 2" in the "#course-listing ul.ml" "css_element"
And the "movecategoriesto" "select" should be disabled
And the "resortcategoriesby" "select" should be disabled
And the "resortcoursesby" "select" should be disabled
And the "movecoursesto" "select" should be disabled
And I select course "Course 1" in the management interface
And the "movecoursesto" "select" should be enabled
And the "movecategoriesto" "select" should be disabled
And the "resortcategoriesby" "select" should be disabled
And the "resortcoursesby" "select" should be disabled
And I select course "Course 2" in the management interface
And the "movecoursesto" "select" should be enabled
And the "movecategoriesto" "select" should be disabled
And the "resortcategoriesby" "select" should be disabled
And the "resortcoursesby" "select" should be disabled
And I select category "Cat 3" in the management interface
And the "movecoursesto" "select" should be enabled
And the "movecategoriesto" "select" should be enabled
And the "resortcategoriesby" "select" should be enabled
And the "resortcoursesby" "select" should be enabled
And I unselect course "Course 2" in the management interface
And the "movecoursesto" "select" should be enabled
And the "movecategoriesto" "select" should be enabled
And the "resortcategoriesby" "select" should be enabled
And the "resortcoursesby" "select" should be enabled
And I unselect course "Course 1" in the management interface
And the "movecoursesto" "select" should be disabled
And the "movecategoriesto" "select" should be enabled
And the "resortcategoriesby" "select" should be enabled
And the "resortcoursesby" "select" should be enabled
And I unselect category "Cat 3" in the management interface
And the "movecoursesto" "select" should be disabled
And the "movecategoriesto" "select" should be disabled
And the "resortcategoriesby" "select" should be disabled
And the "resortcoursesby" "select" should be disabled