summaryrefslogtreecommitdiff
path: root/addons/point_of_sale/static/tests/tours/helpers/OrderManagementScreenTourMethods.js
blob: 26e48589134cb950afcd9e1139e50eb35d8fc20f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
odoo.define('point_of_sale.tour.OrderManagementScreenTourMethods', function (require) {
    'use strict';

    const { createTourMethods } = require('point_of_sale.tour.utils');

    class Do {
        clickBack() {
            return [
                {
                    content: 'order management screen, click back button',
                    trigger: '.order-management-screen .control-panel .button.back',
                },
            ];
        }
        clickOrder(name, [otherCol, otherColVal] = [null, null]) {
            let trigger = `.order-management-screen .order-list .order-row .item.name:contains("${name}")`;
            if (otherCol) {
                trigger = `${trigger} ~ .item.${otherCol}:contains("${otherColVal}")`;
            }
            return [
                {
                    content: `clicking order '${name}' from orderlist`,
                    trigger,
                },
            ];
        }
        clickInvoiceButton() {
            return [
                {
                    content: 'click invoice button',
                    trigger: '.order-management-screen .control-button span:contains("Invoice")',
                },
            ];
        }
        clickPrintReceiptButton() {
            return [
                {
                    content: 'click reprint receipt button',
                    trigger: '.order-management-screen .control-button span:contains("Print Receipt")'
                }
            ]
        }
        clickCustomerButton() {
            return [
                {
                    content: 'click customer button',
                    trigger: '.order-management-screen .actionpad .button.set-customer',
                },
            ];
        }
        closeReceipt() {
            return [
                {
                    content: 'close receipt',
                    trigger: '.receipt-screen .button.back',
                }
            ]
        }
    }

    class Check {
        isShown() {
            return [
                {
                    content: 'order management screen is shown',
                    trigger: '.pos .pos-content .order-management-screen',
                    run: () => {},
                },
            ];
        }
        orderlistHas({ orderName, total, customer }) {
            const steps = [];
            steps.push({
                content: `order list has row having: name '${orderName}', total '${total}'`,
                trigger: `.order-list .order-row .item:contains("${orderName}") ~ .item:contains("${total}")`,
                run: () => {},
            });
            if (customer) {
                steps.push({
                    content: `order list has row having: name '${orderName}', customer '${customer}'`,
                    trigger: `.order-list .order-row .item:contains("${orderName}") ~ .item:contains("${customer}")`,
                    run: () => {},
                });
            }
            return steps;
        }
        highlightedOrderRowHas(name) {
            return [
                {
                    content: `order '${name}' in orderlist is highligted`,
                    trigger: `.order-list .order-row.highlight:has(> .item:contains("${name}"))`,
                    run: () => {},
                },
            ];
        }
        orderRowIsNotHighlighted(name) {
            return [
                {
                    content: `order '${name}' in orderlist is not highligted`,
                    trigger: `.order-list .order-row:not(:has(.highlight)):has(> .item:contains("${name}"))`,
                    run: () => {},
                },
            ];
        }
        orderDetailsHas({ lines, total }) {
            const steps = [];
            for (let { product, quantity } of lines) {
                steps.push({
                    content: `order details has product '${product}' and quantity '${quantity}'`,
                    trigger: `.orderlines .product-name:contains("${product}") ~ .info strong:contains("${quantity}")`,
                    run: () => {},
                });
            }
            if (total) {
                steps.push({
                    content: `order details has total amount of ${total}`,
                    trigger: `.order-container .summary .total .value:contains("${total}")`,
                    run: () => {},
                });
            }
            return steps;
        }
        customerIs(name) {
            return [
                {
                    content: `set customer is '${name}'`,
                    trigger: `.order-management-screen .actionpad .set-customer:contains("${name}")`,
                    run: () => {},
                },
            ];
        }
        reprintReceiptIsShown() {
            return [
                {
                    content: 'reprint receipt screen is shown',
                    trigger: '.pos .receipt-screen',
                    run: () => {},
                }
            ]
        }
        receiptChangeIs(amount) {
            return [
                {
                    content: `receipt change is ${amount}`,
                    trigger: `.pos-receipt-amount.receipt-change:contains("${amount}")`,
                    run: () => {},
                }
            ]
        }
        receiptOrderDataContains(orderInfo) {
            return [
                {
                    content: `order data contains ${orderInfo}`,
                    trigger: `.pos-receipt-order-data:contains("${orderInfo}")`,
                    run: () => {},
                }
            ]
        }
        receiptAmountIs(amount) {
            return [
                {
                    content: `receipt amount is ${amount}`,
                    trigger: `.pos-receipt-amount:contains("${amount}")`,
                    run: () => {},
                }
            ]
        }
        isNotHidden() {
            return [
                {
                    content: 'order management screen is not hidden',
                    trigger: `.order-management-screen:not(:has(.oe_hidden))`,
                    run: () => {},
                }
            ]
        }
    }

    return createTourMethods('OrderManagementScreen', Do, Check);
});