diff options
| author | Xavier Morel <xmo@odoo.com> | 2020-07-06 09:37:49 +0000 |
|---|---|---|
| committer | Xavier Morel <xmo@odoo.com> | 2020-07-09 07:23:04 +0000 |
| commit | 350ed97c4556f6c6ea1a736db0ea5a804b28ba08 (patch) | |
| tree | fa582e732f3426a1c7a2cda9cb8344e9702b5a0d /addons/web/static/tests/widgets | |
| parent | ccea563abbbae48b7b914f5b12e59b02e167d486 (diff) | |
[FIX] web: async operations should not live in init
Support for the "allow exports" group was implemented by checking the
group in init(), which is sync. Move that check over to willStart
instead.
Also add a default mock for user_has_group (makes it so it always
replies that the user doesn't have the group), and override that
specifically for the group we're interested in in the export tests, so
those tests have access to the Export action / option.
closes odoo/odoo#54254
X-original-commit: 30968ac93373990338c23f49e678d272b8e60c6b
Signed-off-by: Xavier Morel (xmo) <xmo@odoo.com>
Diffstat (limited to 'addons/web/static/tests/widgets')
| -rw-r--r-- | addons/web/static/tests/widgets/data_export_tests.js | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/addons/web/static/tests/widgets/data_export_tests.js b/addons/web/static/tests/widgets/data_export_tests.js index e7fb9864791..8890ee48c20 100644 --- a/addons/web/static/tests/widgets/data_export_tests.js +++ b/addons/web/static/tests/widgets/data_export_tests.js @@ -40,7 +40,9 @@ QUnit.module('widgets', { records: [], }, }; - + this.mockSession = { + async user_has_group(g) { return g === 'base.group_allow_export'; } + } this.mockDataExportRPCs = function (route) { if (route === '/web/export/formats') { return Promise.resolve([ @@ -100,6 +102,7 @@ QUnit.module('widgets', { }, mockRPC: this.mockDataExportRPCs, session: { + ...this.mockSession, get_file: function (params) { assert.step(params.url); params.complete(); @@ -148,6 +151,7 @@ QUnit.module('widgets', { }, mockRPC: this.mockDataExportRPCs, session: { + ...this.mockSession, get_file: function (params) { const data = JSON.parse(params.data.data); assert.deepEqual({ids: data.ids, domain: data.domain}, expectedData); @@ -207,6 +211,7 @@ QUnit.module('widgets', { viewOptions: { hasActionMenus: true, }, + session: this.mockSession, mockRPC: this.mockDataExportRPCs, }); @@ -249,6 +254,7 @@ QUnit.module('widgets', { viewOptions: { hasActionMenus: true, }, + session: this.mockSession, mockRPC: this.mockDataExportRPCs, }); @@ -283,6 +289,7 @@ QUnit.module('widgets', { model: 'partner', data: this.data, arch: `<tree export_xlsx="0"><field name="foo"/></tree>`, + session: this.mockSession, }); assert.containsNone(list, '.o_list_export_xlsx') list.destroy(); @@ -302,6 +309,7 @@ QUnit.module('widgets', { </tree>`, domain: [['bar', '!=', 'glou']], session: { + ...this.mockSession, get_file(args) { let data = JSON.parse(args.data.data); assert.strictEqual(args.url, '/web/export/xlsx', "should call get_file with the correct url"); @@ -346,6 +354,7 @@ QUnit.module('widgets', { groupBy: ['foo', 'bar'], domain: [['bar', '!=', 'glou']], session: { + ...this.mockSession, get_file(args) { let data = JSON.parse(args.data.data); assert.strictEqual(args.url, '/web/export/xlsx', "should call get_file with the correct url"); |
