import { setupHTMLBuilder } from "@html_builder/../tests/helpers"; import { expect, test, describe } from "@odoo/hoot"; import { animationFrame, clear, click, fill, waitFor } from "@odoo/hoot-dom"; import { contains } from "@web/../tests/web_test_helpers"; describe.current.tags("desktop"); const websiteContent = `
`; test("change rating score", async () => { await setupHTMLBuilder(websiteContent); expect(":iframe .s_rating .s_rating_active_icons i").toHaveCount(3); expect(":iframe .s_rating .s_rating_inactive_icons i").toHaveCount(2); await contains(":iframe .s_rating").click(); await contains(".options-container [data-action-id='activeIconsNumber'] input").click(); await clear(); await fill("1"); await animationFrame(); expect(":iframe .s_rating .s_rating_active_icons i").toHaveCount(1); await contains(".options-container [data-action-id='totalIconsNumber'] input").click(); await clear(); await fill("4"); await animationFrame(); expect(":iframe .s_rating .s_rating_inactive_icons i").toHaveCount(3); expect(":iframe .s_rating").toHaveInnerHTML( `Quality ` ); }); test("Ensure order of operations when clicking very fast on two options", async () => { await setupHTMLBuilder(websiteContent); await contains(":iframe .s_rating").click(); await waitFor("[data-label='Icon']"); expect("[data-label='Icon'] .dropdown-toggle").toHaveText("Stars"); expect(":iframe .s_rating").not.toHaveAttribute("data-active-custom-icon"); await click(".options-container [data-action-id='customIcon']"); await click(".options-container [data-class-action='fa-2x']"); await animationFrame(); expect(":iframe .s_rating_icons").not.toHaveClass("fa-2x"); await contains(".modal-dialog .fa-glass").click(); expect(":iframe .s_rating").toHaveAttribute("data-active-custom-icon", "fa fa-glass"); expect("[data-label='Icon'] .dropdown-toggle").toHaveText("Custom"); expect(":iframe .s_rating_icons").toHaveClass("fa-2x"); await contains(".o-snippets-top-actions .fa-undo").click(); expect("[data-label='Icon'] .dropdown-toggle").toHaveText("Custom"); expect(":iframe .s_rating").toHaveAttribute("data-active-custom-icon", "fa fa-glass"); expect(":iframe .s_rating_icons").not.toHaveClass("fa-2x"); await contains(".o-snippets-top-actions .fa-undo").click(); expect("[data-label='Icon'] .dropdown-toggle").toHaveText("Stars"); expect(":iframe .s_rating").not.toHaveAttribute("data-active-custom-icon"); expect(":iframe .s_rating_icons").not.toHaveClass("fa-2x"); });