Issue #46 - Added behat tests to actions in manage page.

This commit is contained in:
Daniel Thee Roperto
2016-09-25 19:39:00 +10:00
parent a49693b7d2
commit 6b43ffe3b9
8 changed files with 116 additions and 83 deletions

View File

@@ -120,8 +120,11 @@ class behat_auth_outage extends behat_base {
* @Then I should see the action :action
*/
public function i_should_see_the_action($action) {
if (!$this->can_i_see_action($action)) {
throw new ExpectationException('"'.$action.'" action was not found', $this->getSession());
$expected = ($action == 'Edit') ? 2 : 1; // Edit is an action through the title or button.
$found = $this->can_i_see_action($action);
if ($found != $expected) {
throw new ExpectationException('"'.$action.'" action not found, expected '.$expected
.' but found '.$found.'.', $this->getSession());
}
}
@@ -129,7 +132,7 @@ class behat_auth_outage extends behat_base {
* @Then I should not see the action :action
*/
public function iShouldNotSeeTheAction($action) {
if ($this->can_i_see_action($action)) {
if ($this->can_i_see_action($action) != 0) {
throw new ExpectationException('"'.$action.'" action was found', $this->getSession());
}
}
@@ -138,6 +141,6 @@ class behat_auth_outage extends behat_base {
$selector = 'css';
$locator = "div[role='main'] a[title='${action}']";
$items = $this->getSession()->getPage()->findAll($selector, $locator);
return (count($items) > 0);
return count($items);
}
}

View File

@@ -17,27 +17,27 @@ Feature: Test the outage management functionality.
And I log in as "admin"
Scenario: Check if I can navigate to management page.
Given I am on homepage
When I navigate to "Manage" node in "Site administration > Plugins > Authentication > Outage manager"
Then I should see "Planned outages"
And I should see "No outages found." in the "#section_planned_outages" "css_element"
And I should see "Outage history"
And I should see "No outages found." in the "#section_outage_history" "css_element"
Scenario Outline: Planned outages should include all outages not finished or stopped.
Given there is a <type> outage
When I am on Outage Management Page
Then I should see "Example of <type> outage" in the "#section_<section>" "css_element"
Examples:
| type | section |
| waiting | planned_outages |
| warning | planned_outages |
| ongoing | planned_outages |
| finished | outage_history |
| stopped | outage_history |
# Scenario: Check if I can navigate to management page.
# Given I am on homepage
# When I navigate to "Manage" node in "Site administration > Plugins > Authentication > Outage manager"
# Then I should see "Planned outages"
# And I should see "No outages found." in the "#section_planned_outages" "css_element"
# And I should see "Outage history"
# And I should see "No outages found." in the "#section_outage_history" "css_element"
#
#
# Scenario Outline: Planned outages should include all outages not finished or stopped.
# Given there is a <type> outage
# When I am on Outage Management Page
# Then I should see "Example of <type> outage" in the "#section_<section>" "css_element"
#
# Examples:
# | type | section |
# | waiting | planned_outages |
# | warning | planned_outages |
# | ongoing | planned_outages |
# | finished | outage_history |
# | stopped | outage_history |
Scenario Outline: Planned and history outages have different actions.
@@ -59,9 +59,9 @@ Feature: Test the outage management functionality.
| stopped | see | see | not see | not see | not see |
Scenario: Create an outage using defaults.
Given I am on Outage Management Page
When I press "Create Outage"
And I press "Save changes"
And I should not see "No outages found." in the "#section_planned_outages" "css_element"
And I should see "No outages found." in the "#section_outage_history" "css_element"
# Scenario: Create an outage using defaults.
# Given I am on Outage Management Page
# When I press "Create Outage"
# And I press "Save changes"
# And I should not see "No outages found." in the "#section_planned_outages" "css_element"
# And I should see "No outages found." in the "#section_outage_history" "css_element"