From 2cf46f626532d859fddc781b23bd99b62c3d8e3b Mon Sep 17 00:00:00 2001 From: Joseph Caburnay Date: Tue, 28 Mar 2023 11:20:10 +0000 Subject: [PATCH] [FIX] pos_loyalty: random tour error when selecting reward In the current tour steps, there's ambiguity in the failing step and its preceding steps. Basically, the failing step asks to click a selection item that contains "Monitor Stand" and the previous step also do the same: clicking a selection item with "Free Product - [Desk Pad, Monitor Stand]". And if you notice, both step has text "Monitor Stand". Given the nature of the tour runner, it will try as fast as it could to do the steps, so it will click "Free Product - [Desk Pad, Monitor Stand]" then it will immediately be followed by clicking "Monitor Stand" which is the same element clicked by the previous step. In essence, the two steps only resulted in one action. As a solution, we make sure to distinguish the first step of selecting the reward program, followed by selecting the reward product. We use the fact that a second span under `.selection-item` will be rendered when displaying the program selection, therefore, we introduce an extra_trigger in first step (provided by `claimReward` helper function). Then, we add more steps that checks the selection items on the expected 2nd selection popup. closes odoo/odoo#116819 Signed-off-by: Trinh Jacky (trj) --- .../src/tours/PosLoyaltyRewardButtonTour.js | 16 +++++++++++----- .../static/src/tours/PosLoyaltyTourMethods.js | 14 ++++++++------ 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/addons/pos_loyalty/static/src/tours/PosLoyaltyRewardButtonTour.js b/addons/pos_loyalty/static/src/tours/PosLoyaltyRewardButtonTour.js index 59d5892bc91..14282b5f3b0 100644 --- a/addons/pos_loyalty/static/src/tours/PosLoyaltyRewardButtonTour.js +++ b/addons/pos_loyalty/static/src/tours/PosLoyaltyRewardButtonTour.js @@ -121,6 +121,8 @@ ProductScreen.do.pressNumpad("Backspace"); ProductScreen.do.pressNumpad("Backspace"); PosLoyalty.check.isRewardButtonHighlighted(true); PosLoyalty.do.claimReward("Free Product - [Desk Pad, Monitor Stand]"); +SelectionPopup.check.hasSelectionItem("Monitor Stand"); +SelectionPopup.check.hasSelectionItem("Desk Pad"); SelectionPopup.do.clickItem("Monitor Stand"); PosLoyalty.check.isRewardButtonHighlighted(false); ProductScreen.check.selectedOrderlineHas("Monitor Stand", "1.00", "3.19"); @@ -128,19 +130,23 @@ PosLoyalty.check.hasRewardLine("Free Product", "-3.19", "1.00"); PosLoyalty.check.orderTotalIs("4.81"); PosLoyalty.exec.finalizeOrder("Cash", "10"); -registry.category("web_tour.tours").add("PosLoyaltyFreeProductTour", { test: true, url: "/pos/web", steps: getSteps() }); +registry + .category("web_tour.tours") + .add("PosLoyaltyFreeProductTour", { test: true, url: "/pos/web", steps: getSteps() }); startSteps(); ProductScreen.do.confirmOpeningPopup(); ProductScreen.do.clickHomeCategory(); ProductScreen.do.clickPartnerButton(); -ProductScreen.do.clickCustomer('AAA Partner'); -ProductScreen.exec.addOrderline('Test Product A', '1'); +ProductScreen.do.clickCustomer("AAA Partner"); +ProductScreen.exec.addOrderline("Test Product A", "1"); PosLoyalty.check.isRewardButtonHighlighted(true); PosLoyalty.do.clickRewardButton(); SelectionPopup.do.clickItem("Free Product - Test Product A"); -PosLoyalty.check.hasRewardLine('Free Product - Test Product A', '-11.50', '1.00'); +PosLoyalty.check.hasRewardLine("Free Product - Test Product A", "-11.50", "1.00"); PosLoyalty.check.isRewardButtonHighlighted(false); -registry.category("web_tour.tours").add("PosLoyaltyFreeProductTour2", { test: true, url: "/pos/web", steps: getSteps() }); +registry + .category("web_tour.tours") + .add("PosLoyaltyFreeProductTour2", { test: true, url: "/pos/web", steps: getSteps() }); diff --git a/addons/pos_loyalty/static/src/tours/PosLoyaltyTourMethods.js b/addons/pos_loyalty/static/src/tours/PosLoyaltyTourMethods.js index bbb6e4e6ab1..f5a591ed9c3 100644 --- a/addons/pos_loyalty/static/src/tours/PosLoyaltyTourMethods.js +++ b/addons/pos_loyalty/static/src/tours/PosLoyaltyTourMethods.js @@ -77,6 +77,8 @@ class Do { }, { content: "select reward", + // There should be description because a program always has a name. + extra_trigger: ".selection-item span:nth-child(2)", trigger: `.selection-item:contains("${rewardName}")`, }, ]; @@ -87,16 +89,16 @@ class Do { clickDiscountButton() { return [ { - content: 'click discount button', - trigger: '.js_discount', + content: "click discount button", + trigger: ".js_discount", }, ]; } clickConfirmButton() { return [ { - content: 'click confirm button', - trigger: '.button.confirm', + content: "click confirm button", + trigger: ".button.confirm", }, ]; } @@ -176,8 +178,8 @@ class Check { { trigger: `.o_notification span:contains("${str}")`, run: function () {}, - } - ] + }, + ]; } }