nnnjjj123
2020-11-17 1b2c1edb61190eeb19f465ff031eaa3b2a1b8dbc
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
define([
    'intern!tdd',
    'intern/chai!assert',
    'intern/dojo/node!leadfoot/helpers/pollUntil',
    'require'
], function (test, assert, pollUntil, require) {
    // dgrid.css defines a 300ms transition duration for .dgrid-tree-container
    // Add 20% for good measure
    var TRANSITION_DELAY = 360;
 
    function createExpandTest(clickTarget, clickMethod) {
        return function () {
            var xOffset = 0;
            // Nudge the y-offset of the cursor down a bit for good measure (default seems to be 0,0 in the target
            // element; in Firefox the click has been known to hit just above the target element)
            var remote = this.remote;
 
            if (remote.environmentType.browserName === 'safari') {
                console.warn('Warning: skipping a tree functional test because ' +
                    'the safari web driver does not support mouseMoveTo.');
                return;
            }
 
            // With the cell selector used in the double-click test the cursor will be positioned at the start of the
            // cell, right over the expando
            // Move the cursor a bit to the right so it's not on the expando
            if (clickMethod === 'doubleClick') {
                xOffset = 30;
            }
 
            // Turn off whitespace check because it doesn't like [clickMethod]() on its own line
            /* jshint white: false */
            return remote.findByCssSelector('#treeGrid-row-AF ' + clickTarget)
                .moveMouseTo(xOffset, 8)
                [clickMethod]()
                .sleep(TRANSITION_DELAY)
                .end()
                .findByCssSelector('#treeGrid-row-SD')
                .isDisplayed()
                .then(function (isDisplayed) {
                    assert.ok(isDisplayed, 'Expanded rows should be visible');
                })
                .end()
                .findByCssSelector('#treeGrid-row-AF ' + clickTarget)
                .moveMouseTo(xOffset, 8)
                [clickMethod]()
                .sleep(TRANSITION_DELAY)
                .end()
                .findByCssSelector('#treeGrid-row-SD')
                .isDisplayed()
                .then(function (isDisplayed) {
                    assert.ok(!isDisplayed, 'Collapsed rows should not be visible');
                })
                .end();
        };
    }
 
    test.suite('dgrid/tree functional tests', function () {
 
        test.before(function () {
            var remote = this.remote;
 
            return remote.get(require.toUrl('./Tree.html'))
                .then(pollUntil(function () {
                    return window.ready;
                }, null, 5000));
        });
 
        test.test('expand/collapse: click on expando node', createExpandTest('.dgrid-expando-icon', 'click'));
        test.test('expand/collapse: double-click on cell node', createExpandTest('.dgrid-column-0', 'doubleClick'));
    });
 
    test.suite('dgrid/Tree functional tests with CompoundColumns', function () {
 
        test.before(function () {
            var remote = this.remote;
 
            return remote.get(require.toUrl('./TreeCompound.html'))
                .then(pollUntil(function () {
                    return window.ready;
                }, null, 5000));
        });
 
        test.test('expand/collapse: click on expando node', createExpandTest('.dgrid-expando-icon', 'click'));
        test.test('expand/collapse: double-click on cell node', createExpandTest('.dgrid-column-set-0', 'doubleClick'));
    });
 
    test.suite('dgrid/Tree functional tests with CompoundColumns after column reset', function () {
 
        test.before(function () {
            var remote = this.remote;
 
            return remote.get(require.toUrl('./TreeCompound.html'))
                .then(pollUntil(function () {
                    return window.ready;
                }, null, 5000))
                .then(function () {
                    return remote.execute(function () {
                        /* global treeGrid */
                        treeGrid.set('columns', treeGrid.get('columns'));
                    });
                });
        });
 
        test.test('expand/collapse: click on expando node', createExpandTest('.dgrid-expando-icon', 'click'));
        test.test('expand/collapse: double-click on cell node', createExpandTest('.dgrid-column-set-0', 'doubleClick'));
    });
});