diff options
| author | Francois Volral <fvo@odoo.com> | 2018-07-09 14:58:05 +0200 |
|---|---|---|
| committer | Francois Volral <fvo@odoo.com> | 2018-08-10 17:21:17 +0200 |
| commit | 3d2ca8104e46721b5db319a2aeb0ee971cb009d7 (patch) | |
| tree | 4821f6c432449f84267374b925fe9be06efa7119 /addons/web/static/tests/views/graph_tests.js | |
| parent | 4a40db209706a5adae879a2b4349f873b336ccb9 (diff) | |
[IMP] web: Handle date interval in graph charts
This commit only applies for chart grouped on date or datetime fields.
In that case:
- Line Charts : fill missing groups and doesn't display undefined values.
- Bar Charts : doesn't fill missing groups but display undefined values.
- Pie Charts : doesn't fill missing groups but display undefined values.
This commit is part of task #1835644
Diffstat (limited to 'addons/web/static/tests/views/graph_tests.js')
| -rw-r--r-- | addons/web/static/tests/views/graph_tests.js | 43 |
1 files changed, 38 insertions, 5 deletions
diff --git a/addons/web/static/tests/views/graph_tests.js b/addons/web/static/tests/views/graph_tests.js index 1ed9e799a4a..3dbb298e23c 100644 --- a/addons/web/static/tests/views/graph_tests.js +++ b/addons/web/static/tests/views/graph_tests.js @@ -16,13 +16,14 @@ QUnit.module('Views', { bar: {string: "bar", type: "boolean"}, product_id: {string: "Product", type: "many2one", relation: 'product', store: true}, color_id: {string: "Color", type: "many2one", relation: 'color'}, + date: {string: "Date", type: 'date'}, }, records: [ - {id: 1, foo: 3, bar: true, product_id: 37}, - {id: 2, foo: 53, bar: true, product_id: 37, color_id: 7}, - {id: 3, foo: 2, bar: true, product_id: 37}, - {id: 4, foo: 24, bar: false, product_id: 37}, - {id: 5, foo: 4, bar: false, product_id: 41}, + {id: 1, foo: 3, bar: true, product_id: 37, date: "2016-01-01"}, + {id: 2, foo: 53, bar: true, product_id: 37, color_id: 7, date: "2016-01-03"}, + {id: 3, foo: 2, bar: true, product_id: 37, date: "2016-03-04"}, + {id: 4, foo: 24, bar: false, product_id: 37, date: "2016-03-07"}, + {id: 5, foo: 4, bar: false, product_id: 41, date: "2016-05-01"}, {id: 6, foo: 63, bar: false, product_id: 41}, {id: 7, foo: 42, bar: false, product_id: 41}, ] @@ -309,6 +310,9 @@ QUnit.module('Views', { QUnit.test('correctly uses graph_ keys from the context', function (assert) { var done = assert.async(); assert.expect(6); + + var lastOne = _.last(this.data.foo.records); + lastOne.color_id = 14; var graph = createView({ View: GraphView, @@ -350,6 +354,9 @@ QUnit.module('Views', { var done = assert.async(); assert.expect(2); + var lastOne = _.last(this.data.foo.records); + lastOne.color_id = 14; + var graph = createView({ View: GraphView, model: 'foo', @@ -377,6 +384,9 @@ QUnit.module('Views', { 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", @@ -643,6 +653,29 @@ QUnit.module('Views', { "Bouh should be the first measure"); assert.strictEqual(graph.$buttons.find('.o_graph_measures_list .dropdown-item:last').data('field'), '__count__', "Count should be the last measure"); + + graph.destroy(); + }); + + QUnit.test('Undefined should appear in bar, pie graph but not in line graph', function (assert) { + assert.expect(4); + + var graph = createView({ + View: GraphView, + model: "foo", + groupBy:['date'], + data: this.data, + arch: '<graph string="Partners" type="line">' + + '<field name="bar"/>' + + '</graph>', + }); + + assert.strictEqual(graph.$("svg.nvd3-svg:contains('Undefined')").length, 0); + assert.strictEqual(graph.$("svg.nvd3-svg:contains('January')").length, 1); + + graph.$buttons.find('.o_graph_button[data-mode=bar]').click(); + assert.strictEqual(graph.$("svg.nvd3-svg:contains('Undefined')").length, 1); + assert.strictEqual(graph.$("svg.nvd3-svg:contains('January')").length, 1); graph.destroy(); }); |
