Commit 1da9e692 authored by Rebecca Blundell's avatar Rebecca Blundell Committed by Robert Lyon

Bug 1752477: Behat test: image gallery block

-could be combined with nested_folders_images
-adding step to click a css selector without having to specify text
inside it
-also adding a properties step to call the above without passing
locators directly in feature files

Change-Id: I2b72e8c4d4506bbf24a37c64a4d3d27b0aad2aa4
(cherry picked from commit 173e04dc)
parent 67700a0c
......@@ -364,6 +364,21 @@ class BehatGeneral extends BehatBase {
$node->keyPress($key_press);
}
/**
* @Given I click on the :selector element
* @param string $selector - css selector
*/
public function i_click_on_the($selector) {
$page = $this->getSession()->getPage();
$element = $page->find('css', $selector);
if (empty($element)) {
throw new Exception("No html element found for the selector ('$selector')");
}
$element->click();
}
/**
* Click on the link or button which is located inside the second element.
*
......@@ -831,37 +846,46 @@ class BehatGeneral extends BehatBase {
* @param string $property
* @param string $location
*/
public function get_property_call_funct($step_funct, $text, $property, $location = null) {
$css_locator = get_property($property, $location);
// get_property returns null if locator not found
if (!$css_locator) {
public function get_property_call_funct($step_funct, $text, $property, $location = null) {
$css_locator = get_property($property, $location);
// get_property returns null if locator not found
if (!$css_locator) {
throw new ExpectationException('"A property called "' . $property . '" was not found in the properties.php file. Check that file or try passing a css locator directly"',
$this->getSession());
}
else {
// switch covers steps in BehatGeneral that pass a css_locator
switch ($step_funct) {
case "click on":
$funct = "i_click_on_in_the";
break;
case "follow":
$funct = "i_follow_in_the";
break;
case "press":
$funct = "i_press_in_the";
break;
case "should see":
$funct = "assert_element_contains_text";
break;
case "should not see":
$funct = "assert_element_not_contains_text";
break;
}
$this->$funct($text, $css_locator[0], $css_locator[1]);
}
}
}
else {
// switch covers steps in BehatGeneral that pass a css_locator
switch ($step_funct) {
case "click on":
$funct = "i_click_on_in_the";
break;
case "follow":
$funct = "i_follow_in_the";
break;
case "press":
$funct = "i_press_in_the";
break;
case "should see":
$funct = "assert_element_contains_text";
break;
case "should not see":
$funct = "assert_element_not_contains_text";
break;
}
$this->$funct($text, $css_locator[0], $css_locator[1]);
}
}
/**
/**
* @Given I click on the :property property
* @param string $property
*/
public function click_on_property($property) {
$property = get_property($property);
$this->i_click_on_the($property[0]);
}
/**
* @Then /^I should see "(?P<text_string>(?:[^"]|\\")*)" in the
* "(?P<property_string>(?:[^"]|\\")*)" property in "(?P<location_string>(?:[^"]|\\")*)"$/
* @param string $text
......@@ -870,14 +894,14 @@ class BehatGeneral extends BehatBase {
*/
public function should_see_property_in_location($text, $property, $location) {
$css_locator = get_property_in_location($property, $location);
if (!$css_locator) {
throw new ExpectationException('"A property called $property was not found in the properties.php file. Check that file or try passing a css locator directly"',
$this->getSession());
}
else {
$this->assert_element_contains_text($text, $css_locator[0], $css_locator[1]);
}
$css_locator = get_property_in_location($property, $location);
if (!$css_locator) {
throw new ExpectationException('"A property called $property was not found in the properties.php file. Check that file or try passing a css locator directly"',
$this->getSession());
}
else {
$this->assert_element_contains_text($text, $css_locator[0], $css_locator[1]);
}
}
/**
......
......@@ -15,6 +15,7 @@ define ("LOCATOR_CONSTANTS", json_encode(array(
'Latest changes I can view' => array(".bt-newviews", "css_element"),
'Resume field block' => array(".bt-resumefield", "css_element"),
'Watched pages' => array(".bt-watchlist", "css_element"),
'Select' => array(".btn[title='Select']", "css_element"),
'Comment preview' => array(".commentreplyview", "css_element"),
'Comment text' => array(".comment-text", "css_element"),
'Extensions sub-menu' => array(".configextensions ul", "css_element"),
......
@javascript @core
Feature:
Background:
Given the following "users" exist:
| username | password | email | firstname | lastname | institution | authname | role |
| UserA | Kupuh1pa! | UserA@example.org | Angela | User | mahara | internal | member |
And the following "pages" exist:
| title | description | ownertype | ownername |
| Page UserA_01 | Page 01 | user | UserA |
Scenario:
Given I log in as "UserA" with password "Kupuh1pa!"
When I choose "Files" in "Content" from main menu
And I fill in "Folder1" for "files_filebrowser_createfolder_name"
And I press "Create folder"
And I follow "Folder1"
And I attach the file "Image1.jpg" to "File"
And I attach the file "Image2.png" to "File"
And I attach the file "Image3.png" to "File"
# Creating folder 1
Given I choose "Pages and collections" in "Portfolio" from main menu
And I click on "Edit" in "Page UserA_01" panel menu
And I expand "Media" node
And I follow "Image gallery"
And I press "Add"
And I select the radio "Image selection: Display all images from a folder including images uploaded later"
And I click on the "Select" property
And I select the radio "Style: Thumbnails (square)"
And I press "Save"
And I display the page
Then I should see images within the block "Image gallery"
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