Commit 474fda44 authored by Rebecca Blundell's avatar Rebecca Blundell
Browse files

Bug 1733769: test for making one comment from a list public

new general step for interacting with comment based on text in comment
edited property step to abstract out switch statement into its own funct
test making a comment public works on one comment only
test functionality for page owner/comment owner approval of making
comments public.

Change-Id: I411e854ef2280b9d8731e5307d81f5a507902bd6
parent 720e1774
......@@ -195,7 +195,8 @@ class BehatForms extends BehatBase {
$selectortype = "css_element";
switch ($label) {
case "Search for...":
$id = substr($value, 0, -1);
//format string - ids are user/group, not Users/Groups
$id = strtolower(substr($value, 0, -1));
$locator = "#$id";
break;
case "General":
......
......@@ -881,25 +881,10 @@ class BehatGeneral extends BehatBase {
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 {
$step_funct = $this->switch_funct($step_funct);
// 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]);
}
}
......@@ -1796,4 +1781,47 @@ JS;
$this->visitPath("/view/unsubscribe.php?a=watchlist&t={$token}");
}
/**
* Switch to assign the secondary function to be called by a
* generic primary function
*
*/
private function switch_action($action) {
switch ($action) {
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;
}
return $funct;
}
/**
* Allows interaction with comments in a list using text
* contained in the comment, as the id tags are dynamic.
*
* @Then /^I (?P<action>.*) "(?P<element>(?:[^"]|\\")*)" in the "(?P<text>(?:[^"]|\\")*)" comment$/
*
* @param string $action the first element of the step used to call
* a secondary function.
* @param string $element part of the comment id to interact with
* @param string $text part of the comment text
*/
public function i_interact_comment($action, $element, $text) {
$xpath = "//*[@id=\"feedbacktable\"]/*/div[contains(normalize-space(.), '$text')]";
$action = $this->switch_action($action);
$this->$action($element, $xpath, "xpath_element");
}
}
@javascript @core @comments
Feature: As a user I want to make just one comment from a list public (Bug 1729423)
so others can see that comment,
while the rest of the list remains private
Background:
Given the following "users" exist:
| username | password | email | firstname | lastname | institution | authname | role |
| UserA | Kupuh1pa! | UserA@example.org | Angela | User | mahara | internal | user |
| UserB | Kupuh1pa! | UserB@example.org | Bob | User | mahara | internal | user |
And the following "pages" exist:
| title | description | ownertype | ownername |
| Page UserA_01 | Page 01| user | UserA |
| Page UserA_02 | Page 02 | user | UserA |
| Page UserA_03 | Page 03 | user | UserA |
And the following "collections" exist:
| title | description | ownertype | ownername | pages |
| Collection UserA_01 | Collection 01 | user | UserA | Page UserA_01, Page UserA_02 |
# make following comments exist option?
Scenario:
Given I log in as "UserA" with password "Kupuh1pa!"
# what about making sharing a background step... permissions exist???
And I choose "Shared by me" in "Portfolio" from main menu
And I follow "Collections"
And I click on "Edit access" in "Collection UserA_01" row
And I set the select2 value "Page UserA_03" for "editaccess_views"
And I select "Users" from "Search for..." in shared with select2 box
And I select "Bob User" from select2 search box in row number "1"
And I press "Save"
And I log out
And I log in as "UserB" with password "Kupuh1pa!"
And I follow "Page UserA_03"
And I fill in "This is comment 1" in editor "Comment"
And I disable the switch "Make comment public"
And I press "Comment"
And I fill in "This is comment 2" in editor "Comment"
And I disable the switch "Make comment public"
And I press "Comment"
And I fill in "This is comment 3" in editor "Comment"
And I disable the switch "Make comment public"
And I press "Comment"
And I fill in "This is comment 4" in editor "Comment"
And I disable the switch "Make comment public"
And I press "Comment"
And I fill in "This is comment 5" in editor "Comment"
And I disable the switch "Make comment public"
And I press "Comment"
And I fill in "This is comment 6" in editor "Comment"
And I disable the switch "Make comment public"
And I press "Comment"
And I fill in "This is comment 7" in editor "Comment"
And I disable the switch "Make comment public"
And I press "Comment"
And I fill in "This is comment 8" in editor "Comment"
And I disable the switch "Make comment public"
And I press "Comment"
And I fill in "This is comment 9" in editor "Comment"
And I disable the switch "Make comment public"
And I press "Comment"
And I fill in "This is comment 10" in editor "Comment"
And I disable the switch "Make comment public"
And I press "Comment"
And I fill in "This is comment 11" in editor "Comment"
And I disable the switch "Make comment public"
And I press "Comment"
And I fill in "This is comment 12" in editor "Comment"
And I disable the switch "Make comment public"
And I press "Comment"
And I follow "Previous page"
And I click on "Edit" in "This is comment 2" row
And I enable the switch "Make comment public"
And I press "Save"
And I should see "A message has been sent to Angela User to request that the comment be made public."
And I log out
# log in as page owner to authorise the comment to be public
And I log in as "UserA" with password "Kupuh1pa!"
And I choose "Pages and collections" in "Portfolio" from main menu
And I follow "Page UserA_03"
And I click on "Make comment public" in the "This is comment 2" comment
And I should see "This comment is private" in the "This is comment 1" comment
And I should see "This comment is private" in the "This is comment 9" comment
And I should not see "This comment is private" in the "This is comment 2" comment
And I follow "Next page"
And I click on "Make comment public" in the "This is comment 11" comment
And I should see "A message has been sent to Bob User to request that the comment be made public."
And I choose "Pages and collections" in "Portfolio" from main menu
And I follow "Collection UserA_01"
And I fill in "This is comment 1" in editor "Comment"
And I disable the switch "Make comment public"
And I press "Comment"
And I fill in "This is comment 2" in editor "Comment"
And I disable the switch "Make comment public"
And I press "Comment"
And I fill in "This is comment 3" in editor "Comment"
And I disable the switch "Make comment public"
And I press "Comment"
And I click on "Make comment public" in the "This is comment 3" comment
And I log out
And I log in as "UserB" with password "Kupuh1pa!"
And I follow "Collection UserA_01"
And I should see "This is comment 3"
And I should not see "This is comment 2"
And I should not see "This is comment 1"
And I choose "Shared with me" in "Portfolio" from main menu
And I follow "Page UserA_03"
And I should not see "This comment is private" in the "This is comment 2" comment
And I follow "Next page"
And I should see "This comment is private" in the "This is comment 11" comment
And I click on "Make comment public"
And I should not see "This comment is private" in the "This is comment 11" comment
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