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

- Either fix the test module or find another solution. The current testmodule cannot be enabled because of JavaScript errors as it's not a valid plugin:
-- Error: [CKEDITOR.resourceManager.load] Resource name "llama_button" was not found at "/core/modules/ckeditor/tests/modules/js/llama_button.js?t=G8JJ".
-- Error: [CKEDITOR.resourceManager.load] Resource name "llama_button" was not found at "/core/modules/ckeditor/tests/modules/js/llama_button.js?t=G8JJ"
- Figure out a way to fix the dialog JavaScript error
-- Reproduceable in the UI by the following steps:
--- Open add group dialog
--- Lose focus on the input field
--- While scrolling click the cancel button and keep scrolling
-- Cause: the event is debounced and the debounced event is triggered after the dialog is closed.

- Maybe find out why the Styles input can't handle a newline?
-- Manually comparing the results (fileMerge) states the strings are identical, the assertion disagrees. It must be an invisible character difference.

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.

michielnugter’s picture

I made an attempt at converting this test. There are several problems still though.

- There are JavaScript problems after adding a group, I have actually reproduced these but can't exactly figure out how. If I know how I should either upgrade this issue to a bug or open a new issue?
- Divider dragging doesn't work yet.
- Enabling the ckeditor_test module causes all kinds of problems somehow.
- Test still failes.

Posting my work in progress, curious if anyone has suggestions on fixing it.

claudiu.cristea’s picture

Status: Active » Needs review

Status: Needs review » Needs work

The last submitted patch, 2: 2809463-CKEditorAdminTest-testExistingFormat.patch, failed testing.

michielnugter’s picture

Status: Needs work » Active

I figured out some more on the JavaScript error.

The error is: Error: cannot call methods on dialog prior to initialization; attempted to call method 'option'

It's triggerd in dialog-position.js on line 62, a handler for a window resize event for the dialog. In the test (and on very rare occasions) it's triggered when the event handler is still triggered while the dialog is not there anymore.

I fine-tuned the patch a little and with the module testing disabled and the lines in dialog-position.js disabled the test now passes.

I also used a simplyfied Styles input as there are problems with the endline in the test.

Todo:
- Figure out why the module cannot be enabled while it could in the old test
-- I think it has something to do with the fact that JavaScript is actually executed and now causes problems, making the ckeditor_test module unusable in it's current state.
- Figure out a way to fix the dialog JavaScript error
- Maybe find out why the Styles input can't handle a newline?
-- Manually comparing the results (fileMerge) states the strings are identical, the assertion disagrees. It must be an invisible character difference.

