Commit fe7a0634 authored by Son Nguyen's avatar Son Nguyen Committed by Robert Lyon
Browse files

Implement the step: 'I configure the block "Block title"'

and 'I delete the block "Block title"'

Change-Id: I88359a315350d2b196c56d98fe5ba417cff8b12f
parent 09328e49
<?php
/**
* @package mahara
* @subpackage test/behat
* @author Son Nguyen, Catalyst IT Ltd
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL version 3 or later
* @copyright For copyright information on Mahara, please see the README file distributed with this software.
* @copyright portions from Moodle Behat, 2013 David Monllaó
*
*/
/**
* Steps definitions for Mahara views(pages)
*
*/
require_once(__DIR__ . '/BehatBase.php');
use Behat\Mink\Exception\ElementNotFoundException as ElementNotFoundException;
/**
* Mahara view/page interactive step definitions
*
*/
class BehatView extends BehatBase {
/**
* Helper function to get the block div.
*
* @throws ElementNotFoundException if node not found.
* @param string $blocktitle the title of the block e.g. "About me", "My pages".
* @return NodeElement
*/
protected function get_block($blocktitle) {
// Avoid problems with quotes.
$nodetextliteral = $this->escaper->escapeLiteral($blocktitle);
$exception = new ElementNotFoundException($this->getSession(),
'The block "' . $blocktitle . '"');
$xpath = "//div[@id='column-container']"
. "//div[contains(concat(' ', normalize-space(@class), ' '), concat(' ', 'blockinstance', ' '))]"
. "//div[contains(concat(' ', normalize-space(@class), ' '), concat(' ', 'blockinstance-header', ' '))]"
. "/h2[normalize-space(.)=" . $nodetextliteral . "]";
$titlenode = $this->find('xpath', $xpath, $exception);
$blocknode = $titlenode->getParent()->getParent();
return $blocknode;
}
/**
* Configure a block
*
* @throws ElementNotFoundException if not found.
* @Given /^I configure the block "(?P<block_title>(?:[^"]|\\")*)"$/
*/
public function i_configure_block($blocktitle) {
$block = $this->get_block($blocktitle);
$exception = new ElementNotFoundException($this->getSession(),
'The configuration div of block "' . $blocktitle . '"');
$blockconfigbutton = $this->find('xpath',
"/div[contains(concat(' ', normalize-space(@class), ' '), concat(' ', 'blockinstance-controls', ' '))]"
. "/input[contains(concat(' ', normalize-space(@class), ' '), concat(' ', 'configurebutton', ' '))]",
$exception,
$block
);
$blockconfigbutton->press();
}
/**
* Delete a block
*
* @throws ElementNotFoundException if not found.
* @Given /^I delete the block "(?P<block_title>(?:[^"]|\\")*)"$/
*/
public function i_delete_block($blocktitle) {
$block = $this->get_block($blocktitle);
$exception = new ElementNotFoundException($this->getSession(),
'The configuration div of block "' . $blocktitle . '"');
$blockconfigbutton = $this->find('xpath',
"/div[contains(concat(' ', normalize-space(@class), ' '), concat(' ', 'blockinstance-controls', ' '))]"
. "/input[contains(concat(' ', normalize-space(@class), ' '), concat(' ', 'deletebutton', ' '))]",
$exception,
$block
);
$blockconfigbutton->press();
}
}
\ No newline at end of file
......@@ -17,6 +17,7 @@ require_once(dirname(dirname(__DIR__)) . '/classes/BehatHooks.php');
require_once(dirname(dirname(__DIR__)) . '/classes/BehatGeneral.php');
require_once(dirname(dirname(__DIR__)) . '/classes/BehatNavigation.php');
require_once(dirname(dirname(__DIR__)) . '/classes/BehatForms.php');
require_once(dirname(dirname(__DIR__)) . '/classes/BehatView.php');
require_once(dirname(dirname(__DIR__)) . '/classes/BehatDataGenerators.php');
use Behat\Behat\Context\BehatContext,
......@@ -36,6 +37,7 @@ class BehatMaharaInitContext extends MinkContext {
$this->useContext('BehatGeneral', new BehatGeneral($parameters));
$this->useContext('BehatNavigation', new BehatNavigation($parameters));
$this->useContext('BehatForms', new BehatForms($parameters));
$this->useContext('BehatView', new BehatView($parameters));
$this->useContext('BehatDataGenerators', new BehatDataGenerators($parameters));
$this->useContext('mahara', new MaharaContext($parameters));
}
......
@javascript @core @core_group
@javascript @core @core_group @test
Feature: Displaying multiple groups on a page
In order to better organize the groups
As an admin create 10 groups
So I can limit the number of groups showing in mygroup display on the profile page
Background:
Given the following "users" exist:
| username | password | email | firstname | lastname | institution | authname | role |
| userA | Password1 | test01@example.com | Pete | Mc | mahara | internal | member |
And the following "groups" exist:
| name | owner | description | grouptype | open | invitefriends | editroles | submittableto | allowarchives | members | staff |
| Testing Group 1 | userA | This is group 01 | standard | ON | OFF | all | ON | ON | admin | |
| Testing Group 2 | userA | This is group 02 | standard | ON | OFF | all | ON | ON | admin | |
| Testing Group 3 | userA | This is group 03 | standard | ON | OFF | all | ON | ON | admin | |
| Testing Group 4 | userA | This is group 04 | standard | ON | OFF | all | ON | ON | admin | |
| Testing Group 5 | userA | This is group 05 | standard | ON | OFF | all | ON | ON | admin | |
| Testing Group 6 | userA | This is group 06 | standard | ON | OFF | all | ON | ON | admin | |
| Testing Group 7 | userA | This is group 07 | standard | ON | OFF | all | ON | ON | admin | |
| Testing Group 8 | userA | This is group 08 | standard | ON | OFF | all | ON | ON | admin | |
| Testing Group 9 | userA | This is group 09 | standard | ON | OFF | all | ON | ON | admin | |
| Testing Group 10 | userA | This is group 10 | standard | ON | OFF | all | ON | ON | admin | |
Scenario: Create groups and limit display on profile page (Bug 1426983)
# Log in as "Admin" User
Given I log in as "admin" with password "Password1"
# Log in as a normal user
Given I log in as "userA" with password "Password1"
# Verifying log in was successful
And I should see "Admin User"
And I should see "Pete"
# Creating several groups to test
When I follow "Groups"
And I choose "Groups"
And I follow "Create group"
And I fill in "Group name" with "Testing Group 1"
And I press "Save group"
And I follow "Groups"
And I follow "Create group"
And I fill in "Group name" with "Testing Group 2"
And I press "Save group"
And I follow "Groups"
And I follow "Create group"
And I fill in "Group name" with "Testing Group 3"
And I press "Save group"
And I follow "Groups"
And I follow "Create group"
And I fill in "Group name" with "Testing Group 4"
And I press "Save group"
And I follow "Groups"
And I follow "Create group"
And I fill in "Group name" with "Testing Group 5"
And I press "Save group"
And I follow "Groups"
And I follow "Create group"
And I fill in "Group name" with "Testing Group 6"
And I press "Save group"
And I follow "Groups"
And I follow "Create group"
And I fill in "Group name" with "Testing Group 7"
And I press "Save group"
And I follow "Groups"
And I follow "Create group"
And I fill in "Group name" with "Testing Group 8"
And I press "Save group"
And I follow "Groups"
And I follow "Create group"
And I fill in "Group name" with "Testing Group 9"
And I press "Save group"
And I follow "Groups"
And I follow "Create group"
And I fill in "Group name" with "Testing Group 10"
And I set the following fields to these values:
| Group name | Testing Group 11 |
And I fill in "This is group 11" in WYSIWYG editor "editgroup_description_ifr"
And I press "Save group"
# Changing the amount of groups seen in My groups block
Then I follow "Portfolio"
And I follow "Profile page"
And I follow "Edit this page"
And I press "Configure 'My groups' block (ID 16)"
And I configure the block "My groups"
And I fill in "Maximum number of groups to display" with "3"
And I press "Save"
And I press "Done"
And I follow "Profile page"
And I should see "10 groups"
\ No newline at end of file
And I should see "11 groups"
Markdown is supported
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