Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EWPP-258: Create Behat test for testing "API steps" #315

Open
wants to merge 11 commits into
base: master
Choose a base branch
from

Conversation

georgebaev
Copy link
Contributor

This functionality adds the Behat tests for testing the API steps

Copy link
Contributor

@drishu drishu left a comment

Choose a reason for hiding this comment

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

I've updated the branch with latest master, so drone is red, but I see Adam is working on fixing the patch issues.

And I should see the text "A general contact"
And the "oe_organisation_eu_org[0][target_id]" field should contain "Arab Common Market (http://eurovoc.europa.eu/1793)"
And the "oe_organisation_org_type" field should contain "eu"
And the "Teaser" field should contain "My teaser"
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's update the node with a non eu organisation type and check the value was set

*
* @When :option should be selected for :field select
*/
public function shouldBeSelectedForSelect($option, $field) {
Copy link
Contributor

Choose a reason for hiding this comment

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

IF we wont use this let's remove it

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I use this method in the refactored Behat statements

Copy link
Member

Choose a reason for hiding this comment

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

Don't we have this already from the Drupal extension?

And the "Registration capacity" field should contain "Event capacity"
And the "Entrance fee" field should contain "1234"
And I should see the text "Facebook"
And the "oe_event_registration_dates[0][value][day]" field should contain "1"
Copy link
Contributor

Choose a reason for hiding this comment

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

can't we use shouldBeSelectedForSelect in these situations ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I refactored the statements

And I press "Edit" in the "A general contact" row
And I wait for AJAX to finish
And the "Phone number" field should contain "+32477792933"
And the "Country" field should contain "HU"
Copy link
Contributor

Choose a reason for hiding this comment

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

we should verify the rest of the address and the social media,
also check values of venue and press contact

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added statements which verify the values in the entity's View page.

And the "oe_project_calls[0][title]" field should contain "Info site"
And the "Results" field should contain "My Results"
And the "Teaser" field should contain "My teaser"
And I should see the text "A Stakeholder"
Copy link
Contributor

Choose a reason for hiding this comment

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

we should check for all avail values in the inline entity form for stackeholders, participants and general contact

@georgebaev
Copy link
Contributor Author

@drishu I added the missing field values tests. Can you please review?

@georgebaev georgebaev changed the title D8TEWPPE-73: Create Behat test for testing "API steps" EWPP-258: Create Behat test for testing "API steps" Oct 15, 2020
*
* When I set "Field" to the date "22-02-2019"
* When I set "Field" to the date "22-02-2019 14:30" using format "d-m-Y H:i"
* Then datetime "15 1 2020 12 30" is selected for "Start date" of "Datetime"
Copy link
Member

Choose a reason for hiding this comment

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

Keep the previous format. Also avoid passive forms as much as possible:

Suggested change
* Then datetime "15 1 2020 12 30" is selected for "Start date" of "Datetime"
* When I set "22-02-2019 14:30" as "start date" for "Field name"

* @Then datetime :value is selected for :field_item of :field_group
* @Then date :value is selected for :field_item of :field_group
*/
public function isSelectedForOf($value, $field_item, $field_group): void {
Copy link
Member

Choose a reason for hiding this comment

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

Type hinting are missing. Also in the other methods.

* @Then the :field field contains :value
*/
public function theFieldContains($field, $value) {
$node = $this->getSession()->getPage()->findField($field);
Copy link
Member

Choose a reason for hiding this comment

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

You need to first assert that the field exists, before trying to access its value. You can use assert session for this.

*
* @When I press :button in the :rowText row
*/
public function iPressInTheRow($button, $rowText) {
Copy link
Member

Choose a reason for hiding this comment

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

Missing type hints and code sniffing shouldn't have passed here, as camel case is not allowed for method parameters. Check if that actually runs on these classes too.

$rows = $page->findAll('css', 'tr');

if (empty($rows)) {
throw new \Exception(sprintf('No rows found on the page %s', $this->getSession()->getCurrentUrl()));
Copy link
Member

Choose a reason for hiding this comment

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

You can use assert sessions to check presence of elements.

*
* @When :option should be selected for :field select
*/
public function shouldBeSelectedForSelect($option, $field) {
Copy link
Member

Choose a reason for hiding this comment

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

Don't we have this already from the Drupal extension?

@@ -0,0 +1,320 @@
@api @event
Feature: context API testing feature.
Copy link
Member

Choose a reason for hiding this comment

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

Indent properly at the beginning of the line.

And the "Online description" field should contain "Event online description"
And datetime "21 2 2019 9 15" is selected for "Start date" of "Online time"
And datetime "21 2 2019 14 0" is selected for "End date" of "Online time"
And the "oe_event_online_link[0][title]" field should contain "Info site"
Copy link
Member

Choose a reason for hiding this comment

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

We don't do this in OpenEuropa, Behat scenarios have to be readable, we have several methods to make this possible, check other components for examples.

Copy link
Member

Choose a reason for hiding this comment

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

Also this is supposed to test our API steps right? Let's assert that values are set correctly by asserting that the expected values are printed out when viewing the node, not by asserting the form. oe_content can provide default view modes.

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

Successfully merging this pull request may close these issues.

3 participants