diff options
| author | Vincent Schippefilt <vsc@odoo.com> | 2019-03-06 14:02:01 +0100 |
|---|---|---|
| committer | Aaron Bohy <aab@odoo.com> | 2019-03-06 20:07:17 +0100 |
| commit | 231f9072bf775bd68d5a4fdbfbffa74fc5df0613 (patch) | |
| tree | e2f22577e6c5bfe1f9f0a1fe2100061d1fd9116e | |
| parent | a6faca318a5913039dc4f8f1b5cf59bd35786121 (diff) | |
[REF] google_drive: adapt code after jQuery update
Part of task 1896658
Co-authored-by: Aaron Bohy <aab@odoo.com>
Co-authored-by: Christophe Matthieu <chm@odoo.com>
Co-authored-by: Mathieu Duckerts-Antoine <dam@odoo.com>
Co-authored-by: David Monjoie <dmo@odoo.com>
Co-authored-by: Martin Geubelle <mge@odoo.com>
Co-authored-by: svs-odoo <svs@odoo.com>
Co-authored-by: Vincent Schippefilt <vsc@odoo.com>
| -rw-r--r-- | addons/google_drive/static/src/js/gdrive.js | 6 | ||||
| -rw-r--r-- | addons/google_drive/static/tests/gdrive_test.js | 37 |
2 files changed, 21 insertions, 22 deletions
diff --git a/addons/google_drive/static/src/js/gdrive.js b/addons/google_drive/static/src/js/gdrive.js index 5855e056161..7ed0487e84d 100644 --- a/addons/google_drive/static/src/js/gdrive.js +++ b/addons/google_drive/static/src/js/gdrive.js @@ -19,7 +19,7 @@ Sidebar.include({ if (this.options.viewType === "form") { def = this._addGoogleDocItems(this.env.model, this.env.activeIds[0]); } - return $.when(def).then(this._super.bind(this)); + return Promise.resolve(def).then(this._super.bind(this)); }, //-------------------------------------------------------------------------- @@ -30,12 +30,12 @@ Sidebar.include({ * @private * @param {string} model * @param {integer} resID - * @returns {Deferred} + * @returns {Promise} */ _addGoogleDocItems: function (model, resID) { var self = this; if (!resID) { - return $.when(); + return Promise.resolve(); } var gdoc_item = _.indexOf(_.pluck(self.items.other, 'classname'), 'oe_share_gdoc'); if (gdoc_item !== -1) { diff --git a/addons/google_drive/static/tests/gdrive_test.js b/addons/google_drive/static/tests/gdrive_test.js index 1e96911de09..158330376bd 100644 --- a/addons/google_drive/static/tests/gdrive_test.js +++ b/addons/google_drive/static/tests/gdrive_test.js @@ -15,7 +15,7 @@ var createView = testUtils.createView; var _addGoogleDocItemsOriginal = GoogleDriveSideBar.prototype._addGoogleDocItems; var _addGoogleDocItemsMocked = function (model, resID) { - return $.when(); + return Promise.resolve(); }; GoogleDriveSideBar.prototype._addGoogleDocItems = _addGoogleDocItemsMocked; @@ -67,10 +67,10 @@ QUnit.module('gdrive_integration', { }, function () { QUnit.module('Google Drive Sidebar'); - QUnit.test('rendering of the google drive attachments in Sidebar', function (assert) { + QUnit.test('rendering of the google drive attachments in Sidebar', async function (assert) { assert.expect(3); - var form = createView({ + var form = await createView({ View: FormView, model: 'partner', data: this.data, @@ -83,10 +83,10 @@ QUnit.module('gdrive_integration', { if (route === '/web/dataset/call_kw/google.drive.config/get_google_drive_config') { assert.deepEqual(args.args, ['partner', 1], 'The route to get google drive config should have been called'); - return $.when([{id: 27, name: 'Cyberdyne Systems'}]); + return Promise.resolve([{id: 27, name: 'Cyberdyne Systems'}]); } if (route === '/web/dataset/call_kw/google.drive.config/search_read'){ - return $.when([{google_drive_resource_id: "T1000", + return Promise.resolve([{google_drive_resource_id: "T1000", google_drive_client_id: "cyberdyne.org", id: 1}]); } @@ -94,7 +94,7 @@ QUnit.module('gdrive_integration', { assert.deepEqual(args.args, [27, 1, 'T1000'], 'The route to get the Google url should have been called'); // We don't return anything useful, otherwise it will open a new tab - return $.when(); + return Promise.resolve(); } return this._super.apply(this, arguments); }, @@ -106,18 +106,17 @@ QUnit.module('gdrive_integration', { 'The button to the google action should be present'); // click on gdrive sidebar item - testUtils.dom.click(form.sidebar.$('.o_dropdown_toggler_btn:contains(Action)')); - testUtils.dom.click($googleAction); + await testUtils.dom.click(form.sidebar.$('.o_dropdown_toggler_btn:contains(Action)')); + await testUtils.dom.click($googleAction); form.destroy(); }); - QUnit.test('click on the google drive attachments after switching records', function (assert) { + QUnit.test('click on the google drive attachments after switching records', async function (assert) { assert.expect(3); - var self = this; var currentID; - var form = createView({ + var form = await createView({ View: FormView, model: 'partner', data: this.data, @@ -134,10 +133,10 @@ QUnit.module('gdrive_integration', { if (route === '/web/dataset/call_kw/google.drive.config/get_google_drive_config') { assert.deepEqual(args.args, ['partner', 1], 'The route to get google drive config should have been called'); - return $.when([{id: 27, name: 'Cyberdyne Systems'}]); + return Promise.resolve([{id: 27, name: 'Cyberdyne Systems'}]); } if (route === '/web/dataset/call_kw/google.drive.config/search_read'){ - return $.when([{google_drive_resource_id: "T1000", + return Promise.resolve([{google_drive_resource_id: "T1000", google_drive_client_id: "cyberdyne.org", id: 1}]); } @@ -145,20 +144,20 @@ QUnit.module('gdrive_integration', { assert.deepEqual(args.args, [27, currentID, 'T1000'], 'The route to get the Google url should have been called'); // We don't return anything useful, otherwise it will open a new tab - return $.when(); + return Promise.resolve(); } return this._super.apply(this, arguments); }, }); currentID = 1; - testUtils.dom.click(form.sidebar.$('.o_dropdown_toggler_btn:contains(Action)')); - testUtils.dom.click(form.sidebar.$('.oe_share_gdoc')); + await testUtils.dom.click(form.sidebar.$('.o_dropdown_toggler_btn:contains(Action)')); + await testUtils.dom.click(form.sidebar.$('.oe_share_gdoc')); - testUtils.dom.click(form.pager.$('.o_pager_next')); + await testUtils.dom.click(form.pager.$('.o_pager_next')); currentID = 2; - testUtils.dom.click(form.sidebar.$('.o_dropdown_toggler_btn:contains(Action)')); - testUtils.dom.click(form.sidebar.$('.oe_share_gdoc')); + await testUtils.dom.click(form.sidebar.$('.o_dropdown_toggler_btn:contains(Action)')); + await testUtils.dom.click(form.sidebar.$('.oe_share_gdoc')); form.destroy(); }); |
