@@ -3,9 +3,10 @@ import {
33 insertSnippet ,
44 registerWebsitePreviewTour ,
55 toggleMobilePreview ,
6+ changeOptionInPopover ,
67} from '@website/js/tours/tour_utils' ;
78
8- const columnCountOptSelector = ".snippet-option-layout_column we-select [data-name='column_count_opt'] " ;
9+ const columnCountOptSelector = "div [data-label='Layout'] .dropdown-toggle " ;
910const columnsSnippetRow = ":iframe .s_three_columns .row" ;
1011const textImageSnippetRow = ":iframe .s_text_image .row" ;
1112const changeFirstAndSecondColumnsMobileOrder = ( snippetRowSelector , snippetName ) => {
@@ -48,47 +49,35 @@ registerWebsitePreviewTour("website_update_column_count", {
4849...clickOnSnippet ( {
4950 id : "s_three_columns" ,
5051 name : "Columns" ,
51- } ) , {
52- content : "Open the columns count select" ,
53- trigger : columnCountOptSelector ,
54- run : "click" ,
55- } , {
56- content : "Set 5 columns on desktop" ,
57- trigger : `${ columnCountOptSelector } we-button[data-select-count='5']` ,
58- run : "click" ,
59- } , {
52+ } ) ,
53+ ...changeOptionInPopover ( "Columns" , "Layout" , "[data-action-value='5']" ) ,
54+ {
6055 content : "Check that there are now 5 items on 5 columns, and that it didn't change the mobile layout" ,
6156 trigger : `${ columnsSnippetRow } :has(.col-lg-2:nth-child(5):not(.col-2)):not(:has(:nth-child(6)))` ,
6257} , {
6358 content : "Check that there is an offset on the 1st item to center the row on desktop, but not on mobile" ,
6459 trigger : `${ columnsSnippetRow } > .offset-lg-1:not(.offset-1):first-child` ,
65- } , {
66- content : "Open the columns count select" ,
67- trigger : columnCountOptSelector ,
68- run : "click" ,
69- } , {
70- content : "Set 2 columns on desktop" ,
71- trigger : `${ columnCountOptSelector } we-button[data-select-count='2']` ,
72- run : "click" ,
73- } , {
60+ } ,
61+ ...changeOptionInPopover ( "Columns" , "Layout" , "[data-action-value='2']" ) ,
62+ {
7463 content : "Check that there are still 5 items in the row and click on the last one" ,
7564 trigger : `${ columnsSnippetRow } > :nth-child(5)` ,
7665 run : "click" ,
7766} , {
7867 content : "Delete the item" ,
79- trigger : "we- title:contains( 'Card') .oe_snippet_remove" ,
68+ trigger : "div[data-container- title= 'Card'] .oe_snippet_remove" ,
8069 run : "click" ,
8170} , {
8271 content : "Toggle mobile view" ,
83- trigger : ".o_we_website_top_actions [data-action='mobile']" ,
72+ trigger : ".o-snippets-top-actions button [data-action='mobile']" ,
8473 run : "click" ,
8574} , {
8675 content : "Check that there is 1 column on mobile and click on the selector" ,
87- trigger : `${ columnCountOptSelector } we-toggler :contains('1')` ,
76+ trigger : `${ columnCountOptSelector } :contains('1')` ,
8877 run : "click" ,
8978} , {
9079 content : "Set 3 columns on mobile" ,
91- trigger : ` ${ columnCountOptSelector } we-button [data-select-count ='3']` ,
80+ trigger : ".o_popover div[data-action-id='changeColumnCount'] [data-action-value ='3']" ,
9281 run : "click" ,
9382} , {
9483 content : "Check that there are still 4 items but on rows of 3 columns" ,
@@ -97,60 +86,68 @@ registerWebsitePreviewTour("website_update_column_count", {
9786// As there is no practical way to resize the items through the handles, the
9887// next step approximates part of what could be reached.
9988{
89+ content : "Click on the 2nd item" ,
90+ trigger : `${ columnsSnippetRow } > :nth-child(2)` ,
91+ run : "click" ,
92+ } , {
10093 content : "Add a fake resized class on mobile to the 2nd item" ,
10194 trigger : `${ columnsSnippetRow } > :nth-child(2)` ,
102- run ( ) {
103- this . anchor . classList . replace ( "col-4" , "col-6" ) ;
104- // As this is a hardcoded class replacement, a click is needed to
105- // update the column count.
106- this . anchor . previousElementSibling . click ( ) ;
107- } ,
95+ async run ( ) {
96+ const overlayEl = document . querySelector ( ".oe_overlay.oe_active .o_side_x.e" ) ;
97+
98+ const triggerPointerEvent = ( type , x , y ) => {
99+ const event = new PointerEvent ( type , {
100+ bubbles : true ,
101+ pageX : x ,
102+ pageY : y ,
103+ clientX : x ,
104+ clientY : y ,
105+ pointerType : 'mouse' ,
106+ } ) ;
107+ ( type === "pointermove" ? window : overlayEl ) . dispatchEvent ( event ) ;
108+ } ;
109+
110+ // Trigger pointer down
111+ triggerPointerEvent ( "pointerdown" , 100 , 100 ) ;
112+ // Wait for the mutex/this.next to lock and sizingResolve to be ready
113+ await new Promise ( ( resolve ) => setTimeout ( resolve , 0 ) ) ;
114+ // Dragging
115+ triggerPointerEvent ( "pointermove" , 150 , 100 ) ;
116+ triggerPointerEvent ( "pointerup" , 150 , 100 ) ;
117+ }
108118} , {
109119 content : "Check that the counter shows 'Custom'" ,
110- trigger : `${ columnCountOptSelector } we-toggler :contains('Custom')` ,
120+ trigger : `${ columnCountOptSelector } :contains('Custom')` ,
111121} , {
112122 content : "Click on the 2nd item" ,
113123 trigger : `${ columnsSnippetRow } > :nth-child(2)` ,
114124 run : "click" ,
115125} , {
116126 content : "Change the orders of the 2nd and 3rd items" ,
117- trigger : ":iframe .o_overlay_move_options [data-name='move_right_opt ']" ,
127+ trigger : ".o_overlay_options [aria-label='Move right ']" ,
118128 run : "click" ,
119- } ,
120- {
129+ } , {
121130 trigger : `${ columnsSnippetRow } :has([style*='order: 2;'].order-lg-0:nth-child(2) + [style*='order: 1;'].order-lg-0:nth-child(3))` ,
122- } ,
123- {
131+ } , {
124132 content : "Check that the 1st item now has order: 0 and a class .order-lg-0 " +
125133 "and that order: 1, .order-lg-0 is set on the 3rd item, and order: 2, .order-lg-0 on the 2nd" ,
126134 trigger : `${ columnsSnippetRow } :has([style*='order: 0;'].order-lg-0:first-child)` ,
127135} , {
128136 content : "Toggle desktop view" ,
129- trigger : ".o_we_website_top_actions [data-action='mobile']" ,
137+ trigger : ".o-snippets-top-actions button [data-action='mobile']" ,
130138 run : "click" ,
131- } , {
132- content : "Open the columns count select" ,
133- trigger : columnCountOptSelector ,
134- run : "click" ,
135- } , {
136- content : "Add 2 more items through the columns counter" ,
137- trigger : `${ columnCountOptSelector } we-button[data-select-count='6']` ,
138- run : "click" ,
139- } , {
139+ } ,
140+ ...changeOptionInPopover ( "Columns" , "Layout" , "[data-action-value='6']" ) ,
141+ {
140142 content : "Check that each item has a different mobile order from 0 to 5" ,
141143 trigger : `${ columnsSnippetRow } ${ [ 0 , 1 , 2 , 3 , 4 , 5 ] . map ( n => `:has([style*='order: ${ n } ;'].order-lg-0)` ) . join ( "" ) } ` ,
142144} , {
143145 content : "Click on the 6th item" ,
144146 trigger : `${ columnsSnippetRow } > :nth-child(6)` ,
145147 run : "click" ,
146- } , {
147- // TODO: remove this step. It should not be needed, but the build fails
148- // without it.
149- content : "Wait for move arrows to appear" ,
150- trigger : ":iframe .o_overlay_move_options:has([data-name='move_left_opt'] + .d-none[data-name='move_right_opt'])" ,
151148} , {
152149 content : "Change the orders of the 5th and 6th items to override the mobile orders" ,
153- trigger : ":iframe .o_overlay_move_options [data-name='move_left_opt ']" ,
150+ trigger : ".o_overlay_options [aria-label='Move left ']" ,
154151 run : "click" ,
155152} , {
156153 content : "Check that there are no orders anymore" ,
0 commit comments