MDL-44440 behat: Other fixes to make clean work properly

- Update the step to follow links inside a treeview
  to work also when JS is disabled.
- Make regions accept header and footer.
- Change some locators refering to non-clean compatible
  regions.
- Restricting click to the table row in forum tracking
  because seems to conflict with the navigation bar when
  using narrow window sizes.
This commit is contained in:
David Monllao 2014-02-24 18:14:57 +08:00
parent 26fb3f5b71
commit 370e88d4fe
8 changed files with 27 additions and 21 deletions

View File

@ -40,7 +40,7 @@ Feature: Page contents assertions
And I log in as "admin"
And I follow "Course 1"
When I dock "Administration" block
Then I should not see "Question bank" in the "region-pre" "region"
Then I should not see "Question bank" in the ".block-region" "css_element"
And I click on "//div[@id='dock']/descendant::h2[normalize-space(.)='Administration']" "xpath_element"
@javascript
@ -50,4 +50,4 @@ Feature: Page contents assertions
| Course 1 | C1 | 0 |
And I log in as "admin"
When I dock "Administration" block
Then I should not see "Turn editing on" in the "region-pre" "region"
Then I should not see "Turn editing on" in the ".block-region" "css_element"

View File

@ -7,8 +7,7 @@ Feature: Forms manipulation
@javascript
Scenario: Basic forms manipulation
Given I log in as "admin"
And I follow "Admin User"
And I follow "Edit profile"
And I navigate to "Edit profile" node in "My profile settings"
When I set the field "First name" to "Field value"
And I set the field "Text editor" to "Plain text area"
And I set the field "Unmask" to "1"

View File

@ -10,8 +10,7 @@ Feature: Transform steps arguments
| fullname | shortname | category |
| Course 1 | C1 | 0 |
And I log in as "admin"
And I follow "Admin User"
And I follow "Edit profile"
And I navigate to "Edit profile" node in "My profile settings"
Scenario: Use nasty strings on steps arguments
When I set the field "Surname" to "$NASTYSTRING1"

View File

@ -6,12 +6,12 @@ Feature: Authentication
Scenario: Log in with the predefined admin user with Javascript disabled
Given I log in as "admin"
Then I should see "You are logged in as Admin User"
Then I should see "You are logged in as Admin User" in the "page-footer" "region"
@javascript
Scenario: Log in with the predefined admin user with Javascript enabled
Given I log in as "admin"
Then I should see "You are logged in as Admin User"
Then I should see "You are logged in as Admin User" in the "page-footer" "region"
Scenario: Log in as an existing admin user filling the form
Given the following "users" exists:
@ -22,7 +22,7 @@ Feature: Authentication
And I set the field "Username" to "testuser"
And I set the field "Password" to "testuser"
And I press "Log in"
Then I should see "You are logged in as"
Then I should see "You are logged in as" in the "page-footer" "region"
Scenario: Log in as an unexisting user filling the form
Given the following "users" exists:
@ -38,4 +38,4 @@ Feature: Authentication
Scenario: Log out
Given I log in as "admin"
When I log out
Then I should see "You are not logged in"
Then I should see "You are not logged in" in the "page-footer" "region"

View File

@ -89,7 +89,7 @@ XPATH
//div[contains(concat(' ', normalize-space(@class), ' '), concat(' ', %locator%, ' '))] | //div[contains(concat(' ', normalize-space(@class), ' '), ' block ')]/descendant::h2[normalize-space(.) = %locator%]/ancestor::div[contains(concat(' ', normalize-space(@class), ' '), ' block ')]
XPATH
, 'region' => <<<XPATH
.//*[self::div | self::section | self::aside][./@id = %locator%]
//*[self::div | self::section | self::aside | self::header | self::footer][./@id = %locator%]
XPATH
, 'table_row' => <<<XPATH
.//tr[contains(normalize-space(.), %locator%)]

View File

@ -200,8 +200,11 @@ class behat_navigation extends behat_base {
if ($node->hasClass('collapsed') || ($node->hasAttribute('data-loaded') && $node->getAttribute('data-loaded') == 0)) {
$xpath = "/p[contains(concat(' ', normalize-space(@class), ' '), ' tree_item ')]/span";
$nodetoexpand = $node->find('xpath', $xpath);
$this->ensure_node_is_visible($nodetoexpand);
$nodetoexpand->click();
if ($this->running_javascript()) {
$this->ensure_node_is_visible($nodetoexpand);
$nodetoexpand->click();
}
}
// If sub-parent nodes then get to the last one.
@ -214,8 +217,10 @@ class behat_navigation extends behat_base {
$xpath = "/p[contains(concat(' ', normalize-space(@class), ' '), ' tree_item ')]";
if ($node->hasClass('collapsed')) {
$nodetoexpand = $node->find('xpath', $xpath);
$this->ensure_node_is_visible($nodetoexpand);
$nodetoexpand->click();
if ($this->running_javascript()) {
$this->ensure_node_is_visible($nodetoexpand);
$nodetoexpand->click();
}
}
}
}
@ -227,12 +232,16 @@ class behat_navigation extends behat_base {
"/a[normalize-space(.)=" . $nodetextliteral . "]";
$node = $node->find('xpath', $xpath);
// Throw exxeption if no node found.
// Throw exception if no node found.
if (!$node) {
throw new ExpectationException('Navigation node "' . $nodetext . ' not found under "' . $parentnodes .
'" block', $this->getSession());
}
$this->ensure_node_is_visible($node);
if ($this->running_javascript()) {
$this->ensure_node_is_visible($node);
}
$node->click();
}
}

View File

@ -59,7 +59,7 @@ Feature: A teacher can set one of 3 possible options for tracking read forum pos
And I follow "Test forum name"
And I follow "Track unread posts"
And I wait to be redirected
And I follow "1"
And I click on "1" "link" in the "Admin User" "table_row"
And I follow "Course 1"
And I should not see "1 unread post"
@ -156,7 +156,7 @@ Feature: A teacher can set one of 3 possible options for tracking read forum pos
And I follow "Test forum name"
And I follow "Track unread posts"
And I wait to be redirected
And I follow "1"
And I click on "1" "link" in the "Admin User" "table_row"
And I follow "Course 1"
And I should not see "1 unread post"

View File

@ -10,8 +10,7 @@ Feature: Upload files
| fullname | shortname | category |
| Course 1 | C1 | 0 |
And I log in as "admin"
And I follow "Admin User"
And I follow "My private files"
And I navigate to "My private files" node in "My profile"
And I upload "lib/tests/fixtures/empty.txt" file to "Files" filemanager
Then I should see "1" elements in "Files" filemanager
And I should see "empty.txt" in the "div.fp-content" "css_element"