Problem/Motivation

working on #2948828: Layout Builder's Field Blocks do not work with Quick Edit I tried to extend QuickEditIntegrationTest to test Layout Builder with QuickEdit

This works if you only want to test a node 1 time but as soon as you go back to the same node as the same user in the same session the test fail randomly.

Proposed resolution

Can we fix the tests so they are more robust?

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

Comments

tedbow created an issue. See original summary.

tedbow’s picture

Status: Active » Needs review
StatusFileSize
new6.65 KB

I have altered \Drupal\Tests\quickedit\FunctionalJavascript\QuickEditIntegrationTest::testArticleNode() to invoke the same test 2x.

Then it runs only this test 50x

Status: Needs review » Needs work

The last submitted patch, 2: 3037436-test_node_50x.patch, failed testing. View results

tedbow’s picture

#2 mostly failed but passed randomly.

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

wim leers’s picture

Issue tags: +JavaScript

Thanks for doing this! 🙏

mostly failed but passed randomly.

😨

tim.plunkett’s picture

Category: Task » Bug report
Priority: Normal » Critical
Issue tags: +Random test failure

Out of 100 runs, this failed 54 times.

wim leers’s picture

Status: Needs work » Needs review
StatusFileSize
new3.15 KB
new9.03 KB

Status: Needs review » Needs work

The last submitted patch, 8: 3037436-8-test_node_50x.patch, failed testing. View results

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

catch’s picture

Title: Make QuickEditIntegrationTest more robust and fail proof » [random test failure] Make QuickEditIntegrationTest more robust and fail proof
Issue tags: -JavaScript +JavaScript
catch’s picture

Status: Needs work » Closed (duplicate)

This is probably fixed by #3082602: Remove transform rule from css_disable_transitions_test. Going to mark as duplicate. Worst case we can re-open it.

catch’s picture

Status: Closed (duplicate) » Needs work

CSS transitions aren't disabled in 8.x, so while that issue might reduce the frequency, it probably doesn't actually fix this.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

jhodgdon’s picture

I have seen several fails in this test in the past few days. Example:
https://www.drupal.org/pift-ci-job/1777967

This is definitely still a problem.

larowlan’s picture

Just got this in head, going to retest

jhodgdon’s picture

