Skip to content
This repository has been archived by the owner on May 3, 2022. It is now read-only.

[Behat] Add Behat test for issue EZP-25642 users 'Delete' button #553

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
26 changes: 26 additions & 0 deletions Features/Context/SubContext/CommonActions.php
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,32 @@ private function goToContentWithPath($path)
$this->clickOnTreePath($path);
}

/**
* @Then I should see a :button action bar button
*
* @param string $buttonText Text of the element in the action bar
*/
public function iShouldSeeActionBarButton($buttonText)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should move this to an ActionBarContext.

{
$element = $this->getElementByText($buttonText, '.ez-actionbar-container .ez-action', '.action-label');
if (!$element) {
throw new \Exception("Action bar button '$buttonText' not found");
Copy link
Contributor

@joaoinacio joaoinacio Apr 20, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

File seems to be using EzAssertion already, should it keep doing so, for consistency?

EzAssertion::assertSingleElement($buttonText, $element, null, 'Action bar button');

}
}

/**
* @Then I should not see a :button action bar button
*
* @param string $buttonText Text of the element in the action bar
*/
public function iShouldNotSeeActionBarButton($buttonText)
{
$element = $this->getElementByText($buttonText, '.ez-actionbar-container .ez-action', '.action-label');
if ($element) {
throw new \Exception("Action bar button '$buttonText' was found");
Copy link
Contributor

@joaoinacio joaoinacio Apr 20, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as above, except it should use a EzAssertion::assertElementNotFound() method instead

}
}

/**
* @Then I am on the :name location view
*/
Expand Down
11 changes: 11 additions & 0 deletions Features/Context/Users.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,17 @@ public function iCreateUser(TableNode $users = null)
}
}

/**
* @When I go to (the) User :username page
*/
public function goToUserPage($username)
{
$this->iAmOnPage('Users');
$this->waitWhileLoading();
$this->clickOnTreePath("$username $username");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually, won't this work solely for users created in behat (same first/last name)?
what about admin, etc?

Correct/long approach would be to load the User's first/last name then use those values.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a context problem, connected to what I have said above.

We should/could store the created user's reference, so that we can easily navigate to it. It would avoid having to reference the same fake string, and we could use uniqid() in generated names to ensure uniqueness.

Copy link
Member

@bdunogier bdunogier Apr 29, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But besides that, @joaoinacio is right.

  1. Either the function accepts a username as an argument, in which case it must use the userService to load the user, and get the content's name.
  2. or the function accepts a user content name, and doesn't have to load the user, but it needs to be specified in the sentence.

If we end up with the scenario I gave as an example:

When I go to a valid user's page
Then I do not see a "Send to trash" action bar button
...

The first sentence would both create the user, and navigate to its page. It could do the navigation part by calling goToUserPage(), using the created content name as the argument.

$this->sleep(); //safeguard for application delays
}

/**
* @When I edit user :username
*/
Expand Down
7 changes: 7 additions & 0 deletions Features/Users/users.feature
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,10 @@ Feature: Use the eZ Users field
And I fill in "Password" with "12345"
And I fill in "Confirm password" with "123456"
Then I should see error messages

@javascript @edge
Scenario: Validate that users have the "Delete" button available
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The scenario describes something a bit different. What about Validates that the "Send to trash" button is replaced with "Delete" when browsing users ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was really suggesting that the sentence was replaced. As I see it, the scenario covers the fact that "Send to trash" is replaced with "Delete". We can easily formulate that as one sentence. Or did you have something else in mind ?

Given there is a User with name "One"
When I go to User "One" page
Then I should not see a "Send to thrash" action bar button
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo: thrash should be trash.

And I should see a "Delete" action bar button
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could replace "and" with "but", I think it works too. And it sounds a bit better :-)