diff --git a/modules/paragraphs_library/tests/src/FunctionalJavascript/ParagraphsLibraryItemEntityBrowserTest.php b/modules/paragraphs_library/tests/src/FunctionalJavascript/ParagraphsLibraryItemEntityBrowserTest.php index c480f1d1d77b0bb3dd85819493d6e62989bb761e..24e492527733ad79e61b4790f9072470ddd190c9 100644 --- a/modules/paragraphs_library/tests/src/FunctionalJavascript/ParagraphsLibraryItemEntityBrowserTest.php +++ b/modules/paragraphs_library/tests/src/FunctionalJavascript/ParagraphsLibraryItemEntityBrowserTest.php @@ -98,16 +98,9 @@ class ParagraphsLibraryItemEntityBrowserTest extends EntityBrowserWebDriverTestB $this->getSession()->switchToIFrame('entity_browser_iframe_paragraphs_library_items'); $style_selector = $this->getSession()->getPage()->find('css', 'input[value="paragraphs_library_item:1"].form-radio'); $style_selector->click(); + $this->assertSession()->buttonExists('Select reusable paragraph')->press(); $this->getSession()->switchToIFrame(); - $drop = <<<JS - jQuery('input[type=submit][value="Select reusable paragraph"]', window.frames['entity_browser_iframe_paragraphs_library_items'].document).trigger('click') -JS; - $this->getSession()->evaluateScript($drop); - // Now wait until the button and iframe is gone, wait at least one second - // because the ajax detection does not reliable detect the active ajax - // processing in the iframe. - sleep(1); $this->waitForAjaxToFinish(); $this->submitForm([], 'Save'); // Check that the paragraph was correctly reused. @@ -159,12 +152,8 @@ JS; $this->getSession()->switchToIFrame('entity_browser_iframe_paragraphs_library_items'); $style_selector = $this->getSession()->getPage()->find('css', 'input[value="paragraphs_library_item:2"].form-radio'); $style_selector->click(); + $this->assertSession()->buttonExists('Select reusable paragraph')->press(); $this->getSession()->switchToIFrame(); - $drop = <<<JS - jQuery('input[type=submit][value="Select reusable paragraph"]', window.frames['entity_browser_iframe_paragraphs_library_items'].document).trigger('click') -JS; - $this->getSession()->evaluateScript($drop); - sleep(1); $this->waitForAjaxToFinish(); // Edit the inside library item after adding it. $this->getSession()->getPage()->pressButton('Edit'); @@ -197,12 +186,8 @@ JS; $style_selector = $this->getSession()->getPage()->find('css', 'input[value="paragraphs_library_item:3"].form-radio'); $this->assertTrue($style_selector->isVisible()); $style_selector->click(); + $this->assertSession()->buttonExists('Select reusable paragraph')->press(); $this->getSession()->switchToIFrame(); - $drop = <<<JS - jQuery('input[type=submit][value="Select reusable paragraph"]', window.frames['entity_browser_iframe_paragraphs_library_items'].document).trigger('click') -JS; - $this->getSession()->evaluateScript($drop); - sleep(1); $this->waitForAjaxToFinish(); $this->assertSession()->elementContains('css', '.paragraphs-collapsed-description .paragraphs-content-wrapper', 'Inner library item'); $this->submitForm([], 'Save'); diff --git a/modules/paragraphs_type_permissions/tests/src/Functional/ParagraphsTypePermissionsTest.php b/modules/paragraphs_type_permissions/tests/src/Functional/ParagraphsTypePermissionsTest.php index 0ca729f23fd76f29e5b2530550b66236fb49c80e..7854d1fe9243a51236071743178b5f067d16e1b6 100644 --- a/modules/paragraphs_type_permissions/tests/src/Functional/ParagraphsTypePermissionsTest.php +++ b/modules/paragraphs_type_permissions/tests/src/Functional/ParagraphsTypePermissionsTest.php @@ -2,6 +2,7 @@ namespace Drupal\Tests\paragraphs_type_permissions\Functional; +use Drupal\image\Entity\ImageStyle; use Drupal\language\Entity\ConfigurableLanguage; use Drupal\Tests\BrowserTestBase; use Drupal\Tests\field_ui\Traits\FieldUiTestTrait; @@ -165,9 +166,12 @@ class ParagraphsTypePermissionsTest extends BrowserTestBase { // Get the node to edit it later. $node = $this->drupalGetNodeByTitle($edit['title[0][value]']); + /** @var \Drupal\Core\File\FileUrlGeneratorInterface $file_url_generator */ + $file_url_generator = \Drupal::service('file_url_generator'); + // Get the images data to check for their presence. - $image_text_tag = '/files/styles/large/public/' . date('Y-m') . '/image-test.png?itok='; - $images_tag = '/files/styles/medium/public/' . date('Y-m') . '/image-test_0.png?itok='; + $image_text_tag = $file_url_generator->transformRelative(ImageStyle::load('large')->buildUrl('public://' . date('Y-m') . '/image-test.png')); + $images_tag = $file_url_generator->transformRelative(ImageStyle::load('medium')->buildUrl('public://' . date('Y-m') . '/image-test_0.png')); // Check that all paragraphs are shown for admin user. $this->assertSession()->responseContains($image_text_tag); diff --git a/src/EventSubscriber/ReplicateFieldSubscriber.php b/src/EventSubscriber/ReplicateFieldSubscriber.php index 7602c0b9530ace282fe5261216b2467f914d7ba1..3b65e7bb4a14f0d0f9c1ff7308588a9251ad8acb 100644 --- a/src/EventSubscriber/ReplicateFieldSubscriber.php +++ b/src/EventSubscriber/ReplicateFieldSubscriber.php @@ -46,7 +46,7 @@ class ReplicateFieldSubscriber implements EventSubscriberInterface { /** * {@inheritdoc} */ - public static function getSubscribedEvents() { + public static function getSubscribedEvents(): array { $events[ReplicatorEvents::replicateEntityField('entity_reference_revisions')][] = 'onClone'; return $events; } diff --git a/tests/src/Functional/Migrate/MigrateUiParagraphsTest.php b/tests/src/Functional/Migrate/MigrateUiParagraphsTest.php index 2a5304e9ed5dfe55be4a2b8720fa2d6dd4692bac..d72aec30a3b27490db517a4e5da92c6d41260785 100644 --- a/tests/src/Functional/Migrate/MigrateUiParagraphsTest.php +++ b/tests/src/Functional/Migrate/MigrateUiParagraphsTest.php @@ -13,6 +13,11 @@ use Drupal\Tests\paragraphs\Traits\ParagraphsNodeMigrationAssertionsTrait; */ class MigrateUiParagraphsTest extends MigrateUiParagraphsTestBase { + /** + * {@inheritdoc} + */ + protected $defaultTheme = 'stark'; + use ParagraphsNodeMigrationAssertionsTrait; /** diff --git a/tests/src/Functional/Migrate/MigrateUiParagraphsTestBase.php b/tests/src/Functional/Migrate/MigrateUiParagraphsTestBase.php index b9096e704cd8ca0f1cf4e4f2f3ead0600e73d098..b5440a3c58c5a539c3086c79cbc885056f2fe461 100644 --- a/tests/src/Functional/Migrate/MigrateUiParagraphsTestBase.php +++ b/tests/src/Functional/Migrate/MigrateUiParagraphsTestBase.php @@ -405,7 +405,7 @@ abstract class MigrateUiParagraphsTestBase extends MigrateUpgradeTestBase { $session = $this->assertSession(); $session->responseContains('Upgrade a site by importing its files and the data from its database into a clean and empty new install of Drupal'); - $this->submitForm([], $this->t('Continue')); + $this->submitForm([], 'Continue'); $session->pageTextContains('Provide credentials for the database of the Drupal site you want to upgrade.'); $driver = $connection_options['driver']; @@ -437,17 +437,17 @@ abstract class MigrateUiParagraphsTestBase extends MigrateUpgradeTestBase { } $edits = $this->translatePostValues($edit); - $this->submitForm($edits, $this->t('Review upgrade')); + $this->submitForm($edits, 'Review upgrade'); $session->pageTextNotContains('Resolve all issues below to continue the upgrade.'); // ID conflict form. - $session->buttonExists($this->t('I acknowledge I may lose data. Continue anyway.')); - $this->submitForm([], $this->t('I acknowledge I may lose data. Continue anyway.')); + $session->buttonExists('I acknowledge I may lose data. Continue anyway.'); + $this->submitForm([], 'I acknowledge I may lose data. Continue anyway.'); $session->statusCodeEquals(200); // Perform the upgrade. - $this->submitForm([], $this->t('Perform upgrade')); - $session->pageTextContains($this->t('Congratulations, you upgraded Drupal!')); + $this->submitForm([], 'Perform upgrade'); + $session->pageTextContains('Congratulations, you upgraded Drupal!'); // Have to reset all the statics after migration to ensure entities are // loadable. diff --git a/tests/src/Functional/ParagraphsUiTest.php b/tests/src/Functional/ParagraphsUiTest.php index 1a5fe79bcb4fbc454f4154c6654167757143c840..816abe2d5296c5008ddd93c8a0015eadd7f4e240 100644 --- a/tests/src/Functional/ParagraphsUiTest.php +++ b/tests/src/Functional/ParagraphsUiTest.php @@ -113,11 +113,16 @@ class ParagraphsUiTest extends ParagraphsTestBase { else { $this->clickLink('Add field'); } - $this->submitForm([ - 'new_storage_type' => 'field_ui:entity_reference_revisions:paragraph', + + $this->getSession()->getPage()->fillField('new_storage_type', 'field_ui:entity_reference_revisions:paragraph'); + if ($this->coreVersion('10.3')) { + $this->getSession()->getPage()->pressButton('Continue'); + } + $edit = [ 'label' => 'Paragraph', 'field_name' => 'paragraph', - ], $this->coreVersion('10.2') ? 'Continue' : 'Save and continue'); + ]; + $this->submitForm($edit, $this->coreVersion('10.2') ? 'Continue' : 'Save and continue'); if (!$this->coreVersion('10.2')) { $this->submitForm([], 'Save field settings'); } diff --git a/tests/src/Functional/WidgetLegacy/ParagraphsAdministrationTest.php b/tests/src/Functional/WidgetLegacy/ParagraphsAdministrationTest.php index 57626cf41ad7439c507708f9a6b6504bbf0b0dda..0efec3a9afd710d41fcce35067601a9bf36f3b75 100644 --- a/tests/src/Functional/WidgetLegacy/ParagraphsAdministrationTest.php +++ b/tests/src/Functional/WidgetLegacy/ParagraphsAdministrationTest.php @@ -145,8 +145,11 @@ class ParagraphsAdministrationTest extends ParagraphsTestBase { $this->drupalGet('admin/structure/paragraphs_type'); $this->assertSession()->pageTextContains('There are no Paragraphs types yet.'); $this->drupalGet('admin/structure/types/manage/paragraphs/fields/add-field'); + $this->getSession()->getPage()->fillField('new_storage_type', 'field_ui:entity_reference_revisions:paragraph'); + if ($this->coreVersion('10.3')) { + $this->getSession()->getPage()->pressButton('Continue'); + } $edit = [ - 'new_storage_type' => 'field_ui:entity_reference_revisions:paragraph', 'label' => 'Paragraph', 'field_name' => 'paragraph', ]; @@ -486,7 +489,7 @@ class ParagraphsAdministrationTest extends ParagraphsTestBase { // Assert the validation error message. $this->assertSession()->pageTextContains('The referenced entity (node: 4) does not exist'); // Triggering unrelated button, assert that error message is still present. - $this->submitForm([], 'Add another item'); + $this->submitForm([], 'Save'); $this->assertSession()->pageTextContains('The referenced entity (node: 4) does not exist'); $this->assertSession()->pageTextContains('Entity reference (value 1) field is required.'); // Try to collapse with an invalid reference. @@ -494,7 +497,7 @@ class ParagraphsAdministrationTest extends ParagraphsTestBase { // Paragraph should be still in edit mode. $this->assertSession()->fieldExists('field_paragraphs[0][subform][field_entity_reference][0][target_id]'); $this->assertSession()->fieldExists('field_paragraphs[0][subform][field_entity_reference][1][target_id]'); - $this->submitForm([], 'Add another item'); + $this->submitForm([], 'Save'); // Assert the validation message. $this->assertSession()->pageTextMatches('/There are no (entities|content items) matching "foo"./'); // Attempt to remove the Paragraph. diff --git a/tests/src/Functional/WidgetLegacy/ParagraphsConfigTest.php b/tests/src/Functional/WidgetLegacy/ParagraphsConfigTest.php index f1a65dacd4d59e1e1143bbb0c426b849fd69039a..ec0f9218d36ad19f22b0d3c861d1c28d267b5138 100644 --- a/tests/src/Functional/WidgetLegacy/ParagraphsConfigTest.php +++ b/tests/src/Functional/WidgetLegacy/ParagraphsConfigTest.php @@ -129,7 +129,7 @@ class ParagraphsConfigTest extends ParagraphsTestBase { $selected_group = [ 'new_storage_type' => 'reference', ]; - $this->submitForm($selected_group, 'Change field group'); + $this->submitForm($selected_group, $this->coreVersion('10.3') ? 'Continue' : 'Change field group'); $edit = [ 'group_field_options_wrapper' => 'field_ui:entity_reference:node', 'label' => 'new_no_field_paragraphs', diff --git a/tests/src/Functional/WidgetStable/ParagraphsAdministrationTest.php b/tests/src/Functional/WidgetStable/ParagraphsAdministrationTest.php index e695eab2e81ab508154699da1469e0775de2002f..808aff3ce18e4fdadf6fc72a261c3b77a7a69ff0 100644 --- a/tests/src/Functional/WidgetStable/ParagraphsAdministrationTest.php +++ b/tests/src/Functional/WidgetStable/ParagraphsAdministrationTest.php @@ -148,8 +148,11 @@ class ParagraphsAdministrationTest extends ParagraphsTestBase { $this->drupalGet('admin/structure/paragraphs_type'); $this->assertSession()->pageTextContains('There are no Paragraphs types yet.'); $this->drupalGet('admin/structure/types/manage/paragraphs/fields/add-field'); + $this->getSession()->getPage()->fillField('new_storage_type', 'field_ui:entity_reference_revisions:paragraph'); + if ($this->coreVersion('10.3')) { + $this->getSession()->getPage()->pressButton('Continue'); + } $edit = [ - 'new_storage_type' => 'field_ui:entity_reference_revisions:paragraph', 'label' => 'Paragraph', 'field_name' => 'paragraph', ]; diff --git a/tests/src/Functional/WidgetStable/ParagraphsConfigTest.php b/tests/src/Functional/WidgetStable/ParagraphsConfigTest.php index 825c4039f2bd148b507966d39e1a7671b0cdbf74..93f7f124607abe78a2a5b262227aa70ae11dd94c 100644 --- a/tests/src/Functional/WidgetStable/ParagraphsConfigTest.php +++ b/tests/src/Functional/WidgetStable/ParagraphsConfigTest.php @@ -129,7 +129,7 @@ class ParagraphsConfigTest extends ParagraphsTestBase { $selected_group = [ 'new_storage_type' => 'reference', ]; - $this->submitForm($selected_group, 'Change field group'); + $this->submitForm($selected_group, $this->coreVersion('10.3') ? 'Continue' : 'Change field group'); $edit = [ 'group_field_options_wrapper' => 'field_ui:entity_reference:node', 'label' => 'new_no_field_paragraphs', diff --git a/tests/src/FunctionalJavascript/ParagraphsAddWidgetTest.php b/tests/src/FunctionalJavascript/ParagraphsAddWidgetTest.php index 72533347ab23d4f7a0ba8b193439b75e175ad0a6..7e24e156667848b37fdc31e9a5328ef465b1eba4 100644 --- a/tests/src/FunctionalJavascript/ParagraphsAddWidgetTest.php +++ b/tests/src/FunctionalJavascript/ParagraphsAddWidgetTest.php @@ -86,7 +86,12 @@ class ParagraphsAddWidgetTest extends WebDriverTestBase { $this->drupalGet('admin/structure/paragraphs_type/' . $paragraph_type . '/fields/add-field'); if ($this->coreVersion('10.2')) { $page->selectFieldOption('new_storage_type', 'formatted_text'); - $this->assertSession()->waitForElementVisible('css', '#text_long'); + if ($this->coreVersion('10.3')) { + $page->pressButton('Continue'); + } + else { + $this->assertSession()->waitForElementVisible('css', '#text_long'); + } $page->selectFieldOption('group_field_options_wrapper', 'text_long'); } else { @@ -111,6 +116,9 @@ class ParagraphsAddWidgetTest extends WebDriverTestBase { $this->drupalGet('/admin/structure/paragraphs_type/nested_test/fields/add-field'); $page->selectFieldOption('new_storage_type', 'field_ui:entity_reference_revisions:paragraph'); + if ($this->coreVersion('10.3')) { + $page->pressButton('Continue'); + } $page->fillField('label', 'Paragraphs'); $this->assertSession()->waitForElementVisible('css', '#edit-name-machine-name-suffix .link'); $page->pressButton('Edit'); @@ -156,7 +164,6 @@ class ParagraphsAddWidgetTest extends WebDriverTestBase { // Find the add button in the nested paragraph with xpath. $element = $this->xpath('//div[contains(@class, "form-item")]/div/div/div[contains(@class, "paragraph-type-add-modal")]/input'); $element[0]->click(); - $this->assertSession()->assertWaitOnAjaxRequest(); // Add a text inside the nested paragraph. $page = $this->getSession()->getPage(); @@ -230,7 +237,12 @@ class ParagraphsAddWidgetTest extends WebDriverTestBase { $this->drupalGet('admin/structure/paragraphs_type/test_1/fields/add-field'); if ($this->coreVersion('10.2')) { $page->selectFieldOption('new_storage_type', 'formatted_text'); - $this->assertSession()->waitForElementVisible('css', '#text_long'); + if ($this->coreVersion('10.3')) { + $page->pressButton('Continue'); + } + else { + $this->assertSession()->waitForElementVisible('css', '#text_long'); + } $page->selectFieldOption('group_field_options_wrapper', 'text_long'); } else { @@ -253,7 +265,12 @@ class ParagraphsAddWidgetTest extends WebDriverTestBase { $this->drupalGet('admin/structure/paragraphs_type/test_2/fields/add-field'); if ($this->coreVersion('10.2')) { $page->selectFieldOption('new_storage_type', 'formatted_text'); - $this->assertSession()->waitForElementVisible('css', '#text_long'); + if ($this->coreVersion('10.3')) { + $page->pressButton('Continue'); + } + else { + $this->assertSession()->waitForElementVisible('css', '#text_long'); + } $page->selectFieldOption('group_field_options_wrapper', 'text_long'); } else { @@ -276,7 +293,12 @@ class ParagraphsAddWidgetTest extends WebDriverTestBase { $this->drupalGet('admin/structure/paragraphs_type/test_3/fields/add-field'); if ($this->coreVersion('10.2')) { $page->selectFieldOption('new_storage_type', 'formatted_text'); - $this->assertSession()->waitForElementVisible('css', '#text_long'); + if ($this->coreVersion('10.3')) { + $page->pressButton('Continue'); + } + else { + $this->assertSession()->waitForElementVisible('css', '#text_long'); + } $page->selectFieldOption('group_field_options_wrapper', 'text_long'); } else { @@ -301,6 +323,9 @@ class ParagraphsAddWidgetTest extends WebDriverTestBase { $this->drupalGet('/admin/structure/paragraphs_type/test_nested/fields/add-field'); $page->selectFieldOption('new_storage_type', 'field_ui:entity_reference_revisions:paragraph'); + if ($this->coreVersion('10.3')) { + $page->pressButton('Continue'); + } $page->fillField('label', 'Paragraphs'); $this->assertSession()->waitForElementVisible('css', '#edit-name-machine-name-suffix .link'); $page->pressButton('Edit'); @@ -351,7 +376,6 @@ class ParagraphsAddWidgetTest extends WebDriverTestBase { $this->getSession()->executeScript("jQuery('input.paragraph-type-add-delta').last().val('')"); for ($i = 1; $i <= 2; $i++) { $page->find('xpath', '//*[@name="button_add_modal" and not(ancestor::table)]')->click(); - $this->assertSession()->assertWaitOnAjaxRequest(); $page->find('xpath', '//*[contains(@class, "paragraphs-add-dialog") and contains(@class, "ui-dialog-content")]//*[contains(@name, "test_' . $i . '")]')->click(); $this->assertSession()->assertWaitOnAjaxRequest(); } @@ -364,7 +388,6 @@ class ParagraphsAddWidgetTest extends WebDriverTestBase { // Add new paragraph to 1st position - set delta to 0 for base paragraphs. $this->getSession()->executeScript("jQuery('input.paragraph-type-add-delta').last().val(0)"); $page->find('xpath', '//*[@name="button_add_modal" and not(ancestor::table)]')->click(); - $this->assertSession()->assertWaitOnAjaxRequest(); $page->find('xpath', '//*[contains(@class, "paragraphs-add-dialog") and contains(@class, "ui-dialog-content")]//*[contains(@name, "test_3")]')->click(); $this->assertSession()->assertWaitOnAjaxRequest(); @@ -376,7 +399,6 @@ class ParagraphsAddWidgetTest extends WebDriverTestBase { // Add new paragraph to 3rd position - set delta to 2 for base paragraphs. $this->getSession()->executeScript("jQuery('input.paragraph-type-add-delta').last().val(2)"); $page->find('xpath', '//*[@name="button_add_modal" and not(ancestor::table)]')->click(); - $this->assertSession()->assertWaitOnAjaxRequest(); $page->find('xpath', '//*[contains(@class, "paragraphs-add-dialog") and contains(@class, "ui-dialog-content")]//*[contains(@name, "test_2")]')->click(); $this->assertSession()->assertWaitOnAjaxRequest(); @@ -388,7 +410,6 @@ class ParagraphsAddWidgetTest extends WebDriverTestBase { // Add new paragraph to last position - using really big delta. $this->getSession()->executeScript("jQuery('input.paragraph-type-add-delta').last().val(1000)"); $page->find('xpath', '//*[@name="button_add_modal" and not(ancestor::table)]')->click(); - $this->assertSession()->assertWaitOnAjaxRequest(); $page->find('xpath', '//*[contains(@class, "paragraphs-add-dialog") and contains(@class, "ui-dialog-content")]//*[contains(@name, "test_1")]')->click(); $this->assertSession()->assertWaitOnAjaxRequest(); @@ -400,7 +421,6 @@ class ParagraphsAddWidgetTest extends WebDriverTestBase { // Clear delta base paragraphs. $this->getSession()->executeScript("jQuery('input.paragraph-type-add-delta').last().val('')"); $page->find('xpath', '//*[@name="button_add_modal" and not(ancestor::table)]')->click(); - $this->assertSession()->assertWaitOnAjaxRequest(); $page->find('xpath', '//*[contains(@class, "paragraphs-add-dialog") and contains(@class, "ui-dialog-content")]//*[contains(@name, "test_3")]')->click(); $this->assertSession()->assertWaitOnAjaxRequest(); @@ -438,35 +458,30 @@ class ParagraphsAddWidgetTest extends WebDriverTestBase { // Add paragraph in nested to have initial state for adding positions. $page->find('xpath', '//*[@name="button_add_modal" and ancestor::table]')->click(); - $this->assertSession()->assertWaitOnAjaxRequest(); $page->find('xpath', '//*[contains(@class, "paragraphs-add-dialog") and contains(@class, "ui-dialog-content")]//*[contains(@name, "test_1")]')->click(); $this->assertSession()->assertWaitOnAjaxRequest(); // Add new paragraph to first position. $this->getSession()->executeScript("jQuery('input.paragraph-type-add-delta').first().val(0)"); $page->find('xpath', '//*[@name="button_add_modal" and ancestor::table]')->click(); - $this->assertSession()->assertWaitOnAjaxRequest(); $page->find('xpath', '//*[contains(@class, "paragraphs-add-dialog") and contains(@class, "ui-dialog-content")]//*[contains(@name, "test_3")]')->click(); $this->assertSession()->assertWaitOnAjaxRequest(); // Add new paragraph to 2nd position - using float value for index. $this->getSession()->executeScript("jQuery('input.paragraph-type-add-delta').first().val(1.1111)"); $page->find('xpath', '//*[@name="button_add_modal" and ancestor::table]')->click(); - $this->assertSession()->assertWaitOnAjaxRequest(); $page->find('xpath', '//*[contains(@class, "paragraphs-add-dialog") and contains(@class, "ui-dialog-content")]//*[contains(@name, "test_2")]')->click(); $this->assertSession()->assertWaitOnAjaxRequest(); // Add new paragraph to first position - using negative index. $this->getSession()->executeScript("jQuery('input.paragraph-type-add-delta').first().val(-100)"); $page->find('xpath', '//*[@name="button_add_modal" and ancestor::table]')->click(); - $this->assertSession()->assertWaitOnAjaxRequest(); $page->find('xpath', '//*[contains(@class, "paragraphs-add-dialog") and contains(@class, "ui-dialog-content")]//*[contains(@name, "test_2")]')->click(); $this->assertSession()->assertWaitOnAjaxRequest(); // Add new paragraph to last position - using some text as position. $this->getSession()->executeScript("jQuery('input.paragraph-type-add-delta').first().val('some_text')"); $page->find('xpath', '//*[@name="button_add_modal" and ancestor::table]')->click(); - $this->assertSession()->assertWaitOnAjaxRequest(); $page->find('xpath', '//*[contains(@class, "paragraphs-add-dialog") and contains(@class, "ui-dialog-content")]//*[contains(@name, "test_3")]')->click(); $this->assertSession()->assertWaitOnAjaxRequest(); diff --git a/tests/src/FunctionalJavascript/ParagraphsClientsideButtonsTest.php b/tests/src/FunctionalJavascript/ParagraphsClientsideButtonsTest.php index b0fc08dd8a8e4522a2c285e315f1f29ea1f1dd1c..b7bfc96230f247fb1841e235199a884c7c7d3e58 100644 --- a/tests/src/FunctionalJavascript/ParagraphsClientsideButtonsTest.php +++ b/tests/src/FunctionalJavascript/ParagraphsClientsideButtonsTest.php @@ -93,6 +93,9 @@ class ParagraphsClientsideButtonsTest extends WebDriverTestBase { if ($this->coreVersion('10.2')) { $page->selectFieldOption('new_storage_type', 'plain_text'); $this->assertSession()->waitForElementVisible('css', '#string'); + if ($this->coreVersion('10.3')) { + $page->pressButton('Continue'); + } $page->selectFieldOption('group_field_options_wrapper', 'string'); } else { @@ -177,7 +180,6 @@ class ParagraphsClientsideButtonsTest extends WebDriverTestBase { $dropdown->click(); $add_above_button = $assert_session->elementExists('css', 'input.paragraphs-dropdown-action--add-above', $second_original_row); $add_above_button->click(); - $assert_session->assertWaitOnAjaxRequest(); $dialog = $page->find('xpath', '//div[contains(@class, "ui-dialog")]'); $dialog->pressButton('text'); $assert_session->assertWaitOnAjaxRequest(); @@ -185,7 +187,6 @@ class ParagraphsClientsideButtonsTest extends WebDriverTestBase { // Add a new paragraph in order to test that the new paragraph is added at the bottom. $page->pressButton('Add Paragraph'); - $assert_session->assertWaitOnAjaxRequest(); $dialog = $page->find('xpath', '//div[contains(@class, "ui-dialog")]'); $dialog->pressButton('text'); $assert_session->assertWaitOnAjaxRequest(); @@ -267,7 +268,6 @@ class ParagraphsClientsideButtonsTest extends WebDriverTestBase { $dropdown->click(); $add_above_button = $assert_session->elementExists('css', 'input.paragraphs-dropdown-action--add-above', $second_original_row); $add_above_button->click(); - $assert_session->assertWaitOnAjaxRequest(); $dialog = $page->find('xpath', '//div[contains(@class, "ui-dialog")]'); $dialog->pressButton('rich_paragraph'); $assert_session->assertWaitOnAjaxRequest(); @@ -276,7 +276,6 @@ class ParagraphsClientsideButtonsTest extends WebDriverTestBase { // Add a text nested paragraph. $add_paragraph_rich_row->click(); - $assert_session->assertWaitOnAjaxRequest(); $dialog = $page->find('xpath', '//div[contains(@class, "ui-dialog")]'); $dialog->pressButton('text'); $assert_session->assertWaitOnAjaxRequest(); @@ -299,7 +298,6 @@ class ParagraphsClientsideButtonsTest extends WebDriverTestBase { $field_storage->save(); // Add the Paragraph back. $add_paragraph_rich_row->click(); - $assert_session->assertWaitOnAjaxRequest(); $dialog = $page->find('xpath', '//div[contains(@class, "ui-dialog")]'); $dialog->pressButton('text'); $assert_session->assertWaitOnAjaxRequest(); @@ -322,7 +320,6 @@ class ParagraphsClientsideButtonsTest extends WebDriverTestBase { $dropdown->click(); $add_above_button = $assert_session->elementExists('css', 'input.paragraphs-dropdown-action--add-above', $first_nested_row); $add_above_button->click(); - $assert_session->assertWaitOnAjaxRequest(); $dialog = $page->find('xpath', '//div[contains(@class, "ui-dialog")]'); $dialog->pressButton('text'); $assert_session->assertWaitOnAjaxRequest(); @@ -346,7 +343,6 @@ class ParagraphsClientsideButtonsTest extends WebDriverTestBase { $dropdown->click(); $add_above_button = $assert_session->elementExists('css', 'input.paragraphs-dropdown-action--add-above', $first_row); $add_above_button->click(); - $assert_session->assertWaitOnAjaxRequest(); $dialog = $page->find('xpath', '//div[contains(@class, "ui-dialog")]'); $dialog->pressButton('text'); $assert_session->assertWaitOnAjaxRequest(); @@ -366,7 +362,6 @@ class ParagraphsClientsideButtonsTest extends WebDriverTestBase { $dropdown->click(); $add_above_button = $assert_session->elementExists('css', 'input.paragraphs-dropdown-action--add-above', $first_row); $add_above_button->click(); - $assert_session->assertWaitOnAjaxRequest(); $dialog = $page->find('xpath', '//div[contains(@class, "ui-dialog")]'); $dialog->pressButton('text'); $assert_session->assertWaitOnAjaxRequest(); diff --git a/tests/src/FunctionalJavascript/ParagraphsEntityReferenceWarningTest.php b/tests/src/FunctionalJavascript/ParagraphsEntityReferenceWarningTest.php index 8f4bc8e319dff755a57971eb1d1309c23258b345..e9cdfa5afdce015034e3ce677d62618585ea839c 100644 --- a/tests/src/FunctionalJavascript/ParagraphsEntityReferenceWarningTest.php +++ b/tests/src/FunctionalJavascript/ParagraphsEntityReferenceWarningTest.php @@ -53,10 +53,17 @@ class ParagraphsEntityReferenceWarningTest extends WebDriverTestBase { $page = $this->getSession()->getPage(); if ($this->coreVersion('10.2')) { $page->find('css', "[name='new_storage_type'][value='reference']")->getParent()->click(); - $this->assertSession()->assertWaitOnAjaxRequest(); + if ($this->coreVersion('10.3')) { + $page->pressButton('Continue'); + } + else { + $this->assertSession()->assertWaitOnAjaxRequest(); + } $page->fillField('label', 'unsupported field'); $page->find('css', "[name='group_field_options_wrapper'][value='entity_reference']")->getParent()->click(); - $this->assertSession()->assertWaitOnAjaxRequest(); + if (!$this->coreVersion('10.3')) { + $this->assertSession()->assertWaitOnAjaxRequest(); + } $page->pressButton('Continue'); $this->assertSession()->pageTextNotContains('Note: Regular paragraph fields should use the revision based reference fields, entity reference fields should only be used for cases when an existing paragraph is referenced from somewhere else.'); diff --git a/tests/src/FunctionalJavascript/ParagraphsStableEditPerspectivesUiTest.php b/tests/src/FunctionalJavascript/ParagraphsStableEditPerspectivesUiTest.php index 04403bccf84f0c160cbd5e603c464c25e3279200..e0460966f8baa0abfcbe7f2373f109550034cf60 100644 --- a/tests/src/FunctionalJavascript/ParagraphsStableEditPerspectivesUiTest.php +++ b/tests/src/FunctionalJavascript/ParagraphsStableEditPerspectivesUiTest.php @@ -196,6 +196,9 @@ class ParagraphsStableEditPerspectivesUiTest extends WebDriverTestBase { $this->drupalGet('admin/structure/types/manage/testcontent/fields/add-field'); $page->selectFieldOption('new_storage_type', 'field_ui:entity_reference_revisions:paragraph'); + if ($this->coreVersion('10.3')) { + $page->pressButton('Continue'); + } $page->fillField('label', 'testparagraphfield'); $this->assertSession()->waitForElementVisible('css', '#edit-name-machine-name-suffix .link'); $page->pressButton('Edit'); diff --git a/tests/src/Kernel/ParagraphsCollapsedSummaryTest.php b/tests/src/Kernel/ParagraphsCollapsedSummaryTest.php index 6b926c939c8aed7fcc5b811de384ff180c288de4..de254e043bbedf1cce9ebe7523092430de99f19d 100644 --- a/tests/src/Kernel/ParagraphsCollapsedSummaryTest.php +++ b/tests/src/Kernel/ParagraphsCollapsedSummaryTest.php @@ -101,7 +101,7 @@ class ParagraphsCollapsedSummaryTest extends KernelTestBase { // Load the paragraph and assert its stored feature settings. $paragraph = Paragraph::load($paragraph->id()); $this->assertEquals($paragraph->getAllBehaviorSettings(), $feature_settings); - $this->assertEquals($paragraph->getSummary(), '<div class="paragraphs-description paragraphs-collapsed-description"><div class="paragraphs-content-wrapper"><span class="summary-content">Example text for a text paragraph</span></div><div class="paragraphs-plugin-wrapper"><span class="summary-plugin"><span class="summary-plugin-label">Text color</span>red</span></div></div>'); + $this->assertEquals((string) $paragraph->getSummary(), '<div class="paragraphs-description paragraphs-collapsed-description"><div class="paragraphs-content-wrapper"><span class="summary-content">Example text for a text paragraph</span></div><div class="paragraphs-plugin-wrapper"><span class="summary-plugin"><span class="summary-plugin-label">Text color</span>red</span></div></div>'); // Check the summary and the additional options. $paragraph_1 = Paragraph::create([ @@ -111,12 +111,12 @@ class ParagraphsCollapsedSummaryTest extends KernelTestBase { $paragraph_1->save(); // We do not include behavior summaries of nested children in the parent // summary. - $this->assertEquals($paragraph_1->getSummary(), '<div class="paragraphs-description paragraphs-collapsed-description"><div class="paragraphs-content-wrapper"><span class="summary-content">Example text for a text paragraph</span></div></div>'); + $this->assertEquals((string) $paragraph_1->getSummary(), '<div class="paragraphs-description paragraphs-collapsed-description"><div class="paragraphs-content-wrapper"><span class="summary-content">Example text for a text paragraph</span></div></div>'); $info = $paragraph_1->getIcons(); $this->assertEquals($info['count']['#prefix'], '<span class="paragraphs-badge" title="1 child">'); $this->assertEquals($info['count']['#suffix'], '</span>'); - $this->assertEquals($paragraph_1->getSummary(['depth_limit' => 0]), ''); + $this->assertEquals((string) $paragraph_1->getSummary(['depth_limit' => 0]), ''); } /** @@ -150,8 +150,8 @@ class ParagraphsCollapsedSummaryTest extends KernelTestBase { 'nested_paragraph_field' => [$paragraph_text_2, $paragraph_nested_1], ]); $paragraph_nested_2->save(); - $this->assertEquals($paragraph_nested_2->getSummary(['show_behavior_summary' => FALSE]), '<div class="paragraphs-description paragraphs-collapsed-description"><div class="paragraphs-content-wrapper"><span class="summary-content">Text paragraph on top level</span></div></div>'); - $this->assertEquals($paragraph_nested_2->getSummary(['show_behavior_summary' => FALSE, 'depth_limit' => 2]), '<div class="paragraphs-description paragraphs-collapsed-description"><div class="paragraphs-content-wrapper"><span class="summary-content">Text paragraph on top level</span>, <span class="summary-content">Text paragraph on nested level</span></div></div>'); + $this->assertEquals((string) $paragraph_nested_2->getSummary(['show_behavior_summary' => FALSE]), '<div class="paragraphs-description paragraphs-collapsed-description"><div class="paragraphs-content-wrapper"><span class="summary-content">Text paragraph on top level</span></div></div>'); + $this->assertEquals((string) $paragraph_nested_2->getSummary(['show_behavior_summary' => FALSE, 'depth_limit' => 2]), '<div class="paragraphs-description paragraphs-collapsed-description"><div class="paragraphs-content-wrapper"><span class="summary-content">Text paragraph on top level</span>, <span class="summary-content">Text paragraph on nested level</span></div></div>'); $info = $paragraph_nested_2->getIcons(); $this->assertEquals($info['count']['#prefix'], '<span class="paragraphs-badge" title="2 children">'); $this->assertEquals($info['count']['#suffix'], '</span>'); @@ -181,7 +181,7 @@ class ParagraphsCollapsedSummaryTest extends KernelTestBase { $paragraph_with_multiple_entity_references->get('field_user_references')->appendItem($user1->id()); $paragraph_with_multiple_entity_references->get('field_user_references')->appendItem($user2->id()); $paragraph_with_multiple_entity_references->save(); - $this->assertEquals('<div class="paragraphs-description paragraphs-collapsed-description"><div class="paragraphs-content-wrapper"><span class="summary-content">bob</span>, <span class="summary-content">pete</span></div></div>', $paragraph_with_multiple_entity_references->getSummary()); + $this->assertEquals('<div class="paragraphs-description paragraphs-collapsed-description"><div class="paragraphs-content-wrapper"><span class="summary-content">bob</span>, <span class="summary-content">pete</span></div></div>', (string) $paragraph_with_multiple_entity_references->getSummary()); } /** diff --git a/tests/src/Unit/migrate/MigrationPluginsAltererTest.php b/tests/src/Unit/migrate/MigrationPluginsAltererTest.php index 4ac93577a65896415a4eb45a86816eb0728d3e76..248cf3815bbbc18ed524b274ddb9718121aec4f0 100644 --- a/tests/src/Unit/migrate/MigrationPluginsAltererTest.php +++ b/tests/src/Unit/migrate/MigrationPluginsAltererTest.php @@ -2,6 +2,7 @@ namespace Drupal\Tests\paragraphs\Unit\migrate; +use Drupal\Core\Logger\LoggerChannelFactoryInterface; use Drupal\paragraphs\MigrationPluginsAlterer; use Drupal\Tests\UnitTestCase; @@ -30,12 +31,11 @@ class MigrationPluginsAltererTest extends UnitTestCase { parent::setUp(); $logger_channel = $this->createMock('Drupal\Core\Logger\LoggerChannelInterface'); - $logger_factory = $this->getMockBuilder('Drupal\Core\Logger\LoggerChannelFactory') - ->getMock(); + $logger_factory = $this->createMock('Drupal\Core\Logger\LoggerChannelFactoryInterface'); $logger_factory->expects($this->atLeastOnce()) ->method('get') ->with('paragraphs') - ->will($this->returnValue($logger_channel)); + ->willReturn($logger_channel); $this->paragraphsMigrationPluginsAlterer = new MigrationPluginsAlterer($logger_factory); }