[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) <trj@odoo.com>
This commit is contained in:
Joseph Caburnay
2023-03-28 18:45:50 +02:00
parent 27cdc052dd
commit 2cf46f6265
2 changed files with 19 additions and 11 deletions
@@ -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() });
@@ -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 () {},
}
]
},
];
}
}