Problem/Motivation

drupalPostAjaxForm() is simulating the behaviour of ajax.js, so using it, doesn't really provide fundamental guarantees.
#2809161: Convert Javascript/AJAX testing to use JavascriptTestBase suggests to convert them to JavascriptTestBase

Proposed resolution

  1. Figure out which part of the test is testing PHP code and which part ajax behaviour
  2. Extract the ajax behaviour into a test that extends JavascriptTestBase

Remaining tasks

User interface changes

API changes

Data model changes

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

dawehner created an issue. See original summary.

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

Drupal 8.3.0-alpha1 will be released the week of January 30, 2017, which means new developments and disruptive changes should now 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.

michielnugter’s picture

Component: phpunit » image.module
Issue tags: +phpunit initiative

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

Drupal 8.4.0-alpha1 will be released the week of July 31, 2017, which means new developments and disruptive changes should now 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.

ApacheEx’s picture

Status: Active » Needs review
FileSize
4.59 KB

Here is a patch. Only testAjaxEnabledEffectForm has ajax part.

Status: Needs review » Needs work

The last submitted patch, 5: 2809507-5.patch, failed testing. View results

dawehner’s picture

Thank you for starting this patch!

+++ b/core/modules/image/tests/src/FunctionalJavascript/ImageAdminStylesTest.php
@@ -0,0 +1,78 @@
+      $page->pressButton(t('Ajax refresh'));
+      $assert_session->assertWaitOnAjaxRequest();
+      $this->drupalPostForm(NULL, $effect_edit, t('Update effect'));

Note: We try to avoid assertWaitOnAjaxRefresh and rather use one of the other methods on \Drupal\FunctionalJavascriptTests\JSWebAssert

ApacheEx’s picture

Status: Needs work » Needs review
FileSize
4.79 KB
1.45 KB

thanks for your feedback. Here is updated patch.

I've also found out why it randomly fails (even on my local).
A style label which generates like this:

$style_label = $this->randomString();

can contain HTML special characters like &, ", ', <, >.
For example, "uMg>&pj will be converted to &quot;uMg&gt;&amp;pj by Html::escape, but browser will convert this html to "uMg&gt;&amp;pj.
Markup::create(Xss::filter($style_label)) seems to fix it.

ApacheEx’s picture

hm, if this patch is passed then whole ImageAdminStylesTest can be converted to BrowserTestBase.
Let's wait for the result and decide next steps.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.0-alpha1 will be released the week of January 17, 2018, which means new developments and disruptive changes should now be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Anonymous’s picture

Added related issue with JTB version.

mondrake’s picture

Status: Needs review » Closed (duplicate)