From 016dcb53add21ae4f8690fffdc1ce7b12919ebd1 Mon Sep 17 00:00:00 2001 From: drishu Date: Mon, 7 Sep 2020 15:57:18 +0000 Subject: [PATCH 01/11] D8TEWPPE-73: Add behat scenarios for api steps. --- tests/Behat/DateFieldContext.php | 23 ++++++++++- tests/Behat/FeatureContext.php | 10 +++++ tests/features/api.feature | 69 ++++++++++++++++++++++++++++++++ 3 files changed, 101 insertions(+), 1 deletion(-) create mode 100644 tests/features/api.feature diff --git a/tests/Behat/DateFieldContext.php b/tests/Behat/DateFieldContext.php index 6ae5fb668..9b42118c7 100644 --- a/tests/Behat/DateFieldContext.php +++ b/tests/Behat/DateFieldContext.php @@ -119,7 +119,28 @@ public function fillDateRangeSelectListField(string $field_item, string $field_g } /** - * Set the date and time value of a date list widget. + * Check values for list date range fields. + * + * @Then :value is selected for :field_item of :field_group + * @TODO: check values against fields. + */ + public function isSelectedForOf($value, $field_item, $field_group) { + $values = explode(' ', $value); + $page = $this->getSession()->getPage(); + + $field_selectors = $this->findDateListRangeFields($field_group); + if (count($field_selectors) > 1) { + throw new \Exception('More than one elements were found.'); + } + + $field_selector = reset($field_selectors); + } + + /** + * Finds a datetime field. + * + * @param string $field + * The field name. * * 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" diff --git a/tests/Behat/FeatureContext.php b/tests/Behat/FeatureContext.php index c18b7ffeb..fb14ce91c 100644 --- a/tests/Behat/FeatureContext.php +++ b/tests/Behat/FeatureContext.php @@ -187,6 +187,16 @@ protected function getLangcodeByName(string $language_name): string { throw new \Exception("Language name '$language_name' is not valid."); } + /** + * Visit a edit page by node title. + * + * @When I visit node :arg1 edit page + */ + public function iVisitNodeEditPage($arg1) { + $node = $this->getNodeByTitle($arg1); + $this->visitPath("/node/{$node->id()}/edit"); + } + /** * Step to fill in multi value fields with columns. * diff --git a/tests/features/api.feature b/tests/features/api.feature new file mode 100644 index 000000000..32eed2a54 --- /dev/null +++ b/tests/features/api.feature @@ -0,0 +1,69 @@ +@api @event + Feature: context API testing feature. + Test entity aware hooks in context classes. + + Scenario: Test EventContentContext and BeforeParseEntityFields alterations are done. + Given I am logged in as a user with the "edit any oe_event content, access content, view published skos concept entities, manage corporate content entities" permission + And the following image: + | name | file | + | Image placeholder | example_1.jpeg | + When the following Event Content entity: + | Title | My event | + | Type | Exhibitions | + | Introduction | Short intro | + | Description summary | Event description summary | + | Description | Event description | + | Featured media legend | Event media legend | + | Summary for report | Event summary for report | + | Report text | Report text | + | Registration start date | 2020-03-01 12:30:00 | + | Registration end date | 2020-03-10 18:30:00 | + | Start date | 2020-06-15 12:30:00 | + | End date | 2020-06-20 18:30:00 | + | Registration URL | http://example.com | + | Registration capacity | Event capacity | + | Entrance fee | 1234 | + | Online type | facebook | + | Online time start | 2019-02-21 09:15:00 | + | Online time end | 2019-02-21 14:00:00 | + | Online description | Event online description | + | Online link | uri: http://ec.europa.eu/info - title: Info | + | Languages | Valencian | + | Organiser is internal | Yes | + | Internal organiser | Directorate-General for Informatics | + | Status | as_planned | + | Event website | uri: https://ec.europa.eu/inea/ - title: INEA | + | Social media links | uri: http://example.com - title: Twitter - link_type: twitter | + | Featured media | Image placeholder | + + When I visit node "My event" edit page + Then I should see the text "My event" + And I should see the text "Exhibitions" + And I should see the text "Short intro" + And I should see the text "Event description summary" + And I should see the text "Event description" +# And I should see the text "Event media legend" + And I should see the text "Event summary for report" + And I should see the text "Report text" + And I should see the text "http://example.com" +# And I should see the text "Event capacity" + And I should see the text "1234" + And I should see the text "Facebook" + And I should see the text "Event online description" + And I should see the text "Info" +# And I should see the text "http://ec.europa.eu/info" +# And I should see the text "Valencian" +# And I should see the text "Directorate-General for Informatics" + And I should see the text "As planned" + And I should see the text "INEA" + And I should see the text "http://example.com" + And I should see the text "Twitter" +# And I should see the text "Image placeholder" + And "15 Jun 2020 12 30" is selected for "Start date" of "Event date" +# 'Organiser name' => 'oe_event_organiser_name', + # @TODO: finish checking daterange fields, check organiser name, see why the commented out ones fail. + # @TODO: check venue & organiser. + + Scenario: Test ProjectContentContext and BeforeParseEntityFields alterations are done. + Given I am logged in as a user with the "edit any oe_project content, access content, view published skos concept entities, manage corporate content entities" permission + # @TODO: finish this. From 315e7f0b52b21e23a74166a514e61ad6eb731c48 Mon Sep 17 00:00:00 2001 From: drishu Date: Wed, 9 Sep 2020 11:08:45 +0000 Subject: [PATCH 02/11] D8TEWPPE-73: Add steps. --- behat.yml.dist | 3 + tests/Behat/DateFieldContext.php | 45 ++++++++++-- tests/Behat/FeatureContext.php | 66 +++++++++++++++++ tests/features/api.feature | 121 ++++++++++++++++++++++--------- 4 files changed, 195 insertions(+), 40 deletions(-) diff --git a/behat.yml.dist b/behat.yml.dist index 272405d0a..294187799 100644 --- a/behat.yml.dist +++ b/behat.yml.dist @@ -17,6 +17,9 @@ default: - Drupal\Tests\oe_media\Behat\FeatureContext - Drupal\Tests\oe_content\Behat\Content\CorporateContentContext - Drupal\Tests\oe_content\Behat\Content\Node\EventContentContext + - Drupal\Tests\oe_content\Behat\Content\Venue\DefaultVenueContext + - Drupal\Tests\oe_content\Behat\Content\Contact\GeneralContactContext + - Drupal\Tests\oe_content\Behat\Content\Contact\PressContactContext - Drupal\Tests\oe_content\Behat\Content\Node\ProjectContentContext - OpenEuropa\Behat\TransformationContext: elements: diff --git a/tests/Behat/DateFieldContext.php b/tests/Behat/DateFieldContext.php index 9b42118c7..23bda7fc6 100644 --- a/tests/Behat/DateFieldContext.php +++ b/tests/Behat/DateFieldContext.php @@ -121,19 +121,54 @@ public function fillDateRangeSelectListField(string $field_item, string $field_g /** * Check values for list date range fields. * - * @Then :value is selected for :field_item of :field_group - * @TODO: check values against fields. + * "15 Jun 2020 12 30" is selected for "Start date" of "My date range field" + * + * @param string $value + * The value of the field. + * @param string $field_item + * The date field item inside the field component. + * @param string $field_group + * The field component's label. + * + * @Then datetime :value is selected for :field_item of :field_group */ - public function isSelectedForOf($value, $field_item, $field_group) { + public function isSelectedForOf($value, $field_item, $field_group): void { $values = explode(' ', $value); - $page = $this->getSession()->getPage(); - $field_selectors = $this->findDateListRangeFields($field_group); + if (count($field_selectors) > 1) { throw new \Exception('More than one elements were found.'); } $field_selector = reset($field_selectors); + if ($field_item === 'End date') { + $field_selector = $field_selector->findAll('css', 'div[id*="end-value"]'); + $field_selector = reset($field_selector); + } + + $date_components = [ + 'Day', + 'Month', + 'Year', + 'Hour', + 'Minute', + ]; + + foreach ($date_components as $index => $date_component) { + $field = $field_selector->findField($date_component); + $optionField = $field->find('named', [ + 'option', + $values[$index], + ]); + + if ($optionField === NULL) { + throw new \Exception('Option not found.'); + } + + if (!$optionField->isSelected()) { + throw new \Exception('Option is not selected.'); + } + } } /** diff --git a/tests/Behat/FeatureContext.php b/tests/Behat/FeatureContext.php index fb14ce91c..0c433cdce 100644 --- a/tests/Behat/FeatureContext.php +++ b/tests/Behat/FeatureContext.php @@ -197,6 +197,72 @@ public function iVisitNodeEditPage($arg1) { $this->visitPath("/node/{$node->id()}/edit"); } + /** + * Checks, that form field has specified value. + * + * @Then the :field field contains :value + */ + public function theFieldContains($field, $value) { + $node = $this->getSession()->getPage()->findField($field); + $actual = $node->getValue(); + + if (strpos($actual, $value) === FALSE) { + throw new \Exception(sprintf('Field %s does not contain %s.', $field, $value)); + } + } + + /** + * Attempts to find a button in a table row containing giving text. + * + * @When I press :button in the :rowText row + */ + public function iPressInTheRow($button, $rowText) { + $page = $this->getSession()->getPage(); + $rows = $page->findAll('css', 'tr'); + + if (empty($rows)) { + throw new \Exception(sprintf('No rows found on the page %s', $this->getSession()->getCurrentUrl())); + } + + /** @var \Behat\Mink\Element\NodeElement $row */ + foreach ($rows as $row) { + if (strpos($row->getText(), $rowText) !== FALSE) { + break; + } + } + + if ($row === NULL) { + throw new \Exception(sprintf('Row "%s" not found', $rowText)); + } + + $button_element = $row->findButton($button); + + if ($button_element === NULL) { + throw new \Exception(sprintf('Button "%s" not found in row %s', $button, $rowText)); + } + + $button_element->press(); + } + + /** + * Assert option is selected. + * + * @When :option should be selected for :field select + */ + public function shouldBeSelectedForSelect($option, $field) { + if (!$element = $this->getSession()->getPage()->findField($field)) { + throw new \Exception(sprintf('Field %s not found.', $field)); + } + + $selected_option = $element->find('css', "option[selected='selected']"); + + if ($selected_option === NULL) { + throw new \Exception(sprintf('Option "%s" not found for %s select', $option, $field)); + } + + Assert::assertTrue($selected_option->getValue() === $option); + } + /** * Step to fill in multi value fields with columns. * diff --git a/tests/features/api.feature b/tests/features/api.feature index 32eed2a54..062a7562d 100644 --- a/tests/features/api.feature +++ b/tests/features/api.feature @@ -2,39 +2,40 @@ Feature: context API testing feature. Test entity aware hooks in context classes. - Scenario: Test EventContentContext and BeforeParseEntityFields alterations are done. + @javascript + Scenario: Test EventContentContext where BeforeParseEntityFields alterations are done. Given I am logged in as a user with the "edit any oe_event content, access content, view published skos concept entities, manage corporate content entities" permission And the following image: | name | file | | Image placeholder | example_1.jpeg | - When the following Event Content entity: - | Title | My event | - | Type | Exhibitions | - | Introduction | Short intro | - | Description summary | Event description summary | - | Description | Event description | - | Featured media legend | Event media legend | - | Summary for report | Event summary for report | - | Report text | Report text | - | Registration start date | 2020-03-01 12:30:00 | - | Registration end date | 2020-03-10 18:30:00 | - | Start date | 2020-06-15 12:30:00 | - | End date | 2020-06-20 18:30:00 | - | Registration URL | http://example.com | - | Registration capacity | Event capacity | - | Entrance fee | 1234 | - | Online type | facebook | + And the following Event Content entity: + | Title | My event | + | Type | Exhibitions | + | Introduction | Short intro | + | Description summary | Event description summary | + | Description | Event description | + | Featured media | Image placeholder | + | Featured media legend | Event media legend | + | Summary for report | Event summary for report | + | Report text | Report text | + | Registration start date | 2020-03-01 12:30:00 | + | Registration end date | 2020-03-10 18:30:00 | + | Start date | 2020-06-15 12:30:00 | + | End date | 2020-06-20 18:30:00 | + | Registration URL | http://example.com | + | Registration capacity | Event capacity | + | Entrance fee | 1234 | + | Online type | facebook | | Online time start | 2019-02-21 09:15:00 | | Online time end | 2019-02-21 14:00:00 | | Online description | Event online description | - | Online link | uri: http://ec.europa.eu/info - title: Info | + | Online link | uri: http://ec.europa.eu/info - title: Info site | | Languages | Valencian | | Organiser is internal | Yes | | Internal organiser | Directorate-General for Informatics | | Status | as_planned | | Event website | uri: https://ec.europa.eu/inea/ - title: INEA | | Social media links | uri: http://example.com - title: Twitter - link_type: twitter | - | Featured media | Image placeholder | When I visit node "My event" edit page Then I should see the text "My event" @@ -42,28 +43,78 @@ And I should see the text "Short intro" And I should see the text "Event description summary" And I should see the text "Event description" -# And I should see the text "Event media legend" + And the "Featured media legend" field should contain "Event media legend" + And I press "Event report" And I should see the text "Event summary for report" And I should see the text "Report text" + And I press "Registration" And I should see the text "http://example.com" -# And I should see the text "Event capacity" - And I should see the text "1234" + 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 I should see the text "Event online description" - And I should see the text "Info" -# And I should see the text "http://ec.europa.eu/info" -# And I should see the text "Valencian" -# And I should see the text "Directorate-General for Informatics" + And datetime "1 Mar 2020 12 30" is selected for "Start date" of "Registration date" + And datetime "10 Mar 2020 18 30" is selected for "End date" of "Registration date" + And I press "Online" + And the "Online description" field should contain "Event online description" + And datetime "21 Feb 2019 9 15" is selected for "Start date" of "Online time" + And datetime "21 Feb 2019 14 00" is selected for "End date" of "Online time" + And the "oe_event_online_link[0][title]" field should contain "Info site" + And the "oe_event_online_link[0][uri]" field should contain "http://ec.europa.eu/info" + And the "oe_event_languages[0][target_id]" field should contain "Valencian (http://publications.europa.eu/resource/authority/language/0D0)" + And the "Internal organiser" field should contain "Directorate-General for Informatics (http://publications.europa.eu/resource/authority/corporate-body/DIGIT)" And I should see the text "As planned" And I should see the text "INEA" And I should see the text "http://example.com" And I should see the text "Twitter" -# And I should see the text "Image placeholder" - And "15 Jun 2020 12 30" is selected for "Start date" of "Event date" -# 'Organiser name' => 'oe_event_organiser_name', - # @TODO: finish checking daterange fields, check organiser name, see why the commented out ones fail. - # @TODO: check venue & organiser. + And the "oe_event_featured_media[0][target_id]" field contains "Image placeholder" + And datetime "15 Jun 2020 12 30" is selected for "Start date" of "Event date" + And datetime "20 Jun 2020 18 30" is selected for "End date" of "Event date" + And the "oe_subject[0][target_id]" field should contain "financing (http://data.europa.eu/uxp/1000)" + And the "oe_author[0][target_id]" field should contain "Directorate-General for Communication (http://publications.europa.eu/resource/authority/corporate-body/COMMU)" + And the "oe_content_content_owner[0][target_id]" field should contain "Directorate-General for Communication (http://publications.europa.eu/resource/authority/corporate-body/COMMU)" + + # Add related entities, such as venues and contacts and reload the page. + When the following Default Venue entity: + | Name | DIGIT | + | Address | country_code: BE - locality: Brussels - address_line1: Rue Belliard 28 - postal_code: 1000 | + | Capacity | 12 people | + | Room | B-28 03/A150 | + And the following Press Contact entity: + | Name | A press contact | + | Address | country_code: HU - locality: Szeged - address_line1: Press contact 1 - postal_code: 6700 | + | Email | press@example.com | + | Phone number | +32477777778 | + | Social media links | uri: http://facebook.com - title: Facebook - link_type: facebook | + And the following General Contact entity: + | Name | A general contact | + | Address | country_code: HU - locality: Budapest - address_line1: General contact 1 - postal_code: 1011 | + | Email | general@example.com | + | Phone number | +32477792933 | + | Social media links | uri: http://instagram.com - title: Instagram - link_type: instagram | + And the Event Content "My event" is updated as follows: + | Venue | DIGIT | + | Contact | A press contact, A general contact | + | Organiser is internal | No | + | Organiser name | Name of the organiser | + And I reload the page + And the "Organiser name" field should contain "Name of the organiser" + + # Assert contacts. + 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 "HU" should be selected for "Country" select in the "Event contact" region +# And the "Country" field should contain "HU" +# And the "oe_event_contact[form][inline_entity_form][entities][0][form][oe_address][0][address][locality]" field should contain "Budapest" +# And I fill in "Office" with "Office" in the "Event contact" region +# And I take a screenshot +# And the "City" field should contain "Budapest" + + + #, General contact 1, 1011, Hungary"" +# And I should see the text "general@example.com" +# And I should see the link "Instagram" - Scenario: Test ProjectContentContext and BeforeParseEntityFields alterations are done. - Given I am logged in as a user with the "edit any oe_project content, access content, view published skos concept entities, manage corporate content entities" permission +# Scenario: Test ProjectContentContext and BeforeParseEntityFields alterations are done. +# Given I am logged in as a user with the "edit any oe_project content, access content, view published skos concept entities, manage corporate content entities" permission # @TODO: finish this. From 0a58740d4e0c94691f8b6e277e0daf3113da7f08 Mon Sep 17 00:00:00 2001 From: George Baev Date: Wed, 7 Oct 2020 15:55:11 +0300 Subject: [PATCH 03/11] D8TEWPPE-73: Add Project Content API steps test. --- behat.yml.dist | 3 + tests/features/api.feature | 169 +++++++++++++++++++++++++++++++++---- 2 files changed, 157 insertions(+), 15 deletions(-) diff --git a/behat.yml.dist b/behat.yml.dist index 294187799..ac441cb66 100644 --- a/behat.yml.dist +++ b/behat.yml.dist @@ -18,9 +18,12 @@ default: - Drupal\Tests\oe_content\Behat\Content\CorporateContentContext - Drupal\Tests\oe_content\Behat\Content\Node\EventContentContext - Drupal\Tests\oe_content\Behat\Content\Venue\DefaultVenueContext + - Drupal\Tests\oe_content\Behat\Content\Organisation\StakeholderOrganisationContext - Drupal\Tests\oe_content\Behat\Content\Contact\GeneralContactContext - Drupal\Tests\oe_content\Behat\Content\Contact\PressContactContext - Drupal\Tests\oe_content\Behat\Content\Node\ProjectContentContext + - Drupal\Tests\oe_content\Behat\Content\Node\CallForTendersContentContext + - Drupal\Tests\oe_content\Behat\Content\Node\OrganisationContentContext - OpenEuropa\Behat\TransformationContext: elements: Internal organiser field: "#edit-oe-event-organiser-internal-0-target-id" diff --git a/tests/features/api.feature b/tests/features/api.feature index 062a7562d..dbf8a5c12 100644 --- a/tests/features/api.feature +++ b/tests/features/api.feature @@ -52,23 +52,46 @@ 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 datetime "1 Mar 2020 12 30" is selected for "Start date" of "Registration date" - And datetime "10 Mar 2020 18 30" is selected for "End date" of "Registration date" + And the "oe_event_registration_dates[0][value][day]" field should contain "1" + And the "oe_event_registration_dates[0][value][month]" field should contain "3" + And the "oe_event_registration_dates[0][value][year]" field should contain "2020" + And the "oe_event_registration_dates[0][value][hour]" field should contain "12" + And the "oe_event_registration_dates[0][value][minute]" field should contain "30" + And the "oe_event_registration_dates[0][end_value][day]" field should contain "10" + And the "oe_event_registration_dates[0][end_value][month]" field should contain "3" + And the "oe_event_registration_dates[0][end_value][year]" field should contain "2020" + And the "oe_event_registration_dates[0][end_value][hour]" field should contain "18" + And the "oe_event_registration_dates[0][end_value][minute]" field should contain "30" And I press "Online" And the "Online description" field should contain "Event online description" - And datetime "21 Feb 2019 9 15" is selected for "Start date" of "Online time" - And datetime "21 Feb 2019 14 00" is selected for "End date" of "Online time" + And the "oe_event_online_dates[0][value][day]" field should contain "21" + And the "oe_event_online_dates[0][value][month]" field should contain "2" + And the "oe_event_online_dates[0][value][year]" field should contain "2019" + And the "oe_event_online_dates[0][value][hour]" field should contain "9" + And the "oe_event_online_dates[0][value][minute]" field should contain "15" + And the "oe_event_online_dates[0][end_value][day]" field should contain "21" + And the "oe_event_online_dates[0][end_value][month]" field should contain "2" + And the "oe_event_online_dates[0][end_value][year]" field should contain "2019" + And the "oe_event_online_dates[0][end_value][hour]" field should contain "14" + And the "oe_event_online_dates[0][end_value][minute]" field should contain "0" And the "oe_event_online_link[0][title]" field should contain "Info site" And the "oe_event_online_link[0][uri]" field should contain "http://ec.europa.eu/info" And the "oe_event_languages[0][target_id]" field should contain "Valencian (http://publications.europa.eu/resource/authority/language/0D0)" And the "Internal organiser" field should contain "Directorate-General for Informatics (http://publications.europa.eu/resource/authority/corporate-body/DIGIT)" And I should see the text "As planned" - And I should see the text "INEA" And I should see the text "http://example.com" And I should see the text "Twitter" And the "oe_event_featured_media[0][target_id]" field contains "Image placeholder" - And datetime "15 Jun 2020 12 30" is selected for "Start date" of "Event date" - And datetime "20 Jun 2020 18 30" is selected for "End date" of "Event date" + And the "oe_event_dates[0][value][day]" field should contain "15" + And the "oe_event_dates[0][value][month]" field should contain "6" + And the "oe_event_dates[0][value][year]" field should contain "2020" + And the "oe_event_dates[0][value][hour]" field should contain "12" + And the "oe_event_dates[0][value][minute]" field should contain "30" + And the "oe_event_dates[0][end_value][day]" field should contain "20" + And the "oe_event_dates[0][end_value][month]" field should contain "6" + And the "oe_event_dates[0][end_value][year]" field should contain "2020" + And the "oe_event_dates[0][end_value][hour]" field should contain "18" + And the "oe_event_dates[0][end_value][minute]" field should contain "30" And the "oe_subject[0][target_id]" field should contain "financing (http://data.europa.eu/uxp/1000)" And the "oe_author[0][target_id]" field should contain "Directorate-General for Communication (http://publications.europa.eu/resource/authority/corporate-body/COMMU)" And the "oe_content_content_owner[0][target_id]" field should contain "Directorate-General for Communication (http://publications.europa.eu/resource/authority/corporate-body/COMMU)" @@ -103,18 +126,134 @@ 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 "HU" should be selected for "Country" select in the "Event contact" region -# And the "Country" field should contain "HU" + And the "Country" field should contain "HU" # And the "oe_event_contact[form][inline_entity_form][entities][0][form][oe_address][0][address][locality]" field should contain "Budapest" # And I fill in "Office" with "Office" in the "Event contact" region # And I take a screenshot # And the "City" field should contain "Budapest" + @javascript + Scenario: Test ProjectContentContext and BeforeParseEntityFields alterations are done. + Given I am logged in as a user with the "edit any oe_project content, access content, view published skos concept entities, manage corporate content entities, view published oe_organisation" permission + + When the following Stakeholder Organisation entity: + | Name | A Stakeholder | + | Acronym | AAAAA | + | Address | country_code: HU - locality: Szeged - address_line1: Press contact 1 - postal_code: 6700 | + | Website | uri: http://facebook.com - title: Facebook | + + And the following Stakeholder Organisation entity: + | Name | A Participant | + | Acronym | PPPPP | + | Address | country_code: HU - locality: Szeged - address_line1: Press contact 1 - postal_code: 6700 | + | Website | uri: http://facebook.com - title: Facebook | - #, General contact 1, 1011, Hungary"" -# And I should see the text "general@example.com" -# And I should see the link "Instagram" + And the following General Contact entity: + | Name | A general contact | + | Address | country_code: HU - locality: Budapest - address_line1: General contact 1 - postal_code: 1011 | + | Email | general@example.com | + | Phone number | +32477792933 | + | Social media links | uri: http://instagram.com - title: Instagram - link_type: instagram | + + And the following image: + | name | file | + | Image placeholder | example_1.jpeg | + + And the following document: + | name | file | + | Document placeholder | document.pdf | + + And the following Project Content entity: + | Title | My project | + | Summary | My Summary | + | Reference | My Reference | + | Project period start date | 2020-01-01 | + | Project period end date | 2020-01-02 | + | Overall budget | 100000 | + | EU contribution | 50000 | + | Website | uri: http://ec.europa.eu/info - title: Info site | + | Body text | My Body text | + | Call for proposals | uri: http://ec.europa.eu/info - title: Info site | + | Results | My Results | + | Teaser | My teaser | + | Coordinators | A Stakeholder | + | Departments | Asian Development Bank | + | Featured media | Image placeholder | + | Funding programme | Anti Fraud Information System (AFIS) | + | Participants | A Participant | + | Project contact | A general contact | + | Documents | Document placeholder | + | Result files | Document placeholder | + + When I visit node "My project" edit page + Then I should see the text "My project" + And I should see the text "My Summary" + And the "Reference" field should contain "My Reference" + And the "oe_project_dates[0][value][day]" field should contain "1" + And the "oe_project_dates[0][value][month]" field should contain "1" + And the "oe_project_dates[0][value][year]" field should contain "2020" + And the "oe_project_dates[0][end_value][day]" field should contain "2" + And the "oe_project_dates[0][end_value][month]" field should contain "1" + And the "oe_project_dates[0][end_value][year]" field should contain "2020" + And the "Overall budget" field should contain "100000" + And the "EU contribution" field should contain "50000" + And the "oe_project_website[0][uri]" field should contain "http://ec.europa.eu/info" + And the "oe_project_website[0][title]" field should contain "Info site" + And the "Body text" field should contain "My Body text" + And the "oe_project_calls[0][uri]" field should contain "http://ec.europa.eu/info" + 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" + And I should see the text "A Participant" + And I should see the text "A general contact" + And the "oe_departments[0][target_id]" field should contain "Asian Development Bank (http://eurovoc.europa.eu/6336)" + And the "oe_project_funding_programme[0][target_id]" field should contain "Anti Fraud Information System (AFIS) (http://publications.europa.eu/resource/authority/eu-programme/AFIS2020)" + + @javascript + Scenario: Test CallForTendersContentContext and BeforeParseEntityFields alterations are done. + Given I am logged in as a user with the "edit any oe_call_tenders content, access content, view published skos concept entities, manage corporate content entities" permission + And the following "Call for tenders" Content entity: + | Title | My Call for tenders | + | Body text | My Body text | + | Publication date | 2020-01-01 | + | Opening date | 2020-01-01 | + | Deadline date | 2020-01-01 10:00:00 | + | Introduction | My Introduction | + | Reference | My Reference | + | Teaser | My teaser | + + When I visit node "My Call for tenders" edit page + Then I should see the text "My Call for tenders" + And the "Introduction" field should contain "My Introduction" + And the "oe_publication_date[0][value][day]" field should contain "1" + And the "oe_publication_date[0][value][month]" field should contain "1" + And the "oe_publication_date[0][value][year]" field should contain "2020" + And the "oe_call_tenders_opening_date[0][value][day]" field should contain "1" + And the "oe_call_tenders_opening_date[0][value][month]" field should contain "1" + And the "oe_call_tenders_opening_date[0][value][year]" field should contain "2020" + And the "oe_call_tenders_deadline[0][value][day]" field should contain "1" + And the "oe_call_tenders_deadline[0][value][month]" field should contain "1" + And the "oe_call_tenders_deadline[0][value][year]" field should contain "2020" + And the "oe_call_tenders_deadline[0][value][hour]" field should contain "10" + And the "oe_call_tenders_deadline[0][value][minute]" field should contain "0" + And the "Reference" field should contain "My Reference" + And the "Body text" field should contain "My Body text" + And the "Teaser" field should contain "My teaser" + + @javascript + Scenario: Test OrganisationContentContext and BeforeParseEntityFields alterations are done. + Given I am logged in as a user with the "edit any oe_organisation content, access content" permission + And the following "Organisation" Content entity: + | Title | My Organisation | + | Introduction | My Introduction | + | Body text | My Body text | + | Acronym | My acronym | + | Alternative title | My Alternative Organisation | -# Scenario: Test ProjectContentContext and BeforeParseEntityFields alterations are done. -# Given I am logged in as a user with the "edit any oe_project content, access content, view published skos concept entities, manage corporate content entities" permission - # @TODO: finish this. + When I visit node "My Organisation" edit page + Then I should see the text "My Organisation" + And the "Introduction" field should contain "My Introduction" + And the "Body text" field should contain "My Body text" + And the "Acronym" field should contain "My acronym" + And the "Alternative title" field should contain "My Alternative Organisation" From 6b7c230b4be8749a76673d2719554c6810c0fa6e Mon Sep 17 00:00:00 2001 From: George Baev Date: Thu, 8 Oct 2020 10:20:12 +0300 Subject: [PATCH 04/11] D8TEWPPE-73: Alter the PhpCS related formatting. --- tests/Behat/DateFieldContext.php | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/tests/Behat/DateFieldContext.php b/tests/Behat/DateFieldContext.php index 23bda7fc6..c754a9a87 100644 --- a/tests/Behat/DateFieldContext.php +++ b/tests/Behat/DateFieldContext.php @@ -176,12 +176,9 @@ public function isSelectedForOf($value, $field_item, $field_group): void { * * @param string $field * The field name. - * - * 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" - * - * @param string $field - * The label of the field. + * 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". * @param string $value * The value of the field. * @param string $format From 3bc9040f5db1bff04eceb44c3c1af992cb406f11 Mon Sep 17 00:00:00 2001 From: George Baev Date: Thu, 8 Oct 2020 11:29:56 +0300 Subject: [PATCH 05/11] D8TEWPPE-73: Add ContentContext tests. --- tests/features/api.feature | 58 +++++++++++++++++++++++++++----------- 1 file changed, 41 insertions(+), 17 deletions(-) diff --git a/tests/features/api.feature b/tests/features/api.feature index dbf8a5c12..ff54082ea 100644 --- a/tests/features/api.feature +++ b/tests/features/api.feature @@ -122,15 +122,10 @@ And I reload the page And the "Organiser name" field should contain "Name of the organiser" - # Assert contacts. 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" -# And the "oe_event_contact[form][inline_entity_form][entities][0][form][oe_address][0][address][locality]" field should contain "Budapest" -# And I fill in "Office" with "Office" in the "Event contact" region -# And I take a screenshot -# And the "City" field should contain "Budapest" @javascript Scenario: Test ProjectContentContext and BeforeParseEntityFields alterations are done. @@ -213,15 +208,22 @@ @javascript Scenario: Test CallForTendersContentContext and BeforeParseEntityFields alterations are done. Given I am logged in as a user with the "edit any oe_call_tenders content, access content, view published skos concept entities, manage corporate content entities" permission + + And the following document: + | name | file | + | Document placeholder | document.pdf | + And the following "Call for tenders" Content entity: - | Title | My Call for tenders | - | Body text | My Body text | - | Publication date | 2020-01-01 | - | Opening date | 2020-01-01 | - | Deadline date | 2020-01-01 10:00:00 | - | Introduction | My Introduction | - | Reference | My Reference | - | Teaser | My teaser | + | Title | My Call for tenders | + | Body text | My Body text | + | Publication date | 2020-01-01 | + | Opening date | 2020-01-01 | + | Deadline date | 2020-01-01 10:00:00 | + | Introduction | My Introduction | + | Reference | My Reference | + | Teaser | My teaser | + | Documents | Document placeholder | + | Responsible department | Asian Development Bank | When I visit node "My Call for tenders" edit page Then I should see the text "My Call for tenders" @@ -240,16 +242,34 @@ And the "Reference" field should contain "My Reference" And the "Body text" field should contain "My Body text" And the "Teaser" field should contain "My teaser" + And the "oe_departments[0][target_id]" field should contain "Asian Development Bank (http://eurovoc.europa.eu/6336)" @javascript Scenario: Test OrganisationContentContext and BeforeParseEntityFields alterations are done. - Given I am logged in as a user with the "edit any oe_organisation content, access content" permission + Given I am logged in as a user with the "edit any oe_organisation content, access content, view published skos concept entities" permission + + And the following General Contact entity: + | Name | A general contact | + | Address | country_code: HU - locality: Budapest - address_line1: General contact 1 - postal_code: 1011 | + | Email | general@example.com | + | Phone number | +32477792933 | + | Social media links | uri: http://instagram.com - title: Instagram - link_type: instagram | + + And the following image: + | name | file | + | Image placeholder | example_1.jpeg | + And the following "Organisation" Content entity: - | Title | My Organisation | - | Introduction | My Introduction | - | Body text | My Body text | + | Title | My Organisation | + | Introduction | My Introduction | + | Body text | My Body text | | Acronym | My acronym | | Alternative title | My Alternative Organisation | + | Contact | A general contact | + | EU organisation | Arab Common Market | + | Organisation type | eu | + | Logo | Image placeholder | + | Teaser | My teaser | When I visit node "My Organisation" edit page Then I should see the text "My Organisation" @@ -257,3 +277,7 @@ And the "Body text" field should contain "My Body text" And the "Acronym" field should contain "My acronym" And the "Alternative title" field should contain "My Alternative Organisation" + 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" From d3a097c4e7f278d45e181904f678142c8b4762c2 Mon Sep 17 00:00:00 2001 From: George Baev Date: Tue, 13 Oct 2020 10:55:46 +0300 Subject: [PATCH 06/11] D8TEWPPE-73: Alter the select Behat statements. --- tests/features/api.feature | 96 +++++++++++++++++++------------------- 1 file changed, 48 insertions(+), 48 deletions(-) diff --git a/tests/features/api.feature b/tests/features/api.feature index ff54082ea..3913ff397 100644 --- a/tests/features/api.feature +++ b/tests/features/api.feature @@ -52,28 +52,28 @@ 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" - And the "oe_event_registration_dates[0][value][month]" field should contain "3" - And the "oe_event_registration_dates[0][value][year]" field should contain "2020" - And the "oe_event_registration_dates[0][value][hour]" field should contain "12" - And the "oe_event_registration_dates[0][value][minute]" field should contain "30" - And the "oe_event_registration_dates[0][end_value][day]" field should contain "10" - And the "oe_event_registration_dates[0][end_value][month]" field should contain "3" - And the "oe_event_registration_dates[0][end_value][year]" field should contain "2020" - And the "oe_event_registration_dates[0][end_value][hour]" field should contain "18" - And the "oe_event_registration_dates[0][end_value][minute]" field should contain "30" + And "1" should be selected for "oe_event_registration_dates[0][value][day]" select + And "3" should be selected for "oe_event_registration_dates[0][value][month]" select + And "2020" should be selected for "oe_event_registration_dates[0][value][year]" select + And "12" should be selected for "oe_event_registration_dates[0][value][hour]" select + And "30" should be selected for "oe_event_registration_dates[0][value][minute]" select + And "10" should be selected for "oe_event_registration_dates[0][end_value][day]" select + And "3" should be selected for "oe_event_registration_dates[0][end_value][month]" select + And "2020" should be selected for "oe_event_registration_dates[0][end_value][year]" select + And "18" should be selected for "oe_event_registration_dates[0][end_value][hour]" select + And "30" should be selected for "oe_event_registration_dates[0][end_value][minute]" select And I press "Online" And the "Online description" field should contain "Event online description" - And the "oe_event_online_dates[0][value][day]" field should contain "21" - And the "oe_event_online_dates[0][value][month]" field should contain "2" - And the "oe_event_online_dates[0][value][year]" field should contain "2019" - And the "oe_event_online_dates[0][value][hour]" field should contain "9" - And the "oe_event_online_dates[0][value][minute]" field should contain "15" - And the "oe_event_online_dates[0][end_value][day]" field should contain "21" - And the "oe_event_online_dates[0][end_value][month]" field should contain "2" - And the "oe_event_online_dates[0][end_value][year]" field should contain "2019" - And the "oe_event_online_dates[0][end_value][hour]" field should contain "14" - And the "oe_event_online_dates[0][end_value][minute]" field should contain "0" + And "21" should be selected for "oe_event_online_dates[0][value][day]" select + And "2" should be selected for "oe_event_online_dates[0][value][month]" select + And "2019" should be selected for "oe_event_online_dates[0][value][year]" select + And "9" should be selected for "oe_event_online_dates[0][value][hour]" select + And "15" should be selected for "oe_event_online_dates[0][value][minute]" select + And "21" should be selected for "oe_event_online_dates[0][end_value][day]" select + And "2" should be selected for "oe_event_online_dates[0][end_value][month]" select + And "2019" should be selected for "oe_event_online_dates[0][end_value][year]" select + And "14" should be selected for "oe_event_online_dates[0][end_value][hour]" select + And "0" should be selected for "oe_event_online_dates[0][end_value][minute]" select And the "oe_event_online_link[0][title]" field should contain "Info site" And the "oe_event_online_link[0][uri]" field should contain "http://ec.europa.eu/info" And the "oe_event_languages[0][target_id]" field should contain "Valencian (http://publications.europa.eu/resource/authority/language/0D0)" @@ -82,16 +82,16 @@ And I should see the text "http://example.com" And I should see the text "Twitter" And the "oe_event_featured_media[0][target_id]" field contains "Image placeholder" - And the "oe_event_dates[0][value][day]" field should contain "15" - And the "oe_event_dates[0][value][month]" field should contain "6" - And the "oe_event_dates[0][value][year]" field should contain "2020" - And the "oe_event_dates[0][value][hour]" field should contain "12" - And the "oe_event_dates[0][value][minute]" field should contain "30" - And the "oe_event_dates[0][end_value][day]" field should contain "20" - And the "oe_event_dates[0][end_value][month]" field should contain "6" - And the "oe_event_dates[0][end_value][year]" field should contain "2020" - And the "oe_event_dates[0][end_value][hour]" field should contain "18" - And the "oe_event_dates[0][end_value][minute]" field should contain "30" + And "15" should be selected for "oe_event_dates[0][value][day]" select + And "6" should be selected for "oe_event_dates[0][value][month]" select + And "2020" should be selected for "oe_event_dates[0][value][year]" select + And "12" should be selected for "oe_event_dates[0][value][hour]" select + And "30" should be selected for "oe_event_dates[0][value][minute]" select + And "20" should be selected for "oe_event_dates[0][end_value][day]" select + And "6" should be selected for "oe_event_dates[0][end_value][month]" select + And "2020" should be selected for "oe_event_dates[0][end_value][year]" select + And "18" should be selected for "oe_event_dates[0][end_value][hour]" select + And "30" should be selected for "oe_event_dates[0][end_value][minute]" select And the "oe_subject[0][target_id]" field should contain "financing (http://data.europa.eu/uxp/1000)" And the "oe_author[0][target_id]" field should contain "Directorate-General for Communication (http://publications.europa.eu/resource/authority/corporate-body/COMMU)" And the "oe_content_content_owner[0][target_id]" field should contain "Directorate-General for Communication (http://publications.europa.eu/resource/authority/corporate-body/COMMU)" @@ -184,12 +184,12 @@ Then I should see the text "My project" And I should see the text "My Summary" And the "Reference" field should contain "My Reference" - And the "oe_project_dates[0][value][day]" field should contain "1" - And the "oe_project_dates[0][value][month]" field should contain "1" - And the "oe_project_dates[0][value][year]" field should contain "2020" - And the "oe_project_dates[0][end_value][day]" field should contain "2" - And the "oe_project_dates[0][end_value][month]" field should contain "1" - And the "oe_project_dates[0][end_value][year]" field should contain "2020" + And "1" should be selected for "oe_project_dates[0][value][day]" select + And "1" should be selected for "oe_project_dates[0][value][month]" select + And "2020" should be selected for "oe_project_dates[0][value][year]" select + And "2" should be selected for "oe_project_dates[0][end_value][day]" select + And "1" should be selected for "oe_project_dates[0][end_value][month]" select + And "2020" should be selected for "oe_project_dates[0][end_value][year]" select And the "Overall budget" field should contain "100000" And the "EU contribution" field should contain "50000" And the "oe_project_website[0][uri]" field should contain "http://ec.europa.eu/info" @@ -205,7 +205,7 @@ And the "oe_departments[0][target_id]" field should contain "Asian Development Bank (http://eurovoc.europa.eu/6336)" And the "oe_project_funding_programme[0][target_id]" field should contain "Anti Fraud Information System (AFIS) (http://publications.europa.eu/resource/authority/eu-programme/AFIS2020)" - @javascript + @javascript @aabbcc Scenario: Test CallForTendersContentContext and BeforeParseEntityFields alterations are done. Given I am logged in as a user with the "edit any oe_call_tenders content, access content, view published skos concept entities, manage corporate content entities" permission @@ -228,17 +228,17 @@ When I visit node "My Call for tenders" edit page Then I should see the text "My Call for tenders" And the "Introduction" field should contain "My Introduction" - And the "oe_publication_date[0][value][day]" field should contain "1" - And the "oe_publication_date[0][value][month]" field should contain "1" - And the "oe_publication_date[0][value][year]" field should contain "2020" - And the "oe_call_tenders_opening_date[0][value][day]" field should contain "1" - And the "oe_call_tenders_opening_date[0][value][month]" field should contain "1" - And the "oe_call_tenders_opening_date[0][value][year]" field should contain "2020" - And the "oe_call_tenders_deadline[0][value][day]" field should contain "1" - And the "oe_call_tenders_deadline[0][value][month]" field should contain "1" - And the "oe_call_tenders_deadline[0][value][year]" field should contain "2020" - And the "oe_call_tenders_deadline[0][value][hour]" field should contain "10" - And the "oe_call_tenders_deadline[0][value][minute]" field should contain "0" + And "1" should be selected for "oe_publication_date[0][value][day]" select + And "1" should be selected for "oe_publication_date[0][value][month]" select + And "2020" should be selected for "oe_publication_date[0][value][year]" select + And "1" should be selected for "oe_call_tenders_opening_date[0][value][day]" select + And "1" should be selected for "oe_call_tenders_opening_date[0][value][month]" select + And "2020" should be selected for "oe_call_tenders_opening_date[0][value][year]" select + And "1" should be selected for "oe_call_tenders_deadline[0][value][day]" select + And "1" should be selected for "oe_call_tenders_deadline[0][value][month]" select + And "2020" should be selected for "oe_call_tenders_deadline[0][value][year]" select + And "10" should be selected for "oe_call_tenders_deadline[0][value][hour]" select + And "0" should be selected for "oe_call_tenders_deadline[0][value][minute]" select And the "Reference" field should contain "My Reference" And the "Body text" field should contain "My Body text" And the "Teaser" field should contain "My teaser" From 7f5ccfac3f9355c4db9d90c2dae145a8d52876e6 Mon Sep 17 00:00:00 2001 From: George Baev Date: Tue, 13 Oct 2020 17:31:28 +0300 Subject: [PATCH 07/11] D8TEWPPE-73: Expand the Event Behat test. --- tests/features/api.feature | 82 ++++++++++++++++++++++++++------------ 1 file changed, 57 insertions(+), 25 deletions(-) diff --git a/tests/features/api.feature b/tests/features/api.feature index 3913ff397..20bd20c95 100644 --- a/tests/features/api.feature +++ b/tests/features/api.feature @@ -8,6 +8,7 @@ And the following image: | name | file | | Image placeholder | example_1.jpeg | + And the following Event Content entity: | Title | My event | | Type | Exhibitions | @@ -37,6 +38,30 @@ | Event website | uri: https://ec.europa.eu/inea/ - title: INEA | | Social media links | uri: http://example.com - title: Twitter - link_type: twitter | + And the following Default Venue entity: + | Name | DIGIT | + | Address | country_code: BE - locality: Brussels - address_line1: Rue Belliard 28 - postal_code: 1000 | + | Capacity | 12 people | + | Room | B-28 03/A150 | + + And the following Press Contact entity: + | Name | A press contact | + | Address | country_code: HU - locality: Szeged - address_line1: Press contact 1 - postal_code: 6700 | + | Email | press@example.com | + | Phone number | +32477777778 | + | Social media links | uri: http://facebook.com - title: Facebook - link_type: facebook | + + And the following General Contact entity: + | Name | A general contact | + | Address | country_code: BG - locality: Varna - address_line1: General contact 1 - postal_code: 9009 | + | Email | general@example.com | + | Phone number | +359525566778 | + | Social media links | uri: http://instagram.com - title: Instagram - link_type: instagram | + + And the Event Content "My event" is updated as follows: + | Venue | DIGIT | + | Contact | A press contact, A general contact | + When I visit node "My event" edit page Then I should see the text "My event" And I should see the text "Exhibitions" @@ -96,36 +121,43 @@ And the "oe_author[0][target_id]" field should contain "Directorate-General for Communication (http://publications.europa.eu/resource/authority/corporate-body/COMMU)" And the "oe_content_content_owner[0][target_id]" field should contain "Directorate-General for Communication (http://publications.europa.eu/resource/authority/corporate-body/COMMU)" - # Add related entities, such as venues and contacts and reload the page. - When the following Default Venue entity: - | Name | DIGIT | - | Address | country_code: BE - locality: Brussels - address_line1: Rue Belliard 28 - postal_code: 1000 | - | Capacity | 12 people | - | Room | B-28 03/A150 | - And the following Press Contact entity: - | Name | A press contact | - | Address | country_code: HU - locality: Szeged - address_line1: Press contact 1 - postal_code: 6700 | - | Email | press@example.com | - | Phone number | +32477777778 | - | Social media links | uri: http://facebook.com - title: Facebook - link_type: facebook | - And the following General Contact entity: - | Name | A general contact | - | Address | country_code: HU - locality: Budapest - address_line1: General contact 1 - postal_code: 1011 | - | Email | general@example.com | - | Phone number | +32477792933 | - | Social media links | uri: http://instagram.com - title: Instagram - link_type: instagram | And the Event Content "My event" is updated as follows: - | Venue | DIGIT | - | Contact | A press contact, A general contact | | Organiser is internal | No | | Organiser name | Name of the organiser | + And I reload the page And the "Organiser name" field should contain "Name of the organiser" - 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" + # Fill in the required field + And I fill in "oe_teaser[0][value]" with "Alternative teaser" + And I press "Save" + + And I should see "DIGIT" + And I should see "Belgium" + And I should see "Rue Belliard 28" + And I should see "1000" + And I should see "12 people" + And I should see "B-28 03/A150" + + # The Press Contact data + And I should see "A press contact" + And I should see "Hungary" + And I should see "Szeged" + And I should see "Press contact 1" + And I should see "6700" + And I should see "press@example.com" + And I should see "+32477777778" + And I should see "Facebook" + + # The General Contact data + And I should see "A general contact" + And I should see "Bulgaria" + And I should see "Varna" + And I should see "General contact 1" + And I should see "9009" + And I should see "general@example.com" + And I should see "+359525566778" + And I should see "Instagram" @javascript Scenario: Test ProjectContentContext and BeforeParseEntityFields alterations are done. @@ -205,7 +237,7 @@ And the "oe_departments[0][target_id]" field should contain "Asian Development Bank (http://eurovoc.europa.eu/6336)" And the "oe_project_funding_programme[0][target_id]" field should contain "Anti Fraud Information System (AFIS) (http://publications.europa.eu/resource/authority/eu-programme/AFIS2020)" - @javascript @aabbcc + @javascript Scenario: Test CallForTendersContentContext and BeforeParseEntityFields alterations are done. Given I am logged in as a user with the "edit any oe_call_tenders content, access content, view published skos concept entities, manage corporate content entities" permission From 555e0193c8de404d688780ea0eddd12eb26b5a2e Mon Sep 17 00:00:00 2001 From: George Baev Date: Wed, 14 Oct 2020 07:49:09 +0300 Subject: [PATCH 08/11] D8TEWPPE-73: Test for correct social links. --- tests/features/api.feature | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/features/api.feature b/tests/features/api.feature index 20bd20c95..db65fe842 100644 --- a/tests/features/api.feature +++ b/tests/features/api.feature @@ -55,7 +55,7 @@ | Name | A general contact | | Address | country_code: BG - locality: Varna - address_line1: General contact 1 - postal_code: 9009 | | Email | general@example.com | - | Phone number | +359525566778 | + | Phone number | +359525566778 | | Social media links | uri: http://instagram.com - title: Instagram - link_type: instagram | And the Event Content "My event" is updated as follows: @@ -148,6 +148,7 @@ And I should see "press@example.com" And I should see "+32477777778" And I should see "Facebook" + And I should see the link "Facebook" pointing to "http://facebook.com" # The General Contact data And I should see "A general contact" @@ -158,6 +159,7 @@ And I should see "general@example.com" And I should see "+359525566778" And I should see "Instagram" + And I should see the link "Instagram" pointing to "http://instagram.com" @javascript Scenario: Test ProjectContentContext and BeforeParseEntityFields alterations are done. From 9f0d228bf54d8de6fb3c5e3a2eab55e15a86feba Mon Sep 17 00:00:00 2001 From: George Baev Date: Wed, 14 Oct 2020 13:35:23 +0300 Subject: [PATCH 09/11] D8TEWPPE-73: Expand the test fields set. --- tests/features/api.feature | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/tests/features/api.feature b/tests/features/api.feature index db65fe842..6589c29cb 100644 --- a/tests/features/api.feature +++ b/tests/features/api.feature @@ -239,6 +239,37 @@ And the "oe_departments[0][target_id]" field should contain "Asian Development Bank (http://eurovoc.europa.eu/6336)" And the "oe_project_funding_programme[0][target_id]" field should contain "Anti Fraud Information System (AFIS) (http://publications.europa.eu/resource/authority/eu-programme/AFIS2020)" + And I press "Edit" in the "A Stakeholder" row + And I wait for AJAX to finish + And the "oe_project_coordinators[form][inline_entity_form][entities][0][form][name][0][value]" field should contain "A Stakeholder" + And the "oe_project_coordinators[form][inline_entity_form][entities][0][form][oe_acronym][0][value]" field should contain "AAAAA" + And "HU" should be selected for "oe_project_coordinators[form][inline_entity_form][entities][0][form][oe_address][0][address][country_code]" select + And the "oe_project_coordinators[form][inline_entity_form][entities][0][form][oe_address][0][address][locality]" field should contain "Szeged" + And the "oe_project_coordinators[form][inline_entity_form][entities][0][form][oe_address][0][address][postal_code]" field should contain "6700" + And the "oe_project_coordinators[form][inline_entity_form][entities][0][form][oe_website][0][uri]" field should contain "http://facebook.com" + + And I press "Edit" in the "A Participant" row + And I wait for AJAX to finish + And the "oe_project_participants[form][inline_entity_form][entities][0][form][name][0][value]" field should contain "A Participant" + And the "oe_project_participants[form][inline_entity_form][entities][0][form][oe_acronym][0][value]" field should contain "PPPPP" + And "HU" should be selected for "oe_project_participants[form][inline_entity_form][entities][0][form][oe_address][0][address][country_code]" select + And the "oe_project_participants[form][inline_entity_form][entities][0][form][oe_address][0][address][locality]" field should contain "Szeged" + And the "oe_project_participants[form][inline_entity_form][entities][0][form][oe_address][0][address][postal_code]" field should contain "6700" + And the "oe_project_participants[form][inline_entity_form][entities][0][form][oe_website][0][uri]" field should contain "http://facebook.com" + + And I press "Edit" in the "A general contact row" row + And I wait for AJAX to finish + And the "oe_project_contact[form][inline_entity_form][entities][0][form][name][0][value]" field should contain "A general contact" + And "HU" should be selected for "oe_project_contact[form][inline_entity_form][entities][0][form][oe_address][0][address][country_code]" select + And the "oe_project_contact[form][inline_entity_form][entities][0][form][oe_address][0][address][locality]" field should contain "Budapest" + And the "oe_project_contact[form][inline_entity_form][entities][0][form][oe_address][0][address][address_line1]" field should contain "General contact 1" + And the "oe_project_contact[form][inline_entity_form][entities][0][form][oe_address][0][address][postal_code]" field should contain "1011" + And the "oe_project_contact[form][inline_entity_form][entities][0][form][oe_email][0][value]" field should contain "general@example.com" + And the "oe_project_contact[form][inline_entity_form][entities][0][form][oe_phone][0][value]" field should contain "+32477792933" + And the "oe_project_contact[form][inline_entity_form][entities][0][form][oe_social_media][0][uri]" field should contain "http://instagram.com" + And the "oe_project_contact[form][inline_entity_form][entities][0][form][oe_social_media][0][title]" field should contain "Instagram" + And "instagram" should be selected for "oe_project_contact[form][inline_entity_form][entities][0][form][oe_social_media][0][link_type]" select + @javascript Scenario: Test CallForTendersContentContext and BeforeParseEntityFields alterations are done. Given I am logged in as a user with the "edit any oe_call_tenders content, access content, view published skos concept entities, manage corporate content entities" permission From 81ec44abae61239d69c8749f896db87220851497 Mon Sep 17 00:00:00 2001 From: George Baev Date: Thu, 15 Oct 2020 13:51:12 +0300 Subject: [PATCH 10/11] D8TEWPPE-73: Test the non-EU organisation type. --- tests/features/api.feature | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/features/api.feature b/tests/features/api.feature index 6589c29cb..914338f65 100644 --- a/tests/features/api.feature +++ b/tests/features/api.feature @@ -346,3 +346,9 @@ 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" + + And the Organisation Content "My Organisation" is updated as follows: + | Organisation type | non_eu | + + And I reload the page + And the "oe_organisation_org_type" field should contain "non_eu" From 5489f278e23af785d7d0fd3ae69c64ba063c5e7a Mon Sep 17 00:00:00 2001 From: drishu Date: Fri, 16 Oct 2020 08:36:33 +0000 Subject: [PATCH 11/11] EWPP-258: Syntax improvement. --- tests/Behat/DateFieldContext.php | 32 ++++++++++------ tests/Behat/FeatureContext.php | 3 +- tests/features/api.feature | 64 ++++++++------------------------ 3 files changed, 37 insertions(+), 62 deletions(-) diff --git a/tests/Behat/DateFieldContext.php b/tests/Behat/DateFieldContext.php index c754a9a87..040037955 100644 --- a/tests/Behat/DateFieldContext.php +++ b/tests/Behat/DateFieldContext.php @@ -121,7 +121,7 @@ public function fillDateRangeSelectListField(string $field_item, string $field_g /** * Check values for list date range fields. * - * "15 Jun 2020 12 30" is selected for "Start date" of "My date range field" + * Then datetime "15 1 2020 12 30" is selected for "Start date" of "Datetime" * * @param string $value * The value of the field. @@ -131,42 +131,50 @@ public function fillDateRangeSelectListField(string $field_item, string $field_g * The field component's label. * * @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 { + $page = $this->getSession()->getPage(); $values = explode(' ', $value); - $field_selectors = $this->findDateListRangeFields($field_group); + $group = $page->find('named', ['fieldset', $field_group]); + $elements = $group->findAll('css', '.container-inline'); - if (count($field_selectors) > 1) { - throw new \Exception('More than one elements were found.'); + if (empty($elements)) { + throw new \Exception('Datetime fields not found.'); } - $field_selector = reset($field_selectors); + $fields = $elements[0]; + if ($field_item === 'End date') { - $field_selector = $field_selector->findAll('css', 'div[id*="end-value"]'); - $field_selector = reset($field_selector); + $fields = $elements[1]; } $date_components = [ 'Day', 'Month', 'Year', - 'Hour', - 'Minute', ]; + if (count($values) > 3) { + $date_components += [ + 'Hour', + 'Minute', + ]; + } + foreach ($date_components as $index => $date_component) { - $field = $field_selector->findField($date_component); + $field = $fields->findField($date_component); $optionField = $field->find('named', [ 'option', $values[$index], ]); if ($optionField === NULL) { - throw new \Exception('Option not found.'); + throw new \Exception(sprintf('%s option not found.', $date_component)); } if (!$optionField->isSelected()) { - throw new \Exception('Option is not selected.'); + throw new \Exception(sprintf('%s not selected for %s option.', $values[$index], $date_component)); } } } diff --git a/tests/Behat/FeatureContext.php b/tests/Behat/FeatureContext.php index 0c433cdce..c258d9140 100644 --- a/tests/Behat/FeatureContext.php +++ b/tests/Behat/FeatureContext.php @@ -257,7 +257,8 @@ public function shouldBeSelectedForSelect($option, $field) { $selected_option = $element->find('css', "option[selected='selected']"); if ($selected_option === NULL) { - throw new \Exception(sprintf('Option "%s" not found for %s select', $option, $field)); + print_r($element->getHtml()); + throw new \Exception(sprintf('Option "%s" not selected for %s select', $option, $field)); } Assert::assertTrue($selected_option->getValue() === $option); diff --git a/tests/features/api.feature b/tests/features/api.feature index 914338f65..31fff47f4 100644 --- a/tests/features/api.feature +++ b/tests/features/api.feature @@ -77,28 +77,12 @@ 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 "1" should be selected for "oe_event_registration_dates[0][value][day]" select - And "3" should be selected for "oe_event_registration_dates[0][value][month]" select - And "2020" should be selected for "oe_event_registration_dates[0][value][year]" select - And "12" should be selected for "oe_event_registration_dates[0][value][hour]" select - And "30" should be selected for "oe_event_registration_dates[0][value][minute]" select - And "10" should be selected for "oe_event_registration_dates[0][end_value][day]" select - And "3" should be selected for "oe_event_registration_dates[0][end_value][month]" select - And "2020" should be selected for "oe_event_registration_dates[0][end_value][year]" select - And "18" should be selected for "oe_event_registration_dates[0][end_value][hour]" select - And "30" should be selected for "oe_event_registration_dates[0][end_value][minute]" select + And datetime "1 3 2020 12 30" is selected for "Start date" of "Registration date" + And datetime "10 3 2020 18 30" is selected for "End date" of "Registration date" And I press "Online" And the "Online description" field should contain "Event online description" - And "21" should be selected for "oe_event_online_dates[0][value][day]" select - And "2" should be selected for "oe_event_online_dates[0][value][month]" select - And "2019" should be selected for "oe_event_online_dates[0][value][year]" select - And "9" should be selected for "oe_event_online_dates[0][value][hour]" select - And "15" should be selected for "oe_event_online_dates[0][value][minute]" select - And "21" should be selected for "oe_event_online_dates[0][end_value][day]" select - And "2" should be selected for "oe_event_online_dates[0][end_value][month]" select - And "2019" should be selected for "oe_event_online_dates[0][end_value][year]" select - And "14" should be selected for "oe_event_online_dates[0][end_value][hour]" select - And "0" should be selected for "oe_event_online_dates[0][end_value][minute]" select + 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" And the "oe_event_online_link[0][uri]" field should contain "http://ec.europa.eu/info" And the "oe_event_languages[0][target_id]" field should contain "Valencian (http://publications.europa.eu/resource/authority/language/0D0)" @@ -107,16 +91,8 @@ And I should see the text "http://example.com" And I should see the text "Twitter" And the "oe_event_featured_media[0][target_id]" field contains "Image placeholder" - And "15" should be selected for "oe_event_dates[0][value][day]" select - And "6" should be selected for "oe_event_dates[0][value][month]" select - And "2020" should be selected for "oe_event_dates[0][value][year]" select - And "12" should be selected for "oe_event_dates[0][value][hour]" select - And "30" should be selected for "oe_event_dates[0][value][minute]" select - And "20" should be selected for "oe_event_dates[0][end_value][day]" select - And "6" should be selected for "oe_event_dates[0][end_value][month]" select - And "2020" should be selected for "oe_event_dates[0][end_value][year]" select - And "18" should be selected for "oe_event_dates[0][end_value][hour]" select - And "30" should be selected for "oe_event_dates[0][end_value][minute]" select + And datetime "15 6 2020 12 30" is selected for "Start date" of "Event date" + And datetime "20 6 2020 18 30" is selected for "End date" of "Event date" And the "oe_subject[0][target_id]" field should contain "financing (http://data.europa.eu/uxp/1000)" And the "oe_author[0][target_id]" field should contain "Directorate-General for Communication (http://publications.europa.eu/resource/authority/corporate-body/COMMU)" And the "oe_content_content_owner[0][target_id]" field should contain "Directorate-General for Communication (http://publications.europa.eu/resource/authority/corporate-body/COMMU)" @@ -218,12 +194,8 @@ Then I should see the text "My project" And I should see the text "My Summary" And the "Reference" field should contain "My Reference" - And "1" should be selected for "oe_project_dates[0][value][day]" select - And "1" should be selected for "oe_project_dates[0][value][month]" select - And "2020" should be selected for "oe_project_dates[0][value][year]" select - And "2" should be selected for "oe_project_dates[0][end_value][day]" select - And "1" should be selected for "oe_project_dates[0][end_value][month]" select - And "2020" should be selected for "oe_project_dates[0][end_value][year]" select + And date "1 1 2020" is selected for "Start date" of "Project period" + And date "2 1 2020" is selected for "End date" of "Project period" And the "Overall budget" field should contain "100000" And the "EU contribution" field should contain "50000" And the "oe_project_website[0][uri]" field should contain "http://ec.europa.eu/info" @@ -293,17 +265,9 @@ When I visit node "My Call for tenders" edit page Then I should see the text "My Call for tenders" And the "Introduction" field should contain "My Introduction" - And "1" should be selected for "oe_publication_date[0][value][day]" select - And "1" should be selected for "oe_publication_date[0][value][month]" select - And "2020" should be selected for "oe_publication_date[0][value][year]" select - And "1" should be selected for "oe_call_tenders_opening_date[0][value][day]" select - And "1" should be selected for "oe_call_tenders_opening_date[0][value][month]" select - And "2020" should be selected for "oe_call_tenders_opening_date[0][value][year]" select - And "1" should be selected for "oe_call_tenders_deadline[0][value][day]" select - And "1" should be selected for "oe_call_tenders_deadline[0][value][month]" select - And "2020" should be selected for "oe_call_tenders_deadline[0][value][year]" select - And "10" should be selected for "oe_call_tenders_deadline[0][value][hour]" select - And "0" should be selected for "oe_call_tenders_deadline[0][value][minute]" select + And date "1 1 2020" is selected for "Start date" of "Publication date" + And date "1 1 2020" is selected for "Start date" of "Opening date" + And datetime "1 1 2020 10 0" is selected for "Start date" of "Deadline date" And the "Reference" field should contain "My Reference" And the "Body text" field should contain "My Body text" And the "Teaser" field should contain "My teaser" @@ -348,7 +312,9 @@ And the "Teaser" field should contain "My teaser" And the Organisation Content "My Organisation" is updated as follows: - | Organisation type | non_eu | + | Organisation type | non_eu | + | oe_organisation_non_eu_org_type | http://data.europa.eu/uxp/1051 | And I reload the page - And the "oe_organisation_org_type" field should contain "non_eu" + And "non_eu" should be selected for "oe_organisation_org_type" select + And "http://data.europa.eu/uxp/1051" should be selected for "oe_organisation_non_eu_org_type" select