summaryrefslogtreecommitdiff
path: root/addons/pos_restaurant/static/tests/tours/helpers/SplitBillScreenTourMethods.js
blob: 7f58a1fc083d86e0d0a036607a21c44dbbebaa93 (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
odoo.define('pos_restaurant.tour.SplitBillScreenTourMethods', function (require) {
    'use strict';

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

    class Do {
        clickOrderline(name, totalQuantity) {
            let trigger = `li.orderline .product-name:contains("${name}")`;
            if (totalQuantity) {
                trigger += ` ~ .info-list .info:contains("${totalQuantity}")`;
            }
            return [
                {
                    content: `click '${name}' orderline with total quantity of '${totalQuantity}'`,
                    trigger,
                },
            ];
        }
        clickBack() {
            return [
                {
                    content: 'click back button',
                    trigger: `.splitbill-screen .button.back`,
                },
            ];
        }
        clickPay() {
            return [
                {
                    content: 'click pay button',
                    trigger: `.splitbill-screen .pay-button .button`
                }
            ]
        }
    }

    class Check {
        orderlineHas(name, totalQuantity, splitQuantity) {
            return [
                {
                    content: `'${name}' orderline has total quantity of '${totalQuantity}'`,
                    trigger: `li.orderline .product-name:contains("${name}") ~ .info-list .info:contains("${totalQuantity}")`,
                    run: () => {},
                },
                {
                    content: `'${name}' orderline has '${splitQuantity}' quantity to split`,
                    trigger: `li.orderline .product-name:contains("${name}") ~ .info-list .info em:contains("${splitQuantity}")`,
                    run: () => {},
                },
            ];
        }
        subtotalIs(amount) {
            return [
                {
                    content: `total amount of split is '${amount}'`,
                    trigger: `.splitbill-screen .order-info .subtotal:contains("${amount}")`,
                },
            ];
        }
    }

    class Execute {}

    return createTourMethods('SplitBillScreen', Do, Check, Execute);
});