[FIX] mass_mailing: add test for emoji widget
Go to the form view of mailing.mailing, write "hello " as the subject, insert an emoji, you end up with "hello:)" instead of "hello :)". The problem is that when the input loose the focus, it is automatically trim. Reconfigure the `char_emojis` widget so that is doesn't trim. task-id-3493168 closes odoo/odoo#136530 X-original-commit: 2adda1eb2760ccf970761f424105e245afc3de3f Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com> Signed-off-by: Julien Castiaux (juc) <juc@odoo.com>
This commit is contained in:
@@ -16,6 +16,10 @@ export class EmojisCharField extends EmojisFieldCommon(CharField) {
|
||||
this.targetEditElement = useRef("input");
|
||||
this._setupOverride();
|
||||
}
|
||||
|
||||
get shouldTrim() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
EmojisCharField.template = "mail.EmojisCharField";
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
/** @odoo-module **/
|
||||
|
||||
import { click, editInput, nextTick } from "@web/../tests/helpers/utils";
|
||||
import { setupViewRegistries } from "@web/../tests/views/helpers";
|
||||
import { start } from "@mail/../tests/helpers/test_utils";
|
||||
import { addFakeModel } from "@bus/../tests/helpers/model_definitions_helpers";
|
||||
|
||||
let serverData;
|
||||
|
||||
QUnit.module("mail", {}, () => {
|
||||
QUnit.module("widgets", {}, (hooks) => {
|
||||
addFakeModel("mailing.mailing", {
|
||||
subject: { string: "Subject", type: "char", trim: true }
|
||||
});
|
||||
|
||||
hooks.beforeEach(() => {
|
||||
serverData = {
|
||||
views: {
|
||||
"mailing.mailing,false,form": `
|
||||
<form>
|
||||
<field name="subject" widget="char_emojis"/>
|
||||
</form>
|
||||
`
|
||||
},
|
||||
}
|
||||
setupViewRegistries();
|
||||
});
|
||||
|
||||
QUnit.module("emojis_char_field_tests.js");
|
||||
|
||||
QUnit.test("emojis_char_field_tests widget: insert emoji at end of word", async function (assert) {
|
||||
assert.expect(2);
|
||||
const {openFormView} = await start({serverData});
|
||||
await openFormView("mailing.mailing");
|
||||
|
||||
const inputName = document.querySelector("input#subject_0");
|
||||
await editInput(inputName, null, "Hello");
|
||||
assert.strictEqual(inputName.value, "Hello");
|
||||
|
||||
click(document, ".o_field_char_emojis button");
|
||||
await nextTick();
|
||||
click(document, '.o-Emoji[data-codepoints="😀"]');
|
||||
assert.strictEqual(inputName.value, "Hello😀");
|
||||
});
|
||||
|
||||
QUnit.test("emojis_char_field_tests widget: insert emoji as new word", async function (assert) {
|
||||
assert.expect(2);
|
||||
const {openFormView} = await start({serverData});
|
||||
await openFormView("mailing.mailing");
|
||||
|
||||
const inputName = document.querySelector("input#subject_0");
|
||||
await editInput(inputName, null, "Hello ");
|
||||
assert.strictEqual(inputName.value, "Hello ");
|
||||
|
||||
click(document, ".o_field_char_emojis button");
|
||||
await nextTick();
|
||||
click(document, '.o-Emoji[data-codepoints="😀"]');
|
||||
assert.strictEqual(inputName.value, "Hello 😀");
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user