Problem/Motivation

In the current WebDriverTestBase test we somehow missed \Drupal\FunctionalJavascriptTests\JSWebAssert::assertWaitOnAjaxRequest(), which is ideal for being the next command after pressing a link/button that triggers AJAX-thingies. And there are a lot of those in our FunctionalJavascriptTests

Currently we are do a lot of waitForElement black magic, which seems to be slower and the elements we're waiting for are not always correct.

Steps to reproduce

Use \Drupal\FunctionalJavascriptTests\JSWebAssert::assertWaitOnAjaxRequest() instead of waitForElement-voodoo.

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

Spokje created an issue. See original summary.

spokje’s picture

Title: Speed up WebDriverTestBase tests » Speed up FunctionalJavascriptTests tests
Issue summary: View changes

spokje’s picture

Status: Active » Needs review

Last test of Dev branch:

00:04:45.221 Tests to be run:
00:04:45.221   - Drupal\Tests\inline_entity_form\FunctionalJavascript\TranslationTest
00:04:45.221   - Drupal\Tests\inline_entity_form\FunctionalJavascript\SimpleWidgetTest
00:04:45.221   - Drupal\Tests\inline_entity_form\FunctionalJavascript\ElementWebTest
00:04:45.221   - Drupal\Tests\inline_entity_form\FunctionalJavascript\ComplexWidgetTest
00:04:45.221   - Drupal\Tests\inline_entity_form\FunctionalJavascript\ComplexWidgetRevisionsTest
00:04:45.221   - Drupal\Tests\inline_entity_form\FunctionalJavascript\ComplexSimpleWidgetTest
00:04:45.221 
00:04:45.221 Test run started:
00:04:45.221   Thursday, April 15, 2021 - 16:19
00:04:45.221 
00:04:45.221 Test summary
00:04:45.221 ------------
00:04:45.221 
00:05:03.030 Drupal\Tests\inline_entity_form\FunctionalJavascript\Transla   1 passes                                      
00:05:03.030 Drupal\Tests\inline_entity_form\FunctionalJavascript\SimpleW   4 passes                                      
00:05:49.440 Drupal\Tests\inline_entity_form\FunctionalJavascript\Element   1 passes                                      
00:06:02.229 Drupal\Tests\inline_entity_form\FunctionalJavascript\Complex  14 passes                                      
00:09:25.146 Drupal\Tests\inline_entity_form\FunctionalJavascript\Complex   4 passes                                      
00:12:39.436 Drupal\Tests\inline_entity_form\FunctionalJavascript\Complex   1 passes                                      
00:12:55.878 
00:12:56.105 Test run duration: 8 min 10 sec

This MR:

00:04:10.786 Tests to be run:
00:04:10.786   - Drupal\Tests\inline_entity_form\FunctionalJavascript\TranslationTest
00:04:10.786   - Drupal\Tests\inline_entity_form\FunctionalJavascript\SimpleWidgetTest
00:04:10.786   - Drupal\Tests\inline_entity_form\FunctionalJavascript\ElementWebTest
00:04:10.786   - Drupal\Tests\inline_entity_form\FunctionalJavascript\ComplexWidgetTest
00:04:10.786   - Drupal\Tests\inline_entity_form\FunctionalJavascript\ComplexWidgetRevisionsTest
00:04:10.786   - Drupal\Tests\inline_entity_form\FunctionalJavascript\ComplexSimpleWidgetTest
00:04:10.786 
00:04:10.786 Test run started:
00:04:10.786   Saturday, April 17, 2021 - 20:13
00:04:10.786 
00:04:10.786 Test summary
00:04:10.786 ------------
00:04:10.786 
00:04:29.686 Drupal\Tests\inline_entity_form\FunctionalJavascript\Transla   1 passes                                      
00:04:29.686 Drupal\Tests\inline_entity_form\FunctionalJavascript\SimpleW   4 passes                                      
00:05:17.781 Drupal\Tests\inline_entity_form\FunctionalJavascript\Element   1 passes                                      

00:05:31.068 Drupal\Tests\inline_entity_form\FunctionalJavascript\Complex  14 passes                                      

00:09:02.682 Drupal\Tests\inline_entity_form\FunctionalJavascript\Complex   4 passes                                      

00:10:22.713 Drupal\Tests\inline_entity_form\FunctionalJavascript\Complex   1 passes                                      
00:10:40.290 
00:10:40.427 Test run duration: 6 min 29 sec
geek-merlin’s picture

First i thought that's genius. Then i googled that method, and it looks like the approach is doomed:
#3061852: [META] Deprecate assertWaitOnAjaxRequest() and make the JsWebAssert::waitFor*() methods behave like real assertions

spokje’s picture

Status: Needs review » Needs work

Meh!

I'll need to look into the new proposed waitFor*() methods to see if they're as fast as the (sadly deemed) unreliable assertWaitOnAjaxRequest method.

Back to NW.