import { test } from "@odoo/hoot"; import { testEditor } from "../_helpers/editor"; import { deleteBackward, insertText } from "../_helpers/user_actions"; test("should parse correctly a span inside a Link", async () => { await testEditor({ contentBefore: '

ab[]c

', contentAfter: '

ab[]c

', }); }); test("should parse correctly an empty span inside a Link", async () => { await testEditor({ contentBefore: '

ab[]c

', contentAfter: '

ab[]c

', }); }); test("should parse correctly a span inside a Link 2", async () => { await testEditor({ contentBefore: '

ab[]cd

', contentAfter: '

ab[]cd

', }); }); test("should parse correctly an empty span inside a Link then add a char", async () => { await testEditor({ contentBefore: '

ab[]c

', stepFunction: async (editor) => { await insertText(editor, "c"); }, contentAfter: '

abc[]c

', }); }); test("should parse correctly a span inside a Link then add a char", async () => { await testEditor({ contentBefore: '

ab[]d

', stepFunction: async (editor) => { await insertText(editor, "c"); }, // JW cAfter: '

abc[]d

', contentAfter: '

abc[]d

', }); }); test("should parse correctly a span inside a Link then add a char 2", async () => { await testEditor({ contentBefore: '

ab[]de

', stepFunction: async (editor) => { await insertText(editor, "c"); }, contentAfter: '

abc[]de

', }); }); test("should parse correctly a span inside a Link then add a char 3", async () => { await testEditor({ contentBefore: '

abc[]e

', stepFunction: async (editor) => { await insertText(editor, "d"); }, // JW cAfter: '

abcd[]e

', contentAfter: '

abcd[]e

', }); }); test("should add a character after the link", async () => { await testEditor({ contentBefore: '

ab[]d

', stepFunction: async (editor) => { await insertText(editor, "c"); }, // JW cAfter: '

abc[]d

', contentAfter: '

abc[]d

', }); }); test("should add two character after the link", async () => { await testEditor({ contentBefore: '

ab[]e

', stepFunction: async (editor) => { await insertText(editor, "cd"); }, contentAfter: '

abcd[]e

', }); }); test("should add a character after the link if range just after link", async () => { await testEditor({ contentBefore: '

ab[]d

', stepFunction: async (editor) => { await insertText(editor, "c"); }, contentAfter: '

abc[]d

', }); }); test("should add a character in the link after a br tag", async () => { await testEditor({ contentBefore: '

ab
[]
d

', stepFunction: async (editor) => { await insertText(editor, "c"); }, contentAfter: '

ab
c[]
d

', }); }); test("should remove an empty link on save", async () => { await testEditor({ contentBefore: '

ab[]c

', contentBeforeEdit: '

a\ufeff\ufeffb[]\ufeff\ufeffc

', stepFunction: deleteBackward, contentAfterEdit: '

a\ufeff\ufeff[]\ufeff\ufeffc

', contentAfter: "

a[]c

", }); await testEditor({ contentBefore: '

ab

', contentBeforeEdit: '

a\ufeff\ufeff\ufeffb

', contentAfterEdit: '

a\ufeff\ufeff\ufeffb

', contentAfter: "

ab

", }); }); test("should not remove a link containing an image on save", async () => { await testEditor({ contentBefore: '

ab

', contentBeforeEdit: '

ab

', contentAfterEdit: '

ab

', contentAfter: '

ab

', }); }); test("should not remove a document link on save", async () => { await testEditor({ contentBefore: '

ab

', contentBeforeEdit: '

ab

', contentAfterEdit: '

ab

', contentAfter: '

ab

', }); }); test("should not remove a link containing a pictogram on save", async () => { await testEditor({ contentBefore: '

ab

', contentBeforeEdit: '

a\ufeff\ufeff\u200b\ufeff\ufeffb

', contentAfterEdit: '

a\ufeff\ufeff\u200b\ufeff\ufeffb

', contentAfter: '

ab

', }); }); test("should not add a character in the link if start of paragraph", async () => { await testEditor({ contentBefore: '

ab

[]d

', stepFunction: async (editor) => { await insertText(editor, "c"); }, contentAfter: '

ab

c[]d

', }); }); // test.todo('should select and replace all text and add the next char in bold', async () => { // await testEditor({ // contentBefore: '

[]123

abc

', // stepFunction: async (editor) => { // const p = editor.selection.anchor.parent.nextSibling(); // await editor.execCommand('setSelection', { // vSelection: { // anchorNode: p.firstLeaf(), // anchorPosition: RelativePosition.BEFORE, // focusNode: p.lastLeaf(), // focusPosition: RelativePosition.AFTER, // direction: Direction.FORWARD, // }, // }); // await editor.execCommand('insert', 'd'); // }, // contentAfter: '

123

d[]

', // }); // });