public function ParagraphsFeaturesTest::testDeleteConfirmation in Thunder 6.2.x
Same name and namespace in other branches
- 8.5 tests/src/FunctionalJavascript/Integration/ParagraphsFeaturesTest.php \Drupal\Tests\thunder\FunctionalJavascript\Integration\ParagraphsFeaturesTest::testDeleteConfirmation()
- 8.2 tests/src/FunctionalJavascript/Integration/ParagraphsFeaturesTest.php \Drupal\Tests\thunder\FunctionalJavascript\Integration\ParagraphsFeaturesTest::testDeleteConfirmation()
- 8.3 tests/src/FunctionalJavascript/Integration/ParagraphsFeaturesTest.php \Drupal\Tests\thunder\FunctionalJavascript\Integration\ParagraphsFeaturesTest::testDeleteConfirmation()
- 8.4 tests/src/FunctionalJavascript/Integration/ParagraphsFeaturesTest.php \Drupal\Tests\thunder\FunctionalJavascript\Integration\ParagraphsFeaturesTest::testDeleteConfirmation()
- 6.0.x tests/src/FunctionalJavascript/Integration/ParagraphsFeaturesTest.php \Drupal\Tests\thunder\FunctionalJavascript\Integration\ParagraphsFeaturesTest::testDeleteConfirmation()
- 6.1.x tests/src/FunctionalJavascript/Integration/ParagraphsFeaturesTest.php \Drupal\Tests\thunder\FunctionalJavascript\Integration\ParagraphsFeaturesTest::testDeleteConfirmation()
Testing of delete confirmation for paragraphs.
File
- tests/
src/ FunctionalJavascript/ Integration/ ParagraphsFeaturesTest.php, line 29
Class
- ParagraphsFeaturesTest
- Tests the paragraph feature for delete confirmation dialog.
Namespace
Drupal\Tests\thunder\FunctionalJavascript\IntegrationCode
public function testDeleteConfirmation() {
$page = $this
->getSession()
->getPage();
$term = $this
->loadTermByUuid('bfc251bc-de35-467d-af44-1f7a7012b845');
$this
->articleFillNew([
'field_channel' => $term
->id(),
'title[0][value]' => 'Article 1',
'field_seo_title[0][value]' => 'Article 1',
]);
// Add text paragraph with two elements.
$this
->addTextParagraph(static::$paragraphsField, 'Test Delete Confirmation to delete text');
$this
->addTextParagraph(static::$paragraphsField, 'Test Delete Confirmation to stay text');
$this
->clickSave();
$this
->drupalGet('node/10/edit');
$customDeleteButton = $page
->find('xpath', '//div[contains(@id, "field-paragraphs-0-item-wrapper")]//button[contains(@class, "paragraph-form-item__action--remove")]');
$hiddenDeleteButton = $page
->find('xpath', '//div[contains(@id, "field-paragraphs-0-item-wrapper")]//button[contains(@class, "paragraph-form-item__action--remove")]');
$this
->assertTrue($customDeleteButton
->isVisible(), 'Delete button should be visible and not hidden behind drop-down');
$this
->assertTrue($hiddenDeleteButton
->isVisible(), 'Default button from paragraphs should not be visible');
$this
->scrollElementInView('div[id^="field-paragraphs-0-item-wrapper"] button.paragraph-form-item__action--remove');
$customDeleteButton
->click();
$confirmButton = $page
->find('xpath', '//*[contains(@class, "paragraphs-features__delete-confirmation")]//button[contains(@class, "paragraphs-features__delete-confirmation__remove-button")]');
$confirmButton
->click();
$this
->assertWaitOnAjaxRequest();
$this
->assertEquals(1, $this
->getNumberOfParagraphs(static::$paragraphsField));
$this
->editParagraph($page, 'field_paragraphs', 1);
$customFormDeleteButton = $page
->find('xpath', '//div[contains(@id, "field-paragraphs-1-item-wrapper")]//button[contains(@class, "paragraph-form-item__action--remove")]');
$hiddenFormDeleteButton = $page
->find('xpath', '//div[contains(@id, "field-paragraphs-1-item-wrapper")]//button[contains(@class, "paragraph-form-item__action--remove")]');
$this
->assertTrue($customFormDeleteButton
->isVisible(), 'Delete button should be visible');
$this
->assertTrue($hiddenFormDeleteButton
->isVisible(), 'Default button from paragraphs should not be visible');
$this
->scrollElementInView('div[id^="field-paragraphs-1-item-wrapper"] button.paragraph-form-item__action--remove');
$customFormDeleteButton
->click();
$this
->assertFalse($customFormDeleteButton
->isVisible(), 'Delete button should hidden behind confirmation dialog');
$cancelButton = $page
->find('xpath', '//*[contains(@class, "paragraphs-features__delete-confirmation")]//button[contains(@class, "paragraphs-features__delete-confirmation__cancel-button")]');
$cancelButton
->click();
$this
->assertEquals(1, $this
->getNumberOfParagraphs(static::$paragraphsField));
$this
->assertTrue($customFormDeleteButton
->isVisible(), 'Delete button should be visible again');
}