Skip to content

Commit fb53b18

Browse files
divy-odooged-odoo
authored andcommitted
[IMP] website: adapt website_update_column_count
This commit include the fix of website_update_column_cout tour and update the option on toggle on/off mobile preview.
1 parent 3b3c696 commit fb53b18

File tree

2 files changed

+48
-52
lines changed

2 files changed

+48
-52
lines changed

addons/website/static/tests/tours/website_update_column_count.js

Lines changed: 48 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -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";
910
const columnsSnippetRow = ":iframe .s_three_columns .row";
1011
const textImageSnippetRow = ":iframe .s_text_image .row";
1112
const 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",

addons/website/tests/test_ui.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -620,7 +620,6 @@ def test_website_media_dialog_insert_media(self):
620620
def test_website_text_font_size(self):
621621
self.start_tour('/@/', 'website_text_font_size', login='admin', timeout=300)
622622

623-
@unittest.skip
624623
def test_update_column_count(self):
625624
self.start_tour(self.env['website'].get_client_action_url('/'), 'website_update_column_count', login="admin")
626625

0 commit comments

Comments
 (0)