Commit ff8ca5d3 authored by Son Nguyen's avatar Son Nguyen

Implement behat fixture for clicking link/button in a specified row

Bug 1403238

Change-Id: I5bd36d08054bd7a5146bd49732f308c3c5dbe298
Signed-off-by: default avatarSon Nguyen <son.nguyen@catalyst.net.nz>
parent b4b8463c
......@@ -103,6 +103,7 @@ class BehatBase extends Behat\MinkExtension\Context\RawMinkContext {
// With named selectors we can be more specific.
if ($selector == 'named') {
$selector = $selector . '_partial';
$exceptiontype = $locator[0];
$exceptionlocator = $locator[1];
......
......@@ -318,19 +318,23 @@ class BehatGeneral extends BehatBase {
}
/**
* Click on the link or button inside a table row containing the specified text.
* Click on the link or button inside a list/table row containing the specified text.
*
* @When /^I click on "(?P<link_or_button>(?:[^"]|\\")*)" in the "(?P<row_text_string>(?:[^"]|\\")*)" table row$/
* @When /^I click on "(?P<link_or_button>(?:[^"]|\\")*)" in "(?P<row_text_string>(?:[^"]|\\")*)" row$/
* @param string $link_or_button we look for
* @param string $tablerowtext The table row text
* @param string $rowtext The list/table row text
* @throws ElementNotFoundException
*/
public function i_click_on_in_the_table_row($link_or_button, $tablerowtext) {
public function i_click_on_in_row($link_or_button, $rowtext) {
// The table row container.
$nocontainerexception = new ElementNotFoundException($this->getSession(), '"' . $tablerowtext . '" row text ');
$tablerowtext = $this->getSession()->getSelectorsHandler()->xpathLiteral($tablerowtext);
$rownode = $this->find('xpath', "//tr[contains(., $tablerowtext)]", $nocontainerexception);
$rowtextliteral = $this->getSession()->getSelectorsHandler()->xpathLiteral($rowtext);
$exception = new ElementNotFoundException($this->getSession(), 'text', null, 'the row containing the text "' . $rowtext . '"');
$xpath = "//div[contains(concat(' ', normalize-space(@class), ' '), concat(' ', 'listrow', ' '))" .
" and contains(normalize-space(.), " . $rowtextliteral . ")]" .
"|" .
"//tr[contains(normalize-space(.), " . $rowtextliteral . ")]";
$rownode = $this->find('xpath', $xpath, $exception);
// Looking for the element DOM node inside the specified row.
list($selector, $locator) = $this->transform_selector('link_or_button', $link_or_button);
......
......@@ -87,7 +87,7 @@ XPATH
, 'filemanager' => <<<XPATH
//div[contains(concat(' ', normalize-space(@class), ' '), ' ffilemanager ')]/descendant::input[@id = //label[contains(normalize-space(string(.)), %locator%)]/@for]
XPATH
);
);
/**
* Returns the behat selector and locator for a given mahara selector and locator
......
......@@ -26,9 +26,12 @@ Feature: Mahara users can manage their pages
| Site Page 01 | This is the page 01 of the site | institution | mahara |
| Institution Page 01 | This is the page 01 of the Institution One| institution | instone |
| Group Page 01 | This is the page 01 of the group 01 | group | group 01 |
Scenario: List my portfolio pages
Scenario: List and edit my portfolio pages
Given I log in as "userD" with password "Password1"
When I go to "view/index.php"
And I wait "1" seconds
Then I should see "Page 01"
And I should see "Page 02"
\ No newline at end of file
And I should see "Page 02"
And I click on "Edit content and layout" in "Page 01" row
And I wait "1" seconds
And I should see "Edit content"
\ No newline at end of file
@javascript @core @page @share
Feature: Mahara users can share their pages
As a mahara user/admin
I can share my pages to others and see shared pages from others
Background:
Given the following "institutions" exist:
| name | displayname | registerallowed | registerconfirm |
| instone | Institution One | ON | OFF |
| insttwo | Institution Two | ON | OFF |
And the following "users" exist:
| username | password | email | firstname | lastname | institution | authname | role |
| userA | Password1 | test01@example.com | Pete | Mc | mahara | internal | admin |
| userB | Password1 | test02@example.com | Son | Nguyen | instone | internal | admin |
| userC | Password1 | test03@example.com | Jack | Smith | insttwo | internal | staff |
| userD | Password1 | test04@example.com | Eden | Wilson | mahara | internal | member |
And the following "groups" exist:
| name | owner | description | grouptype | open | invitefriends | editroles | submittableto | allowarchives | members | staff |
| group 01 | userA | This is group 01 | standard | ON | ON | all | ON | ON | userB, userC | userD |
And the following "pages" exist:
| title | description| ownertype | ownername |
| D's Page 01 | UserD's page 01 | user | userD |
| D's Page 02 | UserD's page 02 | user | userD |
| A's Page 01 | UserA's page 01 | user | userA |
| B's Page 02 | UserB's page 02 | user | userB |
Scenario: Share pages
Given I log in as "userD" with password "Password1"
When I go to "view/share.php"
Then I should see "D's Page 01"
And I should see "D's Page 02"
And I click on "Edit access" in "D's Page 01" row
And I wait "1" seconds
And I should see "Edit access"
\ No newline at end of file
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