Skip to content

Commit

Permalink
Fix a Behat step definition for verifiying the text on the author mer…
Browse files Browse the repository at this point in the history
…ging dialog box (#49)

because we use a Bootstrap modal that's invisible by default, the text we won't to match is not seen by Behat, unless we toggle the modal
by injecting javascript into the Webdriver browser.
  • Loading branch information
Rija Menage committed Apr 3, 2018
1 parent 48b0bff commit 8943116
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
12 changes: 9 additions & 3 deletions tests/features/bootstrap/AuthorMergingContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,15 @@ public function __construct(array $parameters)
*/
public function aDialogBoxReads($arg1)
{
return array(
new Step\Given("I should see \"{$arg1}\""),
);
//modal dialog are invisible by default until they are toogled by javascript
//so we need to get that javascript executed by the javascript-capable headless browser
$script = "(function(){return ($('#author_merge').is(':visible'));})();";//toogle the modal dialog to visible
$result = $this->getMainContext()->getSession()->evaluateScript($script);
PHPUnit_Framework_Assert::assertTrue($result);
$script = "(function(){return $('#author_merge').html();})();"; //capture the html of the modal dialog
$result = $this->getMainContext()->getSession()->evaluateScript($script);
PHPUnit_Framework_Assert::assertEquals(1,preg_match("/$arg1/",$result));

}


Expand Down
2 changes: 1 addition & 1 deletion tests/features/merge-authors-49.feature
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Scenario: Presssing the merge an author button leads to author table and then me
And I wait "2" seconds
And I click on the row for author id "3794"
And I wait "5" seconds
# And A dialog box reads "Confirm merging these two authors?"
And A dialog box reads "Confirm merging these two authors?"
And I should see "ID:"
And I should see "Surname:"
And I should see "First name:"
Expand Down

0 comments on commit 8943116

Please sign in to comment.