Debian Codegraph @

addons/pos_loyalty/static/tests/tours/pos_loyalty_tour.js

raw
1 /* global posmodel */
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 TicketScreen from "@point_of_sale/../tests/pos/tours/utils/ticket_screen_util";
5 import * as ReceiptScreen from "@point_of_sale/../tests/pos/tours/utils/receipt_screen_util";
6 import * as SelectionPopup from "@point_of_sale/../tests/generic_helpers/selection_popup_util";
7 import * as PartnerList from "@point_of_sale/../tests/pos/tours/utils/partner_list_util";
8 import * as Dialog from "@point_of_sale/../tests/generic_helpers/dialog_util";
9 import * as Chrome from "@point_of_sale/../tests/pos/tours/utils/chrome_util";
10 import * as PaymentScreen from "@point_of_sale/../tests/pos/tours/utils/payment_screen_util";
11 import * as Notification from "@point_of_sale/../tests/generic_helpers/notification_util";
12 import * as Utils from "@point_of_sale/../tests/generic_helpers/utils";
13 import { registry } from "@web/core/registry";
14 import { scan_barcode } from "@point_of_sale/../tests/generic_helpers/utils";
15
16 registry.category("web_tour.tours").add("PosLoyaltyTour1", {
17 steps: () =>
18 [
19 // --- PoS Loyalty Tour Basic Part 1 ---
20 // Generate coupons for PosLoyaltyTour2.
21
22 Chrome.startPoS(),
23 Dialog.confirm("Open Register"),
24
25 // basic order
26 // just accept the automatically applied promo program
27 // applied programs:
28 // - on cheapest product
29 ProductScreen.addOrderline("Whiteboard Pen", "5"),
30 PosLoyalty.hasRewardLine("90% on the cheapest product", "-2.88"),
31 PosLoyalty.selectRewardLine("on the cheapest product"),
32 PosLoyalty.orderTotalIs("13.12"),
33 PosLoyalty.finalizeOrder("Cash", "20"),
34
35 // remove the reward from auto promo program
36 // no applied programs
37 ProductScreen.addOrderline("Whiteboard Pen", "6"),
38 PosLoyalty.hasRewardLine("on the cheapest product", "-2.88"),
39 PosLoyalty.orderTotalIs("16.32"),
40 PosLoyalty.removeRewardLine("90% on the cheapest product"),
41 PosLoyalty.orderTotalIs("19.2"),
42 PosLoyalty.finalizeOrder("Cash", "20"),
43
44 // order with coupon code from coupon program
45 // applied programs:
46 // - coupon program
47 ProductScreen.addOrderline("Desk Organizer", "9"),
48 PosLoyalty.hasRewardLine("on the cheapest product", "-4.59"),
49 PosLoyalty.removeRewardLine("90% on the cheapest product"),
50 PosLoyalty.orderTotalIs("45.90"),
51 PosLoyalty.enterCode("invalid_code"),
52 Notification.has("invalid_code"),
53 PosLoyalty.enterCode("1234"),
54 PosLoyalty.hasRewardLine("Free Product - Desk Organizer", "-15.30"),
55 PosLoyalty.finalizeOrder("Cash", "50"),
56
57 // Use coupon but eventually remove the reward
58 // applied programs:
59 // - on cheapest product
60 ProductScreen.addOrderline("Letter Tray", "4"),
61 ProductScreen.addOrderline("Desk Organizer", "9"),
62 PosLoyalty.hasRewardLine("90% on the cheapest product", "-4.59"),
63 PosLoyalty.orderTotalIs("62.43"),
64 PosLoyalty.enterCode("5678"),
65 PosLoyalty.hasRewardLine("Free Product - Desk Organizer", "-15.30"),
66 PosLoyalty.orderTotalIs("47.13"),
67 PosLoyalty.removeRewardLine("Free Product"),
68 PosLoyalty.orderTotalIs("62.43"),
69 PosLoyalty.finalizeOrder("Cash", "90"),
70
71 // specific product discount
72 // applied programs:
73 // - on cheapest product
74 // - on specific products
75 ProductScreen.addOrderline("Magnetic Board", "10"), // 1.98
76 ProductScreen.addOrderline("Desk Organizer", "3"), // 5.1
77 ProductScreen.addOrderline("Letter Tray", "4"), // 4.8 tax 10%
78 PosLoyalty.hasRewardLine("90% on the cheapest product", "-1.78"),
79 PosLoyalty.orderTotalIs("54.44"),
80 PosLoyalty.enterCode("promocode"),
81 PosLoyalty.hasRewardLine("50% on specific products", "-16.66"), // 17.55 - 1.78*0.5
82 PosLoyalty.orderTotalIs("37.78"),
83 PosLoyalty.finalizeOrder("Cash", "50"),
84 ].flat(),
85 });
86
87 registry.category("web_tour.tours").add("PosLoyaltyTour2", {
88 steps: () =>
89 [
90 // --- PoS Loyalty Tour Basic Part 2 ---
91 // Using the coupons generated from PosLoyaltyTour1.
92
93 // Test that global discount and cheapest product discounts can be accumulated.
94 // Applied programs:
95 // - global discount
96 // - on cheapest discount
97 Chrome.startPoS(),
98 ProductScreen.addOrderline("Desk Organizer", "10"), // 5.1
99 PosLoyalty.hasRewardLine("on the cheapest product", "-4.59"),
100 ProductScreen.addOrderline("Letter Tray", "4"), // 4.8 tax 10%
101 PosLoyalty.hasRewardLine("on the cheapest product", "-4.59"),
102 PosLoyalty.enterCode("123456"),
103 PosLoyalty.hasRewardLine("10% on your order", "-4.64"),
104 PosLoyalty.hasRewardLine("10% on your order", "-2.11"),
105 PosLoyalty.orderTotalIs("60.78"), //SUBTOTAL
106 PosLoyalty.finalizeOrder("Cash", "70"),
107
108 // Scanning coupon twice.
109 // Also apply global discount on top of free product to check if the
110 // calculated discount is correct.
111 // Applied programs:
112 // - coupon program (free product)
113 // - global discount
114 // - on cheapest discount
115 ProductScreen.addOrderline("Desk Organizer", "11"), // 5.1 per item
116 PosLoyalty.hasRewardLine("90% on the cheapest product", "-4.59"),
117 PosLoyalty.orderTotalIs("51.51"),
118 // add global discount and the discount will be replaced
119 PosLoyalty.enterCode("345678"),
120 PosLoyalty.hasRewardLine("10% on your order", "-5.15"),
121 // add free product coupon (for qty=11, free=4)
122 // the discount should change after having free products
123 // it should go back to cheapest discount as it is higher
124 PosLoyalty.enterCode("5678"),
125 PosLoyalty.hasRewardLine("Free Product - Desk Organizer", "-20.40"),
126 PosLoyalty.hasRewardLine("90% on the cheapest product", "-4.59"),
127 // set quantity to 18
128 // free qty stays the same since the amount of points on the card only allows for 4 free products
129 //TODO: The following step should works with ProductScreen.clickNumpad("⌫", "8"),
130 ProductScreen.clickNumpad("⌫", "⌫", "1", "8"),
131 PosLoyalty.hasRewardLine("10% on your order", "-6.68"),
132 PosLoyalty.hasRewardLine("Free Product - Desk Organizer", "-20.40"),
133 // scan the code again and check notification
134 PosLoyalty.enterCode("5678"),
135 PosLoyalty.orderTotalIs("60.13"),
136 PosLoyalty.finalizeOrder("Cash", "65"),
137
138 // Specific products discount (with promocode) and free product (1357)
139 // Applied programs:
140 // - discount on specific products
141 // - free product
142 ProductScreen.addOrderline("Desk Organizer", "6"), // 5.1 per item
143 PosLoyalty.hasRewardLine("on the cheapest product", "-4.59"),
144 PosLoyalty.removeRewardLine("90% on the cheapest product"),
145 PosLoyalty.enterCode("promocode"),
146 PosLoyalty.hasRewardLine("50% on specific products", "-15.30"),
147 PosLoyalty.enterCode("1357"),
148 PosLoyalty.hasRewardLine("Free Product - Desk Organizer", "-10.20"),
149 PosLoyalty.hasRewardLine("50% on specific products", "-10.20"),
150 PosLoyalty.orderTotalIs("10.20"),
151 PosLoyalty.finalizeOrder("Cash", "20"),
152
153 // Check reset program
154 // Enter two codes and reset the programs.
155 // The codes should be checked afterwards. They should return to new.
156 // Applied programs:
157 // - cheapest product
158 ProductScreen.addOrderline("Monitor Stand", "6"), // 3.19 per item
159 PosLoyalty.enterCode("098765"),
160 PosLoyalty.hasRewardLine("90% on the cheapest product", "-2.87"),
161 PosLoyalty.hasRewardLine("10% on your order", "-1.63"),
162 PosLoyalty.orderTotalIs("14.64"),
163 PosLoyalty.removeRewardLine("90% on the cheapest product"),
164 PosLoyalty.hasRewardLine("10% on your order", "-1.91"),
165 PosLoyalty.orderTotalIs("17.23"),
166 ProductScreen.clickControlButton("Reset Programs"),
167 PosLoyalty.hasRewardLine("90% on the cheapest product", "-2.87"),
168 PosLoyalty.orderTotalIs("16.27"),
169 PosLoyalty.finalizeOrder("Cash", "20"),
170 ].flat(),
171 });
172
173 registry.category("web_tour.tours").add("PosLoyaltyTour3", {
174 steps: () =>
175 [
176 // --- PoS Loyalty Tour Basic Part 3 ---
177
178 Chrome.startPoS(),
179 Dialog.confirm("Open Register"),
180
181 ProductScreen.clickDisplayedProduct("Promo Product"),
182 PosLoyalty.orderTotalIs("34.50"),
183 ProductScreen.clickDisplayedProduct("Product B"),
184 PosLoyalty.hasRewardLine("100% on specific products", "25.00"),
185 ProductScreen.clickDisplayedProduct("Product A"),
186 PosLoyalty.hasRewardLine("100% on specific products", "15.00"),
187 PosLoyalty.orderTotalIs("34.50"),
188 ProductScreen.clickDisplayedProduct("Product A"),
189 PosLoyalty.hasRewardLine("100% on specific products", "21.82"),
190 PosLoyalty.hasRewardLine("100% on specific products", "18.18"),
191 PosLoyalty.orderTotalIs("49.50"),
192 ].flat(),
193 });
194
195 registry.category("web_tour.tours").add("PosLoyaltyTour4", {
196 steps: () =>
197 [
198 Chrome.startPoS(),
199 Dialog.confirm("Open Register"),
200
201 ProductScreen.addOrderline("Test Product 1", "1"),
202 ProductScreen.addOrderline("Test Product 2", "1"),
203 ProductScreen.clickPriceList("Public Pricelist"),
204 PosLoyalty.enterCode("abcda"),
205 PosLoyalty.orderTotalIs("0.00"),
206 ProductScreen.clickPriceList("Test multi-currency"),
207 PosLoyalty.orderTotalIs("0.00"),
208 ].flat(),
209 });
210
211 registry.category("web_tour.tours").add("PosCouponTour5", {
212 steps: () =>
213 [
214 Chrome.startPoS(),
215 Dialog.confirm("Open Register"),
216 ProductScreen.clickPartnerButton(),
217 ProductScreen.clickCustomer("AAAA"),
218 ProductScreen.addOrderline("Test Product 1", "1", "100"),
219 PosLoyalty.pointsAwardedAre("115"),
220 PosLoyalty.clickDiscountButton(),
221 Dialog.confirm(),
222 ProductScreen.totalAmountIs("92.00"),
223 PosLoyalty.pointsAwardedAre("92"),
224 Chrome.endTour(),
225 ].flat(),
226 });
227
228 //transform the last tour to match the new format
229 registry.category("web_tour.tours").add("PosLoyaltyTour6", {
230 steps: () =>
231 [
232 Chrome.startPoS(),
233 Dialog.confirm("Open Register"),
234
235 ProductScreen.clickPartnerButton(),
236 ProductScreen.clickCustomer("AAA Partner"),
237 ProductScreen.clickDisplayedProduct("Test Product A"),
238 PosLoyalty.checkAddedLoyaltyPoints("26.5"),
239 ProductScreen.clickControlButton("Reward"),
240 SelectionPopup.has("$ 1 per point on your order", { run: "click" }),
241 ProductScreen.totalAmountIs("165.00"),
242 ProductScreen.clickPayButton(),
243 PaymentScreen.clickPaymentMethod("Cash"),
244 PaymentScreen.clickValidate(),
245 ReceiptScreen.isShown(),
246 PosLoyalty.isLoyaltyPointsAvailable(),
247 Utils.refresh(),
248 ReceiptScreen.isShown(),
249 PosLoyalty.isLoyaltyPointsAvailable(),
250 ].flat(),
251 });
252
253 registry.category("web_tour.tours").add("PosLoyaltyTour7", {
254 steps: () =>
255 [
256 Chrome.startPoS(),
257 Dialog.confirm("Open Register"),
258
259 ProductScreen.addOrderline("Test Product", "1"),
260 PosLoyalty.orderTotalIs("100"),
261 PosLoyalty.enterCode("abcda"),
262 PosLoyalty.orderTotalIs("90"),
263 ].flat(),
264 });
265
266 registry.category("web_tour.tours").add("PosLoyaltyTour8", {
267 steps: () =>
268 [
269 Chrome.startPoS(),
270 Dialog.confirm("Open Register"),
271
272 ProductScreen.clickDisplayedProduct("Product B"),
273 ProductScreen.clickDisplayedProduct("Product A"),
274 ProductScreen.totalAmountIs("50.00"),
275 ].flat(),
276 });
277
278 registry.category("web_tour.tours").add("PosLoyaltySpecificDiscountCategoryTour", {
279 steps: () =>
280 [
281 Chrome.startPoS(),
282 Dialog.confirm("Open Register"),
283
284 ProductScreen.clickDisplayedProduct("Product A", true, "1", "15.00"),
285 PosLoyalty.orderTotalIs("15.00"),
286
287 ProductScreen.clickDisplayedProduct("Product B", true, "1", "50.00"),
288 PosLoyalty.orderTotalIs("40.00"),
289 ].flat(),
290 });
291
292 registry.category("web_tour.tours").add("PosLoyaltyTour9", {
293 steps: () =>
294 [
295 Chrome.startPoS(),
296 Dialog.confirm("Open Register"),
297
298 ProductScreen.clickPartnerButton(),
299 ProductScreen.clickCustomer("AAA Partner"),
300 ProductScreen.clickDisplayedProduct("Product B"),
301 ProductScreen.clickDisplayedProduct("Product A"),
302 ProductScreen.totalAmountIs("210.00"),
303 PosLoyalty.isRewardButtonHighlighted(true),
304 PosLoyalty.claimReward("$ 5"),
305 ProductScreen.totalAmountIs("205.00"),
306 ].flat(),
307 });
308
309 registry.category("web_tour.tours").add("PosLoyaltyTour10", {
310 steps: () =>
311 [
312 Chrome.startPoS(),
313 Dialog.confirm("Open Register"),
314 ProductScreen.clickPartnerButton(),
315 ProductScreen.clickCustomer("AAA Partner"),
316 PosLoyalty.customerIs("AAA Partner"),
317 ProductScreen.clickDisplayedProduct("Product Test"),
318 ProductScreen.totalAmountIs("1.00"),
319 ProductScreen.selectedOrderlineHas("Product Test", "1"),
320 PosLoyalty.isRewardButtonHighlighted(true),
321 PosLoyalty.claimReward("Free Product B"),
322 {
323 content: `click on reward item`,
324 trigger: `.selection-item:contains("Free Product B")`,
325 run: "click",
326 },
327 PosLoyalty.hasRewardLine("Free Product B", "-1.00"),
328 ProductScreen.totalAmountIs("1.00"),
329 PosLoyalty.isRewardButtonHighlighted(false),
330 ].flat(),
331 });
332
333 registry.category("web_tour.tours").add("PosLoyaltyTour11.1", {
334 steps: () =>
335 [
336 Chrome.startPoS(),
337 Dialog.confirm("Open Register"),
338 ProductScreen.clickPartnerButton(),
339 ProductScreen.clickCustomer("AAA Partner"),
340 PosLoyalty.customerIs("AAA Partner"),
341 ProductScreen.addOrderline("Product Test", "3"),
342 ProductScreen.totalAmountIs("150.00"),
343 PosLoyalty.isRewardButtonHighlighted(false),
344 PosLoyalty.finalizeOrder("Cash", "150"),
345 ].flat(),
346 });
347
348 registry.category("web_tour.tours").add("PosLoyaltyTour11.2", {
349 steps: () =>
350 [
351 Chrome.startPoS(),
352 ProductScreen.clickPartnerButton(),
353 ProductScreen.clickCustomer("AAA Partner"),
354 PosLoyalty.customerIs("AAA Partner"),
355 ProductScreen.clickDisplayedProduct("Product Test"),
356 ProductScreen.totalAmountIs("50.00"),
357 PosLoyalty.isRewardButtonHighlighted(false),
358 PosLoyalty.enterCode("123456"),
359 PosLoyalty.isRewardButtonHighlighted(true),
360 PosLoyalty.claimReward("Free Product"),
361 PosLoyalty.hasRewardLine("Free Product", "-3.00"),
362 PosLoyalty.isRewardButtonHighlighted(false),
363 ProductScreen.totalAmountIs("50.00"),
364 PosLoyalty.finalizeOrder("Cash", "50"),
365 ].flat(),
366 });
367
368 registry.category("web_tour.tours").add("PosLoyaltyMinAmountAndSpecificProductTour", {
369 steps: () =>
370 [
371 Chrome.startPoS(),
372 Dialog.confirm("Open Register"),
373
374 ProductScreen.clickDisplayedProduct("Product A"),
375 ProductScreen.selectedOrderlineHas("Product A", "1", "20.00"),
376 PosLoyalty.orderTotalIs("20.00"),
377
378 ProductScreen.clickDisplayedProduct("Product B"),
379 ProductScreen.selectedOrderlineHas("Product B", "1", "30.00"),
380 PosLoyalty.orderTotalIs("50.00"),
381
382 ProductScreen.clickDisplayedProduct("Product A"),
383 ProductScreen.selectedOrderlineHas("Product A", "2", "40.00"),
384 PosLoyalty.orderTotalIs("66.00"),
385 ].flat(),
386 });
387
388 registry.category("web_tour.tours").add("PosLoyaltyTour12", {
389 steps: () =>
390 [
391 Chrome.startPoS(),
392 Dialog.confirm("Open Register"),
393 ProductScreen.addOrderline("Free Product A", "2"),
394 ProductScreen.clickDisplayedProduct("Free Product A"),
395 ProductScreen.totalAmountIs("2.00"),
396 PosLoyalty.hasRewardLine("Free Product", "-1.00"),
397 ProductScreen.addOrderline("Free Product B", "2"),
398 ProductScreen.clickDisplayedProduct("Free Product B"),
399 ProductScreen.totalAmountIs("12.00"),
400 PosLoyalty.hasRewardLine("Free Product", "-5.00"),
401 ProductScreen.clickDisplayedProduct("Free Product B"),
402 ProductScreen.clickDisplayedProduct("Free Product B"),
403 ProductScreen.clickDisplayedProduct("Free Product B"),
404 ProductScreen.selectedOrderlineHas("Free Product B", "6"),
405 ProductScreen.totalAmountIs("22.00"),
406 PosLoyalty.hasRewardLine("Free Product", "-10.00"),
407 ].flat(),
408 });
409
410 function createOrderCoupon(totalAmount, couponName, couponAmount, loyaltyPoints) {
411 return [
412 Chrome.startPoS(),
413 Dialog.confirm("Open Register"),
414 ProductScreen.clickPartnerButton(),
415 ProductScreen.clickCustomer("AAAA"),
416 ProductScreen.addOrderline("product_a", "1"),
417 ProductScreen.addOrderline("product_b", "1"),
418 PosLoyalty.enterCode("promocode"),
419 PosLoyalty.hasRewardLine(`${couponName}`, `${couponAmount}`),
420 PosLoyalty.orderTotalIs(`${totalAmount}`),
421 PosLoyalty.pointsAwardedAre(`${loyaltyPoints}`),
422 PosLoyalty.finalizeOrder("Cash", `${totalAmount}`),
423 ].flat();
424 }
425
426 registry.category("web_tour.tours").add("PosLoyaltyPointsDiscountNoDomainProgramNoDomain", {
427 steps: () => [createOrderCoupon("135.00", "10% on your order", "-15.00", "135")].flat(),
428 });
429
430 registry.category("web_tour.tours").add("PosLoyaltyPointsDiscountNoDomainProgramDomain", {
431 steps: () => [createOrderCoupon("135.00", "10% on your order", "-15.00", "100")].flat(),
432 });
433
434 registry.category("web_tour.tours").add("PosLoyaltyPointsDiscountWithDomainProgramDomain", {
435 steps: () => [createOrderCoupon("140.00", "10% on food", "-10.00", "90")].flat(),
436 });
437
438 registry.category("web_tour.tours").add("PosLoyaltyPointsGlobalDiscountProgramNoDomain", {
439 steps: () =>
440 [
441 Chrome.startPoS(),
442 Dialog.confirm("Open Register"),
443 ProductScreen.addOrderline("product_a", "1"),
444 ProductScreen.clickPartnerButton(),
445 ProductScreen.clickCustomer("AAAA"),
446 PosLoyalty.hasRewardLine("10% on your order", "-10.00"),
447 PosLoyalty.orderTotalIs("90"),
448 PosLoyalty.pointsAwardedAre("90"),
449 PosLoyalty.finalizeOrder("Cash", "90"),
450 ].flat(),
451 });
452
453 registry.category("web_tour.tours").add("ChangeRewardValueWithLanguage", {
454 steps: () =>
455 [
456 Chrome.startPoS(),
457 Dialog.confirm("Open Register"),
458
459 ProductScreen.clickDisplayedProduct("Desk Organizer"),
460 ProductScreen.selectedOrderlineHas("Desk Organizer", "1", "5.10"),
461 ProductScreen.clickPartnerButton(),
462 ProductScreen.clickCustomer("Partner Test 1"),
463 PosLoyalty.isRewardButtonHighlighted(true, true),
464 PosLoyalty.claimReward("$ 2 on your order"),
465 PosLoyalty.hasRewardLine("$ 2 on your order", "-2.00"),
466 PosLoyalty.orderTotalIs("3.10"),
467 ].flat(),
468 });
469
470 registry.category("web_tour.tours").add("PosLoyaltyArchivedRewardProductsInactive", {
471 steps: () =>
472 [
473 Chrome.startPoS(),
474 Dialog.confirm("Open Register"),
475
476 ProductScreen.clickDisplayedProduct("Test Product A"),
477 ProductScreen.clickPartnerButton(),
478 ProductScreen.clickCustomer("AAAA"),
479 PosLoyalty.isRewardButtonHighlighted(false, true),
480 ProductScreen.selectedOrderlineHas("Test Product A", "1", "100.00"),
481 PosLoyalty.finalizeOrder("Cash", "100"),
482 ].flat(),
483 });
484
485 registry.category("web_tour.tours").add("PosLoyaltyArchivedRewardProductsActive", {
486 steps: () =>
487 [
488 Chrome.startPoS(),
489 ProductScreen.clickDisplayedProduct("Test Product A"),
490 ProductScreen.clickPartnerButton(),
491 ProductScreen.clickCustomer("AAAA"),
492 PosLoyalty.isRewardButtonHighlighted(true),
493 ProductScreen.selectedOrderlineHas("Test Product A", "1", "100.00"),
494 PosLoyalty.finalizeOrder("Cash", "100"),
495 ].flat(),
496 });
497
498 registry.category("web_tour.tours").add("CustomerLoyaltyPointsDisplayed", {
499 steps: () =>
500 [
501 Chrome.startPoS(),
502 Dialog.confirm("Open Register"),
503
504 ProductScreen.clickDisplayedProduct("product_a"),
505 ProductScreen.selectedOrderlineHas("product_a", "1", "100.00"),
506
507 ProductScreen.clickPartnerButton(),
508 ProductScreen.clickCustomer("John Doe"),
509
510 PosLoyalty.orderTotalIs("100.00"),
511 PosLoyalty.pointsAwardedAre("100"),
512 PosLoyalty.finalizeOrder("Cash", "100.00"),
513
514 PosLoyalty.checkPartnerPoints("John Doe", "100.00"),
515 ].flat(),
516 });
517
518 registry.category("web_tour.tours").add("PosLoyalty2DiscountsSpecificGlobal", {
519 steps: () =>
520 [
521 Chrome.startPoS(),
522 Dialog.confirm("Open Register"),
523
524 ProductScreen.clickPartnerButton(),
525 ProductScreen.clickCustomer("AAAA"),
526
527 ProductScreen.addOrderline("Test Product A", "5"),
528 ProductScreen.clickDisplayedProduct("Test Product B"),
529 PosLoyalty.hasRewardLine("10% on your order", "-3.00"),
530 PosLoyalty.hasRewardLine("10% on Test Product B", "-0.45"),
531 PosLoyalty.finalizeOrder("Cash", "100"),
532 ].flat(),
533 });
534
535 registry.category("web_tour.tours").add("PosLoyaltySpecificProductDiscountWithGlobalDiscount", {
536 steps: () =>
537 [
538 Chrome.startPoS(),
539 Dialog.confirm("Open Register"),
540 ProductScreen.addOrderline("Product A", "1"),
541 PosLoyalty.hasRewardLine("$ 40 on Product A", "-40.00"),
542 PosLoyalty.clickDiscountButton(),
543 Dialog.confirm(),
544 PosLoyalty.hasRewardLine("$ 40 on Product A", "-40.00"),
545 PosLoyalty.orderTotalIs("20.00"),
546 ].flat(),
547 });
548
549 registry.category("web_tour.tours").add("PosRewardProductScan", {
550 steps: () =>
551 [
552 Chrome.startPoS(),
553 Dialog.confirm("Open Register"),
554
555 scan_barcode("95412427100283"),
556 ProductScreen.selectedOrderlineHas("product_a", "1", "1,150.00"),
557 PosLoyalty.hasRewardLine("50% on your order", "-575.00"),
558 PosLoyalty.orderTotalIs("575.00"),
559 PosLoyalty.finalizeOrder("Cash", "575.00"),
560 ].flat(),
561 });
562
563 registry.category("web_tour.tours").add("PosRewardProductScanGS1", {
564 steps: () =>
565 [
566 Chrome.startPoS(),
567 scan_barcode("0195412427100283"),
568 ProductScreen.selectedOrderlineHas("product_a", "1", "1,150.00"),
569 PosLoyalty.hasRewardLine("50% on your order", "-575.00"),
570 PosLoyalty.orderTotalIs("575.00"),
571 PosLoyalty.finalizeOrder("Cash", "575.00"),
572 ].flat(),
573 });
574
575 registry.category("web_tour.tours").add("PosLoyaltyPromocodePricelist", {
576 steps: () =>
577 [
578 Chrome.startPoS(),
579 Dialog.confirm("Open Register"),
580 ProductScreen.addOrderline("Test Product 1", "1"),
581 PosLoyalty.enterCode("hellopromo"),
582 PosLoyalty.orderTotalIs("25.87"),
583 ].flat(),
584 });
585
586 registry.category("web_tour.tours").add("RefundRulesProduct", {
587 steps: () =>
588 [
589 Chrome.startPoS(),
590 Dialog.confirm("Open Register"),
591 ProductScreen.clickDisplayedProduct("product_a"),
592 PosLoyalty.finalizeOrder("Cash", "1000"),
593 ProductScreen.isShown(),
594 ...ProductScreen.clickRefund(),
595 TicketScreen.filterIs("Paid"),
596 TicketScreen.selectOrder("001"),
597 ProductScreen.clickNumpad("1"),
598 TicketScreen.confirmRefund(),
599 PaymentScreen.isShown(),
600 ].flat(),
601 });
602
603 registry.category("web_tour.tours").add("test_two_variant_same_discount", {
604 steps: () =>
605 [
606 Chrome.startPoS(),
607 Dialog.confirm("Open Register"),
608 ProductScreen.clickDisplayedProduct("Sofa"),
609 Chrome.clickBtn("Add"),
610 ].flat(),
611 });
612
613 registry.category("web_tour.tours").add("test_settle_dont_give_points_again", {
614 steps: () =>
615 [
616 Chrome.startPoS(),
617 Dialog.confirm("Open Register"),
618 ProductScreen.clickPartnerButton(),
619 PartnerList.settleCustomerAccount("AAA Partner", "10.00", "TSJ/"),
620 ].flat(),
621 });
622
623 registry.category("web_tour.tours").add("test_refund_does_not_decrease_points", {
624 steps: () =>
625 [
626 Chrome.startPoS(),
627 Dialog.confirm("Open Register"),
628 ProductScreen.clickPartnerButton(),
629 ProductScreen.clickCustomer("Refunding Guy", true),
630 ProductScreen.clickDisplayedProduct("Refund Product"),
631 ProductScreen.clickControlButton("Reward"),
632 SelectionPopup.has("$ 1 per point on your order", { run: "click" }),
633 PosLoyalty.finalizeOrder("Cash", "200"),
634 ProductScreen.clickRefund(),
635 TicketScreen.selectOrder("001"),
636 ProductScreen.clickNumpad("1"),
637 ProductScreen.clickLine("$ 1 per point on your order"),
638 ProductScreen.clickNumpad("1"),
639 TicketScreen.confirmRefund(),
640 PaymentScreen.totalIs("-200.00"),
641 PaymentScreen.clickPaymentMethod("Cash"),
642 PaymentScreen.clickValidate(),
643 ].flat(),
644 });
645
646 registry.category("web_tour.tours").add("test_discount_after_unknown_scan", {
647 steps: () =>
648 [
649 Chrome.startPoS(),
650 Dialog.confirm("Open Register"),
651 ProductScreen.addOrderline("Test Product A", "1"),
652 scan_barcode("00998877665544332211"), //should be unknown
653 PosLoyalty.hasRewardLine("10% on Test Product A", "-0.50"),
654 ProductScreen.totalAmountIs("4.50"),
655 ].flat(),
656 });
657
658 registry.category("web_tour.tours").add("test_scan_loyalty_card_select_customer", {
659 steps: () =>
660 [
661 Chrome.startPoS(),
662 Dialog.confirm("Open Register"),
663 scan_barcode("0444-e050-4548"),
664 ProductScreen.customerIsSelected("AAA Test Partner"),
665 ].flat(),
666 });
667
668 registry.category("web_tour.tours").add("test_min_qty_points_awarded", {
669 steps: () =>
670 [
671 Chrome.startPoS(),
672 Dialog.confirm("Open Register"),
673 ProductScreen.clickPartnerButton(),
674 ProductScreen.clickCustomer("AA Partner"),
675 ProductScreen.clickDisplayedProduct("Whiteboard Pen"),
676 PosLoyalty.claimReward("Free Product"),
677 PosLoyalty.pointsTotalIs("90"),
678 PosLoyalty.orderTotalIs("0.0"),
679 PosLoyalty.finalizeOrder("Cash", "0.0"),
680 ].flat(),
681 });
682
683 registry.category("web_tour.tours").add("test_confirm_coupon_programs_one_by_one", {
684 steps: () =>
685 [
686 Chrome.startPoS(),
687 Dialog.confirm("Open Register"),
688 {
689 trigger: "body",
690 content: "Create fake orders",
691 run: async () => {
692 // Create 5 orders that will be synced one by one
693 for (let i = 0; i < 5; i++) {
694 const order = posmodel.createNewOrder();
695 const product = posmodel.models["product.template"].find(
696 (p) => p.name === "Desk Pad"
697 );
698 const pm = posmodel.models["pos.payment.method"].getFirst();
699 const program = posmodel.models["loyalty.program"].find(
700 (p) => p.program_type === "gift_card"
701 );
702
703 await posmodel.addLineToOrder({ product_tmpl_id: product }, order);
704 posmodel.addPendingOrder([order.id]);
705 order.addPaymentline(pm);
706 order.state = "paid";
707
708 // Create fake coupon point changes to simulate coupons to be confirmed
709 order.uiState.couponPointChanges = [
710 {
711 points: 124.2,
712 program_id: program.id,
713 coupon_id: -(i + 1),
714 barcode: "",
715 },
716 ];
717 }
718 },
719 },
720 // Create one more order to be able to trigger the sync from the UI
721 ProductScreen.clickDisplayedProduct("Desk Pad"),
722 ProductScreen.clickPayButton(),
723 PaymentScreen.clickPaymentMethod("Bank"),
724 PaymentScreen.clickValidate(),
725 ReceiptScreen.isShown(),
726 ].flat(),
727 });
728
729 registry.category("web_tour.tours").add("test_order_reward_product_tax_included_included", {
730 steps: () =>
731 [
732 Chrome.startPoS(),
733 Dialog.confirm("Open Register"),
734 ProductScreen.addOrderline("Product Include", "1"),
735 PosLoyalty.enterCode("hellopromo"),
736 PosLoyalty.hasRewardLine("$ 10 on your order", "-10.00"),
737 ].flat(),
738 });
739
740 registry.category("web_tour.tours").add("test_order_reward_product_tax_included_excluded", {
741 steps: () =>
742 [
743 Chrome.startPoS(),
744 ProductScreen.addOrderline("Product Include", "1"),
745 PosLoyalty.enterCode("hellopromo"),
746 PosLoyalty.hasRewardLine("$ 10 on your order", "-10.00"),
747 ].flat(),
748 });
749
750 registry.category("web_tour.tours").add("test_specific_reward_product_tax_included_included", {
751 steps: () =>
752 [
753 Chrome.startPoS(),
754 Dialog.confirm("Open Register"),
755 ProductScreen.addOrderline("Product Include", "1"),
756 PosLoyalty.enterCode("hellopromo"),
757 PosLoyalty.hasRewardLine("$ 10 on Product Include", "-10.00"),
758 ].flat(),
759 });
760
761 registry.category("web_tour.tours").add("test_specific_reward_product_tax_included_excluded", {
762 steps: () =>
763 [
764 Chrome.startPoS(),
765 ProductScreen.addOrderline("Product Include", "1"),
766 PosLoyalty.enterCode("hellopromo"),
767 PosLoyalty.hasRewardLine("$ 10 on Product Include", "-10.00"),
768 ].flat(),
769 });
770
771 registry.category("web_tour.tours").add("test_race_conditions_update_program", {
772 steps: () =>
773 [
774 Chrome.startPoS(),
775 Dialog.confirm("Open Register"),
776 ProductScreen.clickDisplayedProduct("Test Product"),
777 PosLoyalty.orderTotalIs("34.87"),
778 {
779 trigger: "body",
780 run: async () => {
781 // Check the number of lines in the order
782 const line_count = document.querySelectorAll(".orderline").length;
783 if (line_count !== 11) {
784 throw new Error(`Expected 11 orderlines, found ${line_count}`);
785 }
786 },
787 },
788 ].flat(),
789 });