Skip to content

Commit

Permalink
MDL-43838 behat: Clean theme compatibility with small and medium scre…
Browse files Browse the repository at this point in the history
…en sizes
  • Loading branch information
David Monllao committed Feb 3, 2014
1 parent 9788e26 commit 3688bd4
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 2 deletions.
35 changes: 34 additions & 1 deletion auth/tests/behat/behat_auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,45 @@ class behat_auth extends behat_base {
*/
public function i_log_in_as($username) {

return array(new Given('I am on homepage'),
// Running this step using the API rather than a chained step because
// we need to see if the 'Log in' link is available or we need to click
// the dropdown to expand the navigation bar before.
$this->getSession()->visit($this->locate_path('/'));

// Generic steps (we will prefix them later expanding the navigation dropdown if necessary).
$steps = array(
new Given('I follow "' . get_string('login') . '"'),
new Given('I fill in "' . get_string('username') . '" with "' . $this->escape($username) . '"'),
new Given('I fill in "' . get_string('password') . '" with "'. $this->escape($username) . '"'),
new Given('I press "' . get_string('login') . '"')
);

// If Javascript is disabled we have enough with these steps.
if (!$this->running_javascript()) {
return $steps;
}

// Wait for the homepage to be ready.
$this->getSession()->wait(self::TIMEOUT * 1000, self::PAGE_READY_JS);

// Checking if we need to click the navbar button to show the navigation menu, it
// is hidden by default when using clean theme and a medium or small size screen size.

// The DOM and the JS should be all ready and loaded. Running without spinning
// as this is a widely used step and we can not spend time here trying to see
// a DOM node that is not always there (at the moment clean is not even the
// default theme...).
$navbuttonjs = "return (
Y.one('.btn-navbar') &&
Y.one('.btn-navbar').getComputedStyle('display') !== 'none'
)";

// Adding an extra click we need to show the 'Log in' link.
if ($this->getSession()->getDriver()->evaluateScript($navbuttonjs)) {
array_unshift($steps, new Given('I click on ".btn-navbar" "css_element"'));
}

return $steps;
}

/**
Expand Down
8 changes: 7 additions & 1 deletion auth/tests/behat/login.feature
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,14 @@ Feature: Authentication
As a user
I need to log into the system

Scenario: Log in with the predefined admin user
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"

@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"

Scenario: Log in as an existing admin user filling the form
Given the following "users" exists:
Expand Down

0 comments on commit 3688bd4

Please sign in to comment.