From 35a32d608d144b68133f431e0f979fa2271d021c Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Sat, 14 Sep 2013 00:20:22 +0200 Subject: [PATCH] More specific behat tree assertion --- tests/behat/features/apply-formatting.feature | 2 +- .../Framework/Test/Behaviour/CmsUiContext.php | 15 +++++++++++++-- tests/behat/features/insert-a-link.feature | 2 +- tests/behat/features/insert-an-image.feature | 3 +-- 4 files changed, 16 insertions(+), 6 deletions(-) diff --git a/tests/behat/features/apply-formatting.feature b/tests/behat/features/apply-formatting.feature index e9bce6190..b65760203 100644 --- a/tests/behat/features/apply-formatting.feature +++ b/tests/behat/features/apply-formatting.feature @@ -11,7 +11,7 @@ Feature: Apply rich formatting to content """

My awesome headline

Some amazing content

""" And I go to "/admin/pages" - Then I follow "About Us" + Then I click on "About Us" in the tree And I focus the "Content" field Scenario: I can control alignment of selected content diff --git a/tests/behat/features/bootstrap/SilverStripe/Framework/Test/Behaviour/CmsUiContext.php b/tests/behat/features/bootstrap/SilverStripe/Framework/Test/Behaviour/CmsUiContext.php index 7516cd41c..379c8ee67 100644 --- a/tests/behat/features/bootstrap/SilverStripe/Framework/Test/Behaviour/CmsUiContext.php +++ b/tests/behat/features/bootstrap/SilverStripe/Framework/Test/Behaviour/CmsUiContext.php @@ -140,7 +140,7 @@ class CmsUiContext extends BehatContext } /** - * @When /^I should see "([^"]*)" in CMS Tree$/ + * @When /^I should see "([^"]*)" in the tree$/ */ public function stepIShouldSeeInCmsTree($text) { @@ -151,7 +151,7 @@ class CmsUiContext extends BehatContext } /** - * @When /^I should not see "([^"]*)" in CMS Tree$/ + * @When /^I should not see "([^"]*)" in the tree$/ */ public function stepIShouldNotSeeInCmsTree($text) { @@ -161,6 +161,17 @@ class CmsUiContext extends BehatContext assertNull($element, sprintf('%s found', $text)); } + /** + * @When /^I click on "([^"]*)" in the tree$/ + */ + public function stepIClickOnElementInTheTree($text) + { + $treeEl = $this->getCmsTreeElement(); + $treeNode = $treeEl->findLink($text); + assertNotNull($treeNode, sprintf('%s not found', $text)); + $treeNode->click(); + } + /** * @When /^I expand the "([^"]*)" CMS Panel$/ */ diff --git a/tests/behat/features/insert-a-link.feature b/tests/behat/features/insert-a-link.feature index 8cae76a3d..14b813c0f 100644 --- a/tests/behat/features/insert-a-link.feature +++ b/tests/behat/features/insert-a-link.feature @@ -9,7 +9,7 @@ So that I can link to a external website or a page on my site Given I am logged in with "ADMIN" permissions Given "About Us" has text in content "You can fill this page out with your own content, or delete it and create your own pages." And I go to "/admin/pages" - Then I should see "About Us" in CMS Tree + And I click on "About Us" in the tree @javascript Scenario: I can select text within the content and apply an internal sitetree url link using the add url button diff --git a/tests/behat/features/insert-an-image.feature b/tests/behat/features/insert-an-image.feature index cdeeecc54..ade71b9af 100644 --- a/tests/behat/features/insert-an-image.feature +++ b/tests/behat/features/insert-an-image.feature @@ -8,10 +8,9 @@ Feature: Insert an image into a page Given a "page" "About Us" Given I am logged in with "ADMIN" permissions And I go to "/admin/pages" - Then I should see "About Us" in CMS Tree + And I click on "About Us" in the tree Scenario: I can insert images into the content - When I follow "About Us" Then I should see an edit page form When I press the "Insert Media" button