Debian Codegraph @

addons/website_event_sale/static/tests/tours/helpers/WebsiteEventSaleTourMethods.js

raw
1 import * as wsTourUtils from '@website_sale/js/tours/tour_utils';
2
3 const closeModal = {
4 content: "Close the ticket picking modal",
5 trigger: `.modal.modal_shown .modal-content button:contains("Close")`,
6 run: "click",
7 };
8
9 export function changePricelist(pricelistName) {
10 return [
11 {
12 content: "Go to page Shop",
13 trigger: '.nav-link:contains("Shop")',
14 run: "click",
15 expectUnloadPage: true,
16 },
17 {
18 content: "Toggle Pricelist",
19 trigger: '.o_pricelist_dropdown > .dropdown-toggle',
20 run: 'click',
21 },
22 {
23 content: `Activate Pricelist ${pricelistName}`,
24 trigger: `.dropdown-item:contains(${pricelistName})`,
25 run: 'click',
26 expectUnloadPage: true,
27 },
28 {
29 content: 'Wait for pricelist to load',
30 trigger: `.dropdown-toggle:contains(${pricelistName})`,
31 },
32 ];
33 }
34 function checkPriceEvent(eventName, price, close = true) {
35 const steps = [
36 {
37 content: "Go to page Event",
38 trigger: '.nav-link:contains("Event")',
39 run: "click",
40 expectUnloadPage: true,
41 },
42 {
43 content: "Open the Pycon event",
44 trigger: `.o_wevent_events_list a:contains(${eventName})`,
45 run: "click",
46 expectUnloadPage: true,
47 },
48 {
49 content: "Open the ticket picking modal",
50 trigger: `button:contains("Register")`,
51 run: "click",
52 },
53 {
54 content: "Verify Price",
55 trigger: `.oe_currency_value:contains(${price})`,
56 },
57 ];
58 if (close) {
59 steps.push(closeModal);
60 }
61 return steps;
62 }
63 function checkPriceDiscountEvent(eventName, price, discount) {
64 return [
65 ...checkPriceEvent(eventName, price, false),
66 {
67 content: "Verify Price before discount",
68 trigger: `del:contains(${discount})`,
69 },
70 closeModal,
71 ];
72 }
73 export function checkPriceCart(price) {
74 return [
75 wsTourUtils.goToCart(),
76 ...wsTourUtils.assertCartAmounts({total: price}),
77 ]
78 }
79 export const getPriceListChecksSteps = function ({pricelistName, eventName, price, priceBeforeDiscount=false}) {
80 const checkPriceSteps = priceBeforeDiscount ? checkPriceDiscountEvent(eventName, price, priceBeforeDiscount) : checkPriceEvent(eventName, price);
81 return [
82 ...changePricelist(pricelistName),
83 ...checkPriceSteps,
84 ...checkPriceCart(price),
85 ]
86 }
87 export default { getPriceListChecksSteps, changePricelist, checkPriceCart }