Skip to content

Commit

Permalink
Merge pull request ezsystems#849 from ezsystems/Fix_BDD_to_work_with_…
Browse files Browse the repository at this point in the history
…content_browse

EZP-27286: Fix BDD to work with content browse
  • Loading branch information
StephaneDiot committed Jun 12, 2017
2 parents 6135235 + c91bba5 commit 6b32c25
Show file tree
Hide file tree
Showing 9 changed files with 100 additions and 107 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Features/ContentActions/CopyContent.feature
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions Features/ContentActions/MoveContent.feature
Expand Up @@ -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"
8 changes: 4 additions & 4 deletions Features/ContentActions/RemoveContent.feature
Expand Up @@ -27,27 +27,27 @@ 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
Given a "News Flash" article exists
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
Given a "News/News child" article exists
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
6 changes: 4 additions & 2 deletions Features/Context/Fields.php
Expand Up @@ -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
Expand Down Expand Up @@ -229,7 +230,8 @@ public function viewThisContent()

$this->clickNavigationZone('Content');
$this->clickNavigationItem('Content structure');
$this->clickOnTreePath($name);
$this->clickOnBrowsePath($name);
$this->confirmSelection();
}

/**
Expand Down
108 changes: 56 additions & 52 deletions Features/Context/PlatformUI.php
Expand Up @@ -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.
*
Expand Down Expand Up @@ -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.
*/
Expand Down
72 changes: 30 additions & 42 deletions Features/Context/SubContext/CommonActions.php
Expand Up @@ -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();
}

/**
Expand Down Expand Up @@ -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
*/
Expand All @@ -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();
}

/**
Expand All @@ -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
*/
Expand Down
2 changes: 1 addition & 1 deletion Features/Context/Users.php
Expand Up @@ -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');
Expand Down
1 change: 0 additions & 1 deletion Features/doc/Sentences.md
Expand Up @@ -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
Expand Down

0 comments on commit 6b32c25

Please sign in to comment.