diff --git a/config/sync/og.og_role.rdf_entity-collection-facilitator.yml b/config/sync/og.og_role.rdf_entity-collection-facilitator.yml index 7ff8cc01078f6feae344d8fb99dc9c240109f152..f7ebcfe8b7a2ad77b1d28914b7c6435091a28698 100644 --- a/config/sync/og.og_role.rdf_entity-collection-facilitator.yml +++ b/config/sync/og.og_role.rdf_entity-collection-facilitator.yml @@ -33,6 +33,7 @@ permissions: - 'create paragraph content 2_column_layout' - 'create paragraph content 3_column_layout' - 'create paragraph content call_to_action' + - 'create paragraph content github_feed' - 'create paragraph content json_map' - 'create paragraph content row' - 'create rdf entity news' @@ -50,6 +51,7 @@ permissions: - 'delete paragraph content 2_column_layout' - 'delete paragraph content 3_column_layout' - 'delete paragraph content call_to_action' + - 'delete paragraph content github_feed' - 'delete paragraph content json_map' - 'delete paragraph content row' - 'edit any custom_page content' @@ -225,6 +227,7 @@ permissions: - 'update paragraph content 2_column_layout' - 'update paragraph content 3_column_layout' - 'update paragraph content call_to_action' + - 'update paragraph content github_feed' - 'update paragraph content json_map' - 'update paragraph content row' - 'view all revisions' diff --git a/config/sync/og.og_role.rdf_entity-solution-facilitator.yml b/config/sync/og.og_role.rdf_entity-solution-facilitator.yml index 93aeb0b84985517afa5e59210a46896c14f81ef7..197c2b2ff0304517a51e2ec8edb368fb82b9245f 100644 --- a/config/sync/og.og_role.rdf_entity-solution-facilitator.yml +++ b/config/sync/og.og_role.rdf_entity-solution-facilitator.yml @@ -24,6 +24,7 @@ permissions: - 'create event content' - 'create glossary content' - 'create news content' + - 'create paragraph content github_feed' - 'delete any asset_distribution rdf_entity' - 'delete any custom_page content' - 'delete any discussion content' @@ -33,6 +34,7 @@ permissions: - 'delete any news content' - 'delete asset_distribution rdf entity' - 'delete contact_information rdf entity' + - 'delete paragraph content github_feed' - 'edit any custom_page content' - 'edit any discussion content' - 'edit any document content' @@ -201,6 +203,7 @@ permissions: - 'update group' - 'update own asset_distribution rdf_entity' - 'update own asset_release rdf_entity' + - 'update paragraph content github_feed' - 'view all revisions' - 'view any unpublished content' - 'view rdf entity' diff --git a/config/sync/user.role.moderator.yml b/config/sync/user.role.moderator.yml index d70fefb2ff4f3a9c7ce710b4888782572e2e4f0b..e8289f2af16db8b56e613936f9f0445b4aeb01bc 100644 --- a/config/sync/user.role.moderator.yml +++ b/config/sync/user.role.moderator.yml @@ -403,7 +403,6 @@ permissions: - 'view licence overview page' - 'view own field_is_eif_category' - 'view own field_is_eif_recommendation' - - 'view paragraph content github_feed' - 'view rdf entity overview' - 'view rdf_entity draft graph' - 'view unpublished rdf entity' diff --git a/tests/features/custom_page/community_content_listing.feature b/tests/features/custom_page/community_content_listing.feature index 092b857e322ca237fd0868d99d23d50ee56ceae2..ee9df81b4e46ce41190b695ec91995c00aa235ce 100644 --- a/tests/features/custom_page/community_content_listing.feature +++ b/tests/features/custom_page/community_content_listing.feature @@ -151,7 +151,7 @@ Feature: # The "List additional actions" is the button arrow that shows the full list of paragraphs to add. Given I press "List additional actions" - Then I press "Add Content listing" in the "Custom page body" paragraphs field + Then I click "Add Content listing" in the "Custom page body" paragraphs field And I uncheck "Show related content" When the following fields should not be visible "Global search, Allow shared content" And I check "Show related content" @@ -483,14 +483,14 @@ Feature: # Paragraph #1. When I press "List additional actions" - And I press "Add Content listing" in the "Custom page body" paragraphs field + And I click "Add Content listing" in the "Custom page body" paragraphs field And I press "Add and configure filter" And I fill in "Solution" with "Save the Planet" # Paragraph #2. When I press "List additional actions" - And I press "Add Content listing" in the "Custom page body" paragraphs field + And I click "Add Content listing" in the "Custom page body" paragraphs field And I press latest "Add and configure filter" And I fill in the latest "Solution" field with "Fight Global Warming" @@ -522,7 +522,7 @@ Feature: # Paragraph #1. When I press "List additional actions" - And I press "Add Content listing" in the "Custom page body" paragraphs field + And I click "Add Content listing" in the "Custom page body" paragraphs field And I press "Add and configure filter" And I fill in "Solution" with "Save gasoline" @@ -535,7 +535,7 @@ Feature: # Paragraph #2. When I press "List additional actions" - And I press "Add Content listing" in the "Custom page body" paragraphs field + And I click "Add Content listing" in the "Custom page body" paragraphs field And I press latest "Add and configure filter" And I fill in the latest "Solution" field with "Black Noise" diff --git a/tests/features/paragraphs/custom_page.paragraphs.feature b/tests/features/paragraphs/custom_page.paragraphs.feature index 41c445ee8b8b16bbc03df6c28129a7c37d5c2cf9..e2511ff92b70386921c188def853fed04ee3c2f6 100644 --- a/tests/features/paragraphs/custom_page.paragraphs.feature +++ b/tests/features/paragraphs/custom_page.paragraphs.feature @@ -24,14 +24,14 @@ Feature: # The first paragraphs item is open by default. Then there should be 1 paragraph in the "Custom page body" field Then I should see the "Remove" button in the "Custom page body" field for paragraph 1 - Given I press "Remove" in the "Custom page body" field for paragraph 1 + Given I click "Remove" in the "Custom page body" field for paragraph 1 Then the page should contain no paragraphs - Given I press "Add Simple paragraph" in the "Custom page body" paragraphs field + Given I click "Add Simple paragraph" in the "Custom page body" paragraphs field Then there should be 1 paragraph in the "Custom page body" field - Given I press "Add Simple paragraph" in the "Custom page body" paragraphs field + Given I click "Add Simple paragraph" in the "Custom page body" paragraphs field Then there should be 2 paragraphs in the "Custom page body" field When I enter "AAAAAAAAAA" in the "Body" wysiwyg editor in the "Custom page body" field for paragraph 1 @@ -106,12 +106,12 @@ Feature: And I open the plus button menu And I click "Add custom page" And I fill in "Title" with "Paragraphs accordion page" - Given I press "Remove" in the "Custom page body" field for paragraph 1 + Given I click "Remove" in the "Custom page body" field for paragraph 1 Then the page should contain no paragraphs # The "List additional actions" is the button arrow that shows the full list of paragraphs to add. Given I press "List additional actions" - Then I press "Add Accordion" in the "Custom page body" paragraphs field + Then I click "Add Accordion" in the "Custom page body" paragraphs field # 3 paragraphs are the default number when adding an accordion. # 1. the accordion wrapper, 2. accordion item and 3. the simple paragraph contained in the item. diff --git a/tests/features/paragraphs/github_feed.feature b/tests/features/paragraphs/github_feed.feature index 50b0221d620d14bae86b4bb4464e4bc45a066db0..8c27f66ef93e185efc2d0954f099d9aaa0927748 100644 --- a/tests/features/paragraphs/github_feed.feature +++ b/tests/features/paragraphs/github_feed.feature @@ -3,17 +3,16 @@ Feature: Github feed paragraph tests. The scenarios are split into 4 tests because re-saving the entity would invalidate the file cache and the tests would require connecting to Github. - Scenario: Test the Github feed paragraph. - Given the following collection: - | title | Paragraphs collection | - | state | validated | + Scenario Outline: Test the Github feed paragraph. + Given the following <group>: + | title | Paragraphs <group> | + | state | validated | And custom_page content: - | title | collection | state | - | Catalogue of paragraphs | Paragraphs collection | published | + | title | <group> | state | + | Catalogue of paragraphs | Paragraphs <group> | published | When I am logged in as a moderator - And I go to the "Catalogue of paragraphs" custom page - And I click "Edit" - And I press "Add Github feed" + And I go to the edit form of the "Catalogue of paragraphs" "custom page" + And I click "Add Github feed" in the "Custom page body" paragraphs field And I fill in the following: | Repository | https://github.com/openeuropa/oe_bootstrap_theme.git | @@ -40,7 +39,7 @@ Feature: Github feed paragraph tests. And I should see the heading "Issues (5)" And I should not see the heading "Comments (5)" - When I click "Edit" + And I go to the edit form of the "Catalogue of paragraphs" "custom page" And I fill in the following: | Type | issue | | Number of items | 5 | @@ -51,15 +50,52 @@ Feature: Github feed paragraph tests. And I should see the heading "Comments (1)" # Test the error message when the repository is invalid. - When I click "Edit" + And I go to the edit form of the "Catalogue of paragraphs" "custom page" And I fill in the following: | Repository | https://some_invalid_repository.com/nothing | And I press "Update" Then I should see the text "The repository must be a valid GitHub repository." # Test a repository that is not found and ensure that the page does not break. - When I click "Edit" + And I go to the edit form of the "Catalogue of paragraphs" "custom page" And I fill in the following: | Repository | https://github.com/some/repository | And I press "Update" Then I should see the heading "Catalogue of paragraphs" + + Examples: + | group | + | collection | + | solution | + + @javascript + Scenario Outline: Facilitators can also access paragraphs. + Given the following <group>: + | title | Paragraphs <group> | + | state | validated | + And custom_page content: + | title | <group> | state | + | Catalogue of paragraphs | Paragraphs <group> | published | + When I am logged in as a facilitator of the "Paragraphs <group>" <group> + And I go to the edit form of the "Catalogue of paragraphs" "custom page" + And I click "Add Github feed" in the "Custom page body" paragraphs field + And I fill in the following: + | Repository | https://github.com/openeuropa/oe_bootstrap_theme.git | + + When I fill in the following: + | Type | pull_request | + | Number of items | 5 | + And I press "Update" + And I should see the heading "Pull requests (5)" + And I go to the edit form of the "Catalogue of paragraphs" "custom page" + + # There should be a single paragraph with the Collapse button available. + And I press "Collapse" + # The only edit button in the main region is the one for the paragraph. + And I should see the button "Edit" in the "Content" region + And I should see the button "Remove" in the "Content" region + + Examples: + | group | + | collection | + | solution | diff --git a/tests/src/Context/JoinupParagraphsContext.php b/tests/src/Context/JoinupParagraphsContext.php index 7c3ddaeb247f9594606b29ff3cbbc77247bd1c8a..661072a0a59416b719d521364ee938dfb350a6b8 100644 --- a/tests/src/Context/JoinupParagraphsContext.php +++ b/tests/src/Context/JoinupParagraphsContext.php @@ -5,6 +5,7 @@ namespace Drupal\joinup\Context; use Behat\Gherkin\Node\TableNode; +use Behat\Mink\Driver\Selenium2Driver; use Behat\Mink\Element\TraversableElement; use Behat\Mink\Exception\ElementNotFoundException; use Drupal\DrupalExtension\Context\RawDrupalContext; @@ -168,10 +169,10 @@ public function assertButtonInParagraphsItem(string $button, string $field, int } /** - * Clicks the remove button in the given paragraphs item. + * Clicks a link in the given paragraphs item. * * @param string $label - * The button label. + * The link label. * @param string $field * The field identifier. One of the keys in the * \JoinupParagraphsSubContext::fieldMapping array. @@ -180,30 +181,35 @@ public function assertButtonInParagraphsItem(string $button, string $field, int * readability. If left empty, the button will be searched in the entire * field. * - * @Given I press :label in the :field field for paragraph :delta - * @Given I press :label in the :field paragraphs field + * @Given I click :label in the :field field for paragraph :delta + * @Given I click :label in the :field paragraphs field */ - public function clickButtonInParagraphsField(string $label, string $field, ?int $delta = NULL): void { - if ($delta === NULL) { - // This is a field button, not linked to any paragraph item, such as the - // button that adds a new paragraph item. - $this->getParagraphsElement($field)->findButton($label)->press(); - return; - } - - $paragraph_item = $this->getParagraphsElementItem($field, --$delta); + public function clickLinkInParagraphsField(string $label, string $field, ?int $delta = NULL): void { + $paragraph_item = ($delta === NULL) ? $this->getParagraphsElement($field) : $this->getParagraphsElementItem($field, --$delta); $this->scrollElementIntoView($paragraph_item); - if (!$button = $paragraph_item->findButton($label)) { + if (!$link = $paragraph_item->findButton($label)) { throw new ElementNotFoundException($this->getSession()->getDriver(), 'button', 'label'); } - // It might be a button beneath the three dots dropdown. - if (!$button->isVisible()) { - $dropdown = $paragraph_item->find('css', 'button.paragraphs-dropdown-toggle'); - $dropdown->click(); + // It might be a button beneath the three dots dropdown. Check for the + // driver as well, because only Selenium2Driver supports isVisible(). + if (($this->getSession()->getDriver() instanceof Selenium2Driver) && !$link->isVisible()) { + // Check first if the button is in the 3-dots dropdown which has the class + // "paragraphs-dropdown-actions". + $xpath = "//div[contains(concat(' ', @class, ' '), ' paragraphs-dropdown-actions ')]"; + if ($paragraph_item->find('xpath', $xpath)?->findButton($label)) { + // Expand the dropdown. + $dropdown = $paragraph_item->find('css', 'button.paragraphs-dropdown-toggle'); + $dropdown->click(); + } + // Else, expand the 'add paragraph' dropdown in case the button is one of + // the 'add paragraph' buttons. + elseif ($dropdown = $paragraph_item->find('css', 'button.dropdown-toggle')) { + $dropdown->click(); + } } - $button->click(); + $link->click(); } /**