Debian Codegraph @

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

raw
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 TicketScreen from "@point_of_sale/../tests/pos/tours/utils/ticket_screen_util";
4 import * as Dialog from "@point_of_sale/../tests/generic_helpers/dialog_util";
5 import * as Chrome from "@point_of_sale/../tests/pos/tours/utils/chrome_util";
6 import * as PartnerList from "@point_of_sale/../tests/pos/tours/utils/partner_list_util";
7 import * as PaymentScreen from "@point_of_sale/../tests/pos/tours/utils/payment_screen_util";
8 import * as Numpad from "@point_of_sale/../tests/generic_helpers/numpad_util";
9 import * as Order from "@point_of_sale/../tests/generic_helpers/order_widget_util";
10 import { negateStep } from "@point_of_sale/../tests/generic_helpers/utils";
11 import { delay } from "@web/core/utils/concurrency";
12 import { registry } from "@web/core/registry";
13
14 registry.category("web_tour.tours").add("EWalletProgramTour1", {
15 steps: () =>
16 [
17 Chrome.startPoS(),
18 Dialog.confirm("Open Register"),
19
20 // Topup 50$ for partner_aaa
21 ProductScreen.clickDisplayedProduct("Top-up eWallet"),
22 PosLoyalty.orderTotalIs("50.00"),
23 ProductScreen.clickPayButton(false),
24 // If there's no partner, we asked to redirect to the partner list screen.
25 Dialog.confirm(),
26 PartnerList.clickPartner("AAAAAAA"),
27 PosLoyalty.finalizeOrder("Cash", "50"),
28
29 // Topup 10$ for partner_bbb
30 ProductScreen.clickPartnerButton(),
31 ProductScreen.clickCustomer("BBBBBBB"),
32 ProductScreen.addOrderline("Top-up eWallet", "1", "10"),
33 PosLoyalty.orderTotalIs("10.00"),
34 PosLoyalty.finalizeOrder("Cash", "10"),
35
36 // Check numpad visibility when clicking on eWallet orderline
37 ProductScreen.addOrderline("Whiteboard Pen"),
38 ProductScreen.clickPartnerButton(),
39 ProductScreen.clickCustomer("AAAAAAA"),
40 PosLoyalty.eWalletButtonState({
41 highlighted: true,
42 text: getEWalletText("Pay"),
43 click: true,
44 }),
45 PosLoyalty.orderTotalIs("0.00"),
46 ...ProductScreen.clickLine("eWallet"),
47 // Added a small wait because the clickLine function uses a 300ms timeout
48 {
49 content: "Wait 300ms after clicking orderline",
50 trigger: "body",
51 async run() {
52 await delay(300);
53 },
54 },
55 Numpad.isVisible(),
56 ...Order.hasLine({
57 withClass: ".selected",
58 run: "click",
59 productName: "eWallet",
60 quantity: "1.0",
61 }),
62 {
63 content: "Wait 300ms after clicking orderline",
64 trigger: "body",
65 async run() {
66 await delay(300);
67 },
68 },
69 negateStep(Numpad.isVisible()),
70 {
71 content: "Click Current Balance line in orderline",
72 trigger: ".orderline li:contains(Current Balance:)",
73 run: "click",
74 },
75 Numpad.isVisible(),
76 ].flat(),
77 });
78
79 const getEWalletText = (suffix) => "eWallet" + (suffix !== "" ? ` ${suffix}` : "");
80 registry.category("web_tour.tours").add("EWalletProgramTour2", {
81 steps: () =>
82 [
83 Chrome.startPoS(),
84 ProductScreen.addOrderline("Whiteboard Pen", "2", "6", "12.00"),
85 PosLoyalty.eWalletButtonState({ highlighted: false }),
86 ProductScreen.clickPartnerButton(),
87 ProductScreen.clickCustomer("AAAAAAA"),
88 PosLoyalty.eWalletButtonState({
89 highlighted: true,
90 text: getEWalletText("Pay"),
91 click: true,
92 }),
93 PosLoyalty.orderTotalIs("0.00"),
94 PosLoyalty.finalizeOrder("Cash", "0"),
95
96 // Consume partner_bbb's full eWallet.
97 ProductScreen.clickPartnerButton(),
98 ProductScreen.clickCustomer("BBBBBBB"),
99 PosLoyalty.eWalletButtonState({ highlighted: false }),
100 ProductScreen.addOrderline("Desk Pad", "6", "6", "36.00"),
101 PosLoyalty.eWalletButtonState({
102 highlighted: true,
103 text: getEWalletText("Pay"),
104 click: true,
105 }),
106 PosLoyalty.eWalletButtonState({ highlighted: false }),
107 PosLoyalty.orderTotalIs("26.00"),
108 PosLoyalty.finalizeOrder("Cash", "26"),
109
110 // Switching partners should work.
111 ProductScreen.clickPartnerButton(),
112 ProductScreen.clickCustomer("BBBBBBB"),
113 ProductScreen.addOrderline("Desk Pad", "2", "19", "38.00"),
114 PosLoyalty.eWalletButtonState({ highlighted: false }),
115 ProductScreen.clickPartnerButton(),
116 ProductScreen.clickCustomer("AAAAAAA"),
117 PosLoyalty.eWalletButtonState({
118 highlighted: true,
119 text: getEWalletText("Pay"),
120 click: true,
121 }),
122 PosLoyalty.orderTotalIs("0.00"),
123 ProductScreen.clickPartnerButton(),
124 ProductScreen.clickCustomer("BBBBBBB"),
125 PosLoyalty.eWalletButtonState({ highlighted: false }),
126 PosLoyalty.orderTotalIs("38.00"),
127 ProductScreen.clickPartnerButton(),
128 ProductScreen.clickCustomer("AAAAAAA"),
129 PosLoyalty.eWalletButtonState({
130 highlighted: true,
131 text: getEWalletText("Pay"),
132 click: true,
133 }),
134 PosLoyalty.orderTotalIs("0.00"),
135 PosLoyalty.finalizeOrder("Cash", "0"),
136
137 // Refund with eWallet.
138 // - Make an order to refund.
139 ProductScreen.clickPartnerButton(),
140 ProductScreen.clickCustomer("BBBBBBB"),
141 ProductScreen.addOrderline("Whiteboard Pen", "1", "20", "20.00"),
142 PosLoyalty.orderTotalIs("20.00"),
143 PosLoyalty.finalizeOrder("Cash", "20"),
144 // - Refund order.
145 ...ProductScreen.clickRefund(),
146 TicketScreen.filterIs("Paid"),
147 TicketScreen.selectOrder("2004"),
148 TicketScreen.confirmRefund(),
149 PaymentScreen.isShown(),
150 PaymentScreen.clickBack(),
151 ProductScreen.isShown(),
152 PosLoyalty.eWalletButtonState({
153 highlighted: true,
154 text: getEWalletText("Refund"),
155 click: true,
156 }),
157 PosLoyalty.orderTotalIs("0.00"),
158 PosLoyalty.finalizeOrder("Cash", "0"),
159 ].flat(),
160 });
161
162 registry.category("web_tour.tours").add("ExpiredEWalletProgramTour", {
163 steps: () =>
164 [
165 Chrome.startPoS(),
166 Dialog.confirm("Open Register"),
167 ProductScreen.clickPartnerButton(),
168 ProductScreen.clickCustomer("AAAA"),
169 ProductScreen.addOrderline("Whiteboard Pen", "2", "6", "12.00"),
170 PosLoyalty.eWalletButtonState({ highlighted: false, click: true }),
171 Dialog.is({ title: "No valid eWallet found" }),
172 Dialog.confirm(),
173 ].flat(),
174 });
175
176 registry.category("web_tour.tours").add("PosLoyaltyPointsEwallet", {
177 steps: () =>
178 [
179 Chrome.startPoS(),
180 Dialog.confirm("Open Register"),
181 ProductScreen.clickPartnerButton(),
182 ProductScreen.clickCustomer("AAAA"),
183 PosLoyalty.eWalletButtonState({ highlighted: false }),
184 ProductScreen.addOrderline("product_a", "1"),
185 PosLoyalty.eWalletButtonState({
186 highlighted: true,
187 text: getEWalletText("Pay"),
188 click: true,
189 }),
190 PosLoyalty.pointsAwardedAre("100"),
191 PosLoyalty.finalizeOrder("Cash", "90.00"),
192 ].flat(),
193 });
194
195 registry.category("web_tour.tours").add("EWalletLoyaltyHistory", {
196 steps: () =>
197 [
198 Chrome.startPoS(),
199 Dialog.confirm("Open Register"),
200
201 ProductScreen.clickDisplayedProduct("Top-up eWallet"),
202 PosLoyalty.orderTotalIs("50.00"),
203 ProductScreen.clickPartnerButton(),
204 PartnerList.clickPartner("AAAAAAA"),
205 PosLoyalty.finalizeOrder("Cash", "50"),
206
207 ProductScreen.addOrderline("Whiteboard Pen", "2", "6", "12.00"),
208 PosLoyalty.eWalletButtonState({ highlighted: false }),
209 ProductScreen.clickPartnerButton(),
210 ProductScreen.clickCustomer("AAAAAAA"),
211 PosLoyalty.eWalletButtonState({
212 highlighted: true,
213 text: getEWalletText("Pay"),
214 click: true,
215 }),
216 PosLoyalty.orderTotalIs("0.00"),
217 PosLoyalty.finalizeOrder("Cash", "0"),
218 ].flat(),
219 });