Skip to content
Snippets Groups Projects
Commit dc407abc authored by Claudiu Cristea's avatar Claudiu Cristea
Browse files

Merge branch 'ISAICP-7886' into 'release-v1-94-1'

ISAICP-7886: Allow facilitators to CRUD a github paragraph.

See merge request !119
parents 127a1dc6 f85ebbaf
No related branches found
No related tags found
2 merge requests!119ISAICP-7886: Allow facilitators to CRUD a github paragraph.,!117Release v1 94 1
......@@ -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'
......
......@@ -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'
......
......@@ -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'
......@@ -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"
......
......@@ -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.
......
......@@ -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 |
......@@ -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();
}
/**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment