summaryrefslogtreecommitdiff
path: root/addons/web/static/tests/fields/relational_fields_mobile_tests.js
blob: cf46aa2c1ccc2b8240db25a040cf32cfa22f8f5b (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
odoo.define("web.relational_fields_mobile_tests", function (require) {
"use strict";

const FormView = require("web.FormView");
const testUtils = require("web.test_utils");

QUnit.module("fields", {}, function () {
    QUnit.module("relational_fields", {
        beforeEach() {
            this.data = {
                partner: {
                    fields: {
                        display_name: { string: "Displayed name", type: "char" },
                        p: {string: "one2many field", type: "one2many", relation: "partner", relation_field: "trululu"},
                        trululu: {string: "Trululu", type: "many2one", relation: "partner"},
                    },
                    records: [{
                        id: 1,
                        display_name: "first record",
                        p: [2, 4],
                        trululu: 4,
                    }, {
                        id: 2,
                        display_name: "second record",
                        p: [],
                        trululu: 1,
                    }, {
                        id: 4,
                        display_name: "aaa",
                    }],
                },
            };
        },
    }, function () {
        QUnit.module("FieldOne2Many");

        QUnit.test("one2many on mobile: display list if present without kanban view", async function (assert) {
            assert.expect(2);

            const form = await testUtils.createView({
                View: FormView,
                model: "partner",
                data: this.data,
                arch: `
                    <form>
                        <field name="p">
                            <tree>
                                <field name="display_name"/>
                            </tree>
                        </field>
                    </form>
                `,
                res_id: 1,
            });

            await testUtils.form.clickEdit(form);
            assert.containsOnce(form, ".o_field_x2many_list",
                "should display one2many's list");
            assert.containsN(form, ".o_field_x2many_list .o_data_row", 2,
                "should display 2 records in one2many's list");

            form.destroy();
        });
    });
});
});