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
ab
c[]d
ab[]c
', contentBeforeEdit: 'a\ufeff\ufeffb[]\ufeff\ufeffc
', stepFunction: deleteBackward, contentAfterEdit: 'a\ufeff\ufeff[]\ufeff\ufeffc
', contentAfter: "a[]c
", }); await testEditor({ contentBefore: '', 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: '', contentBeforeEdit: '', contentAfterEdit: '', contentAfter: '', }); }); test("should not remove a document link on save", async () => { await testEditor({ contentBefore: '', contentBeforeEdit: '', contentAfterEdit: '', contentAfter: '', }); }); test("should not remove a link containing a pictogram on save", async () => { await testEditor({ contentBefore: '', contentBeforeEdit: 'a\ufeff\ufeff\u200b\ufeff\ufeffb
', contentAfterEdit: 'a\ufeff\ufeff\u200b\ufeff\ufeffb
', contentAfter: '', }); }); 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
123