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
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
|
odoo.define('point_of_sale.tour.PaymentScreenTourMethods', function (require) {
'use strict';
const { createTourMethods } = require('point_of_sale.tour.utils');
class Do {
clickPaymentMethod(name) {
return [
{
content: `click '${name}' payment method`,
trigger: `.paymentmethods .button.paymentmethod:contains("${name}")`,
},
];
}
/**
* Delete the paymentline having the given payment method name and amount.
* @param {String} name payment method
* @param {String} amount
*/
clickPaymentlineDelButton(name, amount) {
return [
{
content: `delete ${name} paymentline with ${amount} amount`,
trigger: `.paymentlines .paymentline .payment-name:contains("${name}") ~ .delete-button`,
},
];
}
clickEmailButton() {
return [
{
content: `click email button`,
trigger: `.payment-buttons .js_email`,
},
];
}
clickTipButton() {
return [
{
trigger: `.payment-buttons .js_tip`,
},
];
}
clickInvoiceButton() {
return [{ content: 'click invoice button', trigger: '.payment-buttons .js_invoice' }];
}
clickValidate() {
return [
{
content: 'validate payment',
trigger: `.payment-screen .button.next.highlight`,
},
];
}
/**
* Press the numpad in sequence based on the given space-separated keys.
* Note: Maximum of 2 characters because NumberBuffer only allows 2 consecutive
* fast inputs. Fast inputs is the case in tours.
*
* @param {String} keys space-separated numpad keys
*/
pressNumpad(keys) {
const numberChars = '. +/- 0 1 2 3 4 5 6 7 8 9'.split(' ');
const modeButtons = '+10 +20 +50'.split(' ');
function generateStep(key) {
let trigger;
if (numberChars.includes(key)) {
trigger = `.payment-numpad .number-char:contains("${key}")`;
} else if (modeButtons.includes(key)) {
trigger = `.payment-numpad .mode-button:contains("${key}")`;
} else if (key === 'Backspace') {
trigger = `.payment-numpad .number-char img[alt="Backspace"]`;
}
return {
content: `'${key}' pressed in payment numpad`,
trigger,
};
}
return keys.split(' ').map(generateStep);
}
clickBack() {
return [
{
content: 'click back button',
trigger: '.payment-screen .button.back',
},
];
}
clickTipButton() {
return [
{
trigger: '.payment-screen .button.js_tip',
},
]
}
}
class Check {
isShown() {
return [
{
content: 'payment screen is shown',
trigger: '.pos .payment-screen',
run: () => {},
},
];
}
/**
* Check if change is the provided amount.
* @param {String} amount
*/
changeIs(amount) {
return [
{
content: `change is ${amount}`,
trigger: `.payment-status-change .amount:contains("${amount}")`,
run: () => {},
},
];
}
/**
* Check if the remaining is the provided amount.
* @param {String} amount
*/
remainingIs(amount) {
return [
{
content: `remaining amount is ${amount}`,
trigger: `.payment-status-remaining .amount:contains("${amount}")`,
run: () => {},
},
];
}
/**
* Check if validate button is highlighted.
* @param {Boolean} isHighlighted
*/
validateButtonIsHighlighted(isHighlighted = true) {
return [
{
content: `validate button is ${
isHighlighted ? 'highlighted' : 'not highligted'
}`,
trigger: isHighlighted
? `.payment-screen .button.next.highlight`
: `.payment-screen .button.next:not(:has(.highlight))`,
run: () => {},
},
];
}
/**
* Check if the paymentlines are empty. Also provide the amount to pay.
* @param {String} amountToPay
*/
emptyPaymentlines(amountToPay) {
return [
{
content: `there are no paymentlines`,
trigger: `.paymentlines-empty`,
run: () => {},
},
{
content: `amount to pay is '${amountToPay}'`,
trigger: `.paymentlines-empty .total:contains("${amountToPay}")`,
run: () => {},
},
];
}
/**
* Check if the selected paymentline has the given payment method and amount.
* @param {String} paymentMethodName
* @param {String} amount
*/
selectedPaymentlineHas(paymentMethodName, amount) {
return [
{
content: `line paid via '${paymentMethodName}' is selected`,
trigger: `.paymentlines .paymentline.selected .payment-name:contains("${paymentMethodName}")`,
run: () => {},
},
{
content: `amount tendered in the line is '${amount}'`,
trigger: `.paymentlines .paymentline.selected .payment-amount:contains("${amount}")`,
run: () => {},
},
];
}
}
class Execute {
pay(method, amount) {
const steps = [];
steps.push(...this._do.clickPaymentMethod(method));
for (let char of amount.split('')) {
steps.push(...this._do.pressNumpad(char));
}
steps.push(...this._check.validateButtonIsHighlighted());
steps.push(...this._do.clickValidate());
return steps;
}
}
return createTourMethods('PaymentScreen', Do, Check, Execute);
});
|