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
14 changes: 14 additions & 0 deletions Features/Context/SubContext/CommonActions.php
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,20 @@ private function goToContentWithPath($path)
$this->clickOnTreePath($path);
}


/**
* @Then I should see a :button button in the action bar
*
* @param string $button Text of the element in the action bar
Copy link
Member

Choose a reason for hiding this comment

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

Extra spaces ?

*/
public function iShouldSeeActionBarButton($button)
Copy link
Member

Choose a reason for hiding this comment

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

Argument naming: $buttonText ?

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

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

/**
* @When I go to (the) User :username page
*/
public function goToUserPage($username)
{
$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(); //safegaurd for application delays
Copy link
Contributor

Choose a reason for hiding this comment

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

nitpick: safeguard?

}

/**
* @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 I am on the Users page
Copy link
Member

@bdunogier bdunogier Apr 18, 2016

Choose a reason for hiding this comment

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

How we get there does not really matter in this context.

We could wrap the first three sentences into something like When I view a (valid) User (not perfect, viewing is still a bit of a generic (or technical) domain term, and might be a bit confusing. Any extra domain word that would indicate the user full page ?

Copy link
Contributor

Choose a reason for hiding this comment

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

The objective of the scenario is not to view a users' data, but to be on a user's page, so 'view' might mislead the reader.
But yes, we might shorten the sentences. Suggestion:
Given I am on a user's page
Then I should see a "Delete" button in the action bar

Copy link
Author

Choose a reason for hiding this comment

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

When I am on (valid) User page it is not as generic and it really is what happened. I navigated to the User page so I am on the said user page. However this sentence might cause conflicts with the Given I am on the Users page behat does not like similar sentences.

Copy link
Member

Choose a reason for hiding this comment

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

Given I am on a user's page

Well, "page" is not a term from the platform / platform ui domain. But it is at least a generic web term. Opinion, @dpobel ?

But yes, we might shorten the sentences.

Note that the goal ain't really to shorten, but to limit the context to what matters in, well, the context.

Copy link
Contributor

Choose a reason for hiding this comment

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

i tend to agree with @bdunogier. to testing this delete button existence there is no need to check where are you coming front. in fact, you could access this kind of pages from other places and button should be there too :)

And there is a User with name "One"
When I go to User "One" page
Then I should see a "Delete" button in the action bar
Copy link
Member

Choose a reason for hiding this comment

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

We may want to complete that: what we are testing here is indeed that we are getting a delete button on users, but also that we are not getting a "send to trash" button.

What about

Then I should not see a "Send to trash" button in the action bar
 But I should see a "Delete" button in the action bar

(what about changing the above with I should see a "Delete" action bar button ? Less clutter :-)