The javascript tests fail when run on Drupal 10 with the following:

 Drupal\Tests\scheduler\FunctionalJavascript\SchedulerJavascriptDefaultTimeTest::testTimeWhenSchedulingIsRequired with data set "#node-1" ('node', 'testpage', 'publish')

Behat\Mink\Exception\ResponseTextException: The pattern /Publish required, datepickerFormat \= m\/d\/Y has been (created|updated)/ was not found anywhere in the text of the current page.

/var/www/html/vendor/behat/mink/src/WebAssert.php:811
/var/www/html/vendor/behat/mink/src/WebAssert.php:294
/var/www/html/core/tests/Drupal/Tests/WebAssert.php:852
/var/www/html/modules/contrib/scheduler/tests/src/FunctionalJavascript/SchedulerJavascriptDefaultTimeTest.php:95
/var/www/html/vendor/phpunit/phpunit/src/Framework/TestResult.php:726

Could be related to PHPUnit version, or other testing dependencies that are different on D10 compared to D9.

Issue fork scheduler-3314158

Command icon 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

jonathan1055 created an issue. See original summary.

vishalkhode made their first commit to this issue’s fork.

vishalkhode’s picture

Status: Active » Needs review
jonathan1055’s picture

Thanks for working on this, looks good that the tests pass. I did not know where to start, so just created the issue ready to start investigating. Can you briefly explain why the change to use once has fixed the problem? Thanks.

vishalkhode’s picture

Hi jonathan1055
There was Javascript error in console i.e TypeError: $(...).once is not a function and it is caused due to .once function that is used here. In Drupal 10, jquery.once library has been removed (See here) and it has been replaced with core/once. In the libraries.yaml, I've included both i.e core/jquery.once & core/once, to make sure this works well with Drupal 8,9 & 10.

jonathan1055’s picture

Status: Needs review » Needs work

Thanks for the explanation. So this works in D10 now, and also D9, but it's not working for a Drupal 8 site. The whole (function ($, drupalSettings, once) is not activated at all. However, if I remove the 3rd parameter once then the function is active but fails when getting $default_time = once('default-time-done', '#edit-scheduler-settings', context). It needs the original way of doing it.

Is there a different way to use the 'once' processing so that it is compatible with D8 , D9 and D10? It feels like there should be a way to do this, given that the change record describes the BC layer.

Rajeshreeputra made their first commit to this issue’s fork.

jonathan1055’s picture

Thanks @Rajeshreeputra for the rebase.
I have some thoughts on how to fix this, just wanted to check that you and @vishalkhode are not in the middle of making chnages before I push an update?

vishalkhode’s picture

Hi jonathan1055
No, I'm not looking this at the moment. Please go ahead and push the update and let's see how it goes.

jonathan1055’s picture

Status: Needs work » Needs review

Simple idea, to keep the old default-time library file for use with Core before 9.2. I have checked this locally and it works for D8.9.

vishalkhode’s picture

Hi jonathan1055
I think there are two more places where this needs to be updated. i.e Line #267 and Line #272.

jonathan1055’s picture

Yes you are right, I'll do that. I don't have automated testing running on D8 locally and the Travis builds do not run the javascript tests. Otherwise that fault would have been found. I would like to get the Travis build to run javascript testing, now that we cannot test D8 on drupal.org.

vishalkhode’s picture

Status: Needs review » Reviewed & tested by the community

Reviewed changes and looks good to me.

  • jonathan1055 committed c84e855 on 2.x
    Issue #3314158 by jonathan1055, vishalkhode: Update javascript default...
jonathan1055’s picture

Title: JavascriptDefaultTimeTest fails on Drupal 10 » Update javascript default time to use core/once for D10
Status: Reviewed & tested by the community » Fixed

Thanks @vishalkhode for your work on this.
Fixed.

Status: Fixed » Closed (fixed)

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