From 2dd5bb4d19a8f226e3179f89e7bb9514c630db84 Mon Sep 17 00:00:00 2001 From: Robbie Averill Date: Sun, 16 Jul 2017 23:41:24 +1200 Subject: [PATCH 1/2] NEW Add Behat CMS header tab context methods --- tests/behat/src/CmsUiContext.php | 43 ++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/tests/behat/src/CmsUiContext.php b/tests/behat/src/CmsUiContext.php index 0eeae3ff8..d28029f7d 100644 --- a/tests/behat/src/CmsUiContext.php +++ b/tests/behat/src/CmsUiContext.php @@ -155,6 +155,15 @@ class CmsUiContext implements Context assertNull($element, sprintf('%s found', $text)); } + /** + * @When /^I should see a "([^"]*)" tab in the CMS content header tabs$/ + */ + public function stepIShouldSeeInCMSContentTabs($text) + { + // Wait until visible + assertNotNull($this->getCmsTabElement($text), sprintf('%s content tab not found', $text)); + } + /** * Applies a specific action to an element * @@ -219,6 +228,40 @@ class CmsUiContext implements Context $this->interactWithElement($treeNode, $method); } + /** + * @When /^I (?P(?:(?:double |right |left |)click)|hover) on "(?P[^"]*)" in the header tabs$/ + */ + public function stepIClickOnElementInTheHeaderTabs($method, $text) + { + $tabsNode = $this->getCmsTabElement($text); + assertNotNull($tabsNode, sprintf('%s not found', $text)); + $this->interactWithElement($tabsNode, $method); + } + + /** + * @Then the :text header tab should be active + */ + public function theHeaderTabShouldBeActive($text) + { + assertTrue($this->getCmsTabElement($text)->hasClass('active')); + } + + /** + * @Then the :text header tab should not be active + */ + public function theHeaderTabShouldNotBeActive($text) + { + assertFalse($this->getCmsTabElement($text)->hasClass('active')); + } + + /** + * @return NodeElement + */ + protected function getCmsTabElement($text) + { + return $this->getCmsTabsElement()->findLink($text); + } + /** * @When /^I expand the "([^"]*)" CMS Panel$/ */ From a8b3da69586d42eef873ddfa92a64df70c442b65 Mon Sep 17 00:00:00 2001 From: Robbie Averill Date: Mon, 17 Jul 2017 10:11:59 +1200 Subject: [PATCH 2/2] Check for null values when getting CMS tab elements --- tests/behat/src/CmsUiContext.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tests/behat/src/CmsUiContext.php b/tests/behat/src/CmsUiContext.php index d28029f7d..45a7a8c87 100644 --- a/tests/behat/src/CmsUiContext.php +++ b/tests/behat/src/CmsUiContext.php @@ -243,7 +243,9 @@ class CmsUiContext implements Context */ public function theHeaderTabShouldBeActive($text) { - assertTrue($this->getCmsTabElement($text)->hasClass('active')); + $element = $this->getCmsTabElement($text); + assertNotNull($element); + assertTrue($element->hasClass('active')); } /** @@ -251,7 +253,9 @@ class CmsUiContext implements Context */ public function theHeaderTabShouldNotBeActive($text) { - assertFalse($this->getCmsTabElement($text)->hasClass('active')); + $element = $this->getCmsTabElement($text); + assertNotNull($element); + assertFalse($element->hasClass('active')); } /**