claudiu.cristea’s picture

  1. +++ b/core/modules/ckeditor/src/Tests/CKEditorAdminTest.php
    @@ -73,47 +73,17 @@ function testExistingFormat() {
         );
    +
         $this->drupalPostForm(NULL, $edit, t('Save configuration'));
    ...
    +    return;
    +
    
    @@ -157,38 +127,6 @@ function testExistingFormat() {
    diff --git a/core/modules/ckeditor/tests/modules/css/llama.css b/core/modules/ckeditor/tests/modules/css/llama.css
    
    diff --git a/core/modules/ckeditor/tests/modules/css/llama.css b/core/modules/ckeditor/tests/modules/css/llama.css
    new file mode 100644
    
    new file mode 100644
    index 0000000..e69de29
    
    index 0000000..e69de29
    diff --git a/core/modules/ckeditor/tests/modules/js/llama.js b/core/modules/ckeditor/tests/modules/js/llama.js
    
    diff --git a/core/modules/ckeditor/tests/modules/js/llama.js b/core/modules/ckeditor/tests/modules/js/llama.js
    new file mode 100644
    
    new file mode 100644
    index 0000000..e69de29
    
    index 0000000..e69de29
    diff --git a/core/modules/ckeditor/tests/modules/js/llama_button.js b/core/modules/ckeditor/tests/modules/js/llama_button.js
    
    diff --git a/core/modules/ckeditor/tests/modules/js/llama_button.js b/core/modules/ckeditor/tests/modules/js/llama_button.js
    new file mode 100644
    
    new file mode 100644
    index 0000000..e69de29
    
    index 0000000..e69de29
    diff --git a/core/modules/ckeditor/tests/modules/js/llama_contextual.js b/core/modules/ckeditor/tests/modules/js/llama_contextual.js
    
    diff --git a/core/modules/ckeditor/tests/modules/js/llama_contextual.js b/core/modules/ckeditor/tests/modules/js/llama_contextual.js
    new file mode 100644
    
    new file mode 100644
    index 0000000..e69de29
    
    index 0000000..e69de29
    diff --git a/core/modules/ckeditor/tests/modules/js/llama_contextual_and_button.js b/core/modules/ckeditor/tests/modules/js/llama_contextual_and_button.js
    
    diff --git a/core/modules/ckeditor/tests/modules/js/llama_contextual_and_button.js b/core/modules/ckeditor/tests/modules/js/llama_contextual_and_button.js
    new file mode 100644
    
    new file mode 100644
    index 0000000..e69de29
    
    index 0000000..e69de29
    diff --git a/core/modules/ckeditor/tests/modules/js/llama_css.js b/core/modules/ckeditor/tests/modules/js/llama_css.js
    
    diff --git a/core/modules/ckeditor/tests/modules/js/llama_css.js b/core/modules/ckeditor/tests/modules/js/llama_css.js
    new file mode 100644
    
    new file mode 100644
    index 0000000..e69de29
    

    Unrelated changes. Should be reverted.

  2. +++ b/core/modules/ckeditor/tests/src/FunctionalJavascript/CKEditorAdminTest.php
    @@ -0,0 +1,221 @@
    +  /**
    +   * Modules to enable.
    +   *
    +   * @var array
    +   */
    

    {@inheritdoc}

  3. +++ b/core/modules/ckeditor/tests/src/FunctionalJavascript/CKEditorAdminTest.php
    @@ -0,0 +1,221 @@
    +  public static $modules = array('filter', 'editor', 'ckeditor');
    

    I think is protected in 8.3.x and let's use the square brackets syntax for arrays.

michielnugter’s picture

Very sorry about this, I forgot to upload my files and you reviewed a slightly older patch. I already removed the extra js files.

I fixed the other 2 issues with comments and code formatting.

My earlier todolist is still valid though..

michielnugter’s picture

Issue summary: View changes

I updated the summery with the remaining tasks. I also found out more about why the module doesn't work and did work, there are JavaScript errors because the llama plugin is not defined correctly.

michielnugter’s picture

Status: Active » Needs review
michielnugter’s picture

Issue summary: View changes

Added reproducable steps and cause for the JavaScript error in the dialog. Really seems that it's actually a bug, it's harmless in the actual UI but it will make the test fail.

Status: Needs review » Needs work

The last submitted patch, 7: 2809463-CKEditorAdminTest-testExistingFormat-7.patch, failed testing.

dawehner’s picture

Added reproducable steps and cause for the JavaScript error in the dialog. Really seems that it's actually a bug, it's harmless in the actual UI but it will make the test fail.

It's so great when conversions happen and they uncover other bugs.
@michielnugter
Did you tried to enable the module manually on your installation and check whether things are broken? I guess in that case, its indeed a super valid bug. Don't feel stuck on this particular issue. As you've probably seen, there are many other conversions which might have less resistance to fight against :)

  1. +++ b/core/modules/ckeditor/tests/src/FunctionalJavascript/CKEditorAdminTest.php
    @@ -0,0 +1,226 @@
    +    // Drag buttons into the new group.
    +    $undo_button->dragTo($new_group);
    +    $divider_button->dragTo($new_group);
    +    $redo_button->dragTo($new_group);
    +    $justify_button->dragTo($new_group);
    

    That is so nice!

  2. +++ b/core/modules/ckeditor/tests/src/FunctionalJavascript/CKEditorAdminTest.php
    @@ -0,0 +1,226 @@
    +    $this->createScreenshot('/Library/Webserver/Documents/_testscreenshots/dragresultfinish.jpg');
    

    This might confuse the testbot :)

The last submitted patch, 7: 2809463-CKEditorAdminTest-testExistingFormat-7.patch, failed testing.

michielnugter’s picture

I moved the test for enabling the module back to the original test as it wasn't actually testing anything javascripty.

I updated the Functional test to fix some minor problems, I think it's good for a proper review now.

While searching the issues I found an existing issue for the dialog problem: #2731419: "cannot call methods on dialog prior to initialization" logged when resizing after closing a modal. This issue will need to be committed before this test will pass.

edit: waiting for needs review untill the related issue is fixed.

michielnugter’s picture

Small update to use the new wait...() methods. Let's see if it passes now that mentioned issue is fixed.

Status: Needs review » Needs work

The last submitted patch, 15: 2809463-CKEditorAdminTest-testExistingFormat-15.patch, failed testing.

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 » ckeditor.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.

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.

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

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

Lendude’s picture

Status: Needs work » Closed (outdated)