[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>
This commit is contained in:
committed by
Aaron Bohy
co-authored by
Aaron Bohy
Christophe Matthieu
Mathieu Duckerts-Antoine
David Monjoie
Martin Geubelle
svs-odoo
parent
a6faca318a
commit
231f9072bf
@@ -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) {
|
||||
|
||||
@@ -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();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user