From c91bba5afd6c01f6b61d43f35f9d3e4ee3d18e9a Mon Sep 17 00:00:00 2001 From: stephaneDiot Date: Mon, 3 Apr 2017 14:47:06 +0200 Subject: [PATCH] EZP-26992: Fix BDD tests to work whith content browse --- .travis.yml | 2 +- Features/ContentActions/CopyContent.feature | 2 +- Features/ContentActions/MoveContent.feature | 6 +- Features/ContentActions/RemoveContent.feature | 8 +- Features/Context/Fields.php | 6 +- Features/Context/PlatformUI.php | 108 +++++++++--------- Features/Context/SubContext/CommonActions.php | 72 +++++------- Features/Context/Users.php | 2 +- Features/doc/Sentences.md | 1 - 9 files changed, 100 insertions(+), 107 deletions(-) diff --git a/.travis.yml b/.travis.yml index 960523708..9cdaf1a15 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,7 +14,7 @@ cache: matrix: fast_finish: true - allow_failures: + include: # Run behat first as it takes the most time (don't need to specify php version here as we don't really care about version on host) - php: 5.6 env: BEFORE="./bin/travis/prepare_behat.sh" TEST_CMD="./bin/travis/runbehat.sh" AFTER_SUCCESS='echo "After success"' RUN_INSTALL=1 COMPOSE_FILE="doc/docker-compose/base-prod.yml:doc/docker-compose/selenium.yml" SYMFONY_ENV=behat SYMFONY_DEBUG=0 diff --git a/Features/ContentActions/CopyContent.feature b/Features/ContentActions/CopyContent.feature index 03f736590..ce7de7b11 100644 --- a/Features/ContentActions/CopyContent.feature +++ b/Features/ContentActions/CopyContent.feature @@ -18,7 +18,7 @@ Feature: Copy content And I select the "eZ Platform/Destination" folder in the Universal Discovery Widget And I confirm the selection Then I am notified that "News Flash" has been copied under "Destination" - And I see "Destination/News Flash" in the content tree + And the content item was copied to "Destination/News Flash" # @javascript # Scenario: Copy one object that has children objects using the "Copy Subtree" button diff --git a/Features/ContentActions/MoveContent.feature b/Features/ContentActions/MoveContent.feature index d1fafe3cb..ffb8a6c8e 100644 --- a/Features/ContentActions/MoveContent.feature +++ b/Features/ContentActions/MoveContent.feature @@ -18,12 +18,12 @@ Feature: Move content And I select the "eZ Platform/Older News" folder in the Universal Discovery Widget And I confirm the selection Then I am notified that "News Flash" has been moved under "Older News" - And I see "Older News/News Flash" in the content tree - And I do not see "Origin/News flash" in the content tree + And the content item was moved to "Older News/News Flash" + And the content item "Origin/News flash" was removed @javascript Scenario: Move one object that has children objects Given an "Older News" folder exists And a "Tomorrow news/News Flash" article exists When I move "Tomorrow news" into the "Older News" folder - Then I see "Older News/Tomorrow news/News Flash" in the content tree + And the content item was moved to "Older News/Tomorrow news/News Flash" diff --git a/Features/ContentActions/RemoveContent.feature b/Features/ContentActions/RemoveContent.feature index 767b3a5c5..7fc25192c 100644 --- a/Features/ContentActions/RemoveContent.feature +++ b/Features/ContentActions/RemoveContent.feature @@ -27,7 +27,7 @@ Feature: Remove content When I remove "News Flash" And I confirm the removal Then I am notified that '"News Flash" sent to Trash' - And I do not see "News Flash" in the content tree + And the content item "News Flash" was removed @javascript Scenario: Remove one object and do not confirm the removal @@ -35,14 +35,14 @@ Feature: Remove content When I remove "News Flash" And I cancel the removal Then I am not notified that '"News Flash" sent to Trash' - And I see "News Flash" in the content tree + And "News Flash" content item exists @javascript Scenario: Delete one object that has children objects Given a "News/News child" article exists When I remove "News" And I confirm the removal - Then I do not see "News" in the content tree + Then the content item "News" was removed @javascript Scenario: Removing one object should redirect to it's parent location view @@ -50,4 +50,4 @@ Feature: Remove content When I remove "News child" And I confirm the removal Then I am on the "News" location view - And I do not see "News/News child" in the content tree + And the content item "News/News child" was removed diff --git a/Features/Context/Fields.php b/Features/Context/Fields.php index bcb84906e..a6c2cc2ad 100644 --- a/Features/Context/Fields.php +++ b/Features/Context/Fields.php @@ -89,7 +89,8 @@ public function editThisContent() $this->clickNavigationZone('Content'); $this->clickNavigationItem('Content structure'); - $this->clickOnTreePath($name); + $this->clickOnBrowsePath($name); + $this->confirmSelection(); $this->clickActionBar('Edit'); $this->platformStatus = self::WAITING_FOR_PUBLISHING; // assert @@ -229,7 +230,8 @@ public function viewThisContent() $this->clickNavigationZone('Content'); $this->clickNavigationItem('Content structure'); - $this->clickOnTreePath($name); + $this->clickOnBrowsePath($name); + $this->confirmSelection(); } /** diff --git a/Features/Context/PlatformUI.php b/Features/Context/PlatformUI.php index 9800a66fc..d0c8eddb1 100644 --- a/Features/Context/PlatformUI.php +++ b/Features/Context/PlatformUI.php @@ -331,58 +331,6 @@ protected function clickElementByText($text, $selector, $textSelector = null, $b } } - /** - * Opens a content tree node based on the root of the tree or a given node. - * - * @param string $text The text of the node that is going to be opened - * @param NodeElement $node The base node to expand from, if null defaults to the content tree root - * @return NodeElement The node that was opened - */ - protected function openTreeNode($text, $parentNode) - { - if ($parentNode && $parentNode->hasClass('is-tree-node-close')) { - $toggleNode = $this->findWithWait('.ez-tree-node-toggle', $parentNode, false); - if ($toggleNode && $toggleNode->isVisible()) { - $toggleNode->click(); - // after expanding a node we should wait for loading to finish - $this->sleep(); - $this->waitWhileLoading('.is-tree-node-loading'); - } else { - $parentName = $parentNode->getText(); - throw new \Exception( - "The tree node '$parentName' could not be expanded: " . - ($toggleNode ? 'toggle not visible' : 'toggle not found') - ); - } - } - // find an '.ez-tree-node' element which contains an '.ez-tree-navigate' with text '$text' - $element = $this->getElementByText($text, '.ez-tree-node', '.ez-tree-navigate', $parentNode); - if (!$element) { - throw new \Exception("The tree node '$text' was not found"); - } - - return $element; - } - - /** - * Explores the content tree, expanding it and click on the desired element. - * - * @param string $path The content tree path such as 'Content1/Content2/ContentIWantToClick' - * @param NodeElement $node The base node to expand from - */ - public function openTreePath($path, $node) - { - $this->waitWhileLoading('.ez-tree-loading'); - - $node = $this->findWithWait('.ez-view-treeview.is-tree-loaded', $node); - $path = explode('/', $path); - foreach ($path as $nodeName) { - $node = $this->openTreeNode($nodeName, $node); - } - - $this->findWithWait('.ez-tree-navigate', $node)->click(); - } - /** * Clicks a content browser node based on the root of the browser or a given node. * @@ -418,6 +366,62 @@ public function openFinderExplorerPath($path, $node) } } + /** + * Explores the UDW, expanding it and click on the desired element. + * + * @param string $path The content browse path such as 'Content1/Content2/ContentIWantToClick' + */ + public function clickOnBrowsePath($path) + { + $this->clickDiscoveryBar('Content browse'); + $this->waitWhileLoading('.is-universaldiscovery-hidden'); + $node = $this->findWithWait('.ez-view-universaldiscoveryview'); + $node = $this->findWithWait('.ez-view-universaldiscoveryfinderview .ez-ud-finder-explorerlevel', $node); + + $this->openFinderExplorerPath($path, $node); + } + + /** + * Explores the UDW, to find the desired element. + * + * @param string $path The content browse path such as 'Content1/Content2/ContentIWantToClick' + */ + public function dontSeeBrowsePath($path) + { + $found = true; + try { + $this->clickOnBrowsePath($path); + } catch (\Exception $e) { + $found = false; + } + + if ($found) { + throw new \Exception("Browse path '$path' was found"); + } + + return true; + } + + /** + * @When I confirm the selection + * Confirm selection in Universal discovery. + */ + public function confirmSelection() + { + $elem = $this->findWithWait('.ez-view-universaldiscoveryview'); + $elem->find('css', '.ez-universaldiscovery-confirm')->click(); + } + + /** + * @When I cancel the selection + * Cancel the selection in Universal discovery. + */ + public function cancelSelection() + { + $elem = $this->findWithWait('.ez-view-universaldiscoveryview'); + $elem->find('css', '.ez-universaldiscovery-cancel')->click(); + } + /** * Close the "Confirm" modal dialog, if it is visible. */ diff --git a/Features/Context/SubContext/CommonActions.php b/Features/Context/SubContext/CommonActions.php index 79af7aed6..09f6f3cf8 100644 --- a/Features/Context/SubContext/CommonActions.php +++ b/Features/Context/SubContext/CommonActions.php @@ -231,17 +231,36 @@ public function clickEditActionBar($button) } /** - * @Given I click (on) the content tree with path :path - * @Then I see :path in the content tree - * Explores the content tree, expanding it and click on the desired element + * @Then :path content item does not exists + * @Then :path content item doesn't exists + * @Then the content item :path was removed + * @Then the content item :path was sent to trash + * Explores the finder of the UDW, verify the desired element doesn't exist and close the UDW. * - * @param string $path The content tree path such as 'Content1/Content2/ContentIWantToClick' + * @param string $path The content browse path such as 'Content1/Content2/ContentIWantToClick' */ - public function clickOnTreePath($path) + public function thereIsNoContent($path) { - $node = $this->findWithWait('.ez-view-discoverybarview'); - $this->clickDiscoveryBar('Content tree'); - $this->openTreePath($path, $node); + $this->clickNavigationItem('Content structure'); + $this->dontSeeBrowsePath($path); + $this->cancelSelection(); + } + + /** + * @Then :path content item exists + * @Then the content item :path was not removed + * @Then the content item :path was not sent to trash + * @Then the content item was moved to :path + * @Then the content item was copied to :path + * Explores the finder of the UDW, find the desired element and close the UDW. + * + * @param string $path The content browse path such as 'Content1/Content2/ContentIWantToClick' + */ + public function thereIsAContent($path) + { + $this->clickNavigationItem('Content structure'); + $this->clickOnBrowsePath($path); + $this->confirmSelection(); } /** @@ -285,15 +304,6 @@ public function selectFromUniversalDiscovery($path) $this->openFinderExplorerPath($path, $node); } - /** - * @When I confirm the selection - * Confirm selection in Universal descovery. - */ - public function confirmSelection() - { - $this->clickElementByText('Confirm selection', '.ez-universaldiscovery-confirm'); - } - /** * @Given I am on :name full view */ @@ -306,11 +316,12 @@ public function onFullView($name) /** * Opens a content in PlatformUi. */ - private function goToContentWithPath($path) + public function goToContentWithPath($path) { $this->clickNavigationZone('Content'); $this->clickNavigationItem('Content structure'); - $this->clickOnTreePath($path); + $this->clickOnBrowsePath($path); + $this->confirmSelection(); } /** @@ -324,29 +335,6 @@ public function onLocationView($name) $this->iSeeTitle($name); } - /** - * @Then I don't see :path in the content tree - * @Then I do not see :path in the content tree - * Explores the content tree, expanding it and click on the desired element. - * - * @param string $path The content tree path such as 'Content1/Content2/ContentIWantToClick' - */ - public function dontSeeTreePath($path) - { - $found = true; - try { - $this->clickOnTreePath($path); - } catch (\Exception $e) { - $found = false; - } - - if ($found) { - throw new \Exception("Tree path '$path' was found"); - } - - return true; - } - /** * @Then I see Content :contentName of type :contentType */ diff --git a/Features/Context/Users.php b/Features/Context/Users.php index 85494eb30..d3a132f53 100644 --- a/Features/Context/Users.php +++ b/Features/Context/Users.php @@ -40,7 +40,7 @@ public function iCreateUser(TableNode $users = null) */ public function editUserUser($username) { - $this->clickOnTreePath("$username $username"); + $this->clickOnBrowsePath("$username $username"); $this->sleep(); //safegaurd for application delays $this->waitWhileLoading(); $this->clickActionBar('Edit'); diff --git a/Features/doc/Sentences.md b/Features/doc/Sentences.md index 9fb886672..f9db8682b 100644 --- a/Features/doc/Sentences.md +++ b/Features/doc/Sentences.md @@ -9,7 +9,6 @@ PlatformUI available sentences: Given I click (on) the navigation item :subMenu Given I click (on) the actionbar action :sideMenuOption Given I click (on) the content type :contentType - Given I click (on) the content tree with path :path Given I fill in :field subform with: Given I upload the image :path Given I upload the file :path