I'm getting this one and two others in issues I follow fairly frequently. I think about once a week in total, and it's often QuickEditIntegrationTest... Could we maybe remove the 3 most common culprits (look through the many RTBC issues that have been hanging out for months in the RTBC queue, and see what they've failed on) and not put these repeat offenders back into Core until they will reliably work?

See also #3165263: Allow known flaky tests to be automatically repeated

catch’s picture

catch’s picture

Status: Needs work » Closed (duplicate)

Going to go ahead and mark this as duplicate, since that issue is the first concrete fix for this for a long time. If it does recur, we can re-open.

longwave’s picture

Status: Closed (duplicate) » Needs work

Unfortunately that didn't solve it, this just failed again in https://www.drupal.org/pift-ci-job/1848467

catch’s picture

Title: [random test failure] Make QuickEditIntegrationTest more robust and fail proof » [random test failure] Mark QuickEditIntegrationTest as skipped until we fix it
Status: Needs work » Needs review
StatusFileSize
new770 bytes

That is a shame, I think we should do this.

alexpott’s picture

StatusFileSize
new6.78 KB
    // Wait for CKEditor to load, then verify it has.
    $this->assertJsCondition('CKEDITOR.status === "loaded"');

Only waits for Ckeditor to be ready in the background it doesn't wait for the instances or loaded event to fire - see https://github.com/ckeditor/ckeditor4/blob/d1710c198d8f5007e8d04fed9870b...

I think we can fix this by waiting for the what we expect rather than for ckeditor's internal state.

Status: Needs review » Needs work

The last submitted patch, 22: 3037436-22.patch, failed testing. View results

alexpott’s picture

Status: Needs work » Needs review
StatusFileSize
new839 bytes
new7.6 KB

Been meaning to fix this the unhelpful reporting from WebDriverCurlService for a while.

Status: Needs review » Needs work

The last submitted patch, 24: 3037436-24.patch, failed testing. View results

alexpott’s picture

Status: Needs work » Needs review
StatusFileSize
new494 bytes
new7.63 KB

For a while I've been wondering if concurrency might be causing an issue in JS tests.

alexpott’s picture

StatusFileSize
new7.63 KB
new493 bytes

And with a concurrency of 5

alexpott’s picture

StatusFileSize
new494 bytes
new7.63 KB

Add now 10

Status: Needs review » Needs work

The last submitted patch, 28: 3037436-28.patch, failed testing. View results

alexpott’s picture

Status: Needs work » Needs review
StatusFileSize
new1.2 KB
new8.82 KB

Let's see if going incognito helps...

Status: Needs review » Needs work

The last submitted patch, 30: 3037436-30.patch, failed testing. View results

alexpott’s picture

Status: Needs work » Needs review
StatusFileSize
new1.49 KB
new8.61 KB

Status: Needs review » Needs work

The last submitted patch, 32: 3037436-32.patch, failed testing. View results

alexpott’s picture

Status: Needs work » Needs review
StatusFileSize
new1.78 KB
new9.49 KB

Well as useful as the test passing all the time is the test failing all the time! So the check for

    $this->assertEntityInstanceFieldMarkup('node', 1, 0, [
      'node/1/title/en/full'      => '.quickedit-changed',
      'node/1/field_tags/en/full' => '.quickedit-changed',
    ]);

is bogus. Once "save" is pressed in quickedit this class is eventually removed. It passes now on HEAD because this happens after the AJAX response so most of the time these elements do indeed exist. I have no idea why concurrency makes it more likely to happen - maybe things just go quicker when everything is running the same code.

fingers-crossed this one will pass...

alexpott’s picture

StatusFileSize
new3.56 KB
new5.93 KB

Let's run all the tests...

alexpott’s picture

StatusFileSize
new1.95 KB
new7.14 KB

Consistency... hold_test_request() is never actually called so it doesn't matter but it is best to be consistent. Let's enforce the consistency and the relationship to the time waiting in HoldTestSubscriber

alexpott’s picture

Title: [random test failure] Mark QuickEditIntegrationTest as skipped until we fix it » [random test failure] Make QuickEditIntegrationTest more robust and fail proof

Seeming as the latest approach fixes the test

The last submitted patch, 35: 3037436-35.patch, failed testing. View results

Status: Needs review » Needs work

The last submitted patch, 36: 3037436-36.patch, failed testing. View results

alexpott’s picture

Status: Needs work » Needs review
StatusFileSize
new2.09 KB
new12.27 KB
new8.49 KB

Oh fun. In #35 QuickEditImageTest - it's pressing save and expecting things to test able and not change. We need to use hold_test so we can test what is it testing. Also in reviewing this I realised we can re-instate the checks I removed ....

+++ b/core/modules/quickedit/tests/src/FunctionalJavascript/QuickEditIntegrationTest.php
@@ -273,16 +271,18 @@ public function testArticleNode() {
-    $this->assertEntityInstanceFieldMarkup('node', 1, 0, [
-      'node/1/title/en/full'      => '.quickedit-changed',
-      'node/1/field_tags/en/full' => '.quickedit-changed',
-    ]);

but move them before the hold_test_response() is released.

alexpott’s picture

+++ b/core/modules/quickedit/tests/src/FunctionalJavascript/QuickEditJavascriptTestBase.php
@@ -255,25 +255,9 @@ function () {
   protected function assertEntityInstanceFieldMarkup($entity_type_id, $entity_id, $entity_instance_id, array $expected_field_attributes) {
-    $entity_page_id = $entity_type_id . '/' . $entity_id . '[' . $entity_instance_id . ']';
-    $expected_field_attributes_json = json_encode($expected_field_attributes);
-    $js_match_field_element_attributes = <<<JS
-function () {
-  var expectations = $expected_field_attributes_json;
-  var entityCollection = Drupal.quickedit.collections.entities;
-  var entityModel = entityCollection.get('$entity_page_id');
-  return entityModel.get('fields').reduce(function (result, fieldModel) {
-    var fieldID = fieldModel.get('fieldID');
-    var element = fieldModel.get('el');
-    var matches = element.webkitMatchesSelector(expectations[fieldID]);
-    result[fieldID] = matches ? matches : element.outerHTML;
-    return result;
-  }, {});
-}()
-JS;
-    $result = $this->getSession()->evaluateScript($js_match_field_element_attributes);
     foreach ($expected_field_attributes as $quickedit_field_id => $expectation) {

So I think we one remaining question here is should we remove the now unused arguments. The only thing that is used now the $expected_field_attributes. Maybe we should tidy that up in a follow-up.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

alexpott’s picture

StatusFileSize
new6.63 KB
new12.25 KB

Let's trigger a deprecation. Imo this is not worth a CR but if there are any custom tests using this then at least you can ignore deprecations to make them pass... or make the change. There's no contrib using this.

longwave’s picture

Status: Needs review » Needs work
+++ b/core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderQuickEditTest.php
@@ -202,8 +202,12 @@ protected function assertEntityInstanceFieldStates($entity_type_id, $entity_id,
-  protected function assertEntityInstanceFieldMarkup($entity_type_id, $entity_id, $entity_instance_id, array $expected_field_attributes) {
...
+  protected function assertEntityInstanceFieldMarkup(array $expected_field_attributes) {
+    if (func_num_args() === 4) {
+      $expected_field_attributes = func_get_arg(3);
+      @trigger_error('Calling ' . __METHOD__ . ' with 4 arguments is deprecated in drupal:9.1.x and will throw an error in drupal:10.0.0.', E_USER_DEPRECATED);
+    }

I don't think the deprecation will ever trigger, as $entity_type_id is never going to be an array and so it will fail the type check first.

alexpott’s picture

Status: Needs work » Needs review
StatusFileSize
new2.6 KB
new12.53 KB
longwave’s picture

Status: Needs review » Reviewed & tested by the community

This certainly looks like it should be more reliable, asserting in Mink instead of in-browser JS and not relying on CKEditor internal state definitely feels much cleaner.

jonathan1055’s picture

Status: Reviewed & tested by the community » Needs review
StatusFileSize
new12.64 KB
new2.3 KB

Now that #3048495: Fix Drupal.Semantics.FunctionTriggerError coding standard is RTBC here's an updated patch to make the two new deprecation messages follow standards. Fixing them here has two benefits (a) the people involved here get to check the message in context, and (b) if this issue is committed first it avoids me re-rolling on the main issue.

I've set this back to NR for #47 but of course, if you don't want to fix the message, just put it to RTBC for patch #45

longwave’s picture

Didn't spot here that the deprecated method name should end in () - if you want to make that change and upload it feel free to mark it RTBC.

jonathan1055’s picture

Status: Needs review » Reviewed & tested by the community
StatusFileSize
new12.64 KB
new2.41 KB

OK, thanks for that. Here's the updated patch and interdiff.

  • catch committed 3d7dd76 on 9.2.x
    Issue #3037436 by alexpott, jonathan1055, Wim Leers, catch, tedbow,...

  • catch committed fdd88e0 on 9.1.x
    Issue #3037436 by alexpott, jonathan1055, Wim Leers, catch, tedbow,...

  • catch committed 4575b09 on 9.0.x
    Issue #3037436 by alexpott, jonathan1055, Wim Leers, catch, tedbow,...
catch’s picture

Version: 9.2.x-dev » 9.0.x-dev
Status: Reviewed & tested by the community » Fixed

Committed/pushed to 9.2.x and cherry-picked back to 9.0.x

Doesn't cherry-pick to 8.9.x - marking fixed but please re-open with a backport patch if someone does one.

Status: Fixed » Closed (fixed)

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