diff --git a/addons/web_editor/static/lib/odoo-editor/test/spec/format.test.js b/addons/web_editor/static/lib/odoo-editor/test/spec/format.test.js index 1c372e84b7d..ab96465e8d9 100644 --- a/addons/web_editor/static/lib/odoo-editor/test/spec/format.test.js +++ b/addons/web_editor/static/lib/odoo-editor/test/spec/format.test.js @@ -1,4 +1,4 @@ -import { BasicEditor, testEditor } from '../utils.js'; +import { BasicEditor, testEditor, setTestSelection, Direction } from '../utils.js'; import { applyInlineStyle } from '../../src/commands/commands.js'; const bold = async editor => { @@ -281,6 +281,62 @@ describe('Format', () => { contentAfter: `

${s(`ab[`)}cde]${s(`fg`)}

`, }); }); + it('should make a few characters strikeThrough then remove style inside', async () => { + await testEditor(BasicEditor, { + contentBefore: `

ab[c d]ef

`, + stepFunction: async editor => { + await strikeThrough(editor); + const styleSpan = editor.editable.querySelector('span[style="text-decoration-line: line-through;"]').childNodes[0]; + const selection = { + anchorNode: styleSpan, + anchorOffset: 1, + focusNode: styleSpan, + focusOffset: 2, + direction: Direction.FORWARD, + }; + await setTestSelection(selection); + await strikeThrough(editor); + }, + contentAfter: `

ab${s(`c[`)} ]${s(`d`)}ef

`, + }); + }); + it('should make strikeThrough then more then remove', async () => { + await testEditor(BasicEditor, { + contentBefore: `

abc[ ]def

`, + stepFunction: async editor => { + await strikeThrough(editor); + const pElem = editor.editable.querySelector('p').childNodes; + const selection = { + anchorNode: pElem[0], + anchorOffset: 2, + focusNode: pElem[2], + focusOffset: 1, + direction: Direction.FORWARD, + }; + await setTestSelection(selection); + await strikeThrough(editor); + }, + contentAfter: `

ab${s(`[c d]`)}ef

`, + }); + await testEditor(BasicEditor, { + contentBefore: `

abc[ ]def

`, + stepFunction: async editor => { + await strikeThrough(editor); + const pElem = editor.editable.querySelector('p').childNodes; + const selection = { + anchorNode: pElem[0], + anchorOffset: 2, + focusNode: pElem[2], + focusOffset: 1, + direction: Direction.FORWARD, + }; + await setTestSelection(selection); + await strikeThrough(editor); + await strikeThrough(editor); + }, + contentAfter: `

ab[c d]ef

`, + }); + }); it('should make two paragraphs strikeThrough', async () => { await testEditor(BasicEditor, { contentBefore: '

[abc

def]

', diff --git a/addons/web_editor/static/lib/odoo-editor/test/utils.js b/addons/web_editor/static/lib/odoo-editor/test/utils.js index abad4c14e81..c1ac2e04f96 100644 --- a/addons/web_editor/static/lib/odoo-editor/test/utils.js +++ b/addons/web_editor/static/lib/odoo-editor/test/utils.js @@ -2,7 +2,7 @@ import { OdooEditor } from '../src/OdooEditor.js'; import { sanitize } from '../src/utils/sanitize.js'; import { insertText as insertTextSel } from '../src/utils/utils.js'; -const Direction = { +export const Direction = { BACKWARD: 'BACKWARD', FORWARD: 'FORWARD', };