| 1 |
import * as PosLoyalty from "@pos_loyalty/../tests/tours/utils/pos_loyalty_util"; |
| 2 |
import * as ProductScreen from "@point_of_sale/../tests/pos/tours/utils/product_screen_util"; |
| 3 |
import * as PaymentScreen from "@point_of_sale/../tests/pos/tours/utils/payment_screen_util"; |
| 4 |
import * as Chrome from "@point_of_sale/../tests/pos/tours/utils/chrome_util"; |
| 5 |
import * as Dialog from "@point_of_sale/../tests/generic_helpers/dialog_util"; |
| 6 |
import * as combo from "@point_of_sale/../tests/pos/tours/utils/combo_popup_util"; |
| 7 |
import * as Order from "@point_of_sale/../tests/generic_helpers/order_widget_util"; |
| 8 |
import { inLeftSide } from "@point_of_sale/../tests/pos/tours/utils/common"; |
| 9 |
import { registry } from "@web/core/registry"; |
| 10 |
import { negate } from "@point_of_sale/../tests/generic_helpers/utils"; |
| 11 |
|
| 12 |
registry.category("web_tour.tours").add("PosLoyaltyLoyaltyProgram1", { |
| 13 |
steps: () => |
| 14 |
[ |
| 15 |
Chrome.startPoS(), |
| 16 |
Dialog.confirm("Open Register"), |
| 17 |
|
| 18 |
// Order1: Generates 2 points. |
| 19 |
ProductScreen.addOrderline("Whiteboard Pen", "2"), |
| 20 |
ProductScreen.clickPartnerButton(), |
| 21 |
ProductScreen.clickCustomer("AAA Test Partner"), |
| 22 |
PosLoyalty.orderTotalIs("6.40"), |
| 23 |
PosLoyalty.finalizeOrder("Cash", "10"), |
| 24 |
|
| 25 |
// Order2: Consumes points to get free product. |
| 26 |
ProductScreen.clickPartnerButton(), |
| 27 |
ProductScreen.clickCustomer("AAA Test Partner"), |
| 28 |
ProductScreen.clickDisplayedProduct("Whiteboard Pen", true, "1"), |
| 29 |
ProductScreen.clickDisplayedProduct("Whiteboard Pen", true, "2"), |
| 30 |
// At this point, AAA Test Partner has 4 points. |
| 31 |
PosLoyalty.isMoreControlButtonActive(true), |
| 32 |
PosLoyalty.isRewardButtonHighlighted(true), |
| 33 |
ProductScreen.clickDisplayedProduct("Whiteboard Pen", true, "3"), |
| 34 |
PosLoyalty.hasRewardLine("Free Product - Whiteboard Pen", "-3.20", "1"), |
| 35 |
PosLoyalty.isMoreControlButtonActive(false), |
| 36 |
PosLoyalty.isRewardButtonHighlighted(false), |
| 37 |
PosLoyalty.orderTotalIs("6.40"), |
| 38 |
PosLoyalty.finalizeOrder("Cash", "10"), |
| 39 |
|
| 40 |
// Order3: Generate 4 points. |
| 41 |
// - Initially gets free product, but was removed automatically by changing the |
| 42 |
// number of items to zero. |
| 43 |
// - It's impossible to checked here if the free product reward is really removed |
| 44 |
// so we check in the backend the number of orders that consumed the reward. |
| 45 |
ProductScreen.addOrderline("Whiteboard Pen", "4"), |
| 46 |
PosLoyalty.orderTotalIs("12.80"), |
| 47 |
ProductScreen.clickPartnerButton(), |
| 48 |
ProductScreen.clickCustomer("AAA Test Partner"), |
| 49 |
PosLoyalty.isRewardButtonHighlighted(true), |
| 50 |
ProductScreen.clickDisplayedProduct("Whiteboard Pen"), |
| 51 |
PosLoyalty.hasRewardLine("Free Product - Whiteboard Pen", "-3.20", "1"), |
| 52 |
PosLoyalty.isRewardButtonHighlighted(false), |
| 53 |
ProductScreen.clickNumpad("⌫"), |
| 54 |
// At this point, the reward line should have been automatically removed |
| 55 |
// because there is not enough points to purchase it. Unfortunately, we |
| 56 |
// can't check that here. |
| 57 |
PosLoyalty.orderTotalIs("0.00"), |
| 58 |
ProductScreen.clickDisplayedProduct("Whiteboard Pen", true, "1.00"), |
| 59 |
ProductScreen.clickDisplayedProduct("Whiteboard Pen", true, "2.00"), |
| 60 |
ProductScreen.clickDisplayedProduct("Whiteboard Pen", true, "3.00"), |
| 61 |
PosLoyalty.isRewardButtonHighlighted(false), |
| 62 |
ProductScreen.clickDisplayedProduct("Whiteboard Pen"), |
| 63 |
ProductScreen.selectedOrderlineHas("Whiteboard Pen", "4.00"), |
| 64 |
PosLoyalty.isRewardButtonHighlighted(true), |
| 65 |
|
| 66 |
PosLoyalty.orderTotalIs("12.80"), |
| 67 |
PosLoyalty.finalizeOrder("Cash", "20"), |
| 68 |
].flat(), |
| 69 |
}); |
| 70 |
|
| 71 |
registry.category("web_tour.tours").add("PosLoyaltyLoyaltyProgram2", { |
| 72 |
steps: () => |
| 73 |
[ |
| 74 |
// Order1: Immediately set the customer to Test Partner AAA which has 4 points. |
| 75 |
// - He has enough points to purchase a free product but since there is still |
| 76 |
// no product in the order, reward button should not yet be highlighted. |
| 77 |
// - Furthermore, clicking the reward product should not add it as reward product. |
| 78 |
Chrome.startPoS(), |
| 79 |
ProductScreen.clickPartnerButton(), |
| 80 |
ProductScreen.clickCustomer("AAA Test Partner"), |
| 81 |
// No item in the order, so reward button is off. |
| 82 |
PosLoyalty.isRewardButtonHighlighted(false), |
| 83 |
ProductScreen.clickDisplayedProduct("Whiteboard Pen"), |
| 84 |
PosLoyalty.isRewardButtonHighlighted(true), |
| 85 |
ProductScreen.clickDisplayedProduct("Whiteboard Pen"), |
| 86 |
PosLoyalty.hasRewardLine("Free Product - Whiteboard Pen", "-3.20", "1"), |
| 87 |
PosLoyalty.isRewardButtonHighlighted(false), |
| 88 |
PosLoyalty.orderTotalIs("3.20"), |
| 89 |
PosLoyalty.finalizeOrder("Cash", "10"), |
| 90 |
|
| 91 |
// Order2: Generate 4 points for CCC Test Partner. |
| 92 |
// - Reference: Order2_CCC |
| 93 |
// - But set BBB Test Partner first as the customer. |
| 94 |
ProductScreen.clickPartnerButton(), |
| 95 |
ProductScreen.clickCustomer("BBB Test Partner"), |
| 96 |
PosLoyalty.isRewardButtonHighlighted(false), |
| 97 |
ProductScreen.clickDisplayedProduct("Whiteboard Pen", true, "1"), |
| 98 |
ProductScreen.clickDisplayedProduct("Whiteboard Pen", true, "2"), |
| 99 |
ProductScreen.clickDisplayedProduct("Whiteboard Pen", true, "3"), |
| 100 |
PosLoyalty.isRewardButtonHighlighted(false), |
| 101 |
ProductScreen.clickDisplayedProduct("Whiteboard Pen", true, "4"), |
| 102 |
PosLoyalty.isRewardButtonHighlighted(true), |
| 103 |
ProductScreen.clickPartnerButton(), |
| 104 |
ProductScreen.clickCustomer("CCC Test Partner"), |
| 105 |
PosLoyalty.customerIs("CCC Test Partner"), |
| 106 |
PosLoyalty.orderTotalIs("12.80"), |
| 107 |
PosLoyalty.finalizeOrder("Cash", "20"), |
| 108 |
|
| 109 |
// Order3: Generate 3 points for BBB Test Partner. |
| 110 |
// - Reference: Order3_BBB |
| 111 |
// - But set CCC Test Partner first as the customer. |
| 112 |
ProductScreen.clickPartnerButton(), |
| 113 |
ProductScreen.clickCustomer("CCC Test Partner"), |
| 114 |
PosLoyalty.isRewardButtonHighlighted(false), |
| 115 |
ProductScreen.addOrderline("Whiteboard Pen", "3"), |
| 116 |
ProductScreen.clickPartnerButton(), |
| 117 |
ProductScreen.clickCustomer("BBB Test Partner"), |
| 118 |
PosLoyalty.customerIs("BBB Test Partner"), |
| 119 |
PosLoyalty.orderTotalIs("9.60"), |
| 120 |
PosLoyalty.finalizeOrder("Cash", "10"), |
| 121 |
|
| 122 |
// Order4: Should not have reward because the customer will be removed. |
| 123 |
// - Reference: Order4_no_reward |
| 124 |
ProductScreen.clickDisplayedProduct("Whiteboard Pen", true, "1"), |
| 125 |
PosLoyalty.isRewardButtonHighlighted(false), |
| 126 |
ProductScreen.clickPartnerButton(), |
| 127 |
ProductScreen.clickCustomer("CCC Test Partner"), |
| 128 |
PosLoyalty.isRewardButtonHighlighted(true), |
| 129 |
PosLoyalty.claimReward("Free Product - Whiteboard Pen"), |
| 130 |
PosLoyalty.hasRewardLine("Free Product - Whiteboard Pen", "-3.20", "1"), |
| 131 |
ProductScreen.clickPartnerButton(), |
| 132 |
// This deselects the customer. |
| 133 |
PosLoyalty.unselectPartner(), |
| 134 |
PosLoyalty.customerIs("Customer"), |
| 135 |
PosLoyalty.orderTotalIs("6.40"), |
| 136 |
PosLoyalty.finalizeOrder("Cash", "10"), |
| 137 |
].flat(), |
| 138 |
}); |
| 139 |
|
| 140 |
registry.category("web_tour.tours").add("PosLoyaltyChangeRewardQty", { |
| 141 |
steps: () => |
| 142 |
[ |
| 143 |
Chrome.startPoS(), |
| 144 |
ProductScreen.clickPartnerButton(), |
| 145 |
ProductScreen.clickCustomer("DDD Test Partner"), |
| 146 |
ProductScreen.addOrderline("Desk Organizer", "1"), |
| 147 |
PosLoyalty.isRewardButtonHighlighted(true), |
| 148 |
PosLoyalty.claimReward("Free Product - Whiteboard Pen"), |
| 149 |
PosLoyalty.hasRewardLine("Free Product - Whiteboard Pen", "-3.20", "1"), |
| 150 |
ProductScreen.clickNumpad("Qty"), |
| 151 |
ProductScreen.clickNumpad("1"), |
| 152 |
PosLoyalty.hasRewardLine("Free Product - Whiteboard Pen", "-3.20", "1"), |
| 153 |
].flat(), |
| 154 |
}); |
| 155 |
|
| 156 |
registry.category("web_tour.tours").add("PosLoyaltyLoyaltyProgram3", { |
| 157 |
steps: () => |
| 158 |
[ |
| 159 |
Chrome.startPoS(), |
| 160 |
Dialog.confirm("Open Register"), |
| 161 |
|
| 162 |
// Generates 10.2 points and use points to get the reward product with zero sale price |
| 163 |
ProductScreen.addOrderline("Desk Organizer", "2"), |
| 164 |
ProductScreen.clickPartnerButton(), |
| 165 |
ProductScreen.clickCustomer("AAA Test Partner"), |
| 166 |
|
| 167 |
// At this point, the free_product program is triggered. |
| 168 |
// The reward button should be highlighted. |
| 169 |
PosLoyalty.isRewardButtonHighlighted(true, true), |
| 170 |
PosLoyalty.claimReward("Free Product - Whiteboard Pen"), |
| 171 |
PosLoyalty.hasRewardLine("Free Product - Whiteboard Pen", "-1.00", "1"), |
| 172 |
|
| 173 |
PosLoyalty.orderTotalIs("10.2"), |
| 174 |
PosLoyalty.finalizeOrder("Cash", "10.2"), |
| 175 |
].flat(), |
| 176 |
}); |
| 177 |
|
| 178 |
registry.category("web_tour.tours").add("PosLoyaltyPromotion", { |
| 179 |
steps: () => |
| 180 |
[ |
| 181 |
Chrome.startPoS(), |
| 182 |
Dialog.confirm("Open Register"), |
| 183 |
ProductScreen.clickPartnerButton(), |
| 184 |
ProductScreen.clickCustomer("AAA Partner"), |
| 185 |
ProductScreen.addOrderline("Test Product 1", "1", "100"), |
| 186 |
ProductScreen.totalAmountIs("90.00"), |
| 187 |
].flat(), |
| 188 |
}); |
| 189 |
|
| 190 |
registry.category("web_tour.tours").add("PosLoyaltyDontGrantPointsForRewardOrderLines", { |
| 191 |
steps: () => |
| 192 |
[ |
| 193 |
Chrome.startPoS(), |
| 194 |
Dialog.confirm("Open Register"), |
| 195 |
|
| 196 |
ProductScreen.clickPartnerButton(), |
| 197 |
ProductScreen.clickCustomer("A Test Partner"), |
| 198 |
|
| 199 |
ProductScreen.addOrderline("Desk Organizer", "1"), |
| 200 |
ProductScreen.addOrderline("Whiteboard Pen", "1"), |
| 201 |
PosLoyalty.isRewardButtonHighlighted(true, true), |
| 202 |
PosLoyalty.claimReward("100% on the cheapest product"), |
| 203 |
|
| 204 |
PosLoyalty.orderTotalIs("5.10"), |
| 205 |
PosLoyalty.finalizeOrder("Cash", "5.10"), |
| 206 |
].flat(), |
| 207 |
}); |
| 208 |
|
| 209 |
registry.category("web_tour.tours").add("PosLoyaltyNextOrderCouponExpirationDate", { |
| 210 |
steps: () => |
| 211 |
[ |
| 212 |
Chrome.startPoS(), |
| 213 |
Dialog.confirm("Open Register"), |
| 214 |
|
| 215 |
ProductScreen.addOrderline("Desk Organizer", "3"), |
| 216 |
|
| 217 |
PosLoyalty.finalizeOrder("Cash", "15.3"), |
| 218 |
].flat(), |
| 219 |
}); |
| 220 |
|
| 221 |
registry.category("web_tour.tours").add("PosComboCheapestRewardProgram", { |
| 222 |
steps: () => |
| 223 |
[ |
| 224 |
Chrome.startPoS(), |
| 225 |
Dialog.confirm("Open Register"), |
| 226 |
ProductScreen.clickDisplayedProduct("Expensive product"), |
| 227 |
ProductScreen.clickDisplayedProduct("Office Combo"), |
| 228 |
combo.select("Combo Product 1"), |
| 229 |
combo.select("Combo Product 4"), |
| 230 |
combo.select("Combo Product 6"), |
| 231 |
Dialog.confirm(), |
| 232 |
inLeftSide(Order.hasLine({ productName: "10% on the cheapest product" })), |
| 233 |
PosLoyalty.orderTotalIs("1,204.25"), |
| 234 |
PosLoyalty.finalizeOrder("Cash", "1204.25"), |
| 235 |
ProductScreen.clickDisplayedProduct("Cheap product"), |
| 236 |
ProductScreen.clickDisplayedProduct("Office Combo"), |
| 237 |
combo.select("Combo Product 1"), |
| 238 |
combo.select("Combo Product 4"), |
| 239 |
combo.select("Combo Product 6"), |
| 240 |
Dialog.confirm(), |
| 241 |
Order.hasLine({ productName: "10% on the cheapest product" }), |
| 242 |
PosLoyalty.orderTotalIs("61.03"), |
| 243 |
PosLoyalty.finalizeOrder("Cash", "61.03"), |
| 244 |
].flat(), |
| 245 |
}); |
| 246 |
|
| 247 |
registry.category("web_tour.tours").add("PosComboSpecificProductProgram", { |
| 248 |
steps: () => |
| 249 |
[ |
| 250 |
Chrome.startPoS(), |
| 251 |
Dialog.confirm("Open Register"), |
| 252 |
ProductScreen.clickDisplayedProduct("Office Combo"), |
| 253 |
combo.select("Combo Product 1"), |
| 254 |
combo.select("Combo Product 4"), |
| 255 |
combo.select("Combo Product 6"), |
| 256 |
Dialog.confirm(), |
| 257 |
Order.hasLine({ productName: "10% on Office Combo" }), |
| 258 |
PosLoyalty.orderTotalIs("216.00"), |
| 259 |
PosLoyalty.finalizeOrder("Cash", "216.00"), |
| 260 |
].flat(), |
| 261 |
}); |
| 262 |
|
| 263 |
registry.category("web_tour.tours").add("PosCheapestProductTaxInclude", { |
| 264 |
steps: () => |
| 265 |
[ |
| 266 |
Chrome.startPoS(), |
| 267 |
Dialog.confirm("Open Register"), |
| 268 |
ProductScreen.clickDisplayedProduct("Product"), |
| 269 |
ProductScreen.addOrderline("Desk Organizer", "1"), |
| 270 |
Order.hasLine({ productName: "10% on the cheapest product" }), |
| 271 |
PosLoyalty.orderTotalIs("6.01"), // taxe of 9 cents (≈ 10% HT) |
| 272 |
].flat(), |
| 273 |
}); |
| 274 |
|
| 275 |
registry.category("web_tour.tours").add("test_not_create_loyalty_card_expired_program", { |
| 276 |
steps: () => |
| 277 |
[ |
| 278 |
Chrome.startPoS(), |
| 279 |
Dialog.confirm("Open Register"), |
| 280 |
ProductScreen.clickPartnerButton(), |
| 281 |
ProductScreen.clickCustomer("Test Partner", true), |
| 282 |
ProductScreen.addOrderline("Desk Organizer", "3"), |
| 283 |
PosLoyalty.finalizeOrder("Cash", "15.3"), |
| 284 |
].flat(), |
| 285 |
}); |
| 286 |
|
| 287 |
registry.category("web_tour.tours").add("PosOrderClaimReward", { |
| 288 |
steps: () => |
| 289 |
[ |
| 290 |
Chrome.startPoS(), |
| 291 |
Dialog.confirm("Open Register"), |
| 292 |
ProductScreen.clickPartnerButton(), |
| 293 |
ProductScreen.clickCustomer("Test Partner"), |
| 294 |
ProductScreen.addOrderline("Desk Organizer", "3"), |
| 295 |
PosLoyalty.isPointsDisplayed(true), |
| 296 |
PosLoyalty.claimReward("Free Product - Whiteboard Pen"), |
| 297 |
PosLoyalty.hasRewardLine("Free Product - Whiteboard Pen", "-3.20", "1.00"), |
| 298 |
PosLoyalty.finalizeOrder("Cash", "15.3"), |
| 299 |
].flat(), |
| 300 |
}); |
| 301 |
|
| 302 |
registry.category("web_tour.tours").add("PosOrderNoPoints", { |
| 303 |
steps: () => |
| 304 |
[ |
| 305 |
Chrome.startPoS(), |
| 306 |
ProductScreen.clickPartnerButton(), |
| 307 |
ProductScreen.clickCustomer("Test Partner 2"), |
| 308 |
ProductScreen.addOrderline("Desk Organizer", "3"), |
| 309 |
PosLoyalty.isPointsDisplayed(false), |
| 310 |
PosLoyalty.finalizeOrder("Cash", "15.3"), |
| 311 |
].flat(), |
| 312 |
}); |
| 313 |
|
| 314 |
registry.category("web_tour.tours").add("PosLoyaltyMultipleOrders", { |
| 315 |
steps: () => |
| 316 |
[ |
| 317 |
Chrome.startPoS(), |
| 318 |
Dialog.confirm("Open Register"), |
| 319 |
|
| 320 |
// Order1: Add a product and leave the order in draft. |
| 321 |
ProductScreen.addOrderline("Whiteboard Pen", "2"), |
| 322 |
ProductScreen.clickPartnerButton(), |
| 323 |
ProductScreen.clickCustomer("Partner Test 1"), |
| 324 |
ProductScreen.clickPayButton(), |
| 325 |
PaymentScreen.clickPaymentMethod("Cash"), |
| 326 |
|
| 327 |
// Order2: Finalize a different order. |
| 328 |
Chrome.createFloatingOrder(), |
| 329 |
ProductScreen.addOrderline("Desk Organizer", "1"), |
| 330 |
PosLoyalty.finalizeOrder("Cash", "10"), |
| 331 |
].flat(), |
| 332 |
}); |
| 333 |
|
| 334 |
registry.category("web_tour.tours").add("test_combo_product_dont_grant_point", { |
| 335 |
steps: () => |
| 336 |
[ |
| 337 |
Chrome.startPoS(), |
| 338 |
Dialog.confirm("Open Register"), |
| 339 |
ProductScreen.clickDisplayedProduct("Office Combo"), |
| 340 |
combo.select("Combo Product 1"), |
| 341 |
combo.select("Combo Product 4"), |
| 342 |
combo.select("Combo Product 6"), |
| 343 |
Dialog.confirm(), |
| 344 |
ProductScreen.clickDisplayedProduct("Office Combo"), |
| 345 |
combo.select("Combo Product 1"), |
| 346 |
combo.select("Combo Product 4"), |
| 347 |
combo.select("Combo Product 6"), |
| 348 |
Dialog.confirm(), |
| 349 |
Order.hasLine({ productName: "100% on the cheapest product" }), |
| 350 |
ProductScreen.totalAmountIs("50.00"), |
| 351 |
].flat(), |
| 352 |
}); |
| 353 |
|
| 354 |
registry.category("web_tour.tours").add("test_buy_x_get_y_reward_qty", { |
| 355 |
steps: () => |
| 356 |
[ |
| 357 |
Chrome.startPoS(), |
| 358 |
Dialog.confirm("Open Register"), |
| 359 |
ProductScreen.addOrderline("Whiteboard Pen", "10"), |
| 360 |
ProductScreen.clickDisplayedProduct("Whiteboard Pen"), |
| 361 |
PosLoyalty.hasRewardLine("Free Product - Whiteboard Pen", "-3.20", "1.00"), |
| 362 |
ProductScreen.clickDisplayedProduct("Whiteboard Pen"), |
| 363 |
PosLoyalty.hasRewardLine("Free Product - Whiteboard Pen", "-6.40", "2.00"), |
| 364 |
PosLoyalty.finalizeOrder("Cash", "32"), |
| 365 |
ProductScreen.addOrderline("Whiteboard Pen", "10"), |
| 366 |
PosLoyalty.claimReward("Free Product - Whiteboard Pen"), |
| 367 |
PosLoyalty.hasRewardLine("Free Product - Whiteboard Pen", "-9.60", "3.00"), |
| 368 |
PosLoyalty.finalizeOrder("Cash", "32"), |
| 369 |
].flat(), |
| 370 |
}); |
| 371 |
|
| 372 |
registry.category("web_tour.tours").add("test_multiple_loyalty_products", { |
| 373 |
steps: () => |
| 374 |
[ |
| 375 |
Chrome.startPoS(), |
| 376 |
Dialog.confirm("Open Register"), |
| 377 |
ProductScreen.clickDisplayedProduct("Whiteboard Pen"), |
| 378 |
{ |
| 379 |
content: "Check that selection popup is not opened", |
| 380 |
trigger: negate(`.selection-item`), |
| 381 |
}, |
| 382 |
Order.hasLine({ productName: "Whiteboard Pen", quantity: "1" }), |
| 383 |
Order.hasLine({ productName: "10% on your order", quantity: "1" }), |
| 384 |
].flat(), |
| 385 |
}); |
| 386 |
|
| 387 |
registry.category("web_tour.tours").add("test_max_usage_partner_with_point", { |
| 388 |
steps: () => |
| 389 |
[ |
| 390 |
Chrome.startPoS(), |
| 391 |
Dialog.confirm("Open Register"), |
| 392 |
ProductScreen.addOrderline("Desk Organizer", "3"), |
| 393 |
ProductScreen.clickPartnerButton(), |
| 394 |
ProductScreen.clickCustomer("AAA Partner 2"), |
| 395 |
PosLoyalty.isRewardButtonHighlighted(true), |
| 396 |
PosLoyalty.claimReward("100% on your order"), |
| 397 |
PosLoyalty.finalizeOrder("Cash", "0"), |
| 398 |
ProductScreen.clickPartnerButton(), |
| 399 |
ProductScreen.clickCustomer("AAA Partner"), |
| 400 |
ProductScreen.addOrderline("Desk Organizer", "3"), |
| 401 |
PosLoyalty.isRewardButtonHighlighted(false), |
| 402 |
].flat(), |
| 403 |
}); |