summaryrefslogtreecommitdiff
path: root/addons/web/static/tests/fields/basic_fields_tests.js
diff options
context:
space:
mode:
authorChristophe Simonis <chs@odoo.com>2018-09-17 18:03:41 +0200
committerChristophe Simonis <chs@odoo.com>2018-09-17 18:03:41 +0200
commit0942a57b5adcfae1e5c37f9b7f904e83b131439c (patch)
tree6344b5e103f88724ba0f855e20ba2da80b0e061f /addons/web/static/tests/fields/basic_fields_tests.js
parenta6516c35334de382e2325171def181586e6cdfac (diff)
parentf2b8caff07ba41b851ae9d5015e317753f3eb1a1 (diff)
[MERGE] forward port branch 11.0 up to f2b8caff07b
Diffstat (limited to 'addons/web/static/tests/fields/basic_fields_tests.js')
-rw-r--r--addons/web/static/tests/fields/basic_fields_tests.js39
1 files changed, 39 insertions, 0 deletions
diff --git a/addons/web/static/tests/fields/basic_fields_tests.js b/addons/web/static/tests/fields/basic_fields_tests.js
index 7ae833ece97..4ef08c02999 100644
--- a/addons/web/static/tests/fields/basic_fields_tests.js
+++ b/addons/web/static/tests/fields/basic_fields_tests.js
@@ -2005,6 +2005,45 @@ QUnit.module('basic_fields', {
assert.verifySteps(['destroy']);
});
+ QUnit.test('graph dashboard widget can be destroyed when nv is partially loaded', function (assert) {
+ // this test ensures that the JournalDashboardGraph widget doesn't crash
+ // when being destroyed before nv has been completely loaded
+ assert.expect(2);
+
+ testUtils.patch(basicFields.JournalDashboardGraph, {
+ destroy: function () {
+ assert.step('destroy');
+ // nv is fully loaded only when nvd3.js has been loaded
+ // which happens sequentially after nv.d3.js
+ // we simulate this race condition with:
+ var offWindowResize = window.nv.utils.offWindowResize;
+ window.nv.utils.offWindowResize = undefined;
+ this._super.apply(this, arguments);
+ window.nv.utils.offWindowResize = offWindowResize;
+ },
+ });
+
+ var kanban = createView({
+ View: KanbanView,
+ model: 'partner',
+ data: this.data,
+ arch: '<kanban class="o_kanban_test">' +
+ '<field name="graph_type"/>' +
+ '<templates><t t-name="kanban-box">' +
+ '<div>' +
+ '<field name="graph_data" t-att-graph_type="record.graph_type.raw_value" widget="dashboard_graph"/>' +
+ '</div>' +
+ '</t>' +
+ '</templates></kanban>',
+ domain: [['id', 'in', [1]]],
+ });
+
+ kanban.destroy();
+ testUtils.unpatch(basicFields.JournalDashboardGraph);
+
+ assert.verifySteps(['destroy']);
+ });
+
QUnit.module('AceEditor');
QUnit.test('ace widget on text fields works', function (assert) {