| 1 |
/* global ace */ |
| 2 |
|
| 3 |
import { clickOnSave, registerWebsitePreviewTour } from "@website/js/tours/tour_utils"; |
| 4 |
|
| 5 |
var BROKEN_STEP = { |
| 6 |
// because saving a broken template opens a recovery page with no assets |
| 7 |
// there's no way for the tour to resume on the new page, and thus no way |
| 8 |
// to properly wait for the page to be saved & reloaded in order to fix the |
| 9 |
// race condition of a tour ending on a side-effect (with the possible |
| 10 |
// exception of somehow telling the harness / browser to do it) |
| 11 |
trigger: "body", |
| 12 |
}; |
| 13 |
registerWebsitePreviewTour( |
| 14 |
"test_reset_page_view_complete_flow_part1", |
| 15 |
{ |
| 16 |
url: "/test_page_view", |
| 17 |
// 1. Edit the page through Edit Mode, it will COW the view |
| 18 |
edition: true, |
| 19 |
}, |
| 20 |
() => [ |
| 21 |
{ |
| 22 |
content: "Drag the Intro snippet group and drop it in #oe_structure_test_website_page.", |
| 23 |
trigger: |
| 24 |
".o_block_tab:not(.o_we_ongoing_insertion) #snippet_groups .o_snippet[name='Intro'] .o_snippet_thumbnail .o_snippet_thumbnail_area", |
| 25 |
// id starting by 'oe_structure..' will actually create an inherited view |
| 26 |
run: "drag_and_drop :iframe #oe_structure_test_website_page", |
| 27 |
}, |
| 28 |
{ |
| 29 |
content: "Click on the s_cover snippet.", |
| 30 |
trigger: ':iframe .o_snippet_preview_wrap[data-snippet-id="s_cover"]', |
| 31 |
run: "click", |
| 32 |
}, |
| 33 |
...clickOnSave(), |
| 34 |
// 2. Edit that COW'd view in the HTML editor to break it. |
| 35 |
{ |
| 36 |
content: "open site menu", |
| 37 |
trigger: 'button[data-menu-xmlid="website.menu_site"]', |
| 38 |
run: "click", |
| 39 |
}, |
| 40 |
{ |
| 41 |
content: "open html editor", |
| 42 |
trigger: 'a[data-menu-xmlid="website.menu_ace_editor"]', |
| 43 |
run: "click", |
| 44 |
}, |
| 45 |
{ |
| 46 |
content: "add a broken t-field in page DOM", |
| 47 |
trigger: 'div.ace_line .ace_xml:contains("placeholder")', |
| 48 |
run() { |
| 49 |
ace.edit(document.querySelector("#resource-editor div")) |
| 50 |
.getSession() |
| 51 |
.insert({row: 4, column: 1}, '<t t-field="not.exist"/>\n'); |
| 52 |
}, |
| 53 |
}, |
| 54 |
{ |
| 55 |
trigger: '.ace_content:contains("not.exist")', |
| 56 |
}, |
| 57 |
{ |
| 58 |
content: "save the html editor", |
| 59 |
trigger: ".o_resource_editor button:contains(Save)", |
| 60 |
run: "click", |
| 61 |
}, |
| 62 |
BROKEN_STEP, |
| 63 |
] |
| 64 |
); |
| 65 |
|
| 66 |
registerWebsitePreviewTour( |
| 67 |
"test_reset_page_view_complete_flow_part2", |
| 68 |
{ |
| 69 |
url: "/test_page_view", |
| 70 |
}, |
| 71 |
() => [ |
| 72 |
{ |
| 73 |
content: "check that the view got fixed", |
| 74 |
trigger: ":iframe p:text(Test Page View)", |
| 75 |
}, |
| 76 |
{ |
| 77 |
content: "check that the inherited COW view is still there (created during edit mode)", |
| 78 |
trigger: ":iframe #oe_structure_test_website_page .s_cover", |
| 79 |
}, |
| 80 |
//4. Now break the inherited view created when dropping a snippet |
| 81 |
{ |
| 82 |
content: "open site menu", |
| 83 |
trigger: 'button[data-menu-xmlid="website.menu_site"]', |
| 84 |
run: "click", |
| 85 |
}, |
| 86 |
{ |
| 87 |
content: "open html editor", |
| 88 |
trigger: 'a[data-menu-xmlid="website.menu_ace_editor"]', |
| 89 |
run: "click", |
| 90 |
}, |
| 91 |
{ |
| 92 |
content: "select oe_structure view", |
| 93 |
trigger: ".o_resource_editor_title .o_select_menu_toggler", |
| 94 |
run: "click", |
| 95 |
}, |
| 96 |
{ |
| 97 |
content: "select oe_structure view", |
| 98 |
trigger: ".o_select_menu_menu .o_select_menu_item:contains(Test Page View)", |
| 99 |
run: "click", |
| 100 |
}, |
| 101 |
{ |
| 102 |
content: "add a broken t-field in page DOM", |
| 103 |
trigger: 'div.ace_line .ace_xml:contains("oe_structure_test_website_page")', |
| 104 |
run() { |
| 105 |
ace.edit(document.querySelector("#resource-editor div")) |
| 106 |
.getSession() |
| 107 |
.insert({row: 4, column: 1}, '<t t-field="not.exist"/>\n'); |
| 108 |
}, |
| 109 |
}, |
| 110 |
{ |
| 111 |
content: "save the html editor", |
| 112 |
trigger: ".o_resource_editor button:contains(Save)", |
| 113 |
run: "click", |
| 114 |
}, |
| 115 |
BROKEN_STEP, |
| 116 |
] |
| 117 |
); |