import { describe, test } from "@odoo/hoot"; import { deleteBackward, insertLineBreak, insertText, undo } from "../_helpers/user_actions"; import { testEditor } from "../_helpers/editor"; import { animationFrame } from "@odoo/hoot-mock"; describe("range collapsed", () => { test("should not change the url when a link is not edited", async () => { await testEditor({ contentBefore: '
', contentAfter: '', }); await testEditor({ contentBefore: '', stepFunction: async (editor) => { await insertText(editor, "e"); }, contentAfter: '', }); }); test("should change the url when the label change", async () => { await testEditor({ contentBefore: '', stepFunction: async (editor) => { await insertText(editor, "m"); }, contentAfter: '', }); await testEditor({ contentBefore: '', stepFunction: async (editor) => { await insertText(editor, "o"); }, contentAfter: '', }); await testEditor({ contentBefore: '', stepFunction: async (editor) => { await insertText(editor, "o"); }, contentAfter: '', }); await testEditor({ contentBefore: '', stepFunction: async (editor) => { await insertText(editor, "o"); }, contentAfter: '', }); await testEditor({ contentBefore: '', stepFunction: async (editor) => { await insertText(editor, "r"); }, contentAfter: '', }); }); test("should change the url when the label change, without changing the protocol", async () => { await testEditor({ contentBefore: '', stepFunction: async (editor) => { await insertText(editor, "m"); }, contentAfter: '', }); await testEditor({ contentBefore: '', stepFunction: async (editor) => { await insertText(editor, "m"); }, contentAfter: '', }); }); test("should change the url when the label change, changing to the suitable protocol", async () => { await testEditor({ contentBefore: '', stepFunction: async (editor) => { await insertText(editor, "@"); }, contentAfter: '', }); await testEditor({ contentBefore: '', stepFunction: async (editor) => { deleteBackward(editor); }, contentAfter: '', }); }); test("should change the url in one step", async () => { await testEditor({ contentBefore: '', stepFunction: async (editor) => { await insertText(editor, "m"); await undo(editor); }, contentAfter: '', }); }); test("should not change the url when the label change (1)", async () => { await testEditor({ contentBefore: '', stepFunction: async (editor) => { await insertText(editor, "u"); }, contentAfter: '', }); }); test("should not change the url when the label change (2)", async () => { await testEditor({ contentBefore: '', stepFunction: async (editor) => { await animationFrame(); await insertLineBreak(editor); await insertText(editor, "odoo.com"); }, contentAfter: 'agoogle.com
odoo.com[]b
ago.c[]omb
', }); }); test("should not change the url when the label change", async () => { await testEditor({ contentBefore: '', stepFunction: async (editor) => { await insertText(editor, "e"); }, contentAfter: 'agoogle[]b
', }); await testEditor({ contentBefore: '', stepFunction: async (editor) => { await insertText(editor, "vvv"); }, contentAfter: '', }); }); });