Crossword Functional JS tests failing

Created on 11 December 2022, about 2 years ago
Updated 3 March 2023, almost 2 years ago

Problem/Motivation

Check out https://www.drupal.org/pift-ci-job/2538144 β†’

Within the last few weeks a number of Functional JS fails started.

After much pain I figured out this regression was introduced by #3316816: Stabilize FunctionalJavascript testing AJAX: make ::setValue() trigger both "input" and "formUpdated" events β†’ .

Proposed resolution

TBD

Remaining tasks

User interface changes

API changes

Data model changes

πŸ› Bug report
Status

Fixed

Version

2.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States danflanagan8 St. Louis, US

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡ΊπŸ‡ΈUnited States danflanagan8 St. Louis, US

    Holy moly, I think I have it! The new code in ::setValue() is

            $this->executeJsOnXpath($xpath, <<<JS
    if (typeof Drupal !== 'undefined') {
      var node = {{ELEMENT}};
      var original = node.blur;
      node.blur = function() {
        node.dispatchEvent(new Event("input", {bubbles:true}));
        node.dispatchEvent(new Event("change", {bubbles:true}));
        // Do not wait for the debounce, which only triggers the 'formUpdated` event
        // up to once every 0.3 seconds. In tests, no humans are typing, hence there
        // is no need to debounce.
        // @see Drupal.behaviors.formUpdated
        node.dispatchEvent(new Event("formUpdated", {bubbles:true}));
        node.blur = original;
      };
    }
    JS);

    If I comment out node.dispatchEvent(new Event("input", {bubbles:true})); then the test pass. So I think the problem is that crossword.js doesn't expect the input to be triggered with no real input. The patch here guards against that possibility and passes locally. It also passes my basic manual tests, like using a backspace or a 0 on the keyboard.

  • Status changed to Fixed almost 2 years ago
  • πŸ‡ΊπŸ‡ΈUnited States danflanagan8 St. Louis, US

    It is such an incredible relief to have this fixed! This took hours and hours. It will be good to have green tests on the project page for the first time since October 2022! It was like 5 months of red.

  • πŸ‡¨πŸ‡¦Canada gnumatrix Vancouver, British Columbia

    Nicely done!

  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024