Problem/Motivation
Today, the CKEditorIntegrationTest for the DrupalImage doesn't exists.
I would suggest a new method for DrupalImage into the CKEditorIntegrationTest which will check the basic behaviours of DrupalImage CKEditor Plugin.
To go further, another IntegrationTest should be created for DrupalImageCaption Plugin.
Proposed resolution
Add a new testDrupalImageDialog method.
Remaining tasks
Review
User interface changes
None
API changes
None
Data model changes
None
PS: It's my first contribution to the Core & I learn a lot about the JavascriptTestBase during this patch.
| Comment | File | Size | Author |
|---|---|---|---|
| #38 | 2912399-38_110x.patch | 1.77 KB | wengerk |
| #38 | interdiff-2912399-30-38.txt | 690 bytes | wengerk |
| #38 | 2912399-38.patch | 1.22 KB | wengerk |
| #35 | 2912399-16_110x.patch | 2.19 KB | tedbow |
| #35 | 2912399-30_110x.patch | 2.13 KB | tedbow |
Comments
Comment #2
wengerkComment #3
wengerkComment #4
wengerkComment #5
wim leersThanks, this is a super helpful contribution! ❤️
Rather than creating an entirely new test class with a single
testSomething()method, can you instead add a new test method to\Drupal\Tests\ckeditor\FunctionalJavascript\CKEditorIntegrationTest?That will also make this issue much easier to review :)
Comment #6
wengerkHi Wim Leers !
Thanks, I re-rolled the patch and move it into the
\Drupal\Tests\ckeditor\FunctionalJavascript\CKEditorIntegrationTest.On this patch, I had to create a
clickOnElementfunction to click on a<a>tag (the button into CKeditor Toolbar) which is not reachable with standards Mink functions.For futur JavascriptTests on CKeditor & others it would may be useful to have this function into
JavascriptTestBaseorBrowserTestBase?Comment #7
wim leersLet's let testbot test #6 :)
Comment #8
wim leersUnnecessary change, let's revert this.
Why can't this use
\Drupal\Tests\BrowserTestBase::click()? Isn't the problem that you're not waiting for CKEditor to have loaded? (See\Drupal\Tests\ckeditor\FunctionalJavascript\AjaxCssTest::waitOnCkeditorInstance().)Comment #9
wengerkI didn't know Drupal already added a
clickfunction in\Drupal\Tests\BrowserTestBase! Thanks.I change the code, remove the unnecessary change in #8 & remove the
clickOnElement.Comment #10
wengerkComment #11
wengerkUpdate Motivation & Proposed Resolution according discussion in #5
Comment #12
wim leersGreat! Look how wonderfully small the patch now became :) This is now ready, only the comments need to be refined a little bit more:
Tests if the Image button appears and works as expected.
Asserts the image dialog opens when clicking the Image button.
Once those are done, this is RTBC!
Comment #13
wengerkThanks for you review & your help @wim-leers !
Comment #14
wengerkTesting changes in #13 with testbot.
Comment #15
wim leersThanks! 👍
Comment #16
wengerkThe patch in #13 works but I use some features scheduled for removal in Drupal 9.0.0 e.g.
assertElementPresentfromDrupal\FunctionalTests\AssertLegacyTrait.I switch to the
Drupal\Tests\WebAssertmethods as recommended inDrupal\FunctionalTests\AssertLegacyTrait.Sorry for requesting a review again :/ but I think it's important, specially for new tests, to follow the bests practices.
Comment #17
wengerkchanges to follow bests practices - let's tests it with testbot.
Comment #19
wim leers👍
FYI: upload interdiffs as .txt files, then test bot doesn’t try to test them! That’s the convention we’ve been using here on d.o for years :)
Comment #20
alexpottJust triggering an 8.4.x run as this is adding test coverage and it'd be great if it is backportable.
These two calls could be replaced by
$web_assert->waitForElement('css', '.ui-dialog');but that's not necessary for the patch to be committed.Comment #21
alexpottCrediting @Wim Leers for the code reviews.
Comment #22
alexpottCommitted and pushed e9c9ee5282 to 8.5.x and 1136b5980d to 8.4.x. Thanks!
Comment #27
xjmI believe this issue introduced a new random fail:
https://www.drupal.org/pift-ci-job/794678
https://www.drupal.org/pift-ci-job/794008Edit: not that one, that one is different. See also #2701393: Switching between editors on the format configuration causes errors upon save.This might be fixed by making the change mentioned in #20.
Comment #28
xjm#2701393: Switching between editors on the format configuration causes errors upon save was reverted as well; note that these are two separate random failures in two separate tests, but they have a similar drawback with waiting for the AJAX request but not the element.
Comment #29
tedbowIn Settings Tray we found that relying on
\Drupal\FunctionalJavascriptTests\JSWebAssert::assertWaitOnAjaxRequestcan lead to random failures because often the followingelementExists()check is passing just because the testbot is running fast enough.So we added
\Drupal\Tests\settings_tray\FunctionalJavascript\SettingsTrayJavascriptTestBase::assertElementVisibleAfterWaitwhich is just
$this->assertNotEmpty($this->assertSession()->waitForElementVisible($selector, $locator, $timeout));So I am not sure if in this test your element will be visible but you could replace both these lines with
$this->assertNotEmpty($this->assertSession()->waitForElement('css', '.ui-dialog'));Then you aren't waiting for ajax calls to be done which seems tricky but waiting for the effect of the ajax call, i.e. the element on the page.
Comment #30
wengerkAs suggested in #20 & #29, the both lines:
has been replaced by a single:
$this->assertNotEmpty($web_assert->waitForElement('css', '.ui-dialog'));Thanks all for you help !
Comment #31
wengerkComment #32
tedbow@wengerk thanks for the patch.
Now let's see if we can make the this random failure happen by running only this test 110 times with and without fix in #30
Comment #35
tedbowdarn you "\"
Comment #38
wengerkRe-rolled for Drupal 8.7.x
I also upload a x110 files to asserts no random-fails appear in this test.
The x110 tests fail but no because of random fail. It seems the "old fashion" way to run the same tests did'nt work anymore ?
Comment #40
wengerkComment #41
wim leersComment #43
alexpottSecond time lucky!
Committed and pushed cab7a12733 to 8.7.x and 4390dc6b92 to 8.6.x. Thanks!
Comment #46
wim leersYAY! This helps us be more confident about CKEditor updates :)
Comment #48
idebr commented