import { describe, expect, test } from "@odoo/hoot"; import { waitFor, waitForNone, press, manuallyDispatchProgrammaticEvent } from "@odoo/hoot-dom"; import { setupEditor, testEditor } from "./_helpers/editor"; import { getContent } from "./_helpers/selection"; import { insertText, splitBlock } from "./_helpers/user_actions"; async function simulateEnter(editor) { press("enter"); await manuallyDispatchProgrammaticEvent(editor.editable, "beforeinput", { inputType: "insertParagraph", }); } describe("Blockquote", () => { describe("SplitBlock", () => { test("should force
in blockquote", async () => { await testEditor({ contentBefore: "
abc[]
", stepFunction: splitBlock, contentAfter: "
abc
[]
", }); }); test("should force
in blockquote containing inline element", async () => { await testEditor({ contentBefore: "
abc[]
", stepFunction: splitBlock, contentAfter: "
abc
[]
", }); }); test("should force
in empty blockquote", async () => { await testEditor({ contentBefore: "
[]
", stepFunction: splitBlock, contentAfter: "

[]
", }); }); test("should insert a new paragraph within the blockquote", async () => { await testEditor({ contentBefore: "

abc

def[]

", stepFunction: splitBlock, contentAfter: "

abc

def

[]

", }); }); test("should move an empty paragraph after the blockquote if at the end", async () => { await testEditor({ contentBefore: "

abc

def

[]

", stepFunction: splitBlock, contentAfter: "

abc

def

[]

", }); }); test("should insert a new paragraph within the blockquote tag with rtl direction", async () => { await testEditor({ contentBefore: `
ab[]
`, stepFunction: splitBlock, contentAfter: `
ab
[]
`, }); }); test("should insert a new paragraph within the blockquote tag with rtl direction (2)", async () => { await testEditor({ contentBefore: `

abc[]

`, stepFunction: splitBlock, contentAfter: `

abc

[]

`, }); }); test("should move an empty paragraph after the blockquote with rtl direction if at the end", async () => { await testEditor({ contentBefore: `

abc

[]

`, stepFunction: splitBlock, contentAfter: `

abc

[]

`, }); }); test("should move an empty paragraph after the blockquote with rtl direction if at the end (2)", async () => { await testEditor({ contentBefore: `

abc

[]

`, stepFunction: splitBlock, contentAfter: `

abc

[]

`, }); }); }); describe("Enter Key", () => { test("blockquote should create br on Enter", async () => { const { el, editor } = await setupEditor("

ab[]

"); expect(getContent(el)).toBe(`

ab[]

`); await insertText(editor, "/"); await waitFor(".o-we-powerbox"); await insertText(editor, "quote"); await press("enter"); await waitForNone(".o-we-powerbox"); expect(getContent(el)).toBe("
ab[]
"); await insertText(editor, "c"); await simulateEnter(editor); expect(getContent(el)).toBe("
abc
[]
"); await insertText(editor, "d"); expect(getContent(el)).toBe("
abc
d[]
"); await insertText(editor, "ef"); expect(getContent(el)).toBe("
abc
def[]
"); }); test("blockquote should create br on Enter (2)", async () => { const { el, editor } = await setupEditor("
a[]b
"); await simulateEnter(editor); expect(getContent(el)).toBe("
a
[]b
"); }); test("blockquote should create br on 1st Enter then create p", async () => { const { el, editor } = await setupEditor("
abc
def[]
"); await simulateEnter(editor); expect(getContent(el)).toBe("
abc
def
[]
"); await simulateEnter(editor); expect(getContent(el)).toBe( '
abc
def

[]

' ); }); }); });