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
|
odoo.define('point_of_sale.tour.NumberPopupTourMethods', function (require) {
'use strict';
const { createTourMethods } = require('point_of_sale.tour.utils');
class Do {
/**
* 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 input keys
*/
pressNumpad(keys) {
const numberChars = '0 1 2 3 4 5 6 7 8 9 C'.split(' ');
const modeButtons = '+1 +10 +2 +20 +5 +50'.split(' ');
const decimalSeparators = ', .'.split(' ');
function generateStep(key) {
let trigger;
if (numberChars.includes(key)) {
trigger = `.popup-numpad .number-char:contains("${key}")`;
} else if (modeButtons.includes(key)) {
trigger = `.popup-numpad .mode-button:contains("${key}")`;
} else if (key === 'Backspace') {
trigger = `.popup-numpad .numpad-backspace`;
} else if (decimalSeparators.includes(key)) {
trigger = `.popup-numpad .number-char.dot`;
}
return {
content: `'${key}' pressed in numpad`,
trigger,
};
}
return keys.split(' ').map(generateStep);
}
clickConfirm() {
return [
{
content: 'click confirm button',
trigger: '.popup-number .footer .confirm',
},
];
}
}
class Check {
isShown() {
return [
{
content: 'number popup is shown',
trigger: '.modal-dialog .popup-number',
run: () => {},
},
];
}
inputShownIs(val) {
return [
{
content: 'number input element check',
trigger: '.modal-dialog .popup-number .popup-input',
run: () => {},
},
{
content: `input shown is '${val}'`,
trigger: `.modal-dialog .popup-number .popup-input:contains("${val}")`,
run: () => {},
},
];
}
}
return createTourMethods('NumberPopup', Do, Check);
});
|