Example #1
0
        return concurrency.delay(0).then(function () {
            assert.ok(graph.$('text:contains(xphone)').length,
                        "should contain a text element with product in legend");
            assert.notOk(graph.$('text:contains(red)').length,
                        "should not contain a text element with color in legend");

            testUtils.graph.reload(graph, {groupBy: ['color_id']});

            return concurrency.delay(0);
        }).then(function () {
Example #2
0
        return concurrency.delay(0).then(function () {
            assert.containsN(graph, '.nv-groups rect', 2,
                "should display two groups");

            testUtils.graph.reload(graph, {groupBy: []});
            return concurrency.delay(0).then(function () {
                assert.containsN(graph, '.nv-groups rect', 2,
                    "should still display two groups");

                graph.destroy();
                done();
            });
        });
Example #3
0
        }).then(function () {
            assert.deepEqual(graph.getOwnedQueryParams(), {
                context: {
                    graph_mode: 'line',
                    graph_measure: 'foo',
                    graph_groupbys: ['product_id'],
                    graph_intervalMapping: {},
                },
            }, "context should be correct");

            testUtils.graph.reload(graph, {groupBy: ['product_id', 'color_id']}); // change groupbys

            return concurrency.delay(0);
        }).then(function () {
Example #4
0
        return concurrency.delay(0).then(function () {
            assert.ok(graph.$('div.o_graph_svg_container svg.nvd3-svg').length,
                        "should contain a div with a svg element");
            assert.notOk(graph.$('div.o_view_nocontent').length,
                "should not display the no content helper");
            testUtils.graph.reload(graph, {domain: [['product_id', '=', 4]]});

            assert.notOk(graph.$('div.o_graph_svg_container svg.nvd3-svg').length,
                        "should not contain a div with a svg element");
            assert.ok(graph.$('div.o_view_nocontent').length,
                "should display the no content helper");
            graph.destroy();
            done();
        });
Example #5
0
    QUnit.test('correctly uses graph_ keys from the context (at reload)', function (assert) {
        var done = assert.async();
        assert.expect(8);

        var lastOne = _.last(this.data.foo.records);
        lastOne.color_id = 14;

        var graph = createView({
            View: GraphView,
            model: "foo",
            data: this.data,
            arch: '<graph><field name="product_id"/></graph>',
        });

        assert.strictEqual(graph.renderer.state.mode, "bar", "should be in bar chart mode");
        assert.hasClass(graph.$buttons.find('button[data-mode="bar"]'),'active',
            'bar chart button should be active');

        var reloadParams = {
            context: {
                graph_measure: 'foo',
                graph_mode: 'line',
                graph_groupbys: ['color_id'],
            },
        };
        testUtils.graph.reload(graph, reloadParams);
        return concurrency.delay(0).then(function () {
            // check measure
            assert.strictEqual(graph.$('text.nv-legend-text:contains(Foo)').length, 1,
                "should now use the 'foo' measure");

            // check mode
            assert.strictEqual(graph.renderer.state.mode, "line", "should be in line chart mode");
            assert.doesNotHaveClass(graph.$buttons.find('button[data-mode="bar"]'), 'active',
                'bar chart button should not be active');
            assert.hasClass(graph.$buttons.find('button[data-mode="line"]'),'active',
                'line chart button should be active');

            // check groupbys
            assert.strictEqual(graph.$('text:contains(xphone)').length, 0,
                        "should not contain a text element with product in legend");
            assert.strictEqual(graph.$('text:contains(red)').length, 1,
                        "should contain a text element with color in legend");

            graph.destroy();
            done();
        });
    });
Example #6
0
    QUnit.test('reload graph with correct fields', function (assert) {
        assert.expect(2);

        var graph = createView({
            View: GraphView,
            model: 'foo',
            data: this.data,
            arch: '<graph>' +
                    '<field name="product_id" type="row"/>' +
                    '<field name="foo" type="measure"/>' +
                '</graph>',
            mockRPC: function (route, args) {
                if (args.method === 'read_group') {
                    assert.deepEqual(args.kwargs.fields, ['product_id', 'foo'],
                        "should read the correct fields");
                }
                return this._super.apply(this, arguments);
            },
        });

        testUtils.graph.reload(graph, {groupBy: []});

        graph.destroy();
    });