SettingsTrayBlockFormTest::testBlocks() fails locally 100% of the time and lots of times on Gitlab CI

Created on 18 November 2023, 7 months ago
Updated 27 November 2023, 7 months ago

Problem/Motivation

\Drupal\Tests\settings_tray\FunctionalJavascript\SettingsTrayBlockFormTest::testBlocks() is failing because the \Drupal\Tests\settings_tray\FunctionalJavascript\SettingsTrayTestBase::openBlockForm() is failing to open the form. If you put a sleep in here...

  protected function openBlockForm($block_selector, $contextual_link_container = '') {
    if (!$contextual_link_container) {
      $contextual_link_container = $block_selector;
    }
    // Ensure that contextual link element is present because this is required
    // to open the off-canvas dialog in edit mode.
    $contextual_link = $this->assertSession()->waitForElement('css', "$contextual_link_container .contextual-links a");
    $this->assertNotEmpty($contextual_link);
    // When page first loads Edit Mode is not triggered until first contextual
    // link is added.
    $this->assertNotEmpty($this->assertSession()->waitForElementVisible('css', '.dialog-off-canvas-main-canvas.js-settings-tray-edit-mode'));
    
    // THIS SLEEP MAKES IT ALWAYS PASS...
    sleep(1);

    $block = $this->getSession()->getPage()->find('css', $block_selector);
    $block->mouseOver();
    $block->click();
    $this->waitForOffCanvasToOpen();
    $this->assertOffCanvasBlockFormIsValid();
  }

Prior to 📌 Stabilize FunctionalJavascript testing AJAX: add ::assertExpectedAjaxRequest() Fixed there was

    // Ensure that all other Ajax activity is completed.
    $this->assertSession()->assertWaitOnAjaxRequest();

Where the SLEEP above is...

It'll always pass... also if you change \Drupal\Tests\settings_tray\FunctionalJavascript\SettingsTrayTestBase::getTestThemes() to return only stark it'll pass... and if you get it to return ['stark, 'stable9'] it'll fail on stable9 and not stark. All very odd.

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

🐛 Bug report
Status

Fixed

Version

10.2

Component
Base 

Last updated 1 minute ago

Created by

🇬🇧United Kingdom alexpott 🇪🇺🌍

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.69.0 2024