[FIX] web_editor: Qunit test properly wait for editor stop

closes odoo/odoo#63073

Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
This commit is contained in:
Sébastien Geelen (sge)
2020-12-09 10:24:14 +00:00
parent 30e5e58f3c
commit fd5fc76677
2 changed files with 11 additions and 3 deletions
@@ -42,6 +42,7 @@ var Wysiwyg = Widget.extend({
this.value = options.value || '';
this.options = options;
this.colorPickers = [];
this.isEditorStoppedPromise = new Promise(resolve => this._editorStoppedResolve = resolve);
this.JWEditorLib = JWEditorLib;
if (this.options.enableTranslation) {
this._modeConfig = {
@@ -453,7 +454,7 @@ var Wysiwyg = Widget.extend({
// Saving the content of the editor is not possible after destroy,
// so there's no need to keep the pop-up warning in this case.
window.onbeforeunload = null;
this.editor.stop();
this.editor.stop().then(this._editorStoppedResolve);
this._super();
},
@@ -255,6 +255,7 @@ QUnit.module('web_editor', {}, function () {
odoo.__DEBUG__.services['root.widget'] = rootWidget;
form.destroy();
await wysiwyg.isEditorStoppedPromise;
});
QUnit.test('media dialog: image', async function (assert) {
@@ -320,6 +321,7 @@ QUnit.module('web_editor', {}, function () {
testUtils.mock.unpatch(MediaDialog);
form.destroy();
await wysiwyg.isEditorStoppedPromise;
});
QUnit.test('media dialog: icon', async function (assert) {
@@ -378,6 +380,7 @@ QUnit.module('web_editor', {}, function () {
testUtils.mock.unpatch(MediaDialog);
form.destroy();
await wysiwyg.isEditorStoppedPromise;
});
QUnit.test('save', async function (assert) {
@@ -419,13 +422,17 @@ QUnit.module('web_editor', {}, function () {
await testUtils.nextTick();
await new Promise((resolve) => wysiwyg.editor.execCommand(resolve));
await openColorpicker();
await testUtils.nextTick();
await testUtils.nextTick();
await new Promise((resolve) => wysiwyg.editor.execCommand(resolve));
await testUtils.dom.click($('jw-toolbar .o_we_color_btn[style="background-color:#00FFFF;"]'));
await testUtils.nextTick();
await new Promise((resolve) => wysiwyg.editor.execCommand(resolve));
await testUtils.form.clickSave(form);
await form.destroy();
await wysiwyg.isEditorStoppedPromise;
form.destroy();
});
QUnit.module('cssReadonly');