Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

QUnit testing using Ember helpers? #25

Closed
artsyca opened this issue Jan 28, 2023 · 1 comment
Closed

QUnit testing using Ember helpers? #25

artsyca opened this issue Jan 28, 2023 · 1 comment

Comments

@artsyca
Copy link

artsyca commented Jan 28, 2023

Kudos once again for this addon, it works so well with the latest builds of CKEditor and I'm using it with a custom build and some customizations.

I'm trying to write some sanity tests for my app and I'd like to test the editor using QUnit.

I did a bit of digging and the typeIn helper actually works with contenteditable fields, discussion here: emberjs/ember-test-helpers#793

As far as I can tell, at its core the editor has a contenteditable field, something along these lines:

image

I've tried writing a test to simply enter some text

test('Clear Text', async function (assert) {

  // Set any properties with this.set('myProperty', 'value');
  // Handle any actions with this.set('myAction', function(val) { ... });
  await render(hbs`<MyWhiteboard />`);
  
  await typeIn('.ck.ck-content.ck-editor__editable', 'This is a test');
  assert.dom('button.clear-text').exists();
  await click('button.clear-text');

});

From what I can tell, it finds the element and fires off all the events but nothing ever appears in the editor.

As I write this now I'm starting to wonder if we ought to use CKEditorInspector or something like the getData and setData helpers. (https://ckeditor.com/docs/ckeditor5/latest/framework/guides/development-tools.html#testing-helpers)

I'll give it a try and follow up!

@artsyca
Copy link
Author

artsyca commented Jan 29, 2023

I was very optimistic that something would work, but unfortunately every avenue leads to a dead end.

  • The typeIn helper does indeed work with contenteditable fields but not with CKEditor. I'm not sure if the keystrokes are even making it or just bouncing off but somehow CKEditor seems impervious.
  • CKEditor's own tools are unusable because they can't be loaded alongside the main build, leading to double inclusion errors. Plus they are useless for simulating user input, just getting and setting the editor contents.
  • Trying to trigger pure JS events also doesn't work, plus it's difficult to integrate such behaviour into testing.
  • Exposing the editor to the test suite somewhat works but it leads to promise hell because you need to attach a testing-only action to the component and wait for it to execute after render.

In other words this part of the QA is dead in the water unless we can better understand the CKEditor internals and perhaps write our own helper but I'm not optimistic about it all unfortunately.

Even so, this plugin is top notch and has really helped us integrate CKEditor into our app.

@artsyca artsyca closed this as not planned Won't fix, can't repro, duplicate, stale Jan 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant