Commit d9770f35 authored by Robert Lyon's avatar Robert Lyon
Browse files

Bug 1508204: behat test for removing tagged journal



Change-Id: Ic864bdcb8e777dfc59b81488ada8b82bfae27e0a
Signed-off-by: default avatarRobert Lyon <robertl@catalyst.net.nz>
parent 333ccbd6
Loading
Loading
Loading
Loading
+9 −3
Original line number Diff line number Diff line
@@ -105,11 +105,17 @@ class BehatForms extends BehatBase {
    /**
     * Clears the Select2 field
     *
     * @When /^(?:|I )clear the select2 field "(?P<field>(?:[^"]|\\")*)"$/
     * @When /^(?:|I )clear value "(?P<textValues>(?:[^"]|\\")*)" from select2 field "(?P<field>(?:[^"]|\\")*)"$/
     */
    public function iClearSelect2Field($field) {
    public function iClearSelect2Field($textValues, $field) {
        $page = $this->getSession()->getPage();
        $this->getSession()->executeScript("jQuery('#{$field}').val('').trigger('change');");
        foreach(preg_split('/,\s*/', $textValues) as $value) {
            $option = $page->find('xpath', '//select[@id="' . $field . '"]//option[text()="' . $value . '"]');
            $value = $option->getAttribute('value');
            $value = json_encode($value);
            $this->getSession()->executeScript("jQuery('#{$field} option[value=" . $value . "]').remove();");
        }
        $this->getSession()->executeScript("jQuery('#{$field}').trigger('change');");
    }
    /**
     * Fill Select2 input field
+1 −1
Original line number Diff line number Diff line
@@ -47,7 +47,7 @@ Scenario: Creating a Journal, publishing a draft, using tagged entry block
 # Remove tag from first journal and save
 Given I click on "Edit" in "My diary entry one" row
 And I wait "1" seconds
 And I clear the select2 field "editpost_tags"
 And I clear value "mildred (1)" from select2 field "editpost_tags"
 And I press "Save entry"
 Then I should see "Journal entry saved"
 And I should not see "mildred"
+47 −7
Original line number Diff line number Diff line
@@ -4,6 +4,10 @@ In order to change the configuration of my Journal entry
As a user
So I can benefit from the different settings

Background:
  Given the following "pages" exist:
  | title | description| ownertype | ownername |
  | Page 01 | admins page 01 | admin | admin |

Scenario: Turning on and of switches in Journal configuration block (Bug 1431569)
 Given I log in as "admin" with password "Kupuhipa1"
@@ -40,11 +44,47 @@ Scenario: Creating a Journal entry
 # Changing the switches once and filling out a journal
 And I set the following fields to these values:
 | Title * | Story of my life |
 | Draft | 1 |
 | Allow comments | 0 |
 | Entry | Preventing bugs from appearing :D |
 And I press "Save entry"
 And I fill in select2 input "editpost_tags" with "one" and select "one"
 And I scroll to the base of id "editpost_tags_container"
 And I fill in select2 input "editpost_tags" with "test" and select "test"

 And I press "Save entry"

 And I follow "New entry"
 And I set the following fields to these values:
 | Title * | Story of my life, part 2 |
 | Allow comments | 0 |
 | Entry | Testing tags |
 And I fill in select2 input "editpost_tags" with "two" and select "two"
 And I scroll to the base of id "editpost_tags_container"
 And I fill in select2 input "editpost_tags" with "test" and select "test"
 And I press "Save entry"

 And I follow "New entry"
 And I set the following fields to these values:
 | Title * | Story of my life, part 3 |
 | Allow comments | 0 |
 | Entry | Testing tags some more |
 And I fill in select2 input "editpost_tags" with "three" and select "three"
 And I scroll to the base of id "editpost_tags_container"
 And I fill in select2 input "editpost_tags" with "test" and select "test"
 And I press "Save entry"

 And I choose "Pages" in "Portfolio"
 And I follow "Page 01"
 And I follow "Edit this page"
 And I expand "Journals" node in the "div#content-editor-foldable" "css_element"
 And I follow "Tagged journal entries" in the "div#blog" "css_element"
 And I press "Add"
 And I fill in select2 input "instconf_tagselect" with "one" and select "one"
 And I wait "1" seconds
 And I fill in select2 input "instconf_tagselect" with "two" and select "two"
 And I wait "1" seconds
 And I press "Save"
 And I scroll to the base of id "column-container"
 And I configure the block "Tagged journal entries"
 And I wait "1" seconds
 And I clear value "one" from select2 field "instconf_tagselect"
 And I press "Save"