Debian Codegraph @

addons/pos_restaurant/static/tests/tours/tip_screen_tour.js

raw
1 import * as ProductScreenPos from "@point_of_sale/../tests/pos/tours/utils/product_screen_util";
2 import * as ProductScreenResto from "@pos_restaurant/../tests/tours/utils/product_screen_util";
3 const ProductScreen = { ...ProductScreenPos, ...ProductScreenResto };
4 import * as Dialog from "@point_of_sale/../tests/generic_helpers/dialog_util";
5 import * as PaymentScreen from "@point_of_sale/../tests/pos/tours/utils/payment_screen_util";
6 import * as ReceiptScreen from "@point_of_sale/../tests/pos/tours/utils/receipt_screen_util";
7 import * as FloorScreen from "@pos_restaurant/../tests/tours/utils/floor_screen_util";
8 import * as TicketScreen from "@point_of_sale/../tests/pos/tours/utils/ticket_screen_util";
9 import * as TipScreen from "@pos_restaurant/../tests/tours/utils/tip_screen_util";
10 import * as NumberPopup from "@point_of_sale/../tests/generic_helpers/number_popup_util";
11 import * as Chrome from "@point_of_sale/../tests/pos/tours/utils/chrome_util";
12 import { registry } from "@web/core/registry";
13
14 registry.category("web_tour.tours").add("PosResTipScreenTour", {
15 steps: () =>
16 [
17 // Create order that is synced when draft.
18 // order 1
19 Chrome.startPoS(),
20 Dialog.confirm("Open Register"),
21 FloorScreen.clickTable("2"),
22 ProductScreen.addOrderline("Minute Maid", "1", "2"),
23 ProductScreen.totalAmountIs("2.0"),
24 Chrome.clickPlanButton(),
25 FloorScreen.orderCountSyncedInTableIs("2", "1"),
26 FloorScreen.clickTable("2"),
27 ProductScreen.totalAmountIs("2.0"),
28 ProductScreen.clickPayButton(false),
29 ProductScreen.discardOrderWarningDialog(),
30 PaymentScreen.clickPaymentMethod("Bank"),
31 PaymentScreen.clickPaymentMethod("Bank"),
32 PaymentScreen.clickValidate(),
33 TipScreen.isShown(),
34 Chrome.clickPlanButton(),
35 FloorScreen.clickTable("4"),
36 // order 2
37 ProductScreen.addOrderline("Coca-Cola", "2", "2"),
38 ProductScreen.totalAmountIs("4.0"),
39 Chrome.clickPlanButton(),
40 Chrome.clickOrders(),
41 TicketScreen.selectFilter("Active"),
42 {
43 trigger: `.ticket-screen .orders .order-row:contains(Tipping):contains($ 2.00)`,
44 },
45 Chrome.clickPlanButton(),
46
47 // Create without syncing the draft.
48 // order 3
49 FloorScreen.clickTable("5"),
50 ProductScreen.addOrderline("Minute Maid", "3", "2"),
51 ProductScreen.totalAmountIs("6.0"),
52 ProductScreen.clickPayButton(false),
53 ProductScreen.discardOrderWarningDialog(),
54 PaymentScreen.clickPaymentMethod("Bank"),
55 PaymentScreen.clickValidate(),
56 TipScreen.isShown(),
57 Chrome.clickPlanButton(),
58 FloorScreen.clickNewOrder(),
59 // order 4
60 ProductScreen.addOrderline("Coca-Cola", "4", "2"),
61 ProductScreen.totalAmountIs("8.0"),
62 ProductScreen.clickControlButton("Guests"),
63 NumberPopup.enterValue("2"),
64 NumberPopup.isShown("2"),
65 Dialog.confirm(),
66 ProductScreen.guestNumberIs("2"),
67 ProductScreen.clickCloseButton(),
68 ProductScreen.setTab("Test"),
69 Chrome.clickOrders(),
70 TicketScreen.selectFilter("Active"),
71 {
72 trigger: `.ticket-screen .orders .order-row:contains(Tipping):contains($ 6.00)`,
73 },
74 // Tip 20% on order1
75 TicketScreen.selectOrderByPrice("2.0"),
76 TicketScreen.loadSelectedOrder(),
77 TipScreen.isShown(),
78 TipScreen.totalAmountIs("2.0"),
79 TipScreen.percentAmountIs("15%", "0.30"),
80 TipScreen.percentAmountIs("20%", "0.40"),
81 TipScreen.percentAmountIs("25%", "0.50"),
82 TipScreen.clickPercentTip("20%"),
83 TipScreen.inputAmountIs("0.40"),
84 Chrome.clickPlanButton(),
85 FloorScreen.isShown(),
86 Chrome.clickOrders(),
87 TicketScreen.selectFilter("Active"),
88
89 // Tip 25% on order3
90 TicketScreen.selectOrderByPrice("6.0"),
91 TicketScreen.loadSelectedOrder(),
92 TipScreen.isShown(),
93 TipScreen.totalAmountIs("6.0"),
94 TipScreen.percentAmountIs("15%", "0.90"),
95 TipScreen.percentAmountIs("20%", "1.20"),
96 TipScreen.percentAmountIs("25%", "1.50"),
97 TipScreen.clickPercentTip("25%"),
98 TipScreen.inputAmountIs("1.50"),
99 Chrome.clickPlanButton(),
100 FloorScreen.isShown(),
101 Chrome.clickOrders(),
102
103 // finalize order 4 then tip custom amount
104 TicketScreen.selectOrderByPrice("8.0"),
105 TicketScreen.loadSelectedOrder(),
106 ProductScreen.isShown(),
107 ProductScreen.totalAmountIs("8.0"),
108 ProductScreen.guestNumberIs("2"),
109 ProductScreen.clickCloseButton(),
110 ProductScreen.clickPayButton(false),
111 ProductScreen.discardOrderWarningDialog(),
112 PaymentScreen.clickPaymentMethod("Bank"),
113 PaymentScreen.clickValidate(),
114 TipScreen.isShown(),
115 TipScreen.totalAmountIs("8.0"),
116 TipScreen.percentAmountIs("15%", "1.20"),
117 TipScreen.percentAmountIs("20%", "1.60"),
118 TipScreen.percentAmountIs("25%", "2.00"),
119 TipScreen.setCustomTip("1.00"),
120 TipScreen.inputAmountIs("1.00"),
121 Chrome.clickPlanButton(),
122 FloorScreen.isShown(),
123
124 // settle tips here
125 Chrome.clickOrders(),
126 TicketScreen.selectFilter("Tipping"),
127 TicketScreen.tipContains("1.00"),
128 TicketScreen.settleTips(),
129 TicketScreen.selectFilter("Active"),
130 {
131 trigger: `.ticket-screen .orders .order-row:contains(Ongoing):contains($ 4.00)`,
132 },
133 // tip order2 during payment
134 // tip screen should not show after validating payment screen
135 TicketScreen.selectOrderByPrice("4.0"),
136 TicketScreen.loadSelectedOrder(),
137 ProductScreen.clickPayButton(false),
138 ProductScreen.discardOrderWarningDialog(),
139 PaymentScreen.clickTipButton(),
140
141 NumberPopup.enterValue("1"),
142 NumberPopup.isShown("1"),
143 Dialog.confirm(),
144 PaymentScreen.emptyPaymentlines("5.0"),
145 PaymentScreen.clickPaymentMethod("Cash"),
146 PaymentScreen.clickValidate(),
147 ReceiptScreen.isShown(),
148
149 // order 5
150 // Click directly on "settle" without selecting a Tip
151 ReceiptScreen.clickNextOrder(),
152 FloorScreen.clickTable("2"),
153 ProductScreen.addOrderline("Minute Maid", "3", "2"),
154 ProductScreen.totalAmountIs("6.0"),
155 ProductScreen.clickPayButton(false),
156 ProductScreen.discardOrderWarningDialog(),
157 PaymentScreen.clickPaymentMethod("Bank"),
158 PaymentScreen.clickValidate(),
159 TipScreen.isShown(),
160 TipScreen.clickSettle(),
161 ReceiptScreen.isShown(),
162 ReceiptScreen.clickNextOrder(),
163 FloorScreen.isShown(),
164 ].flat(),
165 });
166
167 registry.category("web_tour.tours").add("test_tip_after_payment", {
168 steps: () =>
169 [
170 Chrome.startPoS(),
171 Dialog.confirm("Open Register"),
172 FloorScreen.clickTable("2"),
173 ProductScreen.addOrderline("Minute Maid", "1", "3"),
174 ProductScreen.clickPayButton(false),
175 ProductScreen.discardOrderWarningDialog(),
176 // case 1: remaining < 0 => increase PaymentLine amount
177 PaymentScreen.enterPaymentLineAmount("Bank", "1"),
178 PaymentScreen.clickTipButton(),
179 {
180 content: "click numpad button: 1",
181 trigger: ".modal div.numpad button:contains(/^1/)",
182 run: "click",
183 },
184 Dialog.confirm(),
185 PaymentScreen.selectedPaymentlineHas("Bank", "2.00"),
186 // case 2: remaining >= 0 and remaining >= tip => don't change PaymentLine amount
187 PaymentScreen.clickPaymentlineDelButton("Bank", "2.00"),
188 PaymentScreen.enterPaymentLineAmount("Bank", "5"),
189 PaymentScreen.clickTipButton(),
190 {
191 content: "click numpad button: 2",
192 trigger: ".modal div.numpad button:contains(/^2/)",
193 run: "click",
194 },
195 Dialog.confirm(),
196 PaymentScreen.selectedPaymentlineHas("Bank", "5.00"),
197 // case 3: remaining >= 0 and remaining < tip => increase by the difference
198 PaymentScreen.clickPaymentlineDelButton("Bank", "5.00"),
199 PaymentScreen.enterPaymentLineAmount("Bank", "5"),
200 PaymentScreen.clickTipButton(),
201 {
202 content: "click numpad button: 3",
203 trigger: ".modal div.numpad button:contains(/^3/)",
204 run: "click",
205 },
206 Dialog.confirm(),
207 PaymentScreen.selectedPaymentlineHas("Bank", "6.00"),
208 Chrome.endTour(),
209 ].flat(),
210 });