| 1 |
import { describe, expect, test } from "@odoo/hoot"; |
| 2 |
import { animationFrame, click, tick } from "@odoo/hoot-dom"; |
| 3 |
import { defineStyle } from "@web/../tests/web_test_helpers"; |
| 4 |
import { setupInteractionWhiteList, startInteractions } from "@web/../tests/public/helpers"; |
| 5 |
|
| 6 |
setupInteractionWhiteList("website.popup"); |
| 7 |
describe.current.tags("interaction_dev"); |
| 8 |
|
| 9 |
test("click on primary button which is add to cart button doesn't close popup", async () => { |
| 10 |
defineStyle(`* { transition: none !important; }`); |
| 11 |
const { core } = await startInteractions(` |
| 12 |
<div class="s_popup o_snippet_invisible" data-vcss="001" data-snippet="s_popup" |
| 13 |
data-name="Popup" id="sPopup" data-invisible="1"> |
| 14 |
<div class="modal fade s_popup_middle modal_shown" |
| 15 |
style="background-color: var(--black-50) !important; display: none;" |
| 16 |
data-show-after="0" |
| 17 |
data-display="afterDelay" |
| 18 |
data-consents-duration="7" |
| 19 |
data-bs-focus="false" |
| 20 |
data-bs-backdrop="false" |
| 21 |
tabindex="-1" |
| 22 |
aria-label="Popup" |
| 23 |
aria-modal="true" |
| 24 |
role="dialog"> |
| 25 |
<div class="modal-dialog d-flex"> |
| 26 |
<div class="modal-content oe_structure"> |
| 27 |
<div class="s_popup_close js_close_popup o_we_no_overlay o_not_editable" aria-label="Close">×</div> |
| 28 |
<section> |
| 29 |
<a href="#" class="btn btn-primary js_add_cart">Primary button</a> |
| 30 |
</section> |
| 31 |
</div> |
| 32 |
</div> |
| 33 |
</div> |
| 34 |
</div > |
| 35 |
`); |
| 36 |
expect(core.interactions).toHaveLength(1); |
| 37 |
const modal = "#sPopup .modal"; |
| 38 |
await tick(); |
| 39 |
await animationFrame(); |
| 40 |
expect(modal).toBeVisible(); |
| 41 |
await tick(); |
| 42 |
await click(".btn-primary"); |
| 43 |
expect(modal).toBeVisible(); |
| 44 |
}); |