| 1 | import { expect, test } from "@odoo/hoot"; |
| 2 | import { mountWithCleanup, onRpc, contains } from "@web/../tests/web_test_helpers"; |
| 3 | import { NewContentSystrayItem } from "@website/client_actions/website_preview/new_content_systray_item"; |
| 4 | import { defineWebsiteModels } from "./builder/website_helpers"; |
| 5 | |
| 6 | defineWebsiteModels(); |
| 7 | |
| 8 | function setupTest() { |
| 9 | onRpc("/web/dataset/call_kw/ir.module.module/search_read", () => { |
| 10 | expect.step("/web/dataset/call_kw/ir.module.module/search_read"); |
| 11 | return []; |
| 12 | }); |
| 13 | onRpc("/website/check_new_content_access_rights", () => { |
| 14 | expect.step("/website/check_new_content_access_rights"); |
| 15 | return []; |
| 16 | }); |
| 17 | onRpc("/website/get_new_page_templates", () => { |
| 18 | expect.step("/website/get_new_page_templates"); |
| 19 | return []; |
| 20 | }); |
| 21 | } |
| 22 | |
| 23 | test("can display a newcontent modal", async () => { |
| 24 | onRpc(({ route }) => { |
| 25 | expect.step(route); |
| 26 | return false; |
| 27 | }); |
| 28 | setupTest(); |
| 29 | await mountWithCleanup(NewContentSystrayItem, { |
| 30 | props: { |
| 31 | onNewPage: () => {}, |
| 32 | }, |
| 33 | }); |
| 34 | await contains(".o_new_content_container button").click(); |
| 35 | expect("div.o_new_content_menu_choices").toHaveCount(1); |
| 36 | expect.verifySteps([ |
| 37 | "/web/dataset/call_kw/ir.module.module/search_read", |
| 38 | "/website/check_new_content_access_rights", |
| 39 | "/website/get_new_page_templates", |
| 40 | ]); |
| 41 | }); |