Debian Codegraph @

addons/pos_hr/static/tests/tours/pos_hr_tour.js

raw
1 import * as PosHr from "@pos_hr/../tests/tours/utils/pos_hr_helpers";
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 ReceiptScreen from "@point_of_sale/../tests/pos/tours/utils/receipt_screen_util";
5 import * as PaymentScreen from "@point_of_sale/../tests/pos/tours/utils/payment_screen_util";
6 import * as Chrome from "@point_of_sale/../tests/pos/tours/utils/chrome_util";
7 import * as NumberPopup from "@point_of_sale/../tests/generic_helpers/number_popup_util";
8 import * as Dialog from "@point_of_sale/../tests/generic_helpers/dialog_util";
9 import * as SelectionPopup from "@point_of_sale/../tests/generic_helpers/selection_popup_util";
10 import * as BackendUtils from "@point_of_sale/../tests/pos/tours/utils/backend_utils";
11 import * as Utils from "@point_of_sale/../tests/generic_helpers/utils";
12 import { registry } from "@web/core/registry";
13 import { negate, scan_barcode } from "@point_of_sale/../tests/generic_helpers/utils";
14
15 registry.category("web_tour.tours").add("PosHrTour", {
16 steps: () =>
17 [
18 Chrome.clickBtn("Open Register"),
19 PosHr.loginScreenIsShown(),
20 PosHr.clickLoginButton(),
21 SelectionPopup.has("Pos Employee1"),
22 SelectionPopup.has("Pos Employee2"),
23 SelectionPopup.has("Mitchell Admin"),
24 SelectionPopup.has("Pos Employee1", { run: "click" }),
25 NumberPopup.enterValue("25"),
26 NumberPopup.isShown("••"),
27 {
28 trigger: "body",
29 run: () => {
30 window.dispatchEvent(new KeyboardEvent("keyup", { key: "8" }));
31 },
32 },
33 NumberPopup.isShown("•••"),
34 NumberPopup.enterValue("1"),
35 NumberPopup.isShown("••••"),
36 Dialog.confirm(),
37 // after trying to close the number popup, the error popup should be shown
38 // successfully confirming the dialog would imply that the error popup is actually shown
39 PosHr.clickLoginButton(),
40 SelectionPopup.has("Pos Employee1", { run: "click" }),
41
42 NumberPopup.enterValue("25"),
43 NumberPopup.isShown("••"),
44 NumberPopup.enterValue("80"),
45 NumberPopup.isShown("••••"),
46 Dialog.confirm(),
47 Dialog.confirm("Open Register"),
48 ProductScreen.isShown(),
49 PosHr.clickCashierName(),
50 SelectionPopup.has("Mitchell Admin", { run: "click" }),
51 PosHr.clickCashierName(),
52 SelectionPopup.has("Pos Employee2", { run: "click" }),
53 NumberPopup.enterValue("12"),
54 NumberPopup.isShown("••"),
55 NumberPopup.enterValue("34"),
56 NumberPopup.isShown("••••"),
57 Dialog.confirm(),
58 ProductScreen.isShown(),
59
60 // Create orders and check if the ticket list has the right employee for each order
61 // order for employee 2
62 ProductScreen.addOrderline("Desk Pad", "1"),
63 ProductScreen.totalAmountIs("1.98"),
64 Chrome.clickOrders(),
65 TicketScreen.nthRowContains(1, "Pos Employee2", false),
66
67 // order for employee 1
68 PosHr.clickLockButton(),
69 Chrome.clickBtn("Unlock Register"),
70 PosHr.login("Pos Employee1", "2580"),
71 Chrome.createFloatingOrder(),
72 ProductScreen.addOrderline("Desk Pad", "1"),
73 ProductScreen.totalAmountIs("1.98"),
74 Chrome.clickOrders(),
75 TicketScreen.nthRowContains(1, "Pos Employee2", false),
76 TicketScreen.nthRowContains(2, "Pos Employee1", false),
77
78 // Cash in/out should be accessible for all users.
79 Chrome.clickMenuOption("Cash In/Out"),
80 Dialog.discard(),
81
82 // order for admin
83 PosHr.clickCashierName(),
84 SelectionPopup.has("Mitchell Admin", { run: "click" }),
85 Chrome.createFloatingOrder(),
86 ProductScreen.addOrderline("Desk Pad", "1", "8"),
87 ProductScreen.totalAmountIs("8.0"),
88 Chrome.clickOrders(),
89 TicketScreen.nthRowContains(3, "Mitchell Admin", false),
90
91 // Close register should be accessible by the admin user.
92 Chrome.clickMenuOption("Close Register"),
93 Dialog.is("Closing Register"),
94 ].flat(),
95 });
96
97 registry.category("web_tour.tours").add("CashierStayLogged", {
98 steps: () =>
99 [
100 Chrome.clickBtn("Open Register"),
101 PosHr.loginScreenIsShown(),
102 PosHr.clickLoginButton(),
103 SelectionPopup.has("Pos Employee1"),
104 SelectionPopup.has("Pos Employee2"),
105 SelectionPopup.has("Mitchell Admin"),
106 SelectionPopup.has("Mitchell Admin", { run: "click" }),
107 Dialog.confirm("Open Register"),
108 PosHr.refreshPage(),
109 ProductScreen.isShown(),
110 Chrome.clickMenuButton(),
111 PosHr.clickLockButton(),
112 PosHr.refreshPage(),
113 PosHr.loginScreenIsShown(),
114 ].flat(),
115 });
116
117 registry.category("web_tour.tours").add("CashierCanSeeProductInfo", {
118 steps: () =>
119 [
120 Chrome.clickBtn("Open Register"),
121 PosHr.loginScreenIsShown(),
122 PosHr.clickLoginButton(),
123 SelectionPopup.has("Mitchell Admin", { run: "click" }),
124 Dialog.confirm("Open Register"),
125 ProductScreen.clickInfoProduct("product_a", [Dialog.confirm("Close")]),
126 Dialog.isNot(),
127 ].flat(),
128 });
129
130 registry.category("web_tour.tours").add("CashierCannotClose", {
131 steps: () =>
132 [
133 Chrome.clickBtn("Open Register"),
134 PosHr.loginScreenIsShown(),
135 PosHr.clickLoginButton(),
136 SelectionPopup.has("Test Employee 3", { run: "click" }),
137 Dialog.confirm("Open Register"),
138 Chrome.clickMenuButton(),
139 {
140 trigger: negate(`span.dropdown-item:contains("Close Register")`),
141 },
142 PosHr.clickCashierName(),
143 SelectionPopup.has("Mitchell Admin", { run: "click" }),
144 Chrome.clickMenuButton(),
145 {
146 trigger: `span.dropdown-item:contains("Close Register")`,
147 },
148 ].flat(),
149 });
150
151 registry.category("web_tour.tours").add("test_basic_user_can_change_price", {
152 steps: () =>
153 [
154 Chrome.clickBtn("Open Register"),
155 PosHr.loginScreenIsShown(),
156 PosHr.clickLoginButton(),
157 SelectionPopup.has("Test Employee 3", { run: "click" }),
158 Dialog.confirm("Open Register"),
159 ProductScreen.addOrderline("Desk Pad", "1", "10", "10"),
160 ].flat(),
161 });
162
163 registry.category("web_tour.tours").add("test_change_on_rights_reflected_directly", {
164 steps: () =>
165 [
166 Chrome.clickBtn("Open Register"),
167 PosHr.loginScreenIsShown(),
168 PosHr.clickLoginButton(),
169 SelectionPopup.has("Mitchell Admin", { run: "click" }),
170 Dialog.confirm("Open Register"),
171 Chrome.clickMenuOption("Backend", { expectUnloadPage: true }),
172 BackendUtils.editShopConfiguration("Shop"),
173 {
174 trigger: ".o_tag:contains('Pos Employee1') .o_delete",
175 run: "click",
176 },
177 BackendUtils.saveConfiguration(),
178 {
179 trigger: ".o_main_navbar .o-dropdown-item:contains('Dashboard')",
180 run: "click",
181 },
182 {
183 trigger: ".btn:contains('Continue Selling')",
184 run: "click",
185 expectUnloadPage: true,
186 },
187 Chrome.clickBtn("Unlock Register"),
188 PosHr.loginScreenIsShown(),
189 PosHr.clickLoginButton(),
190 Utils.negateStep(...SelectionPopup.has("Pos Employee1")),
191 ].flat(),
192 });
193
194 registry.category("web_tour.tours").add("test_minimal_employee_refund", {
195 steps: () =>
196 [
197 Chrome.clickBtn("Unlock Register"),
198 PosHr.loginScreenIsShown(),
199 PosHr.clickLoginButton(),
200 SelectionPopup.has("Minimal Employee", { run: "click" }),
201 Chrome.clickOrders(),
202 TicketScreen.selectFilter("Paid"),
203 TicketScreen.selectOrder("001"),
204 {
205 trigger: negate(".subpads"),
206 },
207 PosHr.clickCashierName(),
208 SelectionPopup.has("Mitchell Admin", { run: "click" }),
209 TicketScreen.selectFilter("Paid"),
210 TicketScreen.selectOrder("001"),
211 {
212 trigger: ".subpads",
213 },
214 ].flat(),
215 });
216
217 registry.category("web_tour.tours").add("test_cashier_changed_in_receipt", {
218 steps: () =>
219 [
220 Chrome.clickBtn("Open Register"),
221 PosHr.loginScreenIsShown(),
222 PosHr.clickLoginButton(),
223 SelectionPopup.has("Mitchell Admin", { run: "click" }),
224 Dialog.confirm("Open Register"),
225 ProductScreen.addOrderline("product_a", "1"),
226 ProductScreen.clickPayButton(),
227 PaymentScreen.clickPaymentMethod("Bank"),
228 PosHr.clickCashierName(),
229 SelectionPopup.has("Test Employee 3", { run: "click" }),
230 PaymentScreen.clickValidate(),
231 ReceiptScreen.cashierNameExists("Test"), // Test Employee 3 (Take the first word)
232 ReceiptScreen.clickNextOrder(),
233 ].flat(),
234 });
235
236 registry.category("web_tour.tours").add("test_cost_and_margin_visibility", {
237 steps: () =>
238 [
239 Chrome.clickBtn("Open Register"),
240 PosHr.loginScreenIsShown(),
241 PosHr.clickLoginButton(),
242 SelectionPopup.has("Mitchell Admin", { run: "click" }),
243 Dialog.confirm("Open Register"),
244 ProductScreen.clickInfoProduct("product_a"),
245 {
246 trigger: ".section-financials :contains('Margin')",
247 },
248 Dialog.confirm("Close"),
249 PosHr.clickCashierName(),
250 SelectionPopup.has("Test Employee 3", { run: "click" }),
251 ProductScreen.clickInfoProduct("product_a"),
252 {
253 trigger: ".section-financials :contains('Margin')",
254 },
255 Dialog.confirm("Close"),
256 PosHr.clickCashierName(),
257 SelectionPopup.has("Test Employee 4", { run: "click" }),
258 ProductScreen.clickInfoProduct("product_a"),
259 Utils.negateStep({
260 trigger: ".section-financials :contains('Margin')",
261 }),
262 ].flat(),
263 });
264
265 registry.category("web_tour.tours").add("pos_hr_go_backend_closed_registered", {
266 steps: () =>
267 [
268 // Admin --> 403: not the one that opened the session
269 Chrome.clickBtn("Backend"),
270 SelectionPopup.has("Mitchell Admin", { run: "click" }),
271 PosHr.loginScreenIsShown(),
272
273 // Employee with user --> 403
274 Chrome.clickBtn("Backend"),
275 SelectionPopup.has("Pos Employee1", { run: "click" }),
276 PosHr.enterPin("2580"),
277 PosHr.loginScreenIsShown(),
278
279 // Employee without user --> 403
280 Chrome.clickBtn("Backend"),
281 SelectionPopup.has("Test Employee 3", { run: "click" }),
282 PosHr.loginScreenIsShown(),
283
284 // Manager without user --> 403
285 Chrome.clickBtn("Backend"),
286 SelectionPopup.has("Test Manager 2", { run: "click" }),
287 PosHr.enterPin("5652"),
288 PosHr.loginScreenIsShown(),
289
290 // Manager that opened the session --> access granted
291 Chrome.clickBtn("Backend"),
292 SelectionPopup.has("Test Manager 1", { run: "click" }),
293 PosHr.enterPin("5651").map((step, index, array) => {
294 if (index === array.length - 1) {
295 return {
296 ...step,
297 expectUnloadPage: true,
298 };
299 }
300 return step;
301 }),
302 PosHr.loginScreenIsNotShown().map((step) => ({ ...step, expectUnloadPage: true })),
303 ].flat(),
304 });
305
306 registry.category("web_tour.tours").add("pos_hr_go_backend_opened_registered", {
307 steps: () =>
308 [
309 Chrome.clickBtn("Open Register"),
310 PosHr.clickLoginButton(),
311
312 // Admin --> 403: not the one that opened the session
313 SelectionPopup.has("Mitchell Admin", { run: "click" }),
314 Chrome.clickBtn("Open Register"),
315 Chrome.existMenuOption("Close Register"),
316 Chrome.notExistMenuOption("Backend"),
317
318 // Employee with user --> 403
319 PosHr.clickCashierName(),
320 SelectionPopup.has("Pos Employee1", { run: "click" }),
321 PosHr.enterPin("2580"),
322 Chrome.notExistMenuOption("Close Register"),
323 Chrome.notExistMenuOption("Backend"),
324
325 // Employee without user --> 403
326 PosHr.clickCashierName(),
327 SelectionPopup.has("Test Employee 3", { run: "click" }),
328 Chrome.notExistMenuOption("Close Register"),
329 Chrome.notExistMenuOption("Backend"),
330
331 // Manager without user --> 403
332 PosHr.clickCashierName(),
333 SelectionPopup.has("Test Manager 2", { run: "click" }),
334 PosHr.enterPin("5652"),
335 Chrome.existMenuOption("Close Register"),
336 Chrome.notExistMenuOption("Backend"),
337
338 // Manager that opened the session --> access granted
339 PosHr.clickCashierName(),
340 SelectionPopup.has("Test Manager 1", { run: "click" }),
341 PosHr.enterPin("5651"),
342 Chrome.existMenuOption("Close Register"),
343 Chrome.clickMenuOption("Backend", { expectUnloadPage: true }),
344 ].flat(),
345 });
346
347 registry
348 .category("web_tour.tours")
349 .add("pos_hr_go_backend_opened_registered_different_user_logged", {
350 steps: () =>
351 [
352 Chrome.clickBtn("Unlock Register"),
353 PosHr.clickLoginButton(),
354
355 // Employee, connected user
356 SelectionPopup.has("Pos Employee1", { run: "click" }),
357 PosHr.enterPin("2580"),
358 Chrome.existMenuOption("Backend"),
359
360 // Manager that opened the session, not connected user
361 PosHr.clickCashierName(),
362 SelectionPopup.has("Test Manager 1", { run: "click" }),
363 PosHr.enterPin("5651"),
364 Chrome.notExistMenuOption("Backend"),
365 ].flat(),
366 });
367
368 registry.category("web_tour.tours").add("test_maximum_closing_difference", {
369 steps: () =>
370 [
371 Chrome.clickBtn("Open Register"),
372 PosHr.clickLoginButton(),
373 SelectionPopup.has("Mitchell Admin", { run: "click" }),
374 ProductScreen.enterOpeningAmount("10"),
375 Chrome.clickBtn("Open Register"),
376
377 PosHr.clickCashierName(),
378 SelectionPopup.has("Test Manager 2", { run: "click" }),
379 PosHr.enterPin("5652"),
380 Chrome.clickMenuOption("Close Register"),
381 Chrome.clickBtn("Close Register"),
382 {
383 trigger: negate(`button:contains("Proceed anyway")`),
384 },
385 Chrome.clickBtn("Ok"),
386 Chrome.clickBtn("Discard"),
387
388 PosHr.clickCashierName(),
389 SelectionPopup.has("Mitchell Admin", { run: "click" }),
390 Chrome.clickMenuOption("Close Register"),
391 Chrome.clickBtn("Close Register"),
392 Chrome.hasBtn("Proceed anyway"),
393 Chrome.clickBtn("Proceed anyway", { expectUnloadPage: true }),
394 PosHr.loginScreenIsShown(),
395 ].flat(),
396 });
397
398 registry.category("web_tour.tours").add("test_scan_employee_barcode_with_pos_hr_disabled", {
399 steps: () =>
400 [
401 // scan a barcode with 041 as prefix for cashiers
402 scan_barcode("041123"),
403 Chrome.clickBtn("Open Register"),
404 ProductScreen.isShown(),
405 ].flat(),
406 });