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

Conversation

miguelcleverti
Copy link

Behat BDD tests for issue https://jira.ez.no/browse/EZP-25642

This test adds the verification that the in the PlatformUI Action bar menu there is a 'Delete' button and not a 'Send to trash'. Since the users should be deleted and not sent to trash.

@miguelcleverti
Copy link
Author

/**
* @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 ?

{
$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');

@miguelcleverti
Copy link
Author

as suggested by @joaoinacio, depends now on EzAssertion

@joaoinacio
Copy link
Contributor

joaoinacio commented Apr 20, 2016

as suggested by @joaoinacio, depends now on EzAssertion

It already did ;)

+1

{
$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.

@andrerom
Copy link
Contributor

+1 (however should pass on travis, trying to restart)

@miguelcleverti
Copy link
Author

miguelcleverti commented Apr 26, 2016

@joaoinacio now the User first and last name are loaded and used instead of assuming they are always the same.
However now this PR depends on these two:

@bdunogier
Copy link
Member

There is a point that I had raised, and that got hidden by a commit, but that still stands: #553 (diff).

I don't think we should have a username at all here, as it doesn't matter to the situation (happens on any user, without any particular characteristic).

Scenario: Validate that users have the "Delete" button available
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.

@miguelcleverti
Copy link
Author

@bdunogier regarding the not having the username on the sentence,... What would you suggest, having a new sentence that uses the admin user or creates a new user just for the test?

@bdunogier
Copy link
Member

bdunogier commented Apr 29, 2016

What would you suggest, having a new sentence that uses the admin user or creates a new user just for the test?

Well, in that scenario, we could use the admin. The problem is that if somebody uses the same sentence to test removal somehow, we will end up in trouble :-)

I'd rather make the sentence create a user. It is what we mostly do for now, is it not ?


@javascript @edge
Scenario: Validate "Send to trash" button is replaced with "Delete" when browsing users
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.

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 ?

@miguelcleverti miguelcleverti force-pushed the ezp_5642_BehatTests branch 3 times, most recently from 2aea1be to d61cd85 Compare May 2, 2016 11:17
Scenario: Validate "Send to trash" button is replaced with "Delete" when browsing users
When I go to a valid User page
Then I should not see a "Send to trash" action bar button
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 :-)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

6 participants