| 1 |
import { |
| 2 |
clickOnSave, |
| 3 |
registerWebsitePreviewTour, |
| 4 |
changeOptionInPopover, |
| 5 |
} from "@website/js/tours/tour_utils"; |
| 6 |
|
| 7 |
function assertEqual(actual, expected) { |
| 8 |
if (actual !== expected) { |
| 9 |
throw new Error(`Assert failed: expected: ${expected} ; got: ${actual}`); |
| 10 |
} |
| 11 |
} |
| 12 |
|
| 13 |
registerWebsitePreviewTour('website_controller_page_listing_layout', { |
| 14 |
url: '/model/exposed-model', |
| 15 |
edition: true, |
| 16 |
}, () => [ |
| 17 |
{ |
| 18 |
content: "website is in preview mode", |
| 19 |
trigger: '.o_website_preview', |
| 20 |
run: "click", |
| 21 |
}, |
| 22 |
{ |
| 23 |
content: "records are listed in grid mode by default", |
| 24 |
trigger: ':iframe .o_website_grid', |
| 25 |
run() { |
| 26 |
const iframeDocument = document.querySelector(".o_website_preview iframe").contentDocument; |
| 27 |
// grid option is selected by default in the switch |
| 28 |
assertEqual(iframeDocument.querySelector(".listing_layout_switcher #o_wstudio_apply_grid").checked, true); |
| 29 |
assertEqual([...iframeDocument.querySelectorAll(".test_record_listing")].length, 2); |
| 30 |
}, |
| 31 |
}, |
| 32 |
{ |
| 33 |
content: "open customize tab", |
| 34 |
trigger: ":iframe .listing_layout_switcher", |
| 35 |
run: "click", |
| 36 |
}, |
| 37 |
{ |
| 38 |
trigger: ".o-snippets-menu .o_customize_tab", |
| 39 |
}, |
| 40 |
...changeOptionInPopover("Layout", "Default Layout", "list"), |
| 41 |
{ |
| 42 |
content: "records are now displayed in list mode", |
| 43 |
trigger: ':iframe .o_website_list', |
| 44 |
run() { |
| 45 |
const iframeDocument = document.querySelector(".o_website_preview iframe").contentDocument; |
| 46 |
// list option is now selected in the switch |
| 47 |
assertEqual(iframeDocument.querySelector(".listing_layout_switcher #o_wstudio_apply_list").checked, true); |
| 48 |
}, |
| 49 |
}, |
| 50 |
...clickOnSave(), |
| 51 |
]); |
| 52 |
|
| 53 |
registerWebsitePreviewTour('website_controller_page_default_page_check', { |
| 54 |
url: '/model/exposed-model', |
| 55 |
}, () => [ |
| 56 |
{ |
| 57 |
content: "records are listed in list mode by default", |
| 58 |
trigger: ':iframe [is-ready=true] .o_website_list', |
| 59 |
run() { |
| 60 |
const iframeDocument = document.querySelector(".o_website_preview iframe").contentDocument; |
| 61 |
// list option is selected by default in the switch |
| 62 |
assertEqual(iframeDocument.querySelector(".listing_layout_switcher #o_wstudio_apply_list").checked, true); |
| 63 |
assertEqual([...iframeDocument.querySelectorAll(".test_record_listing")].length, 2); |
| 64 |
}, |
| 65 |
}, |
| 66 |
]); |