[FIX] web: add test for the fix update buttons in editable list

The test for the fix in 5adb6b62d2 can only be implemented in 12.1
because that is the version that contains the createActionManager helper

Task-1967278

closes odoo/odoo#32817

Signed-off-by: VincentSchippefilt <VincentSchippefilt@users.noreply.github.com>
This commit is contained in:
Priyanka Kakadiya
2019-05-23 11:39:48 +00:00
committed by Vincent Schippefilt
parent b016c73c89
commit 9bcc0498c0
2 changed files with 45 additions and 2 deletions
@@ -376,8 +376,9 @@ var ListController = BasicController.extend({
* @returns {Deferred}
*/
_update: function () {
this._toggleSidebar();
return this._super.apply(this, arguments);
return this._super.apply(this, arguments)
.then(this._toggleSidebar.bind(this))
.then(this._updateButtons.bind(this, 'readonly'));
},
/**
* This helper simply makes sure that the control panel buttons matches the
@@ -14,6 +14,7 @@ var testUtilsDom = require('web.test_utils_dom');
var widgetRegistry = require('web.widget_registry');
var Widget = require('web.Widget');
var createActionManager = testUtils.createActionManager;
var createView = testUtils.createView;
QUnit.module('Views', {
@@ -840,6 +841,47 @@ QUnit.module('Views', {
list.destroy();
});
QUnit.test('editable list view: check that controlpanel buttons are updating when groupby applied', function (assert) {
assert.expect(4);
this.data.foo.fields.foo = {string: "Foo", type: "char", required:true};
var actionManager = createActionManager({
actions: [{
id: 11,
name: 'Partners Action 11',
res_model: 'foo',
type: 'ir.actions.act_window',
views: [[3, 'list']],
search_view_id: [9, 'search'],
}],
archs: {
'foo,3,list': '<tree editable="top"><field name="display_name"/><field name="foo"/></tree>',
'foo,9,search': '<search>'+
'<filter string="candle" name="itsName" context="{\'group_by\': \'foo\'}"/>' +
'</search>',
},
data: this.data,
});
actionManager.doAction(11);
testUtils.dom.click(actionManager.$('.o_list_button_add'));
assert.isNotVisible(actionManager.$('.o_list_button_add'),
"create button should be invisible");
assert.isVisible(actionManager.$('.o_list_button_save'), "save button should be visible");
testUtils.dom.click(actionManager.$('.o_dropdown_toggler_btn:contains("Group By")'));
testUtils.dom.click(actionManager.$('.o_group_by_menu .o_menu_item a:contains("candle")'));
assert.isVisible(actionManager.$('.o_list_button_add'), "create button should be invisible");
assert.isNotVisible(actionManager.$('.o_list_button_save'),
"save button should be invisible after applying groupby");
actionManager.destroy();
});
QUnit.test('selection changes are triggered correctly', function (assert) {
assert.expect(8);