import { expect, test } from "@odoo/hoot"; import { click, press } from "@odoo/hoot-dom"; import { setupEditor, testEditor } from "./_helpers/editor"; import { deleteBackward, insertText } from "./_helpers/user_actions"; import { getContent } from "./_helpers/selection"; import { animationFrame } from "@odoo/hoot-mock"; /** * Rating Star Element Tests */ test("add 3 star elements", async () => { const { el, editor } = await setupEditor("

[]

"); await insertText(editor, "/3star"); await animationFrame(); expect(".o-we-powerbox").toHaveCount(1); await press("Enter"); expect(getContent(el)).toBe( `

\u200B\u200B\u200B\u200B\u200B[]

` ); }); test("add 5 star elements", async () => { const { el, editor } = await setupEditor("

[]

"); await insertText(editor, "/5star"); await animationFrame(); expect(".o-we-powerbox").toHaveCount(1); await press("Enter"); expect(getContent(el)).toBe( `

\u200B\u200B\u200B\u200B\u200B\u200B\u200B[]

` ); }); test("select star rating", async () => { const { el } = await setupEditor( `

\u200B\u200B\u200B\u200B\u200B[]

` ); await click("i.fa-star-o:first"); await animationFrame(); expect(getContent(el)).toBe( `

\u200B\u200B\u200B\u200B\u200B[]

` ); await click("i.fa-star-o:last"); await animationFrame(); expect(getContent(el)).toBe( `

\u200B\u200B\u200B\u200B\u200B[]

` ); await click("i.fa-star:last"); await animationFrame(); expect(getContent(el)).toBe( `

\u200B\u200B\u200B\u200B\u200B[]

` ); }); test("should delete star rating elements when delete is pressed twice", async () => { await testEditor({ contentBefore: `

\u200B\u200B\u200B\u200B\u200B[]

`, stepFunction: async (editor) => { deleteBackward(editor); deleteBackward(editor); }, contentAfter: "

[]

", }); });