Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Christian Fritsch committed Jan 7, 2025
1 parent b01b340 commit 13c1393
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ public function testAddInBetweenFeature() {
// Check that add in between option is available for modal add mode.
$page->selectFieldOption('fields[field_paragraphs][settings_edit_form][settings][add_mode]', 'modal');
$session->executeScript("jQuery('[name=\"fields[field_paragraphs][settings_edit_form][settings][add_mode]\"]').trigger('change');");
$this->assertSession()->assertWaitOnAjaxRequest();

$is_option_visible = $session->evaluateScript("Array.from(document.querySelectorAll('.paragraphs-features__add-in-between__option')).filter((item) => { return !item.disabled }).length === 1");
$this->assertEquals(TRUE, $is_option_visible, 'After modal add mode is selected, "add in between" option should be available.');
$page->checkField('fields[field_paragraphs][settings_edit_form][third_party_settings][paragraphs_features][add_in_between]');
Expand All @@ -49,7 +47,6 @@ public function testAddInBetweenFeature() {
// Check that add in between option is not available for non modal add mode.
$page->selectFieldOption('fields[field_paragraphs][settings_edit_form][settings][add_mode]', 'dropdown');
$session->executeScript("jQuery('[name=\"fields[field_paragraphs][settings_edit_form][settings][add_mode]\"]').trigger('change');");
$this->assertSession()->assertWaitOnAjaxRequest();

$is_option_visible = $session->evaluateScript("Array.from(document.querySelectorAll('.paragraphs-features__add-in-between__option')).filter((item) => { return item.offsetParent }).length === 0");
$this->assertEquals(TRUE, $is_option_visible, 'After add mode is change to non modal, "add in between" option should not be visible.');
Expand All @@ -59,9 +56,7 @@ public function testAddInBetweenFeature() {
// Set modal add mode without add in between option.
$page->selectFieldOption('fields[field_paragraphs][settings_edit_form][settings][add_mode]', 'modal');
$session->executeScript("jQuery('[name=\"fields[field_paragraphs][settings_edit_form][settings][add_mode]\"]').trigger('change');");
$this->assertSession()->assertWaitOnAjaxRequest();
$page->uncheckField('fields[field_paragraphs][settings_edit_form][third_party_settings][paragraphs_features][add_in_between]');
$this->assertSession()->assertWaitOnAjaxRequest();

$this->submitForm([], 'Update');
$this->assertSession()->assertWaitOnAjaxRequest();
Expand Down Expand Up @@ -107,21 +102,18 @@ public function testAddInBetweenFeature() {

// Check first add in between button.
$page->find('xpath', '(//*[contains(concat(" ", normalize-space(@class), " "), " paragraphs-features__add-in-between__button ")])[1]')->click();
$this->assertSession()->assertWaitOnAjaxRequest();
$this->assertSession()->hiddenFieldValueEquals('field_paragraphs[add_more][add_more_delta]', '0');
$page->find('xpath', '//*[contains(@class, "paragraphs-add-dialog") and contains(@class, "ui-dialog-content")]//*[contains(@name, "test_1")]')->click();
$this->assertSession()->assertWaitOnAjaxRequest();

// Check last add in between button.
$this->scrollClick('xpath', '(//*[contains(@class, "paragraphs-features__add-in-between__button ")])[last()]');
$this->assertSession()->assertWaitOnAjaxRequest();
$this->assertSession()->hiddenFieldValueEquals('field_paragraphs[add_more][add_more_delta]', '2');
$page->find('xpath', '//*[contains(@class, "paragraphs-add-dialog") and contains(@class, "ui-dialog-content")]//*[contains(@name, "test_1")]')->click();
$this->assertSession()->assertWaitOnAjaxRequest();

// Check add in between button between existing paragraphs.
$page->find('xpath', '(//*[contains(@class, "paragraphs-features__add-in-between__button ")])[3]')->click();
$this->assertSession()->assertWaitOnAjaxRequest();
$this->assertSession()->hiddenFieldValueEquals('field_paragraphs[add_more][add_more_delta]', '2');
$page->find('xpath', '//*[contains(@class, "paragraphs-add-dialog") and contains(@class, "ui-dialog-content")]//*[contains(@name, "test_1")]')->click();
$this->assertSession()->assertWaitOnAjaxRequest();
Expand Down Expand Up @@ -151,7 +143,6 @@ public function testAddInBetweenFeature() {
$this->assertSession()->assertWaitOnAjaxRequest();
$page->selectFieldOption('fields[field_paragraphs][settings_edit_form][settings][add_mode]', 'modal');
$session->executeScript("jQuery('[name=\"fields[field_paragraphs][settings_edit_form][settings][add_mode]\"]').trigger('change');");
$this->assertSession()->assertWaitOnAjaxRequest();
$page->checkField('fields[field_paragraphs][settings_edit_form][third_party_settings][paragraphs_features][add_in_between]');
$page->fillField('fields[field_paragraphs][settings_edit_form][third_party_settings][paragraphs_features][add_in_between_link_count]', '0');
$this->submitForm([], 'Update');
Expand All @@ -178,21 +169,18 @@ public function testAddInBetweenFeature() {

// Check first add in between button.
$page->find('xpath', '(//*[contains(concat(" ", normalize-space(@class), " "), " paragraphs-features__add-in-between__button ")])[1]')->click();
$this->assertSession()->assertWaitOnAjaxRequest();
$this->assertSession()->hiddenFieldValueEquals('field_paragraphs[0][subform][field_paragraphs][add_more][add_more_delta]', '0');
$page->find('xpath', '//*[contains(@class, "paragraphs-add-dialog") and contains(@class, "ui-dialog-content")]//*[contains(@name, "test_1")]')->click();
$this->assertSession()->assertWaitOnAjaxRequest();

// Check last add in between button.
$this->scrollClick('xpath', '(//*[contains(concat(" ", normalize-space(@class), " "), " paragraphs-features__add-in-between__button ")])[last()]');
$this->assertSession()->assertWaitOnAjaxRequest();
$this->assertSession()->hiddenFieldValueEquals('field_paragraphs[0][subform][field_paragraphs][add_more][add_more_delta]', '1');
$page->find('xpath', '//*[contains(@class, "paragraphs-add-dialog") and contains(@class, "ui-dialog-content")]//*[contains(@name, "test_1")]')->click();
$this->assertSession()->assertWaitOnAjaxRequest();

// Check add in between button between existing paragraphs.
$page->find('xpath', '(//*[contains(concat(" ", normalize-space(@class), " "), " paragraphs-features__add-in-between__button ")])[2]')->click();
$this->assertSession()->assertWaitOnAjaxRequest();
$this->assertSession()->hiddenFieldValueEquals('field_paragraphs[0][subform][field_paragraphs][add_more][add_more_delta]', '1');
$page->find('xpath', '//*[contains(@class, "paragraphs-add-dialog") and contains(@class, "ui-dialog-content")]//*[contains(@name, "test_1")]')->click();
$this->assertSession()->assertWaitOnAjaxRequest();
Expand All @@ -209,7 +197,6 @@ public function testAddInBetweenFeature() {

// Check status after cardinality is exceeded.
$page->find('xpath', '(//*[contains(concat(" ", normalize-space(@class), " "), " paragraphs-features__add-in-between__button ")])[2]')->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();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ public function testAddInBetweenFeature() {
// Check that add in between option is available for modal add mode.
$page->selectFieldOption('fields[field_paragraphs][settings_edit_form][settings][add_mode]', 'modal');
$session->executeScript("jQuery('[name=\"fields[field_paragraphs][settings_edit_form][settings][add_mode]\"]').trigger('change');");
$this->assertSession()->assertWaitOnAjaxRequest();
$is_option_visible = $session->evaluateScript("Array.from(document.querySelectorAll('.paragraphs-features__add-in-between__option')).filter((item) => { return item.offsetParent }).length === 2");
$this->assertEquals(TRUE, $is_option_visible, 'After modal add mode is selected, "add in between" option should be available.');
$page->checkField('fields[field_paragraphs][settings_edit_form][third_party_settings][paragraphs_features][add_in_between]');
Expand Down Expand Up @@ -75,21 +74,18 @@ public function testAddInBetweenFeature() {

// Check first add in between button.
$page->find('xpath', '(//*[contains(@class, "paragraphs-features__add-in-between__button")])[1]')->click();
$this->assertSession()->assertWaitOnAjaxRequest();
$this->assertSession()->hiddenFieldValueEquals('field_paragraphs[add_more][add_more_delta]', '0');
$page->find('xpath', '//*[contains(@class, "paragraphs-add-dialog") and contains(@class, "ui-dialog-content")]//*[contains(@name, "test_1")]')->click();
$this->assertSession()->assertWaitOnAjaxRequest();

// Check last add in between button.
$this->scrollClick('xpath', '(//*[contains(@class, "paragraphs-features__add-in-between__button")])[last()]');
$this->assertSession()->assertWaitOnAjaxRequest();
$this->assertSession()->hiddenFieldValueEquals('field_paragraphs[add_more][add_more_delta]', '2');
$page->find('xpath', '//*[contains(@class, "paragraphs-add-dialog") and contains(@class, "ui-dialog-content")]//*[contains(@name, "test_1")]')->click();
$this->assertSession()->assertWaitOnAjaxRequest();

// Check add in between button between existing paragraphs.
$page->find('xpath', '(//*[contains(concat(" ", normalize-space(@class), " "), " paragraphs-features__add-in-between__button ")])[3]')->click();
$this->assertSession()->assertWaitOnAjaxRequest();
$this->assertSession()->hiddenFieldValueEquals('field_paragraphs[add_more][add_more_delta]', '2');
$page->find('xpath', '//*[contains(@class, "paragraphs-add-dialog") and contains(@class, "ui-dialog-content")]//*[contains(@name, "test_1")]')->click();
$this->assertSession()->assertWaitOnAjaxRequest();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,6 @@ public function testSplitTextFeature() {
// Check that split text option is available for modal add mode.
$page->selectFieldOption('fields[field_paragraphs][settings_edit_form][settings][add_mode]', 'modal');
$session->executeScript("jQuery('[name=\"fields[field_paragraphs][settings_edit_form][settings][add_mode]\"]').trigger('change');");
$this->assertSession()->assertWaitOnAjaxRequest();

$this->submitForm([], 'Update');
$this->assertSession()->assertWaitOnAjaxRequest();
Expand Down Expand Up @@ -385,12 +384,10 @@ public function testSplitTextFeature() {
// Set edit mode to closed.
$page->selectFieldOption('fields[field_paragraphs][settings_edit_form][settings][edit_mode]', 'closed');
$session->executeScript("jQuery('[name=\"fields[field_paragraphs][settings_edit_form][settings][edit_mode]\"]').trigger('change');");
$this->assertSession()->assertWaitOnAjaxRequest();

// Set auto-collapse mode.
$page->selectFieldOption('fields[field_paragraphs][settings_edit_form][settings][autocollapse]', 'all');
$session->executeScript("jQuery('[name=\"fields[field_paragraphs][settings_edit_form][settings][autocollapse]\"]').trigger('change');");
$this->assertSession()->assertWaitOnAjaxRequest();

$this->submitForm([], 'Update');
$this->assertSession()->assertWaitOnAjaxRequest();
Expand Down Expand Up @@ -439,12 +436,10 @@ public function testSplitTextFeature() {
// Disable auto-collapse.
$page->selectFieldOption('fields[field_paragraphs][settings_edit_form][settings][autocollapse]', 'none');
$session->executeScript("jQuery('[name=\"fields[field_paragraphs][settings_edit_form][settings][autocollapse]\"]').trigger('change');");
$this->assertSession()->assertWaitOnAjaxRequest();

// Set edit mode to open.
$page->selectFieldOption('fields[field_paragraphs][settings_edit_form][settings][edit_mode]', 'open');
$session->executeScript("jQuery('[name=\"fields[field_paragraphs][settings_edit_form][settings][edit_mode]\"]').trigger('change');");
$this->assertSession()->assertWaitOnAjaxRequest();

$this->submitForm([], 'Update');
$this->assertSession()->assertWaitOnAjaxRequest();
Expand Down Expand Up @@ -507,7 +502,6 @@ public function testSplitTwice() {
// Check that split text option is available for modal add mode.
$page->selectFieldOption('fields[field_paragraphs][settings_edit_form][settings][add_mode]', 'modal');
$session->executeScript("jQuery('[name=\"fields[field_paragraphs][settings_edit_form][settings][add_mode]\"]').trigger('change');");
$this->assertSession()->assertWaitOnAjaxRequest();

$this->submitForm([], 'Update');
$this->assertSession()->assertWaitOnAjaxRequest();
Expand Down

0 comments on commit 13c1393

Please sign in to comment.