diff --git a/addons/mass_mailing/static/tests/mass_mailing_html_tests.js b/addons/mass_mailing/static/tests/mass_mailing_html_tests.js index ee5b45c1b0d..e039fa14c86 100644 --- a/addons/mass_mailing/static/tests/mass_mailing_html_tests.js +++ b/addons/mass_mailing/static/tests/mass_mailing_html_tests.js @@ -64,7 +64,7 @@ QUnit.module('field html', { }, function () { QUnit.test('save arch and html', async function (assert) { - assert.expect(6); + assert.expect(4); var form = await testUtils.createView({ View: FormView, @@ -85,19 +85,6 @@ QUnit.test('save arch and html', async function (assert) { ' />'+ '', res_id: 1, - mockRPC: function (route, args) { - if (args.method === "write") { - var values = args.args[1]; - assert.strictEqual(values.body_html, - '
code to edit
code to edit
toto toto toto
tata
', + 'toto toto toto
tata
', "should have rendered the field correctly in edit"); form.destroy(); @@ -215,7 +215,7 @@ QUnit.module('web_editor', {}, function () { var pText = $field.find('.note-editable p').first().contents()[0]; Wysiwyg.setRange(pText, 1); - $field.find('.note-toolbar .note-insert button:has(.fa-file-image-o)').mousedown().click(); + await testUtils.dom.click($field.find('.note-toolbar .note-insert button:has(.fa-file-image-o)')); // load static xml file (dialog, media dialog, unsplash image widget) await defMediaDialog; @@ -266,7 +266,7 @@ QUnit.module('web_editor', {}, function () { var pText = $field.find('.note-editable p').first().contents()[0]; Wysiwyg.setRange(pText, 1); - $field.find('.note-toolbar .note-insert button:has(.fa-file-image-o)').mousedown().click(); + await testUtils.dom.click($field.find('.note-toolbar .note-insert button:has(.fa-file-image-o)')); // load static xml file (dialog, media dialog, unsplash image widget) await defMediaDialog; @@ -315,82 +315,8 @@ QUnit.module('web_editor', {}, function () { Wysiwyg.setRange(pText, 1, pText, 10); // text is selected - await testUtils.dom.click($field.find('.note-toolbar .note-bg-color button:first').mousedown()); - await testUtils.dom.click($field.find('.note-toolbar .note-bg-color button[data-value="bg-gamma"]').mousedown()); - - await testUtils.form.clickSave(form); - - form.destroy(); - }); - - QUnit.module('inline-style'); - - QUnit.test('convert style to class on edit', async function (assert) { - assert.expect(5); - - this.data['note.note'].records[0].body = 'toto ' +
- '' +
- 'toto toto
tata
'; - - var form = await testUtils.createView({ - View: FormView, - model: 'note.note', - data: this.data, - arch: '', - res_id: 1, - mockRPC: function (route, args) { - if (args.method === "write") { - assert.strictEqual(args.args[1].body, - '' +
- 'toto ' +
- '' +
- 'toto toto' +
- '
' + - 'tata' + - '
', - "should save the content"); - } - if (route.indexOf("/web_editor/font_to_img/61445/rgb(") !== -1) { - assert.strictEqual(route, - '/web_editor/font_to_img/61445/rgb(255,0,0)/13', - "should use the image in function of the font and the color"); - return Promise.resolve('#'); - } - return this._super.apply(this, arguments); - }, - }); - var $field = form.$('.oe_form_field[name="body"]'); - - assert.strictEqual($field.children('.o_readonly').html(), - '' +
- 'toto ' +
- '' +
- 'toto toto' +
- '
tata
', - "should have rendered a div with correct content in readonly"); - - await testUtils.form.clickEdit(form); - - $field = form.$('.oe_form_field[name="body"]'); - assert.strictEqual($field.find('.note-editable').html(), - '' + - 'toto ' + - '' + - 'toto toto' + - '
' + - 'tata
', - "should have rendered the field correctly in edit (remove inline style that used class)"); + await testUtils.dom.click($field.find('.note-toolbar .note-back-color-preview button:first')); + await testUtils.dom.click($field.find('.note-toolbar .note-back-color-preview button[data-value="bg-gamma"]')); await testUtils.form.clickSave(form); @@ -433,96 +359,10 @@ QUnit.module('web_editor', {}, function () { form.destroy(); }); - QUnit.module('cssEdit'); - - QUnit.test('rendering with iframe for edit mode', async function (assert) { - assert.expect(4); - - var form = await testUtils.createView({ - View: FormView, - model: 'note.note', - data: this.data, - arch: '', - res_id: 1, - }); - var $field = form.$('.oe_form_field[name="body"]'); - assert.strictEqual($field.children('.o_readonly').html(), - 'toto toto toto
tata
', - "should have rendered a div with correct content in readonly"); - - await testUtils.form.clickEdit(form); - - $field = form.$('.oe_form_field[name="body"]'); - var $iframe = $field.find('iframe'); - await $iframe.data('loadDef'); - var doc = $iframe.contents()[0]; - var $content = $('#iframe_target', doc); - - await testUtils.nextTick(); - - assert.strictEqual($content.find('.note-editable').html(), - 'toto toto toto
tata
', - "should have rendered a div with correct content in edit mode"); - - assert.strictEqual(doc.defaultView.getComputedStyle(doc.body).backgroundColor, - 'rgb(255, 0, 0)', - "should load the asset css"); - - $content.find('.note-toolbar .note-bg-color button:first').mousedown().click(); - await testUtils.nextTick(); - - assert.ok($content.find('.note-bg-color').hasClass('show') && $content.find('.note-bg-color .dropdown-menu').hasClass('show'), - "should display toolbar dropdown menu in iframe"); - - form.destroy(); - }); - -QUnit.test('save immediately before iframe is rendered in edit mode', async function (assert) { - assert.expect(1); - - var form = await testUtils.createAsyncView({ - View: FormView, - model: 'note.note', - data: this.data, - arch: '', - res_id: 1, - }); - testUtils.form.clickEdit(form); - await testUtils.nextTick(); - testUtils.form.clickSave(form); - await testUtils.nextTick(); - assert.ok(true, "No traceback encountered. The wysiwyg was cut while not loaded."); - form.destroy(); -}); - - QUnit.test('save immediately before iframe is rendered in edit mode with style-inline', async function (assert) { + QUnit.test('save immediately before iframe is rendered in edit mode', async function (assert) { assert.expect(1); var form = await testUtils.createAsyncView({ - View: FormView, - model: 'note.note', - data: this.data, - arch: '', - res_id: 1, - }); - testUtils.form.clickEdit(form); - await testUtils.nextTick(); - testUtils.form.clickSave(form); - await testUtils.nextTick(); - assert.ok(true, "No traceback encountered. The wysiwyg was cut while not loaded."); - form.destroy(); - }); - - QUnit.test('use colorpicker and save', async function (assert) { - assert.expect(1); - - var form = await testUtils.createView({ View: FormView, model: 'note.note', data: this.data, @@ -530,268 +370,15 @@ QUnit.test('save immediately before iframe is rendered in edit mode', async func 'toto toto toto
tata
', - "should save the content"); - } - return this._super.apply(this, arguments); - }, }); await testUtils.form.clickEdit(form); - var $field = form.$('.oe_form_field[name="body"]'); - var $iframe = $field.find('iframe'); - - await $iframe.data('loadDef'); await testUtils.nextTick(); - - var doc = $iframe.contents()[0]; - var $content = $('#iframe_target', doc); - var $editable = $content.find('.note-editable'); - - // select the text - var pText = $editable.find('p').first().contents()[0]; - Wysiwyg.setRange(pText, 1, pText, 10); - // text is selected - - await testUtils.dom.click($content.find('.note-toolbar .note-bg-color button:first').mousedown()); - await testUtils.dom.click($content.find('.note-toolbar .note-bg-color button[data-value="bg-gamma"]').mousedown()); - await testUtils.form.clickSave(form); + await testUtils.nextTick(); + assert.ok(true, "No traceback encountered. The wysiwyg was cut while not loaded."); form.destroy(); }); - QUnit.module('wrapper'); - - // todo add test wrapper - - QUnit.module('snippet (without iframe)'); - - QUnit.test('rendering with snippet panel', async function (assert) { - var done = assert.async(); - assert.expect(1); - - var form = await testUtils.createView({ - View: FormView, - model: 'note.note', - data: this.data, - arch: '', - res_id: 1, - }); - testUtils.mock.intercept(form, "snippets_loaded", function () { - assert.strictEqual(form.$('.oe_form_field #oe_snippets').length, 1, - "should display the snippet panel"); - form.destroy(); - done(); - }); - await testUtils.form.clickEdit(form); - }); - - QUnit.test('drag&drop snippet', async function (assert) { - assert.expect(1); - - var form = await testUtils.createView({ - View: FormView, - model: 'note.note', - data: this.data, - arch: '', - res_id: 1, - }); - var defSnippets = testUtils.makeTestPromise(); - testUtils.mock.intercept(form, "snippets_loaded", function () { - defSnippets.resolve(); - }); - - await testUtils.form.clickEdit(form); - var $field = form.$('.oe_form_field[name="body"]'); - var $editable = $field.find('.note-editable'); - - await defSnippets; - var $hr = $field.find('.oe_snippet_thumbnail:first'); - testUtils.dom.dragAndDrop($hr, $editable.find('p')); - - assert.strictEqual($editable.data('wysiwyg').getValue().replace(/\s+/g, ' '), - 'toto toto toto
tata
', - "should drop the snippet"); - - form.destroy(); - }); - - // todo add test snippet + customize snippet - - QUnit.module('snippet & cssEdit'); - - QUnit.test('rendering with snippet panel', async function (assert) { - var done = assert.async(); - assert.expect(1); - - var form = await testUtils.createView({ - View: FormView, - model: 'note.note', - data: this.data, - arch: '', - res_id: 1, - }); - testUtils.mock.intercept(form, "snippets_loaded", function () { - var doc = form.$('iframe').contents()[0]; - var $content = $('#iframe_target', doc); - assert.strictEqual($content.find('#oe_snippets').length, 1, - "should display the snippet panel"); - form.destroy(); - done(); - }); - await testUtils.form.clickEdit(form); - }); - - QUnit.test('drag&drop snippet', async function (assert) { - assert.expect(1); - - var form = await testUtils.createView({ - View: FormView, - model: 'note.note', - data: this.data, - arch: '', - res_id: 1, - }); - var defSnippets = testUtils.makeTestPromise(); - testUtils.mock.intercept(form, "snippets_loaded", function () { - defSnippets.resolve(); - }); - await testUtils.form.clickEdit(form); - - await defSnippets; - var doc = form.$('iframe').contents()[0]; - var $content = $('#iframe_target', doc); - var $editable = $content.find('.note-editable'); - - var $hr = $content.find('.oe_snippet_thumbnail:first'); - var from = $hr.offset(); - var to = $editable.find('p').offset(); - - $hr.trigger($.Event("mousedown", { - which: 1, - pageX: from.left + 1, - pageY: from.top + 1 - })); - $hr.trigger($.Event("mousemove", { - which: 1, - pageX: to.left, - pageY: to.top - })); - $hr.trigger($.Event("mouseup", { - which: 1, - pageX: to.left, - pageY: to.top - })); - - assert.strictEqual($editable.data('wysiwyg').getValue().replace(/\s+/g, ' '), - 'toto toto toto
tata
', - "should drop the snippet"); - - form.destroy(); - }); - - QUnit.test('drag&drop snippet options', async function (assert) { - var done = assert.async(); - assert.expect(6); - - var form = await testUtils.createView({ - View: FormView, - model: 'note.note', - data: this.data, - arch: '', - res_id: 1, - }); - var defSnippets = testUtils.makeTestPromise(); - testUtils.mock.intercept(form, "snippets_loaded", function () { - defSnippets.resolve(); - }); - - var defActivateSnippet; - testUtils.mock.intercept(form, "snippet_focused", function (e) { - defActivateSnippet.resolve(e.target); - }); - - await testUtils.form.clickEdit(form); - - defSnippets.then(function () { - var doc = form.$('iframe').contents()[0]; - var $content = $('#iframe_target', doc); - var $editable = $content.find('.note-editable'); - - function dropSnippet() { - defActivateSnippet = testUtils.makeTestPromise(); - - var $hr = $content.find('.oe_snippet_thumbnail:first'); - var from = $hr.offset(); - var to = $editable.find('p').offset(); - - $hr.trigger($.Event("mousedown", { - which: 1, - pageX: from.left + 1, - pageY: from.top + 1 - })); - $hr.trigger($.Event("mousemove", { - which: 1, - pageX: to.left, - pageY: to.top - })); - $hr.trigger($.Event("mouseup", { - which: 1, - pageX: to.left, - pageY: to.top - })); - } - - dropSnippet(); - defActivateSnippet.then(function (snippet) { - assert.strictEqual($editable.data('wysiwyg').getValue().replace(/\s+/g, ' '), - 'toto toto toto
tata
', - "should drop the snippet"); - - assert.strictEqual(snippet.$target.index(), 0, - 'should show the snippet editor for the first dropped block'); - - dropSnippet(); - defActivateSnippet.then(function (snippet) { - assert.strictEqual($editable.data('wysiwyg').getValue().replace(/\s+/g, ' '), - 'toto toto toto
tata
', - "should drop the snippet"); - - assert.strictEqual(snippet.$target.index(), 1, - 'should show the snippet editor for the second dropped block'); - - assert.strictEqual($('.oe_active .oe_overlay_options .btn:visible', doc).length, 4, - 'should show the snippet editor buttons'); - - defActivateSnippet = testUtils.makeTestPromise(); - $editable.find('hr:first').trigger('click'); - defActivateSnippet.then(function (snippet) { - - assert.strictEqual(snippet.$target.index(), 0, - 'should show the snippet editor for the first dropped block'); - - form.destroy(); - done(); - }); - }); - }); - }); - }); - QUnit.module('translation'); QUnit.test('field html translatable', async function (assert) { @@ -824,47 +411,6 @@ QUnit.test('save immediately before iframe is rendered in edit mode', async func await testUtils.form.clickEdit(form); var $button = form.$('.oe_form_field_html .o_field_translate'); assert.strictEqual($button.length, 1, "should have a translate button"); - $button.click(); - - form.destroy(); - _t.database.multi_lang = multiLang; - }); - - QUnit.test('field html translatable in iframe', async function (assert) { - assert.expect(2); - - var multiLang = _t.database.multi_lang; - _t.database.multi_lang = true; - - this.data['note.note'].fields.body.translate = true; - - var form = await testUtils.createView({ - View: FormView, - model: 'note.note', - data: this.data, - arch: '', - res_id: 1, - mockRPC: function (route, args) { - if (route === '/web/dataset/call_button' && args.method === 'translate_fields') { - assert.deepEqual(args.args, ['note.note', 1, 'body'], "should call 'call_button' route"); - return Promise.resolve(); - } - return this._super.apply(this, arguments); - }, - }); - await testUtils.form.clickEdit(form); - var $field = form.$('.oe_form_field[name="body"]'); - var $iframe = $field.find('iframe'); - - await $iframe.data('loadDef'); - await testUtils.nextTick(); - var doc = $iframe.contents()[0]; - var $content = $('#iframe_target', doc); - - var $button = $content.find('.o_field_translate'); - assert.strictEqual($button.length, 1, "should have a translate button"); await testUtils.dom.click($button); form.destroy(); diff --git a/addons/web_editor/static/tests/wysiwyg_keyboard_tests.js b/addons/web_editor/static/tests/wysiwyg_keyboard_tests.js deleted file mode 100644 index cba62aef1c6..00000000000 --- a/addons/web_editor/static/tests/wysiwyg_keyboard_tests.js +++ /dev/null @@ -1,4423 +0,0 @@ -odoo.define('web_editor.wysiwyg.keyboard_tests', function (require) { -"use strict"; - -var weTestUtils = require('web_editor.test_utils'); - -//-------------------------------------------------------------------------- -// tests -//-------------------------------------------------------------------------- - -QUnit.module('web_editor', {}, function () { -QUnit.module('wysiwyg', {}, function () { - -//-------------------------------------------------------------------------- -// Unbreakable tests -//-------------------------------------------------------------------------- -QUnit.module('Unbreakable'); - -var unbreakableTestDom = [ - 'dom to edit
", - steps: [{ - start: "p:contents()[0]->1", - end: "p:contents()[0]->1", - key: 'ENTER', - }], - test: { - content: 'd
om to edit
dom to edit
", - steps: [{ - start: "p:contents()[0]->3", - keyCode: 66, - }], - test: { - content: "domB to edit
", - start: "p:contents()[0]->4", - end: null, - check: function ($editable, assert) { - assert.ok(true); - }, - }, - }, - { - name: "visible char in a link tag entirely selected", - content: '', - steps: [{ - start: "a:contents()[0]->0", - end: "a:contents()[0]->11", - key: 'a', - }], - test: { - content: '', - start: "a:contents()[0]->2", - }, - }, - { - name: "'a' on a selection of all the contents of a complex dom", - content: "dom
to
completelyremove
a
", - start: "b:contents()[0]->1", - }, - }, - { - name: "'a' on a selection of all the contents of a complex dom (2)", - content: "xxx
yyy
xxx a
yyy
xxx
yyy
xxx a
yyy
xxx |
| yyy |
xxx | a | yyy |
xxx |
| yyy |
xxx | a | yyy |
xxx |
| yyy |
xxx | a | yyy |
xxx |
| yyy |
xxx | a | yyy |
| \n' +
- ' xxx \n' + - ' | \n' +
- ' \n' +
- '
| \n' +
- ' \n' +
- ' yyy \n' + - ' | \n' +
- '
| \n' +
- ' xxx \n' + - ' | \n' +
- ' \n' +
- ' a | \n' +
- ' \n' +
- ' yyy \n' + - ' | \n' +
- '
| \n' +
- ' xxx \n' + - ' | \n' +
- ' \n' +
- '
| \n' +
- ' \n' +
- ' yyy \n' + - ' | \n' +
- '
| \n' +
- ' xxx \n' + - ' | \n' +
- ' \n' +
- ' a | \n' +
- ' \n' +
- ' yyy \n' + - ' | \n' +
- '
| \n' +
- ' xxx \n' + - ' | \n' +
- ' \n' +
- '
| \n' +
- ' \n' +
- ' yyy \n' + - ' | \n' +
- '
| \n' +
- ' xxx \n' + - ' | \n' +
- ' \n' +
- ' a | \n' +
- ' \n' +
- ' yyy \n' + - ' | \n' +
- '
bbb
', - steps: [{ - start: "span->0", - end: 'p:contents(1)->3', - key: 'a', - }], - test: { - content: 'a
', - start: "p:contents()[0]->1", - }, - }, - { - name: "' ' at start of p", - content: 'dom to edit
', - steps: [{ - start: "p:contents()[0]->0", - key: ' ', - }], - test: { - content: 'dom to edit
', - start: "p:contents()[0]->1", - }, - }, - { - name: "' ' at end of p", - content: 'dom to edit
', - steps: [{ - start: "p:contents()[0]->11", - key: ' ', - }], - test: { - content: 'dom to edit
', - start: "p:contents()[0]->12", - }, - }, - { - name: "' ' within p", - content: 'dom to edit
', - steps: [{ - start: "p:contents()[0]->2", - key: ' ', - }], - test: { - content: 'do m to edit
', - start: "p:contents()[0]->3", - }, - }, - { - name: "' ' before space within p", - content: 'dom to edit
', - steps: [{ - start: "p:contents()[0]->3", - key: ' ', - }], - test: { - content: 'dom to edit
', - start: "p:contents()[0]->4", - }, - }, - { - name: "' ' after space within p", - content: 'dom to edit
', - steps: [{ - start: "p:contents()[0]->4", - key: ' ', - }], - test: { - content: 'dom to edit
', - start: "p:contents()[0]->5", - }, - }, - { - name: "3x ' ' at start of p", - content: 'dom to edit
', - steps: [{ - start: "p:contents()[0]->0", - key: ' ', - }, { - key: ' ', - }, { - key: ' ', - }], - test: { - content: 'dom to edit
', - start: "p:contents()[0]->3", - }, - }, - { - name: "3x ' ' at end of p", - content: 'dom to edit
', - steps: [{ - start: "p:contents()[0]->11", - key: ' ', - }, { - key: ' ', - }, { - key: ' ', - }], - test: { - content: 'dom to edit
', - start: "p:contents()[0]->14", - }, - }, - { - name: "3x ' ' within p", - content: 'dom to edit
', - steps: [{ - start: "p:contents()[0]->2", - key: ' ', - }, { - key: ' ', - }, { - key: ' ', - }], - test: { - content: 'do m to edit
', - start: "p:contents()[0]->5", - }, - }, - { - name: "3x ' ' before space in p", - content: 'dom to edit
', - steps: [{ - start: "p:contents()[0]->3", - key: ' ', - }, { - key: ' ', - }, { - key: ' ', - }], - test: { - content: 'dom to edit
', - start: "p:contents()[0]->6", - }, - }, - { - name: "3x ' ' after space in p", - content: 'dom to edit
', - steps: [{ - start: "p:contents()[0]->4", - key: ' ', - }, { - key: ' ', - }, { - key: ' ', - }], - test: { - content: 'dom to edit
', - start: "p:contents()[0]->7", - }, - }, - { - name: "'a' in unbreakable with font", - content: 'a
dom to edit
", - steps: [{ - start: "p:contents()[0]->1", - key: 'ENTER', - }], - test: { - content: "d
om to edit
", - start: "p:contents()[1]->0", - }, - }, - { - name: "in p: 2x ENTER", - content: "dom to edit
", - steps: [{ - start: "p:contents()[0]->1", - key: 'ENTER', - }, { - key: 'ENTER', - }], - test: { - content: "d
om to edit
", - start: "p:contents()[2]->0", - }, - }, - { - name: "in p: SHIFT+ENTER", - content: "dom to edit
", - steps: [{ - start: "p:contents()[0]->1", - key: 'ENTER', - shiftKey: true, - }], - test: { - content: "d
om to edit
dom to edit
", - steps: [{ - start: "p:contents()[0]->1", - key: 'ENTER', - shiftKey: true, - }, { - key: 'ENTER', - shiftKey: true, - }], - test: { - content: "d
om to edit
dom to edit
", - steps: [{ - start: "p:contents()[0]->1", - key: 'ENTER', - }, { - key: 'ENTER', - shiftKey: true, - }], - test: { - content: "d
om to edit
dom to edit
", - steps: [{ - start: "p:contents()[0]->1", - end: "p:contents()[0]->7", - key: 'ENTER', - }], - test: { - content: "d
edit
", - start: "p:contents()[1]->0", - end: "p:contents()[1]->0", - }, - }, - { - name: "in p: SHIFT+ENTER on selection", - content: "dom to edit
", - steps: [{ - start: "p:contents()[0]->1", - end: "p:contents()[0]->7", - key: 'ENTER', - shiftKey: true, - }], - test: { - content: "d
edit
a
", - start: "p:contents()[0]->1", - }, - }, - { - name: "across 2 li: ENTER on partial selection", - content: "dom to edit
dom to edit
dom to edit
dom to edit
dom to edit
dom to edit
aaa
dom to edit
bbb
aaa
dom to edit
bbb
aaa
dom to edit
bbb
aaa
dom to edit
bbb
test
test
test
te
st
dom to edit
", - steps: [{ - start: "p:contents()[1]->0", - key: 'ENTER', - shiftKey: true, - }], - test: { - content: "dom
to edit
dom to edit
", - steps: [{ - start: "b:contents()[0]->2", - key: 'ENTER', - }, { - key: 'a', - }], - test: { - content: "do
am to edit
", - start: "b:eq(1):contents()[0]->1", - }, - }, - { - name: "after p > b: ENTER -> 'a'", - content: "dom to edit
", - steps: [{ - start: "p:contents()[1]->0", - key: 'ENTER', - }, { - key: 'a', - }], - test: { - content: "dom
a to edit
", - start: "p:eq(1):contents()[0]->1", - }, - }, - { - name: "after p > b: SHIFT+ENTER -> 'a'", - content: "dom to edit
", - steps: [{ - start: "p:contents()[1]->0", - key: 'ENTER', - shiftKey: true, - }, { - key: 'a', - }], - test: { - content: "dom
a to edit
dom to
edit
", - steps: [{ - start: "p:eq(1):contents()[0]->0", - key: 'ENTER', - }], - test: { - content: "dom to
edit
", - start: "span:eq(2):contents()[0]->0", - }, - }, - { - name: "in p (other-p > span.a before - p > span.b after): ENTER -> 'a' at beginning", - content: "dom to
edit
", - steps: [{ - start: "p:eq(1):contents()[0]->0", - key: 'ENTER', - }, { - key: 'a', - }], - test: { - content: "dom to
aedit
", - start: "span:eq(2):contents()[0]->1", - }, - }, - { - name: "in p (other-p > span.a before - p > span.b after): SHIFT+ENTER at beginning", - content: "dom to
edit
", - steps: [{ - start: "p:eq(1):contents()[0]->0", - key: 'ENTER', - shiftKey: true, - }], - test: { - content: "dom to
edit
dom to
edit
", - steps: [{ - start: "p:eq(1):contents()[0]->0", - key: 'ENTER', - shiftKey: true, - }, { - key: 'a', - }], - test: { - content: "dom to
aedit
dom to edit
", - steps: [{ - start: "p:contents()[0]->0", - end: "p:contents()[0]->11", - key: 'ENTER', - }], - test: { - content: "dom to edit
", - steps: [{ - start: "p:contents()[0]->0", - end: "p:contents()[0]->11", - key: 'ENTER', - }, { - key: 'a', - }], - test: { - content: "a
", - start: "p:eq(1):contents()[0]->1", - }, - }, - { - name: "in p: SHIFT+ENTER on selection of all contents", - content: "dom to edit
", - steps: [{ - start: "p:contents()[0]->0", - end: "p:contents()[0]->11", - key: 'ENTER', - shiftKey: true, - }], - test: { - content: "dom to edit
", - steps: [{ - start: "p:contents()[0]->0", - end: "p:contents()[0]->11", - key: 'ENTER', - shiftKey: true, - }, { - key: 'a', - }], - test: { - content: "
a
dom to edit
", - steps: [{ - start: "p:contents()[0]->3", - key: 'ENTER', - }, { - key: 'ENTER', - }, { - key: 'a', - }], - test: { - content: "dom
a to edit
", - start: "p:eq(2):contents()[0]->1", - }, - }, - { - name: "in p > b: ENTER at start", - content: "dom to edit
", - steps: [{ - start: "b:contents()[0]->0", - key: 'ENTER', - }], - test: { - content: "dom to edit
", - start: "b:eq(1):contents()[0]->0", - }, - }, - { - name: "in p > b: ENTER", - content: "dom to edit
", - steps: [{ - start: "b:contents()[0]->3", - key: 'ENTER', - }], - test: { - content: "dom
to edit
", - start: "b:eq(1):contents()[0]->0", - }, - }, - { - name: "in p > b: SHIFT+ENTER -> ENTER", - content: "dom to edit
", - steps: [{ - start: "b:contents()[0]->3", - key: 'ENTER', - shiftKey: true, - }, { - key: 'ENTER', - }], - test: { - content: "dom
to edit
", - start: "b:eq(1):contents()[0]->0", - }, - }, - { - name: "in p > b: ENTER -> a'", - content: "dom to edit
", - steps: [{ - start: "b:contents()[0]->3", - key: 'ENTER', - }, { - key: 'a', - }], - test: { - content: "dom
a to edit
", - start: "b:eq(1):contents()[0]->1", - }, - }, - { - name: "in p > b: SHIFT+ENTER", - content: "dom to edit
", - steps: [{ - start: "b:contents()[0]->3", - key: 'ENTER', - shiftKey: true, - }], - test: { - content: "dom
to edit
dom to edit
", - steps: [{ - start: "b:contents()[0]->3", - key: 'ENTER', - shiftKey: true, - }, { - key: 'a', - }], - test: { - content: "dom
a to edit
dom to edit
", - steps: [{ - start: "b:contents()[0]->3", - key: 'ENTER', - shiftKey: true, - }, { - key: 'ENTER', - }, { - key: 'a', - }], - test: { - content: "dom
a to edit
", - start: "b:eq(1):contents()[0]->1", - }, - }, - { - name: "in span > b: ENTER", - content: "dom to edit", - steps: [{ - start: "b:contents()[0]->3", - key: 'ENTER', - }], - test: { - content: "domdom to edit
", - steps: [{ - start: "p:contents()[0]->3", - key: 'ENTER', - shiftKey: true, - }, { - key: 'ENTER', - shiftKey: true, - }, { - key: 'a', - }], - test: { - content: "dom
a to edit
dom to edit
", - steps: [{ - start: "p:contents()[0]->3", - key: 'ENTER', - }, { - key: 'ENTER', - shiftKey: true, - }, { - key: 'a', - }], - test: { - content: "dom
a to edit
dom
to edit
", - steps: [{ - start: "p:eq(1):contents()[0]->0", - key: 'ENTER', - }, { - key: 'a', - }], - test: { - content: "dom
a
to edit
", - start: "p:eq(2):contents()[0]->1", - }, - }, - { - name: "in p: SHIFT+ENTER at end", - content: "dom
to edit
", - steps: [{ - start: "p:first:contents()[0]->4", - key: 'ENTER', - shiftKey: true, - }], - test: { - content: "dom
to edit
", - start: "p:first:contents()[2]->0", - }, - }, - { - name: "in p: SHIFT+ENTER at end -> '寺'", - content: "dom
to edit
", - steps: [{ - start: "p:first:contents()[0]->4", - key: 'ENTER', - shiftKey: true, - }, { - keyCode: 23546, /*temple in chinese*/ - }], - test: { - content: "dom
寺
to edit
", - start: "p:first:contents()[2]->1", - }, - }, - { - name: "in empty-p (div > a after): 3x SHIFT+ENTER -> 'a'", - content: "
a
dom to edit
", - steps: [{ - start: "b:contents()[0]->3", - key: 'ENTER', - shiftKey: true, - }, { - key: 'ENTER', - shiftKey: true, - }, { - key: 'BACKSPACE', - }], - test: { - content: "dom
to edit
dom to edit
", - steps: [{ - start: "b:contents()[0]->3", - key: 'ENTER', - shiftKey: false - }, { - key: 'ENTER', - shiftKey: false - }, { - key: 'BACKSPACE', - }, { - key: 'BACKSPACE', - }], - test: { - content: "dom to edit
", - start: "b:contents()[0]->3", - }, - }, - { - name: "in empty-p: 2x ENTER -> 2x BACKSPACE", - content: "dom not to edit
dom not to edit
", - start: "p:first:contents()[0]->15", - }, - }, - { - name: "in p > b: 2x SHIFT+ENTER -> BACKSPACE -> 'a'", - content: "dom to edit
", - steps: [{ - start: "b:contents()[0]->3", - key: 'ENTER', - shiftKey: true, - }, { - key: 'ENTER', - shiftKey: true, - }, { - key: 'BACKSPACE', - }, { - key: 'a', - }], - test: { - content: "dom
a to edit
dom
to edit
dom
a
to edit
dom
to edit
dom
a to edit
dom not to edit
dom to edit
dom not to edit
", - steps: [{ - start: "p:eq(1):contents()[0]->5", - key: 'ENTER', - shiftKey: true, - }, - { - key: 'ENTER', - shiftKey: true, - }, - { - key: 'ENTER', - shiftKey: true, - }, - { - key: 'BACKSPACE', - }, - { - key: 'BACKSPACE', - }, - { - key: 'BACKSPACE', - } - ], - test: { - content: "dom not to edit
dom to edit
dom not to edit
", - start: "p:eq(1):contents()[0]->5", - }, - }, - { - name: "in h1.a > font: 'a' on selection of all contents", - content: "pif
paf
pouf
pif
', - start: "p:contents()[0]->2", - }, - }, - { - name: "in complex-dom: DELETE on partial selection (requires merging non-similar blocks)", - content: "pif
paf
pouf
pif
', - start: "p:contents()[0]->2", - }, - }, - - // paragraph outdent - - { - name: "in p (h1 before): TAB -> BACKSPACE at start (must indent then outdent)", - content: "dom to edit
", - steps: [{ - start: "p:contents()[0]->0", - key: 'TAB', - }, { - key: 'BACKSPACE', - }], - test: { - content: "dom to edit
", - start: "p:contents()[0]->0", - }, - }, - { - name: "in p (h1 before): TAB -> 2x BACKSPACE at start (must indent then outdent, then merge blocks)", - content: "dom to edit
", - steps: [{ - start: "p:contents()[0]->0", - key: 'TAB', - }, { - key: 'BACKSPACE', - }, { - key: 'BACKSPACE', - }], - test: { - content: "1
2
3
1
2
3
2
34
4
2
23
2
4
2
23
2
3
23
4
2
1
1
a
a
a
dom to edit | node |
dom to edit | node |
dom to edit
", - steps: [{ - start: "p:contents()[0]->0", - key: 'TAB', - }], - test: { - content: "dom to edit
", - start: "p:contents()[0]->0", - }, - }, - { - name: "in indented-p: SHIFT+TAB at start", - content: "dom to edit
", - steps: [{ - start: "p:contents()[0]->0", - key: 'TAB', - shiftKey: true, - }], - test: { - content: "dom to edit
", - start: "p:contents()[0]->0", - }, - }, - { - name: "in p: TAB -> BACKSPACE at start", - content: "dom to edit
", - steps: [{ - start: "p:contents()[0]->0", - key: 'TAB', - }, { - key: 'BACKSPACE', - }], - test: { - content: "dom to edit
", - start: "p:contents()[0]->0", - }, - }, - { - name: "in p > b: TAB at start", - content: "dom to edit
", - steps: [{ - start: "b:contents()[0]->0", - key: 'TAB', - }], - test: { - content: "dom to edit
", - start: "b:contents()[0]->4", - }, - }, - { - name: "in p > b: TAB -> BACKSPACE at start", - content: "dom to edit
", - steps: [{ - start: "b:contents()[0]->0", - key: 'TAB', - }, { - key: 'BACKSPACE', - }], - test: { - content: "dom to edit
", - start: "b:contents()[0]->3", - }, - }, -]; - -QUnit.test('Tab', function (assert) { - var done = assert.async(); - weTestUtils.createWysiwyg({ - data: this.data, - wysiwygOptions: { - tooltip: false, - }, - }).then(function (wysiwyg) { - var $editable = wysiwyg.$('.note-editable'); - weTestUtils.testKeyboard($editable, assert, keyboardTestsTab).then(function () { - wysiwyg.destroy(); - done(); - }); - }); -}); - -var keyboardTestsBackspace = [{ - name: "in p: BACKSPACE after span.fa", - content: 'aaabbb
', - steps: [{ - start: "p:contents()[2]->0", - key: 'BACKSPACE', - }], - test: { - content: 'aaabbb
', - start: "p:contents()[0]->3", - }, - }, - { - name: "in empty-p (no br): BACKSPACE (must insert br)", - content: "", - steps: [{ - start: "p->0", - key: 'BACKSPACE', - }], - test: { - content: "dom to edit
", - steps: [{ - start: "p:eq(1):contents()[0]->0", - key: 'BACKSPACE', - }], - test: { - content: "dom to edit
", - start: "p:contents()[0]->0", - }, - }, - { - name: "in p (empty-p.a before): BACKSPACE", - content: "dom to edit
", - steps: [{ - start: "p:eq(1):contents()[0]->0", - key: 'BACKSPACE', - }], - test: { - content: "dom to edit
", - start: "p:contents()[0]->0", - }, - }, - { - name: "in p: BACKSPACE within text", - content: "dom to edit
", - steps: [{ - start: "p:contents()[0]->5", - key: 'BACKSPACE', - }], - test: { - content: "dom o edit
", // The br is there to ensure the carret can enter the p tag - start: "p:contents()[0]->4", - }, - }, - { - name: "in p: 2x BACKSPACE within text", - content: "dom to edit
", - steps: [{ - start: "p:contents()[0]->5", - key: 'BACKSPACE', - }, { - key: 'BACKSPACE', - }], - test: { - content: "domo edit
", // The br is there to ensure the carret can enter the p tag - start: "p:contents()[0]->3", - }, - }, - { - name: "in p (p > span.a before - span.b after): BACKSPACE at beginning (must attach them)", - content: "dom to
edit
", - steps: [{ - start: "p:eq(1):contents()[0]->0", - key: 'BACKSPACE', - }], - test: { - content: "dom toedit
", - start: "span:eq(0):contents()[0]->6", - }, - }, - { - name: "in p (p > span.a before - span.a after): BACKSPACE (must merge them)", - content: "dom to
edit
", - steps: [{ - start: "p:eq(1):contents()[0]->0", - key: 'BACKSPACE', - }], - test: { - content: "dom to edit
", - start: "span:contents()[0]->7", - }, - }, - { - name: "in p (b before): BACKSPACE", - content: "dom to edit
", - steps: [{ - start: "p:contents()[1]->0", - key: 'BACKSPACE', - }], - test: { - content: "do to edit
", - start: "b:contents()[0]->2", - }, - }, - { - name: "in p (div > span.a before - span.a after): BACKSPACE at beginning (must do nothing)", - content: "edit
", - steps: [{ - start: "p:contents()[0]->0", - key: 'BACKSPACE', - }], - test: { - content: "edit
", - start: "span:eq(1):contents()[0]->0", - }, - }, - { - name: "in p: BACKSPACE on partial selection", - content: "dom to edit
", - steps: [{ - start: "p:contents()[0]->1", - end: "p:contents()[0]->7", - key: 'BACKSPACE', - }], - test: { - content: "dedit
", - start: "p:contents()[0]->1", - }, - }, - { - name: "across 2 p's: BACKSPACE on partial selection", - content: "dom
to edit
", - steps: [{ - start: "p:contents()[0]->1", - end: "p:eq(1):contents()[0]->3", - key: 'BACKSPACE', - }], - test: { - content: "dedit
", - start: "p:contents()[0]->1", - }, - }, - { - name: "in p: BACKSPACE within text, with space at beginning", - content: "dom to edit
", - steps: [{ - start: "p:contents()[0]->10", - key: 'BACKSPACE', - }], - test: { - content: "dom o edit
", - start: "p:contents()[0]->4", - }, - }, - { - name: "in p: BACKSPACE within text, with one space at beginning", - content: "dom to edit
", - steps: [{ - start: "p:contents()[0]->6", - key: 'BACKSPACE', - }], - test: { - content: "dom o edit
", - start: "p:contents()[0]->5", - }, - }, - { - name: "in p: BACKSPACE within text, with space at end", - content: "dom to edit
", - steps: [{ - start: "p:contents()[0]->5", - key: 'BACKSPACE', - }], - test: { - content: "dom o edit
", - start: "p:contents()[0]->4", - }, - }, - { - name: "in p: BACKSPACE within text, with one space at end", - content: "dom to edit
", - steps: [{ - start: "p:contents()[0]->5", - key: 'BACKSPACE', - }], - test: { - content: "dom o edit
", - start: "p:contents()[0]->4", - }, - }, - { - name: "in p: BACKSPACE within text, with space at beginning and end", - content: "dom to edit
", - steps: [{ - start: "p:contents()[0]->10", - key: 'BACKSPACE', - }], - test: { - content: "dom o edit
", - start: "p:contents()[0]->4", - }, - }, - { - name: "in p: BACKSPACE within text, with one space at beginning and one at end", - content: "dom to edit
", - steps: [{ - start: "p:contents()[0]->6", - key: 'BACKSPACE', - }], - test: { - content: "dom o edit
", - start: "p:contents()[0]->5", - }, - }, - { - name: "in p: BACKSPACE after \\wdom to edi
t
dom to edi
dom t
", - steps: [{ - start: "p:contents()[0]->5", - key: 'BACKSPACE', - }, { - key: 'a', - }], - test: { - content: "dom a
", - start: "p:contents()[0]->5", - }, - }, - { - name: "in pre: BACKSPACE within text, with space at beginning", - content: "dom to edit", - steps: [{ - start: "pre:contents()[0]->10", - key: 'BACKSPACE', - }], - test: { - content: "
dom o edit", - start: "pre:contents()[0]->9", - }, - }, - { - name: "in pre: BACKSPACE within text, with one space at beginning", - content: "
dom to edit", - steps: [{ - start: "pre:contents()[0]->6", - key: 'BACKSPACE', - }], - test: { - content: "
dom o edit", - start: "pre:contents()[0]->5", - }, - }, - { - name: "in pre: BACKSPACE within text, with space at end", - content: "
dom to edit", - steps: [{ - start: "pre:contents()[0]->5", - key: 'BACKSPACE', - }], - test: { - content: "
dom o edit", - start: "pre:contents()[0]->4", - }, - }, - { - name: "in pre: BACKSPACE within text, with one space at end", - content: "
dom to edit", - steps: [{ - start: "pre:contents()[0]->5", - key: 'BACKSPACE', - }], - test: { - content: "
dom o edit", - start: "pre:contents()[0]->4", - }, - }, - { - name: "in pre: BACKSPACE within text, with space at beginning and end", - content: "
dom to edit", - steps: [{ - start: "pre:contents()[0]->10", - key: 'BACKSPACE', - }], - test: { - content: "
dom o edit", - start: "pre:contents()[0]->9", - }, - }, - { - name: "in pre: BACKSPACE within text, with one space at beginning and one at end", - content: "
dom to edit", - steps: [{ - start: "pre:contents()[0]->6", - key: 'BACKSPACE', - }], - test: { - content: "
dom o edit", - start: "pre:contents()[0]->5", - }, - }, - - // list UL / OL - - { - name: "from p to ul > li: BACKSPACE on whole list", - content: "
dom not to edit
dom to edit
dom not to edit
", - start: "p:contents()[0]->15", - }, - }, - { - name: "in ul > second-li > p: BACKSPACE within text", - content: "dom to
edit
dom to
edi
dom to
dom to
dom to
dom to
a
a
", - start: "p:eq(1):contents()[0]->1", - }, - }, - { - name: "in empty-li (no other li - p before): BACKSPACE", - content: "toto
toto
toto

toto

toto
tutu
toto
tutu
toto
tutu
toto
tutu
toto
xxx
yyy
tutu
toto
xxx
yyy
tutu
toto
xxx
yyy
tutu
toto
xxxyyy
tutu
dom to edit
dom to edit
dom not to edit
dom to edit dom to edit
dom not to edit
a
a
a
dom to edit
", - steps: [{ - start: "p:contents()[0]->0", - end: "p:contents()[0]->11", - key: 'BACKSPACE', - }], - test: { - content: "dom to edit
", - steps: [{ - start: "p:contents()[0]->0", - end: "p:contents()[0]->11", - key: 'BACKSPACE', - }, { - key: 'a', - }], - test: { - content: "a
", - start: "p:contents()[0]->1", - }, - }, - { - name: "in complex-dom: BACKSPACE on selection of most contents", - content: "dom
to
partiallyremove
doove
", - start: "b:contents()[0]->2", - }, - }, - { - name: "in complex-dom: BACKSPACE on selection of all contents", - content: "dom
to
completelyremove
dom
to edit
dom to edit
", - start: "p:contents()[0]->4", - }, - }, - { - name: "in complex-dom (span > b -> ENTER in contents)", - content: "domaaa
bbb
', - steps: [{ - start: "p:eq(1):contents()[0]->0", - key: 'BACKSPACE', - }], - test: { - content: 'aaabbb
', - start: "p:contents()[0]->3", - }, - }, - { - name: "in p with multi br[id] (p before and after) (1)", - content: 'dom not to edit
dom not to edit
', - steps: [{ - start: "p:eq(1)->2", - key: 'BACKSPACE', - }], - test: { - content: 'dom not to edit
dom not to edit
', - start: "p:eq(1)->1", - }, - }, - { - name: "in p with multi br[id] (p before and after) (2)", - content: 'dom not to edit
dom not to edit
', - steps: [{ - start: "br:eq(2)->0", - key: 'BACKSPACE', - }], - test: { - content: 'dom not to edit
dom not to edit
', - start: "p:eq(1)->1", - }, - }, - { - name: "in p with multi br[id] (p before and after): 2x BACKSPACE", - content: 'dom not to edit
dom not to edit
', - steps: [{ - start: "p:eq(1)->2", - key: 'BACKSPACE', - }, { - key: 'BACKSPACE', - }], - test: { - content: 'dom not to edit
dom not to edit
', - start: "p:eq(1)->0", - }, - }, - { - name: "in p with multi br (p before and after) (1)", - content: 'dom not to edit
dom not to edit
', - steps: [{ - start: "p:eq(1)->2", - key: 'BACKSPACE', - }], - test: { - content: 'dom not to edit
dom not to edit
', - start: "p:eq(1)->1", - }, - }, - { - name: "in p with multi br (p before and after) (2)", - content: 'dom not to edit
dom not to edit
', - steps: [{ - start: "br:eq(2)->0", - key: 'BACKSPACE', - }], - test: { - content: 'dom not to edit
dom not to edit
', - start: "p:eq(1)->1", - }, - }, - { - name: "in p with multi br (p before and after): 2x BACKSPACE", - content: 'dom not to edit
dom not to edit
', - steps: [{ - start: "p:eq(1)->2", - key: 'BACKSPACE', - }, { - key: 'BACKSPACE', - }], - test: { - content: 'dom not to edit
dom not to edit
', - start: "p:eq(1)->0", - }, - }, - { - name: "in p: BACKSPACE within text after \w+dom to
edit
dom to
edt
a |
dom not to edit | dom to edit |
dom not to edit | aom to edit |
dom to edit |
dom o edit |
dom not to edit |
dom not to edit | a |
a
', - start: "p:contents()[0]->1", - }, - }, - { - name: "in h1: BACKSPACE on full selection -> DELETE -> 'a'", - content: 'node to merge
', - steps: [{ - start: 'p:contents()[0]->0', - key: 'BACKSPACE', - }], - test: { - content: 'node to merge with
node to merge
', - steps: [{ - start: 'p:eq(1):contents()[0]->0', - key: 'BACKSPACE', - }], - test: { - content: 'node to merge withnode to merge
node to merge with
node to merge
', - steps: [{ - start: 'b:contents()[0]->0', - key: 'BACKSPACE', - }], - test: { - content: 'node to merge withnode to merge
node to merge with
node to merge
', - steps: [{ - start: 'b:contents()[0]->0', - key: 'BACKSPACE', - }], - test: { - content: 'node to merge withnode to merge
dom to
edit
", - steps: [{ - start: "p:eq(1):contents()[0]->0", - key: 'BACKSPACE', - }], - test: { - content: "dom to edit
", - start: "span:eq(0):contents()[0]->7", - }, - }, - { - name: "from h1 to p: BACKSPACE", - content: 'node to merge
', - steps: [{ - start: 'h1:contents()[0]->5', - end: 'p:contents()[0]->2', - key: 'BACKSPACE', - }], - test: { - content: 'node to merge
', - steps: [{ - start: 'b:contents()[0]->0', - end: 'p:contents()[0]->2', - key: 'BACKSPACE', - }], - test: { - content: 'de to merge
', - start: "p:contents()[0]->0", - }, - }, -]; - -QUnit.test('Backspace', function (assert) { - var done = assert.async(); - weTestUtils.createWysiwyg({ - data: this.data, - wysiwygOptions: { - tooltip: false, - }, - }).then(function (wysiwyg) { - var $editable = wysiwyg.$('.note-editable'); - weTestUtils.testKeyboard($editable, assert, keyboardTestsBackspace).then(function () { - wysiwyg.destroy(); - done(); - }); - }); -}); - -var keyboardTestsDelete = [{ - name: "in empty-p (no br): DELETE (must insert br)", - content: "", - steps: [{ - start: "p->0", - key: 'DELETE', - }], - test: { - content: "\n
\n
\n
\n
dom to edit
", - steps: [{ - start: "p->0", - key: 'DELETE', - }], - test: { - content: "dom to edit
", - start: "p:contents()[0]->0", - }, - }, - { - name: "in empty-p (p after): DELETE (2)", - content: "\n
\n
\n dom to edit
", - steps: [{ - start: "p:contents()[1]->0", - key: 'DELETE', - }], - test: { - content: "dom to edit
", - start: "p:contents()[0]->0", - }, - }, - { - name: "in empty-p.a (p after): DELETE", - content: "dom to edit
", - steps: [{ - start: "p->0", - key: 'DELETE', - }], - test: { - content: "dom to edit
", - start: "p:contents()[0]->0", - }, - }, - { - name: "in empty-p.a (p after): DELETE (2)", - content: "dom to edit
", - steps: [{ - start: "p->1", - key: 'DELETE', - }], - test: { - content: "dom to edit
", - start: "p:contents()[0]->0", - }, - }, - { - name: "in p: DELETE at start", - content: "dom to edit
", - steps: [{ - start: "p:contents()[0]->0", - key: 'DELETE', - }], - test: { - content: "om to edit
", // The br is there to ensure the carret can enter the p tag - start: "p:contents()[0]->0", - }, - }, - { - name: "in p: 2x DELETE at start", - content: "dom to edit
", - steps: [{ - start: "p:contents()[0]->0", - key: 'DELETE', - }, { - key: 'DELETE', - }], - test: { - content: "m to edit
", // The br is there to ensure the carret can enter the p tag - start: "p:contents()[0]->0", - }, - }, - { - name: "in p: DELETE within text", - content: "dom to edit
", - steps: [{ - start: "p:contents()[0]->5", - key: 'DELETE', - }], - test: { - content: "dom t edit
", - start: "p:contents()[0]->5", - }, - }, - { - name: "in p: DELETE within text, with space at beginning", - content: "dom to edit
", - steps: [{ - start: "p:contents()[0]->10", - key: 'DELETE', - }], - test: { - content: "dom t edit
", - start: "p:contents()[0]->5", - }, - }, - { - name: "in p: DELETE within text, with one space at beginning", - content: "dom to edit
", - steps: [{ - start: "p:contents()[0]->6", - key: 'DELETE', - }], - test: { - content: "dom t edit
", - start: "p:contents()[0]->6", - }, - }, - { - name: "in p: DELETE within text, with space at end", - content: "dom to edit
", - steps: [{ - start: "p:contents()[0]->5", - key: 'DELETE', - }], - test: { - content: "dom t edit
", - start: "p:contents()[0]->5", - }, - }, - { - name: "in p: DELETE within text, with one space at end", - content: "dom to edit
", - steps: [{ - start: "p:contents()[0]->5", - key: 'DELETE', - }], - test: { - content: "dom t edit
", - start: "p:contents()[0]->5", - }, - }, - { - name: "in p: DELETE within text, with space at beginning and end", - content: "dom to edit
", - steps: [{ - start: "p:contents()[0]->10", - key: 'DELETE', - }], - test: { - content: "dom t edit
", - start: "p:contents()[0]->5", - }, - }, - { - name: "in p: DELETE within text, with one space at beginning and one at end", - content: "dom to edit
", - steps: [{ - start: "p:contents()[0]->6", - key: 'DELETE', - }], - test: { - content: "dom t edit
", - start: "p:contents()[0]->6", - }, - }, - { - name: "in p: DELETE -> 'a' within text, before \\w\\s", - content: "dom t
", - steps: [{ - start: "p:contents()[0]->2", - key: 'DELETE', - }, { - key: 'a', - }], - test: { - content: "doa t
", - start: "p:contents()[0]->3", - }, - }, - { - name: "in pre: DELETE within text, with space at beginning", - content: "dom to edit", - steps: [{ - start: "pre:contents()[0]->10", - key: 'DELETE', - }], - test: { - content: "
dom t edit", - start: "pre:contents()[0]->10", - }, - }, - { - name: "in pre: DELETE within text, with one space at beginning", - content: "
dom to edit", - steps: [{ - start: "pre:contents()[0]->6", - key: 'DELETE', - }], - test: { - content: "
dom t edit", - start: "pre:contents()[0]->6", - }, - }, - { - name: "in pre: DELETE within text, with space at end", - content: "
dom to edit", - steps: [{ - start: "pre:contents()[0]->5", - key: 'DELETE', - }], - test: { - content: "
dom t edit", - start: "pre:contents()[0]->5", - }, - }, - { - name: "in pre: DELETE within text, with one space at end", - content: "
dom to edit", - steps: [{ - start: "pre:contents()[0]->5", - key: 'DELETE', - }], - test: { - content: "
dom t edit", - start: "pre:contents()[0]->5", - }, - }, - { - name: "in pre: DELETE within text, with space at beginning and end", - content: "
dom to edit", - steps: [{ - start: "pre:contents()[0]->10", - key: 'DELETE', - }], - test: { - content: "
dom t edit", - start: "pre:contents()[0]->10", - }, - }, - { - name: "in pre: DELETE within text, with one space at beginning and one at end", - content: "
dom to edit", - steps: [{ - start: "pre:contents()[0]->6", - key: 'DELETE', - }], - test: { - content: "
dom t edit", - start: "pre:contents()[0]->6", - }, - }, - - // list UL / OL - - { - name: "in empty-li (no other li): DELETE (must do nothing)", - content: "
dom not to edit
dom to edit
dom not to edit
", - start: "p:contents()[0]->15", - }, - }, - { - name: "in empty-li (no other li): DELETE -> 'a' (must write into it)", - content: "a
a
a
a
toto
xxx
yyy
tutu
toto
xxxyyy
tutu
toto
xxx
yyy
tutu
toto
xxxyyy
tutu
toto
xxx
yyy
tutu
toto
xxxyyy
tutu
a
domto edit
", - steps: [{ - start: "b:contents()[0]->3", - key: 'DELETE', - }], - test: { - content: "domo edit
", - start: "p:contents(1)->0", - }, - }, - { - name: "in p > span.a (div > span.a after): DELETE at end (must do nothing)", - content: "dom to
dom to
dom to edit
", - steps: [{ - start: "p:contents()[0]->1", - end: "p:contents()[0]->7", - key: 'DELETE', - }], - test: { - content: "dedit
", - start: "p:contents()[0]->1", - }, - }, - { - name: "across 2 p: DELETE on partial selection", - content: "dom
to edit
", - steps: [{ - start: "p:contents()[0]->1", - end: "p:eq(1):contents()[0]->3", - key: 'DELETE', - }], - test: { - content: "dedit
", - start: "p:contents()[0]->1", - }, - }, - { - name: "in p: DELETE on selection of all contents", - content: "dom to edit
", - steps: [{ - start: "p:contents()[0]->0", - end: "p:contents()[0]->11", - key: 'DELETE', - }], - test: { - content: "dom to edit
", - steps: [{ - start: "p:contents()[0]->0", - end: "p:contents()[0]->11", - key: 'DELETE', - }, { - key: 'a', - }], - test: { - content: "a
", - start: "p:contents()[0]->1", - }, - }, - { - name: "in p: DELETE before br", - content: "dom
to edit
dom to edit
", - start: "p:contents()[0]->4", - }, - }, - { - name: "in complex-dom: DELETE on selection of most contents", - content: "dom
to
partiallyremove
doove
", - start: "b:contents()[0]->2", - }, - }, - { - name: "in complex-dom: DELETE on selection of all contents", - content: "dom
to
completelyremove
aaabbb
', - steps: [{ - start: "p:contents()[0]->3", - key: 'DELETE', - }], - test: { - content: 'aaabbb
', - start: "p:contents()[0]->3", - }, - }, - { - name: "in p (hr after): DELETE", - content: 'aaa
bbb
', - steps: [{ - start: "p:eq(0):contents()[0]->3", - key: 'DELETE', - }], - test: { - content: 'aaabbb
', - start: "p:contents()[0]->3", - }, - }, - - // table - - { - name: "in empty-td (td after): DELETE -> 'a' at start", - content: 'a |
dom to edit | dom not to edit |
da to edit | dom not to edit |
dom to edit |
dom o edit |
dom to edit
dom to edit
dom not to edit
dom to editdom to edit
dom not to edit
node to merge
', - steps: [{ - start: 'h1:contents()[0]->18', - key: 'DELETE', - }], - test: { - content: 'node to merge with
node to merge
', - steps: [{ - start: 'p:contents()[0]->18', - key: 'DELETE', - }], - test: { - content: 'node to merge withnode to merge
node to merge with
node to merge
', - steps: [{ - start: 'p:contents()[1]->5', - key: 'DELETE', - }], - test: { - content: 'node to merge withnode to merge
node to merge with
node to merge
', - steps: [{ - start: 'i:contents()[0]->10', - key: 'DELETE', - }], - test: { - content: 'node to merge withnode to merge
dom to
edit
", - steps: [{ - start: "span:contents()[0]->7", - key: 'DELETE', - }], - test: { - content: "dom to edit
", - start: "span:contents()[0]->7", - }, - }, -]; - -var keyboardTestsDeleteDOM = [ - '',
- ' Dear Ready Mat',
- '
',
- ' Here is',
- ' the quotation SO003',
- ' amounting in $ 1,127.50',
- ' from YourCompany.',
- '
',
- ' Do not hesitate to contact us if you have any question.',
- '
',
- '
| ',
- ' Virtual Interior Design On Site ', - ' | ',
- ' ', - ' 10 Hours', - ' | ', - '
toto toto toto
tata
', - }, - }).then(function (wysiwyg) { - var $editable = wysiwyg.getEditable(); - - var $hr = wysiwyg.snippets.$('.oe_snippet_thumbnail:first'); - testUtils.dom.dragAndDrop($hr, $editable.find('p')); - - assert.strictEqual($editable.html().replace(/\s+/g, ' '), - 'toto toto toto
tata
', - "should drop the snippet"); - - testUtils.mock.intercept(wysiwyg, "snippet_focused", function () { - assert.strictEqual($editable.html().replace(/\s+/g, ' '), - 'toto toto toto
tata
', - "should build and focus the snippet"); - - wysiwyg.destroy(); - done(); - }); - }); -}); - -QUnit.test('begin drag&drop must hide popovers', function (assert) { - var done = assert.async(); - assert.expect(2); - - return weTestUtils.createWysiwyg({ - wysiwygOptions: { - snippets: true, - value: - 'test
', - }, - }).then(function (wysiwyg) { - var $editable = wysiwyg.getEditable(); - - $editable.find('.s_hr img').mousedown().click(); - assert.strictEqual($('.note-popover:visible').length, 1, "should display the image popover"); - - var $hr = wysiwyg.snippets.$('.oe_snippet_thumbnail:first'); - testUtils.dom.dragAndDrop($hr, $editable.find('h1'), { - disableDrop: true, - }); - assert.strictEqual($('.note-popover:visible').length, 0, "should hide the image popover"); - testUtils.dom.dragAndDrop($hr, $editable.find('h1'), { - continueMove: true, - }); - - wysiwyg.destroy(); - done(); - }); -}); - -QUnit.test('change size option must hide popovers', function (assert) { - var done = assert.async(); - assert.expect(4); - - return weTestUtils.createWysiwyg({ - wysiwygOptions: { - snippets: true, - value: - 'test
', - }, - }).then(async function (wysiwyg) { - var $editable = wysiwyg.getEditable(); - - await testUtils.dom.click($editable.find('.s_hr img').mousedown()); - assert.strictEqual($('.note-popover:visible').length, 1, "should display the image popover"); - - var $handle = $('#oe_manipulators .o_handle.s'); - testUtils.dom.dragAndDrop($handle, $editable.find('b'), { - disableDrop: true, - }); - assert.ok($handle.hasClass('o_active'), "should active the handle"); - assert.notOk($handle.hasClass('pb32'), "should change the padding bottom"); - assert.strictEqual($('.note-popover:visible').length, 0, "should hide the image popover"); - await testUtils.dom.dragAndDrop($handle, $editable.find('b'), { - continueMove: true, - }); - - wysiwyg.destroy(); - done(); - }); -}); - -QUnit.test('clean the dom before save, after drag&drop', function (assert) { - var done = assert.async(); - assert.expect(1); - - return weTestUtils.createWysiwyg({ - wysiwygOptions: { - snippets: true, - value: 'toto toto toto
tata
', - }, - }).then(function (wysiwyg) { - var $editable = wysiwyg.getEditable(); - - var $hr = wysiwyg.snippets.$('.oe_snippet_thumbnail:first'); - testUtils.dom.dragAndDrop($hr, $editable.find('p')); - - testUtils.mock.intercept(wysiwyg, "snippet_focused", function () { - wysiwyg.save().then(function (result) { - var isDirty = result.isDirty; - var html = result.html; - assert.strictEqual(html.replace(/\s+/g, ' '), - 'toto toto toto
tata
', - "should clean the snippet"); - - wysiwyg.destroy(); - done(); - }); - }); - }); -}); - -QUnit.test('clean the dom before save', function (assert) { - var done = assert.async(); - assert.expect(1); - - return weTestUtils.createWysiwyg({ - wysiwygOptions: { - snippets: true, - value: 'test
', - }, - }).then(function (wysiwyg) { - var $editable = wysiwyg.getEditable(); - - var first = true; - testUtils.mock.intercept(wysiwyg, "snippet_focused", function () { - if (first) { - first = false; - var $hr = $('#oe_manipulators .oe_overlay_options .oe_snippet_move'); - testUtils.dom.dragAndDrop($hr, $editable.find('b')); - } else { - wysiwyg.save().then(function (result) { - assert.strictEqual(result.html.replace(/\s+/g, ' '), - 'test
', - "should move the snippet on the bottom"); - - wysiwyg.destroy(); - done(); - }); - } - }); - - $editable.find('.s_hr').mousedown().click(); - }); -}); - -QUnit.test('clone a snippet', function (assert) { - var done = assert.async(); - assert.expect(2); - - return weTestUtils.createWysiwyg({ - wysiwygOptions: { - snippets: true, - value: 'test
', - }, - }).then(async function (wysiwyg) { - var $editable = wysiwyg.getEditable(); - - testUtils.mock.intercept(wysiwyg, "snippet_focused", async function () { - await testUtils.dom.click($('#oe_manipulators .oe_overlay_options .oe_snippet_clone')); - - assert.strictEqual($editable.html().replace(/\s+/g, ' '), - 'test
', - "should duplicate the snippet"); - - wysiwyg.save().then(function (result) { - assert.strictEqual(result.html.replace(/\s+/g, ' '), - 'test
', - "should duplicate the snippet"); - - wysiwyg.destroy(); - done(); - }); - }); - - await testUtils.dom.click($editable.find('.s_hr').mousedown()); - }); -}); - -QUnit.test('customize snippet', function (assert) { - var done = assert.async(); - assert.expect(2); - - return weTestUtils.createWysiwyg({ - wysiwygOptions: { - snippets: true, - value: 'test
', - }, - }).then(function (wysiwyg) { - var $editable = wysiwyg.getEditable(); - - testUtils.mock.intercept(wysiwyg, "snippet_focused", function () { - $('#oe_manipulators .oe_overlay_options .oe_options a:first').click(); - var $option = $('#oe_manipulators .oe_overlay_options a[data-select-class="align-items-center"]'); - - // assert.strictEqual($option.size(), 1, "should display the snippet option"); - - $option.click(); - - assert.strictEqual($editable.html().replace(/\s+/g, ' '), - 'test
', - "should customized the snippet"); - - $('#oe_manipulators .oe_overlay_options .oe_options a:first').click(); - $('#oe_manipulators .oe_overlay_options a[data-select-class="align-items-end"]').click(); - - assert.strictEqual($editable.html().replace(/\s+/g, ' '), - 'test
', - "should twice customized the snippet"); - - wysiwyg.destroy(); - done(); - }); - - $editable.find('.s_hr').mousedown().click(); - }); -}); - -QUnit.test('background-image', function (assert) { - var done = assert.async(); - assert.expect(2); - - return weTestUtils.createWysiwyg({ - wysiwygOptions: { - snippets: true, - value: - 'Content
' + - 'dom not to edit
dom to edit
', - start: 'p:eq(1):contents()[0]->1', - do: async function () { - await testUtils.dom.triggerEvents($dropdownStyle, ['mousedown', 'click']); - await testUtils.dom.triggerEvents($btnsStyle.find('h1'), ['mousedown', 'click']); - }, - test: { - content: 'dom not to edit
dom not to edit
dom not to edit
dom to edit', - start: 'pre:contents()[0]->0', - end: 'pre:contents()[0]->11', - }, - }, - { - name: "Click NORMAL: pre -> p", - content: '
dom not to edit
dom to edit', - start: 'pre:contents()[0]->1', - do: async function () { - await testUtils.dom.triggerEvents($dropdownStyle, ['mousedown', 'click']); - await testUtils.dom.triggerEvents($btnsStyle.find('p'), ['mousedown', 'click']); - }, - test: { - content: '
dom not to edit
dom to edit
', - start: 'p:eq(1):contents()[0]->0', - end: 'p:eq(1):contents()[0]->11', - }, - }, - { - name: "Click H1 in empty p: empty p -> empty h1", - content: 'dom not to edit
dom to edit
', - start: 'p:eq(1):contents()[0]->1', - end: 'p:eq(1):contents()[0]->5', - do: async function () { - await testUtils.dom.triggerEvents($btnBold, ['mousedown', 'click']); - }, - test: { - content: 'dom not to edit
dom to edit
', - start: 'b:contents()[0]->0', - end: 'b:contents()[0]->4', - }, - }, - { - name: "Click BOLD then 'a': normal -> bold (empty p)", - content: 'a
', - start: 'b:contents()[0]->1', - }, - }, - { - name: "Click BOLD: normal -> bold (across paragraphs)", - content: 'dom to edit
dom to edit
', - start: 'p:contents()[0]->1', - end: 'p:eq(1):contents()[0]->5', - do: async function () { - await testUtils.dom.triggerEvents($btnBold, ['mousedown', 'click']); - }, - test: { - content: 'dom to edit
dom to edit
', - start: 'b:contents()[0]->0', - end: 'b:eq(1):contents()[0]->5', - }, - }, - { - name: "Click BOLD then 'a': normal -> bold (no selection)", - content: 'dom not to edit
dom to edit
', - start: 'p:eq(1):contents()[0]->4', - do: async function () { - await testUtils.dom.triggerEvents($btnBold, ['mousedown', 'click']); - weTestUtils.keydown('a', $editable); - }, - test: { - content: 'dom not to edit
dom ato edit
', - start: 'b:contents()[0]->1', - }, - }, - { - name: "Click BOLD: bold -> normal", - content: 'dom not to edit
dom to edit
', - start: 'b:contents()[0]->0', - end: 'b:contents()[0]->11', - do: async function () { - await testUtils.dom.triggerEvents($btnBold, ['mousedown', 'click']); - }, - test: { - content: 'dom not to edit
dom to edit
', - start: 'p:eq(1):contents()[0]->0', - end: 'p:eq(1):contents()[0]->11', - }, - }, - { - name: "Click BOLD: bold -> normal (partial selection)", - content: 'dom not to edit
dom to edit
', - start: 'b:contents()[0]->4', - end: 'b:contents()[0]->6', - do: async function () { - await testUtils.dom.triggerEvents($btnBold, ['mousedown', 'click']); - }, - test: { - content: 'dom not to edit
dom to edit
', - start: 'p:eq(1):contents()[1]->0', - end: 'p:eq(1):contents()[1]->2', - }, - }, - { - name: "Click BOLD: bold -> normal (no selection)", - content: 'dom not to edit
dom to edit
', - start: 'b:contents()[0]->4', - do: async function () { - await testUtils.dom.triggerEvents($btnBold, ['mousedown', 'click']); - }, - test: { - content: 'dom not to edit
dom \u200Bto edit
', - start: 'p:eq(1):contents()[1]->1', - }, - }, - { - name: "Click BOLD: bold + normal -> normal", - content: 'dom to edit
', - start: 'b:contents()[0]->1', - end: 'p:contents()[1]->4', - do: async function () { - await testUtils.dom.triggerEvents($btnBold, ['mousedown', 'click']); - }, - test: { - content: 'dom to edit
', - start: 'b:contents()[0]->1', - end: 'b:contents()[0]->8', - }, - }, - { - name: "Click BOLD: normal -> bold (with fontawesome)", - content: 'aaabbb
', - start: 'p:contents()[0]->1', - end: 'p:contents()[2]->2', - do: async function () { - await testUtils.dom.triggerEvents($btnBold, ['mousedown', 'click']); - }, - test: { - content: 'aaabbb
', - start: 'b:contents()[0]->0', - end: 'b:contents()[2]->2', - }, - }, - { - name: "Click BOLD + click BOLD: normal -> bold -> normal (with fontawesome)", - content: 'aaabbb
', - start: 'p:contents()[0]->1', - end: 'p:contents()[2]->2', - do: async function () { - await testUtils.dom.triggerEvents($btnBold, ['mousedown', 'click']); - await testUtils.dom.triggerEvents($btnBold, ['mousedown', 'click']); - }, - test: { - content: 'aaabbb
', - start: 'p:contents()[0]->1', - end: 'p:contents()[2]->2', - }, - }, - { - name: "Click BOLD: bold -> normal (with fontawesome)", - content: 'aaabbb
', - start: 'b:contents()[0]->1', - end: 'b:contents()[2]->2', - do: async function () { - await testUtils.dom.triggerEvents($btnBold, ['mousedown', 'click']); - }, - test: { - content: 'aaabbb
', - start: 'p:contents()[1]->0', - end: 'p:contents()[3]->2', - }, - }, - { - name: "Click BOLD: bold -> normal (at start of dom)", - content: 'abc
', - start: 'b:contents()[0]->0', - do: function () { - $btnBold.mousedown().click(); - }, - test: { - content: '\u200Babc
', - start: 'p:contents()[0]->1', - end: 'p:contents()[0]->1', - }, - }, - /* ITALIC */ - { - name: "Click ITALIC: bold -> bold + italic", - content: 'dom not to edit
dom to edit
', - start: 'b:contents()[0]->1', - end: 'b:contents()[0]->5', - do: async function () { - await testUtils.dom.triggerEvents($btnItalic, ['mousedown', 'click']); - }, - test: { - content: 'dom not to edit
dom to edit
', - start: 'i:contents()[0]->0', - end: 'i:contents()[0]->4', - }, - }, - { - name: "Click ITALIC: bold & normal -> italic & bold + italic (across paragraphs)", - content: 'dom to edit
dom to edit
', - start: 'p:contents()[0]->1', - end: 'b:eq(1):contents()[0]->5', - do: async function () { - await testUtils.dom.triggerEvents($btnItalic, ['mousedown', 'click']); - }, - test: { - content: 'dom to edit
dom to edit
', - start: 'i:contents()[0]->0', - end: 'i:eq(1):contents()[0]->5', - }, - }, - /* UNDERLINE */ - { - name: "Click UNDERLINE: bold -> bold + underlined", - content: 'dom not to edit
dom to edit
', - start: 'b:contents()[0]->1', - end: 'b:contents()[0]->5', - do: async function () { - await testUtils.dom.triggerEvents($btnUnderline, ['mousedown', 'click']); - }, - test: { - content: 'dom not to edit
dom to edit
', - start: 'u:contents()[0]->0', - end: 'u:contents()[0]->4', - }, - }, - { - name: "Click UNDERLINE: bold & normal -> underlined & bold + underlined (across paragraphs)", - content: 'dom to edit
dom to edit
', - start: 'p:contents()[0]->1', - end: 'b:eq(1):contents()[0]->5', - do: async function () { - await testUtils.dom.triggerEvents($btnUnderline, ['mousedown', 'click']); - }, - test: { - content: 'dom to edit
dom to edit
', - start: 'u:contents()[0]->0', - end: 'u:eq(1):contents()[0]->5', - }, - }, - /* strikethrough */ - { - name: "Click strikethrough: bold -> bold + strikethrough", - content: 'dom not to edit
dom to edit
', - start: 'b:contents()[0]->1', - end: 'b:contents()[0]->5', - do: async function () { - await testUtils.dom.triggerEvents($strikethrough, ['mousedown', 'click']); - }, - test: { - content: 'dom not to edit
dom to edit
dom to edit
dom to edit
', - start: 'p:contents()[0]->1', - end: 'b:eq(1):contents()[0]->5', - do: async function () { - await testUtils.dom.triggerEvents($strikethrough, ['mousedown', 'click']); - }, - test: { - content: 'dom to edit
dom to edit
dom not to edit
dom to edit
', - start: 'b:contents()[0]->1', - end: 'b:contents()[0]->5', - do: async function () { - await testUtils.dom.triggerEvents($superscript, ['mousedown', 'click']); - }, - test: { - content: 'dom not to edit
dom to edit
', - start: 'sup:contents()[0]->0', - end: 'sup:contents()[0]->4', - }, - }, - { - name: "Click superscript: bold & normal -> superscript & bold + superscript (across paragraphs)", - content: 'dom to edit
dom to edit
', - start: 'p:contents()[0]->1', - end: 'b:eq(1):contents()[0]->5', - do: async function () { - await testUtils.dom.triggerEvents($superscript, ['mousedown', 'click']); - }, - test: { - content: 'dom to edit
dom to edit
', - start: 'sup:contents()[0]->0', - end: 'sup:eq(1):contents()[0]->5', - }, - }, - /* subscript */ - { - name: "Click subscript: bold -> bold + subscript", - content: 'dom not to edit
dom to edit
', - start: 'b:contents()[0]->1', - end: 'b:contents()[0]->5', - do: async function () { - await testUtils.dom.triggerEvents($subscript, ['mousedown', 'click']); - }, - test: { - content: 'dom not to edit
dom to edit
', - start: 'sub:contents()[0]->0', - end: 'sub:contents()[0]->4', - }, - }, - { - name: "Click subscript: bold & normal -> subscript & bold + subscript (across paragraphs)", - content: 'dom to edit
dom to edit
', - start: 'p:contents()[0]->1', - end: 'b:eq(1):contents()[0]->5', - do: async function () { - await testUtils.dom.triggerEvents($subscript, ['mousedown', 'click']); - }, - test: { - content: 'dom to edit
dom to edit
', - start: 'sub:contents()[0]->0', - end: 'sub:eq(1):contents()[0]->5', - }, - }, - /* REMOVE FONT STYLE */ - { - name: "Click REMOVE FONT STYLE: bold -> normal", - content: 'dom not to edit
dom to edit
', - start: 'b:contents()[0]->1', - end: 'b:contents()[0]->5', - do: async function () { - await testUtils.dom.triggerEvents($btnRemoveStyles, ['mousedown', 'click']); - }, - test: { - content: 'dom not to edit
dom to edit
', - start: 'p:eq(1):contents()[1]->0', - end: 'p:eq(1):contents()[1]->4', - }, - }, - { - name: "Click REMOVE FONT STYLE: bold, italic, underlined & normal -> normal (across paragraphs)", - content: 'dom to edit
dom to edit
', - start: 'p:contents()[0]->1', - end: 'u:eq(1):contents()[0]->3', - do: async function () { - await testUtils.dom.triggerEvents($btnRemoveStyles, ['mousedown', 'click']); - }, - test: { - content: 'dom to edit
dom to edit
', - start: 'p:contents()[0]->1', - end: 'p:eq(1):contents()[0]->3', - }, - }, - { - name: "Click REMOVE FONT STYLE: complex -> normal", - content: 'aaabbb
ccc
', - start: 'p:contents()[0]->1', - end: 'font:eq(1):contents()[0]->1', - do: async function () { - await testUtils.dom.triggerEvents($btnRemoveStyles, ['mousedown', 'click']); - }, - test: { - content: 'aaabbb
ccc
', - start: 'p:contents()[0]->1', - end: 'p:eq(1):contents()[0]->1', - }, - }, - { - name: "Click REMOVE FONT STYLE: complex -> normal (with icon)", - content: 'aaabbb
', - start: 'p:contents()[0]->0', - end: 'i:contents()[0]->1', - do: async function () { - await testUtils.dom.triggerEvents($btnRemoveStyles, ['mousedown', 'click']); - }, - test: { - content: 'aaabbb
', - start: 'p:contents()[0]->0', - end: 'p:contents()[2]->2', - }, - }, - /* COMPLEX */ - { - name: "COMPLEX Click BOLD: italic -> italic bold (partial selection)", - content: 'dom not to edit
dom to edit
', - start: 'i:contents()[0]->1', - end: 'i:contents()[0]->5', - do: async function () { - await testUtils.dom.triggerEvents($btnBold, ['mousedown', 'click']); - }, - test: { - content: 'dom not to edit
dom to edit
', - start: 'b:contents()[0]->0', - end: 'b:contents()[0]->4', - }, - }, - { - name: "COMPLEX Click BOLD then 'a': italic bold -> italic (across paragraphs)", - content: 'dom to edit
dom to edit
', - start: 'i:contents()[0]->1', - end: 'b:eq(1):contents()[0]->5', - do: async function () { - await testUtils.dom.triggerEvents($btnBold, ['mousedown', 'click']); - weTestUtils.keydown('a', $editable, { - firstDeselect: true, - }); - }, - test: { - content: 'dom to edit
dom tao edit
', - }, - }, - { - name: "COMPLEX Click BOLD then 'a': bold italic -> italic (no selection)", - content: 'dom to edit
', - start: 'i:contents()[0]->4', - do: async function () { - await testUtils.dom.triggerEvents($btnBold, ['mousedown', 'click']); - weTestUtils.keydown('a', $editable, { - firstDeselect: true, - }); - }, - test: { - content: 'dom ato edit
', - }, - }, - { - name: "COMPLEX Click BOLD then 'a': underlined italic -> underlined italic bold (across paragraphs)", - content: 'dom to edit
dom to edit
', - start: 'i:contents()[0]->1', - end: 'u:eq(1):contents()[0]->5', - do: async function () { - await testUtils.dom.triggerEvents($btnBold, ['mousedown', 'click']); - weTestUtils.keydown('a', $editable, { - firstDeselect: true, - }); - }, - test: { - content: 'dom to edit
dom tao edit
', - }, - }, - { - name: "COMPLEX Click BOLD then 'a': underlined italic -> underlined italic bold (no selection)", - content: 'dom to edit
', - start: 'i:contents()[0]->1', - do: async function () { - await testUtils.dom.triggerEvents($btnBold, ['mousedown', 'click']); - weTestUtils.keydown('a', $editable, { - firstDeselect: true, - }); - }, - test: { - content: 'daom to edit
', - }, - }, - ]; - - var def = Promise.resolve(); - _.each(styleTests, function (test) { - def = def.then(async function() { - testName = test.name; - wysiwyg.setValue(test.content); - test.end = test.end || test.start; - var range = weTestUtils.select(test.start, test.end, $editable); - Wysiwyg.setRange(range.sc, range.so, range.ec, range.eo); - await test.do(); - assert.deepEqual(wysiwyg.getValue(), test.test.content, testName); - $editable[0].normalize(); - if (test.test.start) { - test.test.end = test.test.end || test.test.start; - assert.deepEqual(Wysiwyg.getRange($editable[0]), weTestUtils.select(test.test.start, test.test.end, $editable), testName + carretTestSuffix); - } - }); - }); - - return def.then(function() { - wysiwyg.destroy(); - }); - }); -}); - -QUnit.test('Font size', function (assert) { - assert.expect(10); - - return weTestUtils.createWysiwyg({ - debug: false, - wysiwygOptions: { - - }, - }).then(function (wysiwyg) { - var $editable = wysiwyg.$('.note-editable'); - - var $dropdownFontSize = wysiwyg.$('.note-fontsize .dropdown-toggle'); - var $linksFontSize = wysiwyg.$('.note-fontsize .dropdown-menu .dropdown-item'); - - var sizeTests = [{ - name: "Click 18: default -> 18px", - content: 'dom not to edit
dom to edit
', - start: 'p:eq(1):contents()[0]->1', - end: 'p:eq(1):contents()[0]->5', - do: async function () { - await testUtils.dom.triggerEvents($dropdownFontSize, ['mousedown', 'click']); - await testUtils.dom.triggerEvents($linksFontSize.filter(':contains("18")'), ['mousedown', 'click']); - }, - test: { - content: 'dom not to edit
dom to edit
', - start: 'font:contents()[0]->0', - end: 'font:contents()[0]->4', - }, - }, - { - name: "Click DEFAULT: 18px -> default", - content: 'dom not to edit
dom to edit
', - start: 'font:contents()[0]->1', - end: 'font:contents()[0]->5', - do: async function () { - await testUtils.dom.triggerEvents($dropdownFontSize, ['mousedown', 'click']); - await testUtils.dom.triggerEvents($linksFontSize.filter(':contains("Default")'), ['mousedown', 'click']); - }, - test: { - content: 'dom not to edit
dom to edit
', - start: 'p:eq(1):contents()[1]->0', - end: 'p:eq(1):contents()[1]->4', - }, - }, - { - name: "Click 18: 26px -> 18px", - content: 'dom to edit
', - start: 'font:contents()[0]->1', - end: 'font:contents()[0]->5', - do: async function () { - await testUtils.dom.triggerEvents($dropdownFontSize, ['mousedown', 'click']); - await testUtils.dom.triggerEvents($linksFontSize.filter(':contains("18")'), ['mousedown', 'click']); - }, - test: { - content: '' + - 'd' + - 'om t' + - 'o edit
', - start: 'font:eq(1):contents()[0]->0', - end: 'font:eq(1):contents()[0]->4', - }, - }, - { - name: "Click 18 then 'a' (no selection): default -> 18px", - content: 'dom not to edit
dom to edit
', - start: 'p:eq(1):contents()[0]->1', - do: async function () { - await testUtils.dom.triggerEvents($dropdownFontSize, ['mousedown', 'click']); - await testUtils.dom.triggerEvents($linksFontSize.filter(':contains("18")'), ['mousedown', 'click']); - weTestUtils.keydown('a', $editable, { - firstDeselect: true, - }); - }, - test: { - content: 'dom not to edit
daom to edit
', - start: 'font:contents()[0]->1', - }, - }, - { - name: "Click 18 then 'a' (no selection): 26px -> 18px", - content: 'dom to edit
', - start: 'font:contents()[0]->1', - do: async function () { - await testUtils.dom.triggerEvents($dropdownFontSize, ['mousedown', 'click']); - await testUtils.dom.triggerEvents($linksFontSize.filter(':contains("18")'), ['mousedown', 'click']); - weTestUtils.keydown('a', $editable, { - firstDeselect: true, - }); - }, - test: { - content: '' + - 'd' + - 'a' + - 'om to edit
', - start: 'font:eq(1):contents()[0]->1', - }, - }, - ]; - - var def = Promise.resolve(); - _.each(sizeTests, function (test) { - def = def.then(async function() { - testName = test.name; - wysiwyg.setValue(test.content); - var range = weTestUtils.select(test.start, test.end, $editable); - Wysiwyg.setRange(range.sc, range.so, range.ec, range.eo); - await test.do(); - assert.deepEqual(wysiwyg.getValue(), test.test.content, testName); - assert.deepEqual(Wysiwyg.getRange($editable[0]), weTestUtils.select(test.test.start, test.test.end, $editable), testName + carretTestSuffix); - }); - }); - - return def.then(function() { - wysiwyg.destroy(); - }); - }); -}); - -QUnit.test('Text forecolor', function (assert) { - assert.expect(40); - - return weTestUtils.createWysiwyg({ - debug: false, - wysiwygOptions: { - - }, - }).then(function (wysiwyg) { - var $editable = wysiwyg.$('.note-editable'); - - var $dropdownForeColor = wysiwyg.$('.note-color .note-fore-color .dropdown-toggle'); - var $btnsForeColor = wysiwyg.$('.note-color .note-fore-color .dropdown-menu .note-palette .note-color-btn'); - var forecolorTests = [{ - name: "Click THEME COLORS - ALPHA: default -> alpha theme color", - content: 'dom not to edit
dom to edit
', - start: 'p:eq(1):contents()[0]->1', - end: 'p:eq(1):contents()[0]->5', - do: async function () { - await testUtils.dom.triggerEvents($dropdownForeColor, ['mousedown', 'click']); - await testUtils.dom.triggerEvents($btnsForeColor.filter('.bg-alpha'), ['mousedown', 'click']); - }, - test: { - content: 'dom not to edit
dom to edit
', - start: 'font:contents()[0]->0', - end: 'font:contents()[0]->4', - }, - }, - { - name: "Click THEME COLORS - BLACK 25: alpha theme color & default -> black 25", - content: 'dom not to edit
dom to edit
', - start: 'p:eq(1):contents()[0]->1', - end: 'font:contents()[0]->3', - do: async function () { - await testUtils.dom.triggerEvents($dropdownForeColor, ['mousedown', 'click']); - await testUtils.dom.triggerEvents($btnsForeColor.filter('.bg-black-25'), ['mousedown', 'click']); - }, - test: { - content: 'dom not to edit
dom to edit
', - start: 'font:contents()[0]->0', - end: 'font:contents()[0]->4', - }, - }, - { - name: "Click COMMON COLORS - BLUE #0000FF: black 25 & default -> blue #0000FF", - content: 'dom not to edit
dom to edit
', - start: 'p:eq(1):contents()[0]->1', - end: 'font:contents()[0]->3', - do: async function () { - await testUtils.dom.triggerEvents($dropdownForeColor, ['mousedown', 'click']); - await testUtils.dom.triggerEvents($btnsForeColor.filter('[style="background-color:#0000FF"]'), ['mousedown', 'click']); - }, - test: { - content: 'dom not to edit
dom to edit
', - start: 'font:contents()[0]->0', - end: 'font:contents()[0]->4', - }, - }, - { - name: "Click RESET TO DEFAULT: black 25 & default -> default", - content: 'dom not to edit
dom to edit
', - start: 'p:eq(1):contents()[0]->1', - end: 'font:contents()[0]->3', - do: async function () { - await testUtils.dom.triggerEvents($dropdownForeColor, ['mousedown', 'click']); - await testUtils.dom.triggerEvents($btnsForeColor.filter('.note-color-reset'), ['mousedown', 'click']); - }, - test: { - content: 'dom not to edit
dom to edit
', - start: 'p:eq(1):contents()[0]->1', - end: 'p:eq(1):contents()[0]->5', - }, - }, - { - name: "Click CUSTOM COLORS then CUSTOM COLOR: blue #0000FF & default -> #875A7B", - async: true, - content: 'dom not to edit
dom to edit
', - start: 'p:eq(1):contents()[0]->1', - end: 'font:contents()[0]->3', - do: async function () { - var self = this; - - await testUtils.dom.triggerEvents($dropdownForeColor, ['mousedown', 'click']); - await testUtils.dom.triggerEvents(wysiwyg.$('.note-color .note-fore-color .note-custom-color'), ['mousedown', 'click']); - - $('.modal-dialog .o_hex_input').val('#875A7B').change(); - await testUtils.dom.triggerEvents($('.o_technical_modal .modal-footer .btn-primary:contains("Choose")'), ['mousedown', 'click']); - await testUtils.dom.triggerEvents(wysiwyg.$('.note-color .note-fore-color .note-custom-color-btn:last'), ['mousedown', 'click']); - - assert.deepEqual(wysiwyg.getValue(), - 'dom not to edit
dom to edit
', - self.name); - var range = weTestUtils.select('font:contents()[0]->0', 'font:contents()[0]->4', $editable); - assert.deepEqual(Wysiwyg.getRange($editable[0]), range, self.name + carretTestSuffix); - }, - }, - { - name: "Click CUSTOM COLORS then CUSTOM COLOR: change blue input", - content: 'dom to edit
', - start: 'p:contents()[0]->1', - end: 'p:contents()[0]->6', - do: async function () { - var self = this; - - await testUtils.dom.triggerEvents($dropdownForeColor, ['mousedown', 'click']); - await testUtils.dom.triggerEvents(wysiwyg.$('.note-color .note-fore-color .note-custom-color'), ['mousedown', 'click']); - - $('.modal-dialog .o_blue_input').val('100').change(); - - assert.deepEqual($('.modal-dialog .o_hex_input').val(), '#ff0064', self.name + ' (hex)'); - assert.deepEqual($('.modal-dialog .o_hue_input').val(), '337', self.name + ' (hue)'); - - await testUtils.dom.triggerEvents($('.o_technical_modal .modal-footer .btn-primary:contains("Choose")'), ['mousedown', 'click']); - await testUtils.dom.triggerEvents(wysiwyg.$('.note-color .note-fore-color .note-custom-color-btn:last'), ['mousedown', 'click']); - }, - test: { - content: 'dom to edit
', - start: 'font:contents()[0]->0', - end: 'font:contents()[0]->5', - }, - }, - { - name: "CUSTOM COLOR: change hue, saturation and lightness inputs", - content: 'dom to edit
', - start: 'p:contents()[0]->1', - end: 'p:contents()[0]->6', - do: async function () { - var self = this; - - await testUtils.dom.triggerEvents($dropdownForeColor, ['mousedown', 'click']); - await testUtils.dom.triggerEvents(wysiwyg.$('.note-color .note-fore-color .note-custom-color'), ['mousedown', 'click']); - - $('.modal-dialog .o_hue_input').val('337').change(); - $('.modal-dialog .o_saturation_input').val('50').change(); - $('.modal-dialog .o_lightness_input').val('40').change(); - - assert.deepEqual($('.modal-dialog .o_hex_input').val(), '#99335a', self.name + ' (hex)'); - assert.deepEqual($('.modal-dialog .o_green_input').val(), '51', self.name + ' (green)'); - - await testUtils.dom.triggerEvents($('.o_technical_modal .modal-footer .btn-primary:contains("Choose")'), ['mousedown', 'click']); - await testUtils.dom.triggerEvents(wysiwyg.$('.note-color .note-fore-color .note-custom-color-btn:last'), ['mousedown', 'click']); - }, - test: { - content: 'dom to edit
', - start: 'font:contents()[0]->0', - end: 'font:contents()[0]->5', - }, - }, - { - name: "CUSTOM COLOR: mousedown on area", - content: 'dom to edit
', - start: 'p:contents()[0]->1', - end: 'p:contents()[0]->6', - do: async function () { - var self = this; - - await testUtils.dom.triggerEvents($dropdownForeColor, ['mousedown', 'click']); - await testUtils.dom.triggerEvents(wysiwyg.$('.note-color .note-fore-color .note-custom-color'), ['mousedown', 'click']); - - var $area = $('.modal-dialog .o_color_pick_area'); - var pos = $area.offset(); - $area.trigger($.Event("mousedown", { - which: 1, - pageX: pos.left + 50, - pageY: pos.top + 50 - })); - $area.trigger('mouseup'); - - assert.deepEqual($('.modal-dialog .o_hex_input').val(), '#cfafaf', self.name + ' (hex)'); - assert.deepEqual($('.modal-dialog .o_red_input').val(), '207', self.name + ' (red)'); - assert.deepEqual($('.modal-dialog .o_green_input').val(), '175', self.name + ' (green)'); - assert.deepEqual($('.modal-dialog .o_blue_input').val(), '175', self.name + ' (blue)'); - assert.deepEqual($('.modal-dialog .o_hue_input').val(), '0', self.name + ' (hue)'); - assert.deepEqual($('.modal-dialog .o_saturation_input').val(), '25', self.name + ' (saturation)'); - assert.deepEqual($('.modal-dialog .o_lightness_input').val(), '75', self.name + ' (lightness)'); - - await testUtils.dom.triggerEvents($('.o_technical_modal .modal-footer .btn-primary:contains("Choose")'), ['mousedown', 'click']); - await testUtils.dom.triggerEvents(wysiwyg.$('.note-color .note-fore-color .note-custom-color-btn:last'), ['mousedown', 'click']); - }, - test: { - content: 'dom to edit
', - start: 'font:contents()[0]->0', - end: 'font:contents()[0]->5', - }, - }, - { - name: "CUSTOM COLOR: mousedow on sliders", - content: 'dom to edit
', - start: 'p:contents()[0]->1', - end: 'p:contents()[0]->6', - do: async function () { - var self = this; - - await testUtils.dom.triggerEvents($dropdownForeColor, ['mousedown', 'click']); - await testUtils.dom.triggerEvents(wysiwyg.$('.note-color .note-fore-color .note-custom-color'), ['mousedown', 'click']); - - var $slider1 = $('.modal-dialog .o_slider_pointer'); - var pos1 = $slider1.offset(); - $slider1.trigger($.Event("mousedown", { - which: 1, - pageX: pos1.left, - pageY: pos1.top + 50 - })); - $slider1.trigger('mouseup'); - - assert.deepEqual($('.modal-dialog .o_hex_input').val(), '#83ff00', self.name + ' (hex)'); - - var $slider2 = $('.modal-dialog .o_opacity_slider'); - var pos2 = $slider2.offset(); - $slider2.trigger($.Event("mousedown", { - which: 1, - pageX: pos2.left, - pageY: pos2.top + 80 - })); - $slider2.trigger('mouseup'); - - assert.deepEqual($('.modal-dialog .o_hue_input').val(), '89', self.name + ' (hue)'); - assert.deepEqual($('.modal-dialog .o_opacity_input').val(), '60', self.name + ' (opacity)'); - - await testUtils.dom.triggerEvents($('.o_technical_modal .modal-footer .btn-primary:contains("Choose")'), ['mousedown', 'click']); - await testUtils.dom.triggerEvents(wysiwyg.$('.note-color .note-fore-color .note-custom-color-btn:last'), ['mousedown', 'click']); - }, - test: { - content: 'dom to edit
', - start: 'font:contents()[0]->0', - end: 'font:contents()[0]->5', - }, - }, - { - name: "Apply a color on a fontawesome", - content: 'dom not to edit
', - start: 'i->0', - do: async function () { - await testUtils.dom.triggerEvents($dropdownForeColor, ['mousedown', 'click']); - await testUtils.dom.triggerEvents($btnsForeColor.filter('[style="background-color:#0000FF"]'), ['mousedown', 'click']); - }, - test: { - content: 'dom not to edit
', - start: 'p->2', - }, - }, - { - name: "Apply a color on a font with text", - content: 'dom not to edit
', - start: 'p:contents()[0]->1', - end: 'p:contents()[2]->6', - do: async function () { - await testUtils.dom.triggerEvents($dropdownForeColor, ['mousedown', 'click']); - await testUtils.dom.triggerEvents($btnsForeColor.filter('[style="background-color:#0000FF"]'), ['mousedown', 'click']); - }, - test: { - content: 'dom not to edit
', - start: 'font:eq(0):contents()[0]->0', - end: 'font:eq(1):contents()[0]->6', - }, - }, - { - name: "Apply color, then 'a' (no selection)", - content: 'dom not to edit
', - start: 'p:contents()[0]->1', - do: async function () { - await testUtils.dom.triggerEvents($dropdownForeColor, ['mousedown', 'click']); - await testUtils.dom.triggerEvents($btnsForeColor.filter('[style="background-color:#0000FF"]'), ['mousedown', 'click']); - weTestUtils.keydown('a', $editable, { - firstDeselect: true, - }); - }, - test: { - content: 'daom not to edit
', - start: 'font:contents()[0]->1', - }, - }, - { - name: "Apply color on two ranges with the same color", - content: 'do
m not to edit
do
m not to edit
dom not to edit
dom to edit
', - start: 'p:eq(1):contents()[0]->1', - end: 'p:eq(1):contents()[0]->5', - do: async function () { - await testUtils.dom.triggerEvents($dropdownBgColor, ['mousedown', 'click']); - await testUtils.dom.triggerEvents($btnsBgColor.filter('.bg-alpha'), ['mousedown', 'click']); - }, - test: { - content: 'dom not to edit
dom to edit
', - start: 'font:contents()[0]->0', - end: 'font:contents()[0]->4', - }, - }, - { - name: "Click THEME COLORS - BLACK 25: alpha theme color & default -> black 25", - content: 'dom not to edit
dom to edit
', - start: 'p:eq(1):contents()[0]->1', - end: 'font:contents()[0]->3', - do: async function () { - await testUtils.dom.triggerEvents($dropdownBgColor, ['mousedown', 'click']); - await testUtils.dom.triggerEvents($btnsBgColor.filter('.bg-black-25'), ['mousedown', 'click']); - }, - test: { - content: 'dom not to edit
dom to edit
', - start: 'font:contents()[0]->0', - end: 'font:contents()[0]->4', - }, - }, - { - name: "Click COMMON COLORS - BLUE #0000FF: black 25 & default -> blue #0000FF", - content: 'dom not to edit
dom to edit
', - start: 'p:eq(1):contents()[0]->1', - end: 'font:contents()[0]->3', - do: async function () { - await testUtils.dom.triggerEvents($dropdownBgColor, ['mousedown', 'click']); - await testUtils.dom.triggerEvents($btnsBgColor.filter('[style="background-color:#0000FF"]'), ['mousedown', 'click']); - }, - test: { - content: 'dom not to edit
dom to edit
', - start: 'font:contents()[0]->0', - end: 'font:contents()[0]->4', - }, - }, - { - name: "Click RESET TO DEFAULT: black 25 & default -> default", - content: 'dom not to edit
dom to edit
', - start: 'p:eq(1):contents()[0]->1', - end: 'font:contents()[0]->3', - do: async function () { - await testUtils.dom.triggerEvents($dropdownBgColor, ['mousedown', 'click']); - await testUtils.dom.triggerEvents($btnsBgColor.filter('.note-color-reset'), ['mousedown', 'click']); - }, - test: { - content: 'dom not to edit
dom to edit
', - start: 'p:eq(1):contents()[0]->1', - end: 'p:eq(1):contents()[0]->5', - }, - }, - { - name: "Click CUSTOM COLORS then CUSTOM COLOR: blue #0000FF & default -> #875A7B", - content: 'dom not to edit
dom to edit
', - start: 'p:eq(1):contents()[0]->1', - end: 'font:contents()[0]->3', - async: true, - do: async function () { - testName = "Click CUSTOM COLORS then CUSTOM COLOR: blue #0000FF & default -> #875A7B"; - - await testUtils.dom.triggerEvents($dropdownBgColor, ['mousedown', 'click']); - await testUtils.dom.triggerEvents(wysiwyg.$('.note-color .note-bg-color .note-custom-color'), ['mousedown', 'click']); - await testUtils.fields.editAndTrigger($('.modal-dialog .o_hex_input'), '#875A7B', 'change'); - await testUtils.dom.triggerEvents($('.o_technical_modal .modal-footer .btn-primary:contains("Choose")'), ['mousedown', 'click']); - await testUtils.dom.triggerEvents(wysiwyg.$('.note-color .note-bg-color .note-custom-color-btn:last'), ['mousedown', 'click']); - - assert.deepEqual(wysiwyg.getValue(), - 'dom not to edit
dom to edit
', - testName); - var range = weTestUtils.select('font:contents()[0]->0', - 'font:contents()[0]->4', - $editable); - assert.deepEqual(Wysiwyg.getRange($editable[0]), range, testName + carretTestSuffix); - }, - }, - ]; - - var def = Promise.resolve(); - _.each(bgcolorTests, function (test) { - def = def.then(async function () { - testName = test.name; - wysiwyg.setValue(test.content); - var range = weTestUtils.select(test.start, test.end, $editable); - Wysiwyg.setRange(range.sc, range.so, range.ec, range.eo); - await test.do(); - if (!test.async) { - assert.deepEqual(wysiwyg.getValue(), test.test.content, testName); - assert.deepEqual(Wysiwyg.getRange($editable[0]), weTestUtils.select(test.test.start, test.test.end, $editable), testName + carretTestSuffix); - } - }); - }); - return def.then(function () { - wysiwyg.destroy(); - }); - }); -}); - -QUnit.test('Unordered list', function (assert) { - assert.expect(34); - - return weTestUtils.createWysiwyg({ - debug: false, - wysiwygOptions: { - - }, - }).then(function (wysiwyg) { - var $editable = wysiwyg.$('.note-editable'); - - var $btnUL = wysiwyg.$('.note-para .note-icon-unorderedlist'); - - var ulTests = [{ - name: "Click UL: p -> ul", - content: 'dom not to edit
dom to edit
', - start: 'p:eq(1):contents()[0]->1', - end: 'p:eq(1):contents()[0]->5', - do: async function () { - await testUtils.dom.triggerEvents($btnUL, ['mousedown', 'click']); - }, - test: { - content: 'dom not to edit
dom to edit
dom not to edit
dom to edit
dom to edit
', - start: 'p:eq(1):contents()[0]->1', - end: 'p:eq(2):contents()[0]->5', - do: async function () { - await testUtils.dom.triggerEvents($btnUL, ['mousedown', 'click']); - }, - test: { - content: 'dom not to edit
dom to edit
dom to edit
dom not to edit
dom to edit
dom not to edit
dom to edit
', - start: 'p:eq(1):contents()[0]->1', - end: 'p:eq(1):contents()[0]->5', - }, - }, - { - name: "Click UL: p -> ul (across li's)", - content: 'dom not to edit
dom to edit
dom to edit
dom not to edit
dom to edit
dom to edit
', - start: 'p:eq(1):contents()[0]->1', - end: 'p:eq(2):contents()[0]->5', - }, - }, - { - name: "Click UL: ul -> p (from second li)", - content: 'dom not to edit
xxx
dom to edit
dom not to edit
xxx
dom to edit
', - start: 'p:eq(2):contents()[0]->1', - end: 'p:eq(2):contents()[0]->5', - }, - }, - // Conversion from OL - { - name: "Click UL: ol -> ul", - content: 'dom not to edit
dom to edit
dom not to edit
dom to edit
dom not to edit
dom to edit
dom to edit
dom not to edit
dom to edit
dom to edit
dom not to edit
xxx
dom to edit
dom not to edit
xxx
dom to edit
dom not to edit
xxx
dom to edit
dom not to edit
xxx
dom to edit
dom not to edit
xxx
dom to edit 1
dom to edit 2
dom not to edit
xxx
dom to edit 1
dom to edit 2
dom not to edit
xxx
dom not to edit
dom to edit
dom not to edit
dom not to edit
xxx
dom not to edit
dom to edit
dom not to edit
dom not to edit
dom to edit
dom not to edit
dom to edit
dom not to edit
dom to edit
dom to edit
dom not to edit
dom to edit
dom to edit
dom not to edit
xxx
dom to edit
dom not to edit
xxx
dom to edit
dom not to edit
xxx
dom to edit
dom not to edit
xxx
dom to edit
dom not to edit
xxx
dom to edit 1
dom to edit 2
dom not to edit
xxx
dom to edit 1
dom to edit 2
dom not to edit
xxx
dom not to edit
dom to edit
dom not to edit
dom not to edit
xxx
dom not to edit
dom to edit
dom not to edit
dom not to edit
dom to edit
', - start: 'p:eq(1):contents()[0]->1', - end: 'p:eq(1):contents()[0]->5', - do: async function () { - await testUtils.dom.triggerEvents($btnOL, ['mousedown', 'click']); - }, - test: { - content: 'dom not to edit
dom to edit
dom not to edit
dom to edit
dom to edit
', - start: 'p:eq(1):contents()[0]->1', - end: 'p:eq(2):contents()[0]->5', - do: async function () { - await testUtils.dom.triggerEvents($btnOL, ['mousedown', 'click']); - }, - test: { - content: 'dom not to edit
dom to edit
dom to edit
dom not to edit
dom to edit
dom not to edit
dom to edit
', - start: 'p:eq(1):contents()[0]->1', - end: 'p:eq(1):contents()[0]->5', - }, - }, - { - name: "Click OL: p -> ol (across li's)", - content: 'dom not to edit
dom to edit
dom to edit
dom not to edit
dom to edit
dom to edit
', - start: 'p:eq(1):contents()[0]->1', - end: 'p:eq(2):contents()[0]->5', - }, - }, - { - name: "Click OL: ol -> p (from second li) (2)", - content: 'dom not to edit
dom to edit
dom to edit
dom not to edit
dom to edit
dom to edit
dom not to edit
dom to edit
dom to edit
dom not to edit
dom to edit
dom to edit
a
' + - 'b
c
d
e
a
' + - 'b
c
d
e
a
' + - 'a
' + - 'a
' + - 'a
' + - 'a
' + - 'a
' + - 'a
' + - '| aaa | ' + - '||
a
' + - '
| ' +
- '||
a
' + - '![]() | ' +
- '||
a
' + - 'x
' + - 'aaa
bbb
ccc
ddd
y
', - start: 'p:eq(2):contents(0)->1', - end: 'p:eq(3):contents(0)->1', - do: async function () { - await testUtils.dom.triggerEvents($btnOL, ['mousedown', 'click']); - }, - test: { - content: 'x
' + - 'aaa
bbb
' + - 'ccc
' + - 'ddd
y
', - start: 'p:eq(2):contents(0)->1', - end: 'p:eq(3):contents(0)->1', - }, - }, - { - name: "Click OL with selected LI in UL", - content: 'x
' + - 'aaa
bbb
ccc
ddd
y
', - start: 'p:eq(2):contents(0)->1', - end: 'p:eq(3):contents(0)->1', - do: async function () { - await testUtils.dom.triggerEvents($btnOL, ['mousedown', 'click']); - }, - test: { - content: 'x
' + - 'aaa
bbb
ccc
ddd
y
', - start: 'p:eq(2):contents(0)->1', - end: 'p:eq(3):contents(0)->1', - }, - }, - { - name: "Click OL after ENTER in p > b", - content: "dom to edit
", - start: 'b:contents(0)->11', - do: async function () { - weTestUtils.keydown(13, $editable); // ENTER - await testUtils.dom.triggerEvents($btnOL, ['mousedown', 'click']); - weTestUtils.keydown('a', $editable); // ENTER - }, - test: { - content: "dom to edit
a
dom not to edit
dom to edit
dom not to edit
dom to edit
dom not to edit
dom to edit
dom to edit
dom not to edit
dom to edit
dom to edit
dom not to edit
xxx
dom to edit
dom not to edit
xxx
dom to edit
dom not to edit
xxx
dom to edit
dom not to edit
xxx
dom to edit
dom not to edit
xxx
dom to edit 1
dom to edit 2
dom not to edit
xxx
dom to edit 1
dom to edit 2
dom not to edit
xxx
dom not to edit
dom to edit
dom not to edit
dom not to edit
xxx
dom not to edit
dom to edit
dom not to edit
dom not to edit
dom to edit
dom not to edit
dom to edit
dom not to edit
dom to edit
dom to edit
dom not to edit
dom to edit
dom to edit
dom not to edit
xxx
dom to edit
dom not to edit
xxx
dom to edit
dom not to edit
xxx
dom to edit
dom not to edit
xxx
dom to edit
dom not to edit
xxx
dom to edit 1
dom to edit 2
dom not to edit
xxx
dom to edit 1
dom to edit 2
dom not to edit
xxx
dom not to edit
dom to edit
dom not to edit
dom not to edit
xxx
dom not to edit
dom to edit
dom not to edit
dom not to edit
dom to edit
', - start: 'p:eq(1):contents()[0]->1', - do: async function () { - await testUtils.dom.triggerEvents($dropdownPara, ['mousedown', 'click']); - await testUtils.dom.triggerEvents($btnAlignLeft, ['mousedown', 'click']); - }, - test: { - content: 'dom not to edit
dom to edit
', - start: 'p:eq(1):contents()[0]->1', - }, - }, - { - name: "Click ALIGN LEFT: p (parent align right) -> p align left (does nothing)", - content: 'dom not to edit
dom to edit
dom not to edit
dom to edit
dom not to edit
dom to edit
dom not to edit
dom to edit
dom not to edit
dom to edit
dom to edit
', - start: 'p:eq(1):contents()[0]->1', - end: 'p:eq(2):contents()[0]->5', - do: async function () { - await testUtils.dom.triggerEvents($dropdownPara, ['mousedown', 'click']); - await testUtils.dom.triggerEvents($btnAlignRight, ['mousedown', 'click']); - }, - test: { - content: 'dom not to edit
dom to edit
dom to edit
', - start: 'p:eq(1):contents()[0]->1', - end: 'p:eq(2):contents()[0]->5', - }, - }, - /* ALIGN CENTER */ - { - name: "Click ALIGN CENTER: p -> p align center", - content: 'dom not to edit
dom to edit
', - start: 'p:eq(1):contents()[0]->1', - do: async function () { - await testUtils.dom.triggerEvents($dropdownPara, ['mousedown', 'click']); - await testUtils.dom.triggerEvents($btnAlignCenter, ['mousedown', 'click']); - }, - test: { - content: 'dom not to edit
dom to edit
', - start: 'p:eq(1):contents()[0]->1', - }, - }, - { - name: "Click ALIGN CENTER: p align left & default -> p align center (across paragraphs)", - content: 'dom not to edit
dom to edit
dom to edit
', - start: 'p:eq(1):contents()[0]->1', - end: 'p:eq(2):contents()[0]->5', - do: async function () { - await testUtils.dom.triggerEvents($dropdownPara, ['mousedown', 'click']); - await testUtils.dom.triggerEvents($btnAlignCenter, ['mousedown', 'click']); - }, - test: { - content: 'dom not to edit
dom to edit
dom to edit
', - start: 'p:eq(1):contents()[0]->1', - end: 'p:eq(2):contents()[0]->5', - }, - }, - /* ALIGN RIGHT */ - { - name: "Click ALIGN RIGHT: p align center -> p align right", - content: 'dom not to edit
dom to edit
', - start: 'p:eq(1):contents()[0]->1', - do: async function () { - await testUtils.dom.triggerEvents($dropdownPara, ['mousedown', 'click']); - await testUtils.dom.triggerEvents($btnAlignRight, ['mousedown', 'click']); - }, - test: { - content: 'dom not to edit
dom to edit
', - start: 'p:eq(1):contents()[0]->1', - }, - }, - { - name: "Click ALIGN RIGHT: p align center & default -> p align right (across paragraphs)", - content: 'dom not to edit
dom to edit
dom to edit
', - start: 'p:eq(1):contents()[0]->1', - end: 'p:eq(2):contents()[0]->5', - do: async function () { - await testUtils.dom.triggerEvents($dropdownPara, ['mousedown', 'click']); - await testUtils.dom.triggerEvents($btnAlignRight, ['mousedown', 'click']); - }, - test: { - content: 'dom not to edit
dom to edit
dom to edit
', - start: 'p:eq(1):contents()[0]->1', - end: 'p:eq(2):contents()[0]->5', - }, - }, - /* ALIGN JUSTIFY */ - { - name: "Click ALIGN JUSTIFY: p align right -> p align justify", - content: 'dom not to edit
dom to edit
', - start: 'p:eq(1):contents()[0]->1', - do: async function () { - await testUtils.dom.triggerEvents($dropdownPara, ['mousedown', 'click']); - await testUtils.dom.triggerEvents($btnAlignJustify, ['mousedown', 'click']); - }, - test: { - content: 'dom not to edit
dom to edit
', - start: 'p:eq(1):contents()[0]->1', - }, - }, - { - name: "Click ALIGN JUSTIFY: p align right & default -> p align justify (across paragraphs)", - content: 'dom not to edit
dom to edit
dom to edit
', - start: 'p:eq(1):contents()[0]->1', - end: 'p:eq(2):contents()[0]->5', - do: async function () { - await testUtils.dom.triggerEvents($dropdownPara, ['mousedown', 'click']); - await testUtils.dom.triggerEvents($btnAlignJustify, ['mousedown', 'click']); - }, - test: { - content: 'dom not to edit
dom to edit
dom to edit
', - start: 'p:eq(1):contents()[0]->1', - end: 'p:eq(2):contents()[0]->5', - }, - }, - ]; - - var def = Promise.resolve(); - _.each(alignTests, function (test) { - def = def.then(async function() { - testName = test.name; - wysiwyg.setValue(test.content); - var range = weTestUtils.select(test.start, test.end, $editable); - Wysiwyg.setRange(range.sc, range.so, range.ec, range.eo); - await test.do(); - assert.deepEqual(wysiwyg.getValue(), test.test.content, testName); - assert.deepEqual(Wysiwyg.getRange($editable[0]), weTestUtils.select(test.test.start, test.test.end, $editable), testName + carretTestSuffix); - }); - }); - return def.then(function() { - wysiwyg.destroy(); - }); - }); -}); - -QUnit.test('Indent/outdent', function (assert) { - assert.expect(20); - - return weTestUtils.createWysiwyg({ - debug: false, - wysiwygOptions: { - - }, - }).then(function (wysiwyg) { - var $editable = wysiwyg.$('.note-editable'); - - var $dropdownPara = wysiwyg.$('.note-para .dropdown-toggle'); - var $btnIndent = wysiwyg.$('.note-list .note-btn:eq(1)'); - var $btnOutdent = wysiwyg.$('.note-list .note-btn:first'); - - var indentTests = [ - /* INDENT */ - { - name: "Click INDENT: p -> indented p", - content: 'dom to edit
', - start: 'p:contents()[0]->1', - do: async function () { - await testUtils.dom.triggerEvents($dropdownPara, ['mousedown', 'click']); - await testUtils.dom.triggerEvents($btnIndent, ['mousedown', 'click']); - }, - test: { - content: 'dom to edit
', - start: 'p:contents()[0]->1', - }, - }, - { - name: "Click INDENT: li -> indented li", - content: 'dom
to edit
dom
to edit
aaa
bbb
ccc
ddd
', - start: 'p:eq(1):contents()[0]->0', - end: 'p:eq(3):contents()[0]->3', - do: function () { - $dropdownPara.mousedown().click(); - $btnIndent.mousedown().click(); - }, - test: { - content: 'aaa
bbb
ccc
ddd
', - start: 'p:eq(1):contents()[0]->0', - end: 'p:eq(3):contents()[0]->3', - }, - }, - /* OUTDENT */ - { - name: "Click OUTDENT: indented p -> p", - content: 'dom to edit
', - start: 'p:contents()[0]->1', - do: async function () { - await testUtils.dom.triggerEvents($dropdownPara, ['mousedown', 'click']); - await testUtils.dom.triggerEvents($btnOutdent, ['mousedown', 'click']); - }, - test: { - content: 'dom to edit
', - start: 'p:contents()[0]->1', - }, - }, - { - name: "Click OUTDENT: indented li -> li", - content: 'dom
to edit
dom
to edit
dom
to edit
dom
to edit
x
' + - 'aaa
bbb
ccc
ddd
eee
y
', - start: 'ol ol p:eq(1):contents(0)->1', - do: async function () { - await testUtils.dom.triggerEvents($dropdownPara, ['mousedown', 'click']); - await testUtils.dom.triggerEvents($btnOutdent, ['mousedown', 'click']); - }, - test: { - content: 'x
' + - 'aaa
bbb
ccc
ddd
eee
y
', - start: 'ol:first > li:eq(2) p:contents(0)->1', - }, - }, - { - name: "Click OUTDENT on LI in OL in OL (2)", - content: 'x
' + - 'aaa
bbb
ccc
ddd
eee
y
', - start: 'ol ol p:eq(1):contents(0)->1', - do: async function () { - await testUtils.dom.triggerEvents($dropdownPara, ['mousedown', 'click']); - await testUtils.dom.triggerEvents($btnOutdent, ['mousedown', 'click']); - }, - test: { - content: 'x
' + - 'aaa
bbb
ccc
ddd
eee
y
', - start: 'li:eq(2) p:contents(0)->1', - }, - }, - { - name: "Click OUTDENT on LI in OL", - content: - 'aaa
bbb
ccc
aaa
bbb
' + - 'ccc
dom
' + - 'dom
' + - 'x
' + - 'aaa
bbb
ccc
ddd
eee
y
', - do: async function () { - var $li = $editable.find('li:first'); - $li.trigger($.Event('mousedown', { - offsetX: -10, - })); - }, - test: { - content: 'x
' + - 'aaa
bbb
ccc
ddd
eee
y
', - }, - }, - { - name: "check checkbox in checklist with children (2)", - content: 'x
' + - 'aaa
bbb
ccc
ddd
eee
y
', - do: async function () { - var $li = $editable.find('li:first'); - $li.trigger($.Event('mousedown', { - offsetX: -10, - })); - }, - test: { - content: 'x
' + - 'aaa
bbb
ccc
ddd
eee
y
', - }, - }, - { - name: "uncheck checkbox in checklist with children", - content: 'x
' + - 'aaa
bbb
ccc
ddd
eee
y
', - do: async function () { - var $li = $editable.find('li:first'); - $li.trigger($.Event('mousedown', { - offsetX: -10, - })); - }, - test: { - content: 'x
' + - 'aaa
bbb
ccc
ddd
eee
y
', - }, - }, - { - name: "uncheck checkbox in checklist with children (2)", - content: 'x
' + - 'aaa
bbb
ccc
ddd
eee
y
', - do: async function () { - var $li = $editable.find('li:first'); - $li.trigger($.Event('mousedown', { - offsetX: -10, - })); - }, - test: { - content: 'x
' + - 'aaa
bbb
ccc
ddd
eee
y
', - }, - }, - { - name: "uncheck checkbox in checklist in checklist", - content: 'x
' + - 'aaa
bbb
ccc
ddd
eee
y
', - do: async function () { - var $li = $editable.find('ul ul li:eq(1)'); - $li.trigger($.Event('mousedown', { - offsetX: -10, - })); - }, - test: { - content: 'x
' + - 'aaa
bbb
ccc
ddd
eee
y
', - }, - }, - { - name: "uncheck checkbox in checklist in checklist (2)", - content: 'x
' + - 'aaa
bbb
ccc
ddd
eee
y
', - do: async function () { - var $li = $editable.find('ul ul li:eq(1)'); - $li.trigger($.Event('mousedown', { - offsetX: -10, - })); - }, - test: { - content: 'x
' + - 'aaa
bbb
ccc
ddd
eee
y
', - }, - }, - { - name: "check checkbox in checklist in checklist", - content: 'x
' + - 'aaa
bbb
ccc
ddd
eee
y
', - do: async function () { - var $li = $editable.find('ul ul li:eq(1)'); - $li.trigger($.Event('mousedown', { - offsetX: -10, - })); - }, - test: { - content: 'x
' + - 'aaa
bbb
ccc
ddd
eee
y
', - }, - }, - { - name: "check checkbox in checklist in checklist (2)", - content: 'x
' + - 'aaa
bbb
ccc
ddd
eee
y
', - do: async function () { - var $li = $editable.find('ul ul li:eq(1)'); - $li.trigger($.Event('mousedown', { - offsetX: -10, - })); - }, - test: { - content: 'x
' + - 'aaa
bbb
ccc
ddd
eee
y
', - }, - }, - { - name: "check checkbox in checklist in checklist (full)", - content: 'x
' + - 'aaa
bbb
ccc
ddd
eee
y
', - do: async function () { - var $li = $editable.find('ul ul li:eq(1)'); - $li.trigger($.Event('mousedown', { - offsetX: -10, - })); - }, - test: { - content: 'x
' + - 'aaa
bbb
ccc
ddd
eee
y
', - }, - }, - { - name: "check checkbox in checklist in checklist (full) (2)", - content: 'x
' + - 'aaa
bbb
ccc
ddd
eee
y
', - do: async function () { - var $li = $editable.find('ul ul li:eq(1)'); - $li.trigger($.Event('mousedown', { - offsetX: -10, - })); - }, - test: { - content: 'x
' + - 'aaa
bbb
ccc
ddd
eee
y
', - }, - }, - { - name: "convert 2 ul li ul li into two ul li ul.o_checklist li", - content: '1
' + - '2
' + - '3
' + - '4
' + - '5
' + - '1
' + - '2
' + - '3
' + - '4
' + - '5
' + - 'dom to edit
', - start: "p:contents()[0]->1", - end: "p:contents()[0]->5", - do: async function () { - assert.strictEqual($('.modal-dialog:visible #o_link_dialog_label_input').val(), 'om t', testName + ' (label)'); - await testUtils.fields.editInput($('.modal-dialog:visible #o_link_dialog_url_input'),'#'); - }, - test: { - content: 'dom to edit
', - start: 'a:contents()[0]->0', - end: 'a:contents()[0]->4', - }, - }, - { - name: "Click LINK: p -> a in p (w/ URL) (no selection)", - async: true, - content: 'do edit
', - start: 'p:contents()[0]->1', - do: async function () { - await testUtils.fields.editInput($('.modal-dialog:visible #o_link_dialog_label_input'),'om t'); - await testUtils.fields.editInput($('.modal-dialog:visible #o_link_dialog_url_input'),'#'); - }, - test: { - content: 'dom to edit
', - start: 'p->2', // link not selected, the user can continue to write - end: 'p->2', - }, - }, - { - name: "Click LINK: a.btn in div -> a.btn.btn-outline-alpha in div (edit) (no selection)", - content: '', - start: 'a:contents()[0]->5', - do: async function () { - assert.strictEqual($('.modal-dialog:visible #o_link_dialog_label_input').val(), 'dom to edit', testName + ' (label)'); - await testUtils.fields.editInput($('.modal-dialog:visible #o_link_dialog_url_input'),'#newlink'); - }, - test: { - content: '', - start: 'a->0', - end: 'a->1', - }, - }, - { - name: "Click LINK: p -> a in p (w/ Email)", - async: true, - content: 'dom to edit
', - start: 'p:contents()[0]->1', - end: 'p:contents()[0]->5', - do: async function () { - await testUtils.fields.editInput($('.modal-dialog:visible #o_link_dialog_url_input'),'john.coltrane@example.com'); - }, - test: { - content: 'dom to edit
', - start: 'a:contents()[0]->0', - end: 'a:contents()[0]->4', - }, - }, - { - name: "Click LINK: p -> a in p (w/ URL & Size Large)", - async: true, - content: 'dom to edit
', - start: 'p:contents()[0]->1', - end: 'p:contents()[0]->5', - do: async function () { - await testUtils.fields.editInput($('.modal-dialog:visible #o_link_dialog_url_input'),'#'); - await testUtils.fields.editInput($('.modal-dialog:visible [name="link_style_size"]'),"lg"); - }, - test: { - content: 'dom to edit
', - start: 'a:contents()[0]->0', - end: 'a:contents()[0]->4', - }, - }, - { - name: "Click LINK: a in p -> a.btn-outline-alpha in p with alpha color and target=\"_blank\"", - async: true, - content: '', - start: 'a:contents()[0]->1', - do: async function () { - await testUtils.fields.editInput( $('.modal-dialog:visible #o_link_dialog_url_input'), '#'); - await testUtils.fields.editInput($('.modal-dialog:visible [name="link_style_shape"]'), "outline"); - await testUtils.dom.triggerEvents($('.modal-dialog:visible .o_link_dialog_color .o_link_dialog_color_item.btn-alpha'), ['mousedown', 'click']); - await testUtils.dom.triggerEvents($('.modal-dialog:visible .o_switch [name="is_new_window"]'), ['mousedown', 'click']); - }, - test: { - content: '', - start: 'a->0', - end: 'a->1', - }, - }, - // POPOVER - { - name: "Click LINK in popover after adding link in p", - async: true, - content: 'dom to edit
', - start: "p:contents()[0]->1", - end: "p:contents()[0]->5", - do: async function () { - $('.modal-dialog:visible #o_link_dialog_url_input').val('/link'); - }, - test: { - check: async function () { - await testUtils.dom.triggerEvents($('.note-link-popover .note-btn .note-icon-link'), ['mousedown', 'click']); - - assert.strictEqual($('.modal-dialog:visible #o_link_dialog_label_input').val(), 'om t', testName + ' (label)'); - assert.strictEqual($('.modal-dialog:visible #o_link_dialog_url_input').val(), '/link', testName + ' (url)'); - await testUtils.fields.editInput($('.modal-dialog:visible #o_link_dialog_url_input'), '/newlink'); - await testUtils.dom.triggerEvents($('.modal-dialog:visible .modal-footer .btn.btn-primary:contains("Save")'), ['mousedown', 'click']); - assert.deepEqual(wysiwyg.getValue(), 'dom to edit
', testName); - }, - }, - }, - { - name: "Click UNLINK in popover after adding link in p", - async: true, - content: 'dom to edit
', - start: "p:contents()[0]->1", - end: "p:contents()[0]->5", - do: async function () { - $('.modal-dialog:visible #o_link_dialog_url_input').val('/link'); - }, - test: { - content: 'dom to edit
', - check: async function () { - await testUtils.dom.triggerEvents($('.note-link-popover .note-btn .note-icon-chain-broken'), ['mousedown', 'click']); - - var range = weTestUtils.select('p:contents()[0]->1', 'p:contents()[0]->5', $editable); - assert.deepEqual(Wysiwyg.getRange($editable[0]), range, testName + carretTestSuffix); - }, - }, - }, - ]; - - var def = Promise.resolve(); - _.each(linkTests, function (test) { - def = def.then(async function () { - testName = test.name; - wysiwyg.setValue(test.content); - var range = weTestUtils.select(test.start, test.end, $editable); - Wysiwyg.setRange(range.sc, range.so, range.ec, range.eo); - await _clickLink(test.do, test.test); - }); - }); - return def.then(function () { - wysiwyg.destroy(); - }); - }); -}); - -QUnit.test('Table', function (assert) { - assert.expect(13); - - async function createTable(wysiwyg) { - await testUtils.dom.triggerEvents(wysiwyg.$('.note-table button:first'), ['mousedown', 'click']); - - var $grid = wysiwyg.$('.note-table .note-dimension-picker-mousecatcher'); - var pos = $grid.offset(); - $grid.trigger($.Event('mousemove', { - pageX: pos.left + 40, - pageY: pos.top + 40, - })); - await testUtils.dom.triggerEvents($grid, ['mousedown', 'click']); - } - - return weTestUtils.createWysiwyg({ - debug: false, - wysiwygOptions: {}, - }).then(async function (wysiwyg) { - var $editable = wysiwyg.getEditable(); - - // create a table in an empty dom - - wysiwyg.setValue('dom to edit
'); - range = weTestUtils.select('p:contents()[0]->0', 'p:contents()[0]->0', $editable); - Wysiwyg.setRange(range.sc, range.so, range.ec, range.eo); - - await createTable(wysiwyg); - - assert.strictEqual($editable.html().replace(/\s+/g, ' '), - 'dom to edit
', - "should create a table at start of single p with content"); - - // create a table at end of p with content - - wysiwyg.setValue('dom to edit
'); - range = weTestUtils.select('p:contents()[0]->11', 'p:contents()[0]->11', $editable); - Wysiwyg.setRange(range.sc, range.so, range.ec, range.eo); - - await createTable(wysiwyg); - - assert.strictEqual($editable.html().replace(/\s+/g, ' '), - 'dom to edit
' + - 'dom to edit
'); - range = weTestUtils.select('p:contents()[0]->5', 'p:contents()[0]->5', $editable); - Wysiwyg.setRange(range.sc, range.so, range.ec, range.eo); - - await createTable(wysiwyg); - - assert.strictEqual($editable.html().replace(/\s+/g, ' '), - 'dom t
' + - 'o edit
', - "should create a table"); - - // remove a table - - range = weTestUtils.select('td:first->0', 'td:first->0', $editable); - $(range.sc).mousedown(); - Wysiwyg.setRange(range.sc, range.so, range.ec, range.eo); - - var $trash = $('.note-table-popover:visible button:has(.note-icon-trash)'); - - await testUtils.dom.triggerEvents($trash, ['mousedown', 'click']); - - assert.strictEqual($editable.html().replace(/\s+/g, ' '), - 'dom to edit
', - "should remove the table"); - - // re create a table and table in table - - await createTable(wysiwyg); - await createTable(wysiwyg); - - assert.strictEqual($editable.html().replace(/\s+/g, ' '), - 'dom t
' + - 'o edit
', - "should create a table inside the table"); - - // remove inner table - - range = weTestUtils.select('td td:eq(1)->0', 'td td:eq(1)->0', $editable); - $(range.sc).mousedown(); - Wysiwyg.setRange(range.sc, range.so, range.ec, range.eo); - - $trash = $('.note-table-popover:visible button:has(.note-icon-trash)'); - await testUtils.dom.triggerEvents($trash, ['mousedown', 'click']); - - assert.strictEqual($editable.html().replace(/\s+/g, ' '), - 'dom t
' + - 'o edit
', - "should remove the inner table"); - - // use popover to change row and line - - wysiwyg.setValue('dom t
' + - '0-0 | 0-1 | 0-2 |
1-0 | 1-1 | 1-2 |
2-0 | 2-1 | 2-2 |
o edit
'); - - // remove a row - - range = weTestUtils.select('td:eq(1)->0', 'td:eq(1)->0', $editable); - $(range.sc).mousedown(); - Wysiwyg.setRange(range.sc, range.so, range.ec, range.eo); - await testUtils.dom.triggerEvents($('.note-table-popover:visible button:has(.note-icon-col-remove)'), ['mousedown', 'click']); - - assert.strictEqual($editable.html().replace(/\s+/g, ' '), - 'dom t
' + - '0-0 | 0-2 |
1-0 | 1-2 |
2-0 | 2-2 |
o edit
', - "should remove a row"); - - // remove a line - - range = weTestUtils.select('tr:eq(1) td:eq(1)->0', 'tr:eq(1) td:eq(1)->0', $editable); - $(range.sc).mousedown(); - Wysiwyg.setRange(range.sc, range.so, range.ec, range.eo); - await testUtils.dom.triggerEvents($('.note-table-popover:visible button:has(.note-icon-row-remove)'), ['mousedown', 'click']); - - assert.strictEqual($editable.html().replace(/\s+/g, ' '), - 'dom t
' + - '0-0 | 0-2 |
2-0 | 2-2 |
o edit
', - "should remove a line"); - - // add a row after - - range = weTestUtils.select('tr:eq(1) td:first->0', 'tr:eq(1) td:first->0', $editable); - $(range.sc).mousedown(); - Wysiwyg.setRange(range.sc, range.so, range.ec, range.eo); - await testUtils.dom.triggerEvents($('.note-table-popover:visible button:has(.note-icon-col-after)'), ['mousedown', 'click']); - - assert.strictEqual($editable.html().replace(/\s+/g, ' '), - 'dom t
' + - '0-0 | 0-2 | |
2-0 | 2-2 |
o edit
', - "should add a row after"); - - // add a row before - - $(range.sc).mousedown(); - await testUtils.dom.triggerEvents($('.note-table-popover:visible button:has(.note-icon-col-before)'), ['mousedown', 'click']); - - assert.strictEqual($editable.html().replace(/\s+/g, ' '), - 'dom t
' + - '0-0 | 0-2 | ||
2-0 | 2-2 |
o edit
', - "should add a row before"); - - // add a line after - - $(range.sc).mousedown(); - await testUtils.dom.triggerEvents($('.note-table-popover:visible button:has(.note-icon-row-below)'), ['mousedown', 'click']); - - assert.strictEqual($editable.html().replace(/\s+/g, ' '), - 'dom t
' + - '0-0 | 0-2 | ||
2-0 | 2-2 | ||
o edit
', - "should add a line after"); - - // add a line before - - $(range.sc).mousedown(); - await testUtils.dom.triggerEvents($('.note-table-popover:visible button:has(.note-icon-row-above)'), ['mousedown', 'click']); - - assert.strictEqual($editable.html().replace(/\s+/g, ' '), - 'dom t
' + - '0-0 | 0-2 | ||
2-0 | 2-2 | ||
o edit
', - "should add a line before"); - - wysiwyg.destroy(); - }); -}); - -QUnit.test('CodeView', async function (assert) { - assert.expect(8); - - var wysiwyg = await weTestUtils.createWysiwyg({ - debug: false, - wysiwygOptions: { - codeview: true, - }, - }); - wysiwyg.setValue('dom to edit 
dom to edit a 
\u200B
\u200B
| ' + - ' aaa' + - ' | ' + - '' + - ' bbb' + - ' | ' + - '' + - ' ccc' + - ' | ' + - '
| ' + - ' aaa' + - ' | ' + - '' +
- ' bb b' +
- ' | ' +
- ' ' + - ' ccc' + - ' | ' + - '
| ' +
- ' ' + - ' | ' +
- ' ' +
- ' ' + - ' | ' +
- ' ' +
- ' ' + - ' | ' +
- '
| ' +
- ' ' + - ' | ' +
- ' ' +
- ' ![]() ' + - ' | ' +
- ' ' +
- ' ' + - ' | ' +
- '
\u200B
\u200B
\u200B
\u200B
\u200B
\u200B
\u200B
\u200B
\u200B
\u200B
\u200B\u200B
', - check: async function () { - assert.strictEqual($('.note-icon-popover').css('display'), 'block', testName + ' (popover)'); - }, - }, - }, - // Remove font - { - name: "Click REMOVE in popover after adding font in empty p", - async: true, - content: '\u200B\u200B
', - check: async function () { - await testUtils.dom.triggerEvents($('.note-icon-popover .note-faSize .dropdown-toggle'), ['mousedown', 'click']); - await testUtils.dom.triggerEvents($('.note-icon-popover .note-faSize .dropdown-item:contains("5x")'), ['mousedown', 'click']); - assert.ok($('.note-icon-popover .note-faSize .dropdown-item:contains("5x")').hasClass('active'), testName + ' (popover)'); - }, - }, - }, - // Spin - { - name: "Click SPIN in popover after adding pictogram in empty p", - async: true, - content: '\u200B\u200B
', - check: async function () { - await testUtils.dom.triggerEvents($('.note-icon-popover .note-faSpin .note-btn'), ['mousedown', 'click']); - }, - }, - }, - // Replace pictogram - { - name: "Add PICTOGRAM in empty p then replace it", - async: true, - content: '\u200B\u200B
', - }); - }, - }, - }, - { - name: "Replace PICTOGRAM (i.fa => span.fa)", - async: true, - content: 'tata yoyo
tata
yoyo

\u200B\u200B
', - testName); - }, - }, - }, - { - name: "replace video by pictogram (2)", - async: true, - content: 'aaa
bbb
', - start: "div->0", - do: async function () { - await _insertPictogram('fa-glass'); - }, - test: { - check: async function () { - assert.deepEqual(wysiwyg.getValue(), - 'aaabbb
', - testName); - }, - }, - }, - ]; - - var def = Promise.resolve(); - _.each(mediaTests, function (test) { - def = def.then(async function () { - testName = test.name; - wysiwyg.setValue(test.content); - var range = weTestUtils.select(test.start, test.end, $editable); - await testUtils.dom.triggerEvents($(range.sc), ['mousedown', 'click']); - Wysiwyg.setRange(range.sc, range.so, range.ec, range.eo); - return _clickMedia(wysiwyg, assert, test.do, test.test); - }); - }); - return def.then(function () { - wysiwyg.destroy(); - }); - }); -}); - - -}); -}); -}); -}); diff --git a/addons/web_editor/views/editor.xml b/addons/web_editor/views/editor.xml index 38d56407dbe..1d425a684e3 100644 --- a/addons/web_editor/views/editor.xml +++ b/addons/web_editor/views/editor.xml @@ -183,9 +183,6 @@ - - -