Skip to content
Permalink
Browse files

[IMP]web: Improve tests after rebase

  • Loading branch information...
msh-odoo committed Mar 20, 2019
1 parent fff19ca commit dd983856caa73cc88979dcea7579a6df703f92ce
@@ -1130,7 +1130,6 @@ var BasicModel = AbstractModel.extend({
*
*/
setOptionalColumns: function (list_id, fieldName, enable) {
debugger;
var list = this.localData[list_id];
if (list.type === 'record') {
return;
@@ -57,7 +57,6 @@ var ListRenderer = BasicRenderer.extend({
// This attribute lets us know if there is a handle widget on a field,
// and on which field it is set.
this.handleField = null;
debugger;
this.optionalColumnsEnabled = this.state.optionalColumnsEnabled || [];
this._processColumns(params.columnInvisibleFields || {});
this.rowDecorations = _.chain(this.arch.attrs)
@@ -2789,11 +2789,11 @@ QUnit.module('relational_fields', {
form.destroy();
});

QUnit.test('one2many field in edit mode with optional fields and tash icon', function (assert) {
QUnit.test('one2many field in edit mode with optional fields and tash icon', async function (assert) {
assert.expect(8);

this.data.partner.records[0].p = [2];
var form = createView({
var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -2811,7 +2811,7 @@ QUnit.module('relational_fields', {
// should have 2 columns 1 for foo and 1 for optional dropdown
assert.containsN(form.$('.o_field_one2many'), 'th', 2,
"should be 2 th in the one2many in readonly mode");
testUtils.form.clickEdit(form);
await testUtils.form.clickEdit(form);
// should have 2 columns 1 for foo and 1 for trash icon, dropdown is displayed
// on trash icon cell, no separate cell created for trash icon and optional field dropdown
assert.containsN(form.$('.o_field_one2many'), 'th', 2,
@@ -2824,16 +2824,16 @@ QUnit.module('relational_fields', {
testUtils.dom.click(form.$('.o_field_one2many th.o_add_column > a.dropdown-toggle'));
assert.containsN(form.$('.o_field_one2many'), 'div.o_add_column_dropdown > div.dropdown-item', 1,
"dropdown have 1 optional field");
testUtils.dom.click(form.$('div.o_add_column_dropdown > div.dropdown-item:first input'));
await testUtils.dom.click(form.$('div.o_add_column_dropdown > div.dropdown-item:first input'));
assert.containsN(form.$('.o_field_one2many'), 'th', 3,
"should be 3 th in the one2many after enabling bar column from optional dropdown");

testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
await testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
var $selectedRow = form.$('.o_field_one2many tr.o_selected_row');
assert.strictEqual($selectedRow.length, 1, "should have selected row i.e. edition mode");

testUtils.dom.click(form.$('.o_field_one2many th.o_add_column > a.dropdown-toggle'));
testUtils.dom.click(form.$('div.o_add_column_dropdown > div.dropdown-item:first input'));
await testUtils.dom.click(form.$('div.o_add_column_dropdown > div.dropdown-item:first input'));
$selectedRow = form.$('.o_field_one2many tr.o_selected_row');
assert.strictEqual($selectedRow.length, 0,
"current edition mode discarded when selecting optional field");
@@ -4161,10 +4161,10 @@ QUnit.module('Views', {
delete widgetRegistry.map.asyncWidget;
});

QUnit.test('list view with optional fields rendering', function (assert) {
QUnit.test('list view with optional fields rendering', async function (assert) {
assert.expect(9);

var list = createView({
var list = await createView({
View: ListView,
model: 'foo',
data: this.data,
@@ -4190,7 +4190,7 @@ QUnit.module('Views', {
"dropdown have 2 optional fields");

// enable optional field
testUtils.dom.click(list.$('div.o_add_column_dropdown > div.dropdown-item:first input'));
await testUtils.dom.click(list.$('div.o_add_column_dropdown > div.dropdown-item:first input'));
// 6 th (1 for checkbox, 4 for columns, 1 for optional field dropdown)
assert.containsN(list, 'th', 6, "should have 6 th");
assert.ok(list.$('th:contains(M2O field):not(.o_add_column)').is(':visible'),
@@ -4202,7 +4202,7 @@ QUnit.module('Views', {
list.$('th.o_add_column .dropdown-item [name="m2o"]')[0],
"m2o optional field check box should be checked in dropdown");

testUtils.dom.click(list.$('div.o_add_column_dropdown > div.dropdown-item input:checked'));
await testUtils.dom.click(list.$('div.o_add_column_dropdown > div.dropdown-item input:checked'));
// 5 th (1 for checkbox, 3 for columns, 1 for optional field dropdown)
assert.containsN(list, 'th', 5, "should have 5 th");
assert.notOk(list.$('th:contains(M2O field):not(.o_add_column)').is(':visible'),
@@ -4214,10 +4214,10 @@ QUnit.module('Views', {
list.destroy();
});

QUnit.test('optional fields not disappear even after listview re-rendering(reload)', function (assert) {
QUnit.test('optional fields not disappear even after listview re-rendering(reload)', async function (assert) {
assert.expect(6);

var list = createView({
var list = await createView({
View: ListView,
model: 'foo',
data: this.data,
@@ -4236,21 +4236,21 @@ QUnit.module('Views', {

// enable optional field
testUtils.dom.click(list.$('th.o_add_column > a.dropdown-toggle'));
testUtils.dom.click(list.$('div.o_add_column_dropdown > div.dropdown-item:first input'));
await testUtils.dom.click(list.$('div.o_add_column_dropdown > div.dropdown-item:first input'));
assert.containsN(list, 'th', 6,
"should have 6 th 1 for selector, 4 for columns and 1 for optional field dropdown");
assert.ok(list.$('th:contains(M2O field):not(.o_add_column)').is(':visible'),
"should have a visible m2o field"); //m2o field

// reload listview
list.reload();
await list.reload();
assert.containsN(list, 'th', 6,
"should have 6 th 1 for selector, 4 for columns and 1 for optional field dropdown even after listview reload");
assert.ok(list.$('th:contains(M2O field):not(.o_add_column)').is(':visible'),
"should have a visible m2o field event after listview reload");
"should have a visible m2o field even after listview reload");

testUtils.dom.click(list.$('th.o_add_column > a.dropdown-toggle'));
assert.notOk(list.$('th.o_add_column .dropdown-item [name="m2o"]').is(":checked"));
assert.ok(list.$('th.o_add_column .dropdown-item [name="m2o"]').is(":checked"));

list.destroy();
});

0 comments on commit dd98385

Please sign in to comment.
You can’t perform that action at this time.