Verified Commit a87055c1 authored by Alex Pott's avatar Alex Pott
Browse files

Issue #3272797 by bnjmnm, phenaproxima, xjm: [random test failure] Restore...

Issue #3272797 by bnjmnm, phenaproxima, xjm: [random test failure] Restore LayoutBuilderTest::testConfigurableLayoutSections()

(cherry picked from commit ce4e8fa3)
parent 994805a9
Loading
Loading
Loading
Loading
+11 −4
Original line number Diff line number Diff line
@@ -7,6 +7,7 @@
use Drupal\Core\Url;
use Drupal\FunctionalJavascriptTests\WebDriverTestBase;
use Drupal\Tests\contextual\FunctionalJavascript\ContextualLinkClickTrait;
use Drupal\Tests\system\Traits\OffCanvasTestTrait;

/**
 * Tests the Layout Builder UI.
@@ -17,6 +18,7 @@ class LayoutBuilderTest extends WebDriverTestBase {

  use ContextualLinkClickTrait;
  use LayoutBuilderSortTrait;
  use OffCanvasTestTrait;

  /**
   * {@inheritdoc}
@@ -27,6 +29,7 @@ class LayoutBuilderTest extends WebDriverTestBase {
    'layout_builder',
    'layout_test',
    'node',
    'off_canvas_test',
  ];

  /**
@@ -285,17 +288,19 @@ public function testConfigurableLayoutSections() {
    $assert_session->linkExists('Add section');
    $this->clickLink('Add section');
    $assert_session->assertWaitOnAjaxRequest();
    $assert_session->elementExists('css', '#drupal-off-canvas');
    $this->waitForOffCanvasArea();

    $assert_session->linkExists('One column');
    $this->clickLink('One column');
    $assert_session->assertWaitOnAjaxRequest();
    $this->waitForOffCanvasArea();

    // Add another section.
    $assert_session->linkExists('Add section');
    $this->clickLink('Add section');

    $this->waitForOffCanvasArea();
    $assert_session->waitForElementVisible('named', ['link', 'Layout plugin (with settings)']);
    $assert_session->elementExists('css', '#drupal-off-canvas');

    $assert_session->linkExists('Layout plugin (with settings)');
    $this->clickLink('Layout plugin (with settings)');
@@ -310,9 +315,10 @@ public function testConfigurableLayoutSections() {
    // Ensure validation error is displayed for ConfigureSectionForm.
    $assert_session->linkExists('Add section');
    $this->clickLink('Add section');
    $this->waitForOffCanvasArea();

    $assert_session->waitForElementVisible('named', ['link', 'Layout plugin (with settings)']);
    $this->clickLink('Layout plugin (with settings)');
    $this->markTestSkipped('Temporarily skipped due to random failures.');
    $this->assertOffCanvasFormAfterWait('layout_builder_configure_section');
    $page->fillField('layout_settings[setting_1]', 'Test Validation Error Message');
    $page->pressButton('Add section');
@@ -481,7 +487,8 @@ private function openAddBlockForm($block_title) {
   */
  private function assertOffCanvasFormAfterWait(string $expected_form_id): void {
    $this->assertSession()->assertWaitOnAjaxRequest();
    $off_canvas = $this->assertSession()->waitForElementVisible('css', '#drupal-off-canvas');
    $this->waitForOffCanvasArea();
    $off_canvas = $this->assertSession()->elementExists('css', '#drupal-off-canvas');
    $this->assertNotNull($off_canvas);
    $form_id_element = $off_canvas->find('hidden_field_selector', ['hidden_field', 'form_id']);
    // Ensure the form ID has the correct value and that the form is visible.
+5 −0
Original line number Diff line number Diff line
@@ -18,6 +18,11 @@ protected function waitForOffCanvasArea(): void {
    // The data-resize-done attribute is added by the off_canvas_test module's
    // wrapper around Drupal.offCanvas.resetSize.
    $this->assertNotEmpty($this->assertSession()->waitForElementVisible('css', '[data-resize-done="true"]'));

    // Remove the data-resize-done attribute so in scenarios where off-canvas
    // opens yet another off-canvas, waitForOffCanvasArea() is looking for the
    // attribute on a new dialog, not an existing one.
    $this->getSession()->executeScript('document.querySelector("[data-resize-done]").removeAttribute("data-resize-done")');
  }

}