summaryrefslogtreecommitdiff
path: root/addons/web/static/tests/views/graph_tests.js
diff options
context:
space:
mode:
Diffstat (limited to 'addons/web/static/tests/views/graph_tests.js')
-rw-r--r--addons/web/static/tests/views/graph_tests.js46
1 files changed, 46 insertions, 0 deletions
diff --git a/addons/web/static/tests/views/graph_tests.js b/addons/web/static/tests/views/graph_tests.js
index c7d69b194ff..07f7d060347 100644
--- a/addons/web/static/tests/views/graph_tests.js
+++ b/addons/web/static/tests/views/graph_tests.js
@@ -372,6 +372,52 @@ QUnit.module('Views', {
});
});
+ QUnit.test('correctly uses graph_ keys from the context (at reload)', function (assert) {
+ var done = assert.async();
+ assert.expect(8);
+
+ 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.ok(graph.$buttons.find('button[data-mode="bar"]').hasClass('active'),
+ 'bar chart button should be active');
+
+ var reloadParams = {
+ context: {
+ graph_measure: 'foo',
+ graph_mode: 'line',
+ graph_groupbys: ['color_id'],
+ },
+ };
+ graph.reload(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.notOk(graph.$buttons.find('button[data-mode="bar"]').hasClass('active'),
+ 'bar chart button should not be active');
+ assert.ok(graph.$buttons.find('button[data-mode="line"]').hasClass('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();
+ });
+ });
+
QUnit.test('reload graph with correct fields', function (assert) {
assert.expect(2);