-
Notifications
You must be signed in to change notification settings - Fork 15
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
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this 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" |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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?
tests/features/api.feature
Outdated
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" |
There was a problem hiding this comment.
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 ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I refactored the statements
tests/features/api.feature
Outdated
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" |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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" |
There was a problem hiding this comment.
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
@drishu I added the missing field values tests. Can you please review? |
735889a
to
81ec44a
Compare
* | ||
* 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" |
There was a problem hiding this comment.
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:
* 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 { |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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())); |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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" |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
This functionality adds the Behat tests for testing the API steps