| 1 |
import * as Dialog from "@point_of_sale/../tests/generic_helpers/dialog_util"; |
| 2 |
import * as PosLoyalty from "@pos_loyalty/../tests/tours/utils/pos_loyalty_util"; |
| 3 |
import * as ProductScreen from "@point_of_sale/../tests/pos/tours/utils/product_screen_util"; |
| 4 |
import * as Chrome from "@point_of_sale/../tests/pos/tours/utils/chrome_util"; |
| 5 |
import * as SelectionPopup from "@point_of_sale/../tests/generic_helpers/selection_popup_util"; |
| 6 |
import { registry } from "@web/core/registry"; |
| 7 |
import * as ProductConfiguratorPopup from "@point_of_sale/../tests/pos/tours/utils/product_configurator_util"; |
| 8 |
import { negateStep } from "@point_of_sale/../tests/generic_helpers/utils"; |
| 9 |
import * as PartnerList from "@point_of_sale/../tests/pos/tours/utils/partner_list_util"; |
| 10 |
|
| 11 |
registry.category("web_tour.tours").add("PosLoyaltyFreeProductTour", { |
| 12 |
steps: () => |
| 13 |
[ |
| 14 |
Chrome.startPoS(), |
| 15 |
Dialog.confirm("Open Register"), |
| 16 |
|
| 17 |
ProductScreen.addOrderline("Desk Organizer", "2"), |
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
PosLoyalty.isRewardButtonHighlighted(true), |
| 22 |
|
| 23 |
ProductScreen.clickDisplayedProduct("Desk Organizer", "3"), |
| 24 |
PosLoyalty.hasRewardLine("Free Product - Desk Organizer", "-5.10", "1"), |
| 25 |
|
| 26 |
|
| 27 |
ProductScreen.clickDisplayedProduct("Desk Organizer"), |
| 28 |
ProductScreen.clickDisplayedProduct("Desk Organizer"), |
| 29 |
PosLoyalty.isRewardButtonHighlighted(true), |
| 30 |
ProductScreen.clickDisplayedProduct("Desk Organizer", true, "6"), |
| 31 |
PosLoyalty.hasRewardLine("Free Product - Desk Organizer", "-10.20", "2"), |
| 32 |
|
| 33 |
ProductScreen.clickDisplayedProduct("Desk Organizer"), |
| 34 |
PosLoyalty.isRewardButtonHighlighted(false), |
| 35 |
PosLoyalty.orderTotalIs("25.50"), |
| 36 |
|
| 37 |
PosLoyalty.finalizeOrder("Cash", "30"), |
| 38 |
|
| 39 |
ProductScreen.clickDisplayedProduct("Desk Organizer", true, "1"), |
| 40 |
ProductScreen.clickDisplayedProduct("Desk Organizer", true, "2"), |
| 41 |
ProductScreen.clickDisplayedProduct("Desk Organizer"), |
| 42 |
PosLoyalty.hasRewardLine("Free Product - Desk Organizer", "-5.10", "1"), |
| 43 |
ProductScreen.clickNumpad("9"), |
| 44 |
ProductScreen.selectedOrderlineHas("Desk Organizer", "9"), |
| 45 |
PosLoyalty.hasRewardLine("Free Product - Desk Organizer", "-15.30", "3"), |
| 46 |
ProductScreen.clickNumpad("⌫"), |
| 47 |
ProductScreen.selectedOrderlineHas("Desk Organizer", "0"), |
| 48 |
ProductScreen.clickDisplayedProduct("Desk Organizer", true, "1"), |
| 49 |
ProductScreen.clickDisplayedProduct("Desk Organizer", true, "2"), |
| 50 |
PosLoyalty.isRewardButtonHighlighted(true), |
| 51 |
|
| 52 |
|
| 53 |
PosLoyalty.orderTotalIs("10.20"), |
| 54 |
PosLoyalty.finalizeOrder("Cash", "20"), |
| 55 |
|
| 56 |
ProductScreen.addOrderline("Magnetic Board", "2"), |
| 57 |
PosLoyalty.isRewardButtonHighlighted(false), |
| 58 |
ProductScreen.clickDisplayedProduct("Magnetic Board"), |
| 59 |
PosLoyalty.isRewardButtonHighlighted(true), |
| 60 |
ProductScreen.clickDisplayedProduct("Whiteboard Pen"), |
| 61 |
PosLoyalty.isRewardButtonHighlighted(false), |
| 62 |
PosLoyalty.hasRewardLine("Free Product - Whiteboard Pen", "-3.20", "1"), |
| 63 |
ProductScreen.clickOrderline("Magnetic Board", "3"), |
| 64 |
ProductScreen.selectedOrderlineHas("Magnetic Board", "3"), |
| 65 |
ProductScreen.clickNumpad("6"), |
| 66 |
ProductScreen.selectedOrderlineHas("Magnetic Board", "6"), |
| 67 |
PosLoyalty.isRewardButtonHighlighted(true), |
| 68 |
PosLoyalty.claimReward("Free Product - Whiteboard Pen"), |
| 69 |
PosLoyalty.isRewardButtonHighlighted(false), |
| 70 |
PosLoyalty.hasRewardLine("Free Product - Whiteboard Pen", "-6.40", "2"), |
| 71 |
|
| 72 |
PosLoyalty.orderTotalIs("11.88"), |
| 73 |
PosLoyalty.finalizeOrder("Cash", "20"), |
| 74 |
|
| 75 |
ProductScreen.addOrderline("Magnetic Board", "6"), |
| 76 |
ProductScreen.clickDisplayedProduct("Whiteboard Pen"), |
| 77 |
PosLoyalty.hasRewardLine("Free Product - Whiteboard Pen", "-3.20", "1"), |
| 78 |
PosLoyalty.isRewardButtonHighlighted(true), |
| 79 |
|
| 80 |
ProductScreen.clickOrderline("Magnetic Board", "6"), |
| 81 |
ProductScreen.clickNumpad("⌫"), |
| 82 |
|
| 83 |
PosLoyalty.isRewardButtonHighlighted(false), |
| 84 |
ProductScreen.selectedOrderlineHas("Magnetic Board", "0"), |
| 85 |
ProductScreen.clickDisplayedProduct("Magnetic Board"), |
| 86 |
ProductScreen.selectedOrderlineHas("Magnetic Board", "1"), |
| 87 |
ProductScreen.clickDisplayedProduct("Magnetic Board"), |
| 88 |
ProductScreen.selectedOrderlineHas("Magnetic Board", "2"), |
| 89 |
ProductScreen.clickDisplayedProduct("Magnetic Board"), |
| 90 |
ProductScreen.selectedOrderlineHas("Magnetic Board", "3"), |
| 91 |
PosLoyalty.hasRewardLine("Free Product - Whiteboard Pen", "-3.20", "1"), |
| 92 |
PosLoyalty.isRewardButtonHighlighted(false), |
| 93 |
|
| 94 |
PosLoyalty.orderTotalIs("5.94"), |
| 95 |
PosLoyalty.finalizeOrder("Cash", "10"), |
| 96 |
|
| 97 |
|
| 98 |
|
| 99 |
ProductScreen.clickDisplayedProduct("Wall Shelf Unit"), |
| 100 |
ProductScreen.selectedOrderlineHas("Wall Shelf Unit", "1"), |
| 101 |
PosLoyalty.isRewardButtonHighlighted(false), |
| 102 |
ProductScreen.clickDisplayedProduct("Small Shelf"), |
| 103 |
ProductScreen.selectedOrderlineHas("Small Shelf", "1"), |
| 104 |
PosLoyalty.isRewardButtonHighlighted(true), |
| 105 |
|
| 106 |
ProductScreen.clickDisplayedProduct("Desk Pad"), |
| 107 |
PosLoyalty.isRewardButtonHighlighted(false), |
| 108 |
PosLoyalty.hasRewardLine("Free Product", "-1.98", "1"), |
| 109 |
|
| 110 |
|
| 111 |
ProductScreen.clickNumpad("⌫"), |
| 112 |
ProductScreen.clickNumpad("⌫"), |
| 113 |
PosLoyalty.isRewardButtonHighlighted(true), |
| 114 |
PosLoyalty.claimReward("Free Product - [Desk Pad, Monitor Stand]"), |
| 115 |
SelectionPopup.has("Monitor Stand"), |
| 116 |
SelectionPopup.has("Desk Pad"), |
| 117 |
SelectionPopup.has("Desk Pad", { run: "click" }), |
| 118 |
PosLoyalty.isRewardButtonHighlighted(false), |
| 119 |
PosLoyalty.hasRewardLine("Free Product", "-1.98", "1"), |
| 120 |
ProductScreen.clickNumpad("⌫"), |
| 121 |
ProductScreen.clickNumpad("⌫"), |
| 122 |
PosLoyalty.isRewardButtonHighlighted(true), |
| 123 |
PosLoyalty.claimReward("Free Product - [Desk Pad, Monitor Stand]"), |
| 124 |
SelectionPopup.has("Monitor Stand"), |
| 125 |
SelectionPopup.has("Desk Pad"), |
| 126 |
SelectionPopup.has("Monitor Stand", { run: "click" }), |
| 127 |
PosLoyalty.isRewardButtonHighlighted(false), |
| 128 |
ProductScreen.selectedOrderlineHas("Monitor Stand", "1", "3.19"), |
| 129 |
PosLoyalty.hasRewardLine("Free Product", "-3.19", "1"), |
| 130 |
PosLoyalty.orderTotalIs("4.81"), |
| 131 |
PosLoyalty.finalizeOrder("Cash", "10"), |
| 132 |
].flat(), |
| 133 |
}); |
| 134 |
|
| 135 |
registry.category("web_tour.tours").add("PosLoyaltyFreeProductTour2", { |
| 136 |
steps: () => |
| 137 |
[ |
| 138 |
Chrome.startPoS(), |
| 139 |
Dialog.confirm("Open Register"), |
| 140 |
|
| 141 |
ProductScreen.clickPartnerButton(), |
| 142 |
ProductScreen.clickCustomer("AAA Partner"), |
| 143 |
ProductScreen.addOrderline("Test Product A", "1"), |
| 144 |
PosLoyalty.isRewardButtonHighlighted(true, true), |
| 145 |
ProductScreen.clickControlButton("Reward"), |
| 146 |
SelectionPopup.has("Free Product - Test Product A", { run: "click" }), |
| 147 |
PosLoyalty.hasRewardLine("Free Product - Test Product A", "-11.50", "1"), |
| 148 |
PosLoyalty.isRewardButtonHighlighted(false), |
| 149 |
].flat(), |
| 150 |
}); |
| 151 |
|
| 152 |
registry.category("web_tour.tours").add("test_loyalty_free_product_rewards_2", { |
| 153 |
steps: () => |
| 154 |
[ |
| 155 |
Chrome.startPoS(), |
| 156 |
Dialog.confirm("Open Register"), |
| 157 |
|
| 158 |
ProductScreen.clickDisplayedProduct("Desk Organizer"), |
| 159 |
ProductScreen.clickDisplayedProduct("Desk Organizer"), |
| 160 |
ProductScreen.clickDisplayedProduct("Desk Organizer"), |
| 161 |
PosLoyalty.hasRewardLine("Free Product - Desk Organizer", "-5.10", "1.00"), |
| 162 |
PosLoyalty.orderTotalIs("10.20"), |
| 163 |
PosLoyalty.finalizeOrder("Cash", "10.20"), |
| 164 |
].flat(), |
| 165 |
}); |
| 166 |
|
| 167 |
registry.category("web_tour.tours").add("PosLoyaltySpecificDiscountTour", { |
| 168 |
steps: () => |
| 169 |
[ |
| 170 |
Chrome.startPoS(), |
| 171 |
Dialog.confirm("Open Register"), |
| 172 |
|
| 173 |
ProductScreen.clickDisplayedProduct("Test Product A"), |
| 174 |
ProductScreen.selectedOrderlineHas("Test Product A", "1", "40.00"), |
| 175 |
ProductScreen.clickDisplayedProduct("Test Product B"), |
| 176 |
ProductScreen.selectedOrderlineHas("Test Product B", "1", "40.00"), |
| 177 |
ProductScreen.clickControlButton("Reward"), |
| 178 |
SelectionPopup.has("$ 10 on specific products", { run: "click" }), |
| 179 |
PosLoyalty.hasRewardLine("$ 10 on specific products", "-10.00", "1"), |
| 180 |
PosLoyalty.orderTotalIs("70.00"), |
| 181 |
ProductScreen.clickControlButton("Reward"), |
| 182 |
SelectionPopup.has("$ 10 on specific products", { run: "click" }), |
| 183 |
PosLoyalty.orderTotalIs("60.00"), |
| 184 |
ProductScreen.clickControlButton("Reward"), |
| 185 |
SelectionPopup.has("$ 30 on specific products", { run: "click" }), |
| 186 |
PosLoyalty.hasRewardLine("$ 30 on specific products", "-30.00", "1"), |
| 187 |
PosLoyalty.orderTotalIs("30.00"), |
| 188 |
].flat(), |
| 189 |
}); |
| 190 |
|
| 191 |
registry.category("web_tour.tours").add("PosLoyaltySpecificDiscountWithFreeProductTour", { |
| 192 |
steps: () => |
| 193 |
[ |
| 194 |
Chrome.startPoS(), |
| 195 |
Dialog.confirm("Open Register"), |
| 196 |
ProductScreen.clickDisplayedProduct("Test Product A"), |
| 197 |
ProductScreen.clickDisplayedProduct("Test Product C"), |
| 198 |
PosLoyalty.orderTotalIs("130.00"), |
| 199 |
PosLoyalty.isRewardButtonHighlighted(true, false), |
| 200 |
{ |
| 201 |
content: `click Reward button`, |
| 202 |
trigger: ProductScreen.controlButtonTrigger("Reward"), |
| 203 |
run: "click", |
| 204 |
}, |
| 205 |
Dialog.cancel(), |
| 206 |
PosLoyalty.orderTotalIs("130.00"), |
| 207 |
].flat(), |
| 208 |
}); |
| 209 |
|
| 210 |
registry.category("web_tour.tours").add("PosLoyaltySpecificDiscountWithRewardProductDomainTour", { |
| 211 |
steps: () => |
| 212 |
[ |
| 213 |
|
| 214 |
Dialog.is("A reward could not be loaded"), |
| 215 |
Dialog.confirm("Ok"), |
| 216 |
|
| 217 |
Chrome.startPoS(), |
| 218 |
Dialog.confirm("Open Register"), |
| 219 |
|
| 220 |
ProductScreen.clickDisplayedProduct("Product A"), |
| 221 |
ProductScreen.selectedOrderlineHas("Product A", "1", "15.00"), |
| 222 |
PosLoyalty.orderTotalIs("15.00"), |
| 223 |
|
| 224 |
ProductScreen.clickDisplayedProduct("Product B"), |
| 225 |
ProductScreen.selectedOrderlineHas("Product B", "1", "50.00"), |
| 226 |
PosLoyalty.orderTotalIs("40.00"), |
| 227 |
|
| 228 |
ProductScreen.clickControlButton("Reward"), |
| 229 |
SelectionPopup.has("10$ on your order - Product B - Saleable", { run: "click" }), |
| 230 |
ProductScreen.clickControlButton("Reward"), |
| 231 |
SelectionPopup.has("10$ on your order - Product B - Not Saleable", { run: "click" }), |
| 232 |
PosLoyalty.orderTotalIs("30.00"), |
| 233 |
].flat(), |
| 234 |
}); |
| 235 |
|
| 236 |
registry.category("web_tour.tours").add("PosLoyaltyRewardProductTag", { |
| 237 |
steps: () => |
| 238 |
[ |
| 239 |
Chrome.startPoS(), |
| 240 |
Dialog.confirm("Open Register"), |
| 241 |
|
| 242 |
ProductScreen.clickDisplayedProduct("Desk Organizer"), |
| 243 |
ProductScreen.clickDisplayedProduct("Desk Organizer"), |
| 244 |
PosLoyalty.isRewardButtonHighlighted(true, true), |
| 245 |
PosLoyalty.claimReward("Free Product - [Product A, Product B]"), |
| 246 |
SelectionPopup.has("Product A", { run: "click" }), |
| 247 |
PosLoyalty.hasRewardLine("Free Product", "-2", "1"), |
| 248 |
PosLoyalty.isRewardButtonHighlighted(false, true), |
| 249 |
|
| 250 |
ProductScreen.clickDisplayedProduct("Desk Organizer"), |
| 251 |
ProductScreen.clickDisplayedProduct("Desk Organizer"), |
| 252 |
PosLoyalty.isRewardButtonHighlighted(true, true), |
| 253 |
PosLoyalty.claimReward("Free Product - [Product A, Product B]"), |
| 254 |
SelectionPopup.has("Product B", { run: "click" }), |
| 255 |
PosLoyalty.hasRewardLine("Free Product", "-5", "1"), |
| 256 |
PosLoyalty.isRewardButtonHighlighted(false, true), |
| 257 |
|
| 258 |
ProductScreen.clickDisplayedProduct("Desk Organizer"), |
| 259 |
ProductScreen.clickDisplayedProduct("Desk Organizer"), |
| 260 |
PosLoyalty.isRewardButtonHighlighted(true, true), |
| 261 |
PosLoyalty.claimReward("Free Product - [Product A, Product B]"), |
| 262 |
SelectionPopup.has("Product B", { run: "click" }), |
| 263 |
PosLoyalty.hasRewardLine("Free Product", "-10", "2"), |
| 264 |
PosLoyalty.isRewardButtonHighlighted(false, true), |
| 265 |
].flat(), |
| 266 |
}); |
| 267 |
|
| 268 |
registry.category("web_tour.tours").add("test_loyalty_on_order_with_fixed_tax", { |
| 269 |
steps: () => |
| 270 |
[ |
| 271 |
Chrome.startPoS(), |
| 272 |
Dialog.confirm("Open Register"), |
| 273 |
ProductScreen.clickDisplayedProduct("Product A"), |
| 274 |
PosLoyalty.enterCode("563412"), |
| 275 |
PosLoyalty.hasRewardLine("10% on your order", "-1.50"), |
| 276 |
].flat(), |
| 277 |
}); |
| 278 |
|
| 279 |
registry.category("web_tour.tours").add("test_loyalty_reward_with_variant", { |
| 280 |
steps: () => |
| 281 |
[ |
| 282 |
Chrome.startPoS(), |
| 283 |
Dialog.confirm("Open Register"), |
| 284 |
ProductScreen.clickPartnerButton(), |
| 285 |
PartnerList.searchCustomerValue("Test Partner", true), |
| 286 |
ProductScreen.clickCustomer("Test Partner"), |
| 287 |
ProductScreen.clickDisplayedProduct("Test Product"), |
| 288 |
Dialog.discard(), |
| 289 |
ProductScreen.clickDisplayedProduct("Test Product"), |
| 290 |
ProductConfiguratorPopup.pickRadio("Value 1"), |
| 291 |
Dialog.confirm(), |
| 292 |
ProductScreen.clickDisplayedProduct("Test Product"), |
| 293 |
ProductConfiguratorPopup.pickRadio("Value 1"), |
| 294 |
Dialog.confirm(), |
| 295 |
ProductScreen.clickDisplayedProduct("Test Product"), |
| 296 |
ProductConfiguratorPopup.pickRadio("Value 1"), |
| 297 |
Dialog.confirm(), |
| 298 |
PosLoyalty.hasRewardLine("Free Product", "-10", "1.00"), |
| 299 |
].flat(), |
| 300 |
}); |
| 301 |
|
| 302 |
registry.category("web_tour.tours").add("test_multiple_reward_line_free_product", { |
| 303 |
steps: () => |
| 304 |
[ |
| 305 |
Chrome.startPoS(), |
| 306 |
Dialog.confirm("Open Register"), |
| 307 |
ProductScreen.clickDisplayedProduct("Product A"), |
| 308 |
ProductScreen.clickDisplayedProduct("Product A"), |
| 309 |
ProductScreen.clickDisplayedProduct("Product A"), |
| 310 |
PosLoyalty.hasRewardLine("Free Product - Product A", "-10", "1.00"), |
| 311 |
ProductScreen.clickDisplayedProduct("Product B"), |
| 312 |
ProductScreen.clickDisplayedProduct("Product B"), |
| 313 |
PosLoyalty.hasRewardLine("Free Product - Product B").map(negateStep), |
| 314 |
ProductScreen.clickDisplayedProduct("Product B"), |
| 315 |
PosLoyalty.hasRewardLine("Free Product - Product B", "-5", "1.00"), |
| 316 |
PosLoyalty.hasRewardLine("Free Product - Product A", "-10", "1.00"), |
| 317 |
ProductScreen.clickDisplayedProduct("Product B"), |
| 318 |
ProductScreen.clickDisplayedProduct("Product B"), |
| 319 |
PosLoyalty.hasRewardLine("Free Product - Product B", "-5", "1.00"), |
| 320 |
PosLoyalty.hasRewardLine("Free Product - Product A", "-10", "1.00"), |
| 321 |
ProductScreen.clickDisplayedProduct("Product A"), |
| 322 |
PosLoyalty.hasRewardLine("Free Product - Product B", "-5", "1.00"), |
| 323 |
PosLoyalty.hasRewardLine("Free Product - Product A", "-20", "2.00"), |
| 324 |
].flat(), |
| 325 |
}); |