I found this during #2786459: "Offcanvas" tray should be using the existing dialog system

I will attach patch that proves that if you try to submit a form that is inside a Ajax dialog you will get a GastonJS error like this:

1) Drupal\Tests\system\FunctionalJavascript\SubmitFormTest::testFormSubmit
Zumba\GastonJS\Exception\BrowserError: There was an error inside the PhantomJS portion of GastonJS.
This is probably a bug, so please report it:
click

Inside \Drupal\Tests\system\FunctionalJavascript\DialogSubmitFormTest I have left a comment showing the various ways I have tried to submit form that also throw the same error. Here they are:

$dialog->pressButton('Submit');
$page->pressButton('Submit');
$dialog->find('css', '.js-form-submit')->press();
$dialog->find('css', '.js-form-submit')->click();
$this->submitForm(['msg' => 'the end of the other sentence.'], 'Submit');

The also proves the form can be submitted if it is not a dialog.

I have searched core I don't think anywhere else we are testing submitting a form in an ajax dialog.

If anyone knows a workaround to get this working for now that would be great to fix the test in #2786459: "Offcanvas" tray should be using the existing dialog system

Membership dollars fund testing for the Drupal project. Drupal Association Learn more

Comments

tedbow created an issue. See original summary.

dawehner’s picture

Thanks a ton for writing a test for that!

+++ b/core/modules/system/tests/modules/submit_form_test/src/Controller/LinksController.php
@@ -0,0 +1,37 @@
+   * Displays test links that will open in offcanvas tray.
...
+          'data-dialog-type' => 'modal',

Is there a reason for this mismatch? Modal vs. offcanvas

dawehner’s picture

@tedbow
Just curious, did you tried assertWaitOnAjaxRequest ?

Status: Needs review » Needs work

The last submitted patch, dialog_form_submit_test.patch, failed testing.

tedbow’s picture

Status: Needs work » Needs review
FileSize
5.42 KB
2.08 KB

@dawehner

Is there a reason for this mismatch? Modal vs. offcanvas

Copy and paste error. Fixed

Just curious, did you tried assertWaitOnAjaxRequest ?

I think had tried that. Thought it might be the problem but wasn't. Now using assertWaitOnAjaxRequest.

Status: Needs review » Needs work

The last submitted patch, 5: 2789381-5.patch, failed testing.

dawehner’s picture

Ah sorry, I haven't seen your waiting, too bad that wasn't the problem. I have a look into it now.

dawehner’s picture

FileSize
4.27 KB
3.94 KB
3.94 KB
3.94 KB

Here is what I found out so far. It seems to be that the dialog misses some focus, somehow. One thing which is also weird that normally $this->createScreenshot returns something helpful. In this particular case, it actually didn't. The screenshots are all 1024x99 px. Maybe this is some reason for the weird behaviour.

droplet’s picture

FileSize
33.12 KB

wrong z-index.

Saving your life: #2775653: [PP-2] JavascriptTests with webDriver

dawehner’s picture

Thank you @droplet!

Wim Leers’s picture

droplet’s picture

Status: Closed (duplicate) » Needs work

this isn't a duplication. Because of wrong z-index. You are clicking on DIV, not the actual buttons. It's a bug of Modal (JS) & base theme (missing styles)

We can't use JS to fake our testing engine.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.4.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.