Problem/Motivation
Some tests are sometimes a bit flaky, let's try to improve that.
Issue fork pathauto-3573353
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
mably commentedProblem
PathautoLocaleTest::testLanguagePatternswas intermittently failing on CI with:The first pattern creation had
sleep(1)after the AJAX request for the type selector, but the second pattern creation had no wait at all. On slow CI environments, the AJAX-loaded form fields were not ready whensubmitForm()tried to interact with them.Additionally, both FunctionalJavascript test classes were missing the
#[RunTestsInSeparateProcesses]attribute required since Drupal 11.3.Changes
sleep(1)withwaitForField('pattern')as a targeted wait after the AJAX request completes.addPathautoPattern()helper method to ensure both pattern creations use the same consistent wait behavior.waitForElementVisible()inenableArticleTranslation()after checking theentity_types[node]checkbox.#[RunTestsInSeparateProcesses]and#[Group]attributes toPathautoLocaleTestandPathautoUiTestas required by Drupal 11.3+.waitForField('pattern')toPathautoUiTestafter AJAX.voidreturn types to test methods.Comment #4
mably commentedComment #5
berdirUsing the waitFor methods certainly makes sense, the sleep tends to be very old stuff from before those existed.
Comment #7
mably commentedComment #10
mably commentedContinuation of flaky FunctionalJavascript test fixes.
Use selectFieldOption() for the pattern type select
The pattern type
<select>triggers an AJAX request on change.fillField()doesn't properly trigger the change event on select elements, leading to unreliable AJAX behavior. Replaced withselectFieldOption()followed byassertExpectedAjaxRequest(1)in both test classes (see change record). This also allowed removing the unnecessarywaitForField()calls and the workarounds in PathautoLocaleTest (waitForElementVisible()for machine name, separatefillField('label')).Replace pageTextContains with waitForText after form submissions
pageTextContains()does not wait for the page to load after asubmitForm()— it checks immediately, which causes flaky failures when the browser hasn't finished navigating. Replaced withassertTrue(waitForText(...))where the text check is the primary assertion, or barewaitForText()where it only serves as a synchronization point before subsequent assertions.Other fixes
waitForText()after node creation and content language settingssubmitForm()to ensure the page has finished loading before proceeding.waitForText('Page pattern')after the weight save form to wait for page reload before interacting with the dropbutton.'type'key from$editarray in PathautoUiTest — the type select is already set viaselectFieldOption()beforesubmitForm(), including it in$editwould re-trigger the AJAX.ConfigurableLanguage::createFromLangcode('fr')instead of the UI language add form for more reliable test setup.addPathautoPattern()to avoid checking stale page text after navigation.