[REF] web: remove test coverage overlap in mobile test suite

The tests in the file `relational_fields_mobile_tests.js` - which is
part of the mobile test suite - are actually not specific to mobile.

This commit merges those tests asserts into the tests already present in
the regular test suite. It ensures that all the existing asserts remains
and the actual coverage stays the same.
This commit is contained in:
Pierre Paridans
2019-08-26 14:13:06 +00:00
parent 0a540e0ef2
commit 96a52daa80
4 changed files with 23 additions and 182 deletions
@@ -116,7 +116,7 @@ QUnit.module('fields', {}, function () {
QUnit.module('FieldMany2Many');
QUnit.test('many2many kanban: edition', async function (assert) {
assert.expect(32);
assert.expect(33);
this.data.partner.records[0].timmy = [12, 14];
this.data.partner_type.records.push({ id: 15, display_name: "red", color: 6 });
@@ -250,6 +250,7 @@ QUnit.module('fields', {}, function () {
assert.strictEqual($('.modal .modal-footer .o_btn_remove').length, 1,
'There should be a modal having Remove Button');
await testUtils.dom.click($('.modal .modal-footer .o_btn_remove'));
assert.containsNone($('.o_modal'), "modal should have been closed");
assert.strictEqual(form.$('.o_kanban_record:not(.o_kanban_ghost)').length, 5,
'should contain 5 records');
assert.ok(!form.$('.o_kanban_record:contains(silver)').length,
@@ -2255,7 +2255,7 @@ QUnit.module('fields', {}, function () {
});
QUnit.test('one2many kanban: edition', async function (assert) {
assert.expect(17);
assert.expect(23);
this.data.partner.records[0].p = [2];
var form = await createView({
@@ -2286,6 +2286,22 @@ QUnit.module('fields', {}, function () {
'</field>' +
'</form>',
res_id: 1,
mockRPC: function (route, args) {
if (route === '/web/dataset/call_kw/partner/write') {
var commands = args.args[1].p;
assert.strictEqual(commands.length, 2,
'should have generated two commands');
assert.strictEqual(commands[0][0], 0,
'generated command should be ADD WITH VALUES');
assert.strictEqual(commands[0][2].display_name, "new subrecord 3",
'value of newly created subrecord should be "new subrecord 3"');
assert.strictEqual(commands[1][0], 2,
'generated command should be REMOVE AND DELETE');
assert.strictEqual(commands[1][1], 2,
'deleted record id should be 2');
}
return this._super.apply(this, arguments);
},
});
assert.ok(!form.$('.o_kanban_view .delete_icon').length,
@@ -2341,6 +2357,7 @@ QUnit.module('fields', {}, function () {
assert.strictEqual($('.modal .modal-footer .o_btn_remove').length, 1,
'There should be a modal having Remove Button');
await testUtils.dom.click($('.modal .modal-footer .o_btn_remove'));
assert.containsNone($('.o_modal'), "modal should have been closed");
assert.strictEqual(form.$('.o_kanban_record:not(.o_kanban_ghost)').length, 3,
'should contain 3 records');
await testUtils.dom.click(form.$('.o_kanban_view .delete_icon:first()'));
@@ -2349,6 +2366,9 @@ QUnit.module('fields', {}, function () {
'should contain 1 records');
assert.strictEqual(form.$('.o_kanban_record span:first').text(), 'new subrecord 3',
'the remaining subrecord should be "new subrecord 3"');
// save and check that the correct command has been generated
await testUtils.form.clickSave(form);
form.destroy();
});
@@ -1,179 +0,0 @@
odoo.define('web.relational_fields_tests', function (require) {
"use strict";
var FormView = require('web.FormView');
var testUtils = require('web.test_utils');
var createView = testUtils.createView;
QUnit.module('fields', {}, function () {
QUnit.module('relational_fields', {
beforeEach: function () {
this.data = {
partner: {
fields: {
display_name: { string: "Displayed name", type: "char" },
foo: {string: "Foo", type: "char", default: "My little Foo Value"},
bar: {string: "Bar", type: "boolean", default: true},
int_field: {string: "int_field", type: "integer", sortable: true},
qux: {string: "Qux", type: "float", digits: [16,1] },
p: {string: "one2many field", type: "one2many", relation: 'partner', relation_field: 'trululu'},
trululu: {string: "Trululu", type: "many2one", relation: 'partner'},
partner_ids: {string: "many2many field", type: "many2many", relation: 'partner'},
},
records: [{
id: 1,
display_name: "first record",
bar: true,
foo: "yop",
int_field: 10,
qux: 0.44,
p: [],
trululu: 4,
}, {
id: 2,
display_name: "second record",
bar: true,
foo: "blip",
int_field: 9,
qux: 13,
p: [],
trululu: 1,
}, {
id: 4,
display_name: "aaa",
bar: false,
}],
onchanges: {},
},
};
}
}, function () {
QUnit.module('FieldOne2Many');
QUnit.test('one2many kanban: deletion in mobile', async function (assert) {
assert.expect(9);
this.data.partner.records[0].p = [1, 2];
var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
arch: '<form string="Partners">' +
'<field name="p">' +
'<kanban>' +
'<templates>' +
'<t t-name="kanban-box">' +
'<div class="oe_kanban_global_click">' +
'<field name="display_name"/>' +
'</div>' +
'</t>' +
'</templates>' +
'</kanban>' +
'<form string="Partners">' +
'<field name="display_name"/>' +
'</form>' +
'</field>' +
'</form>',
res_id: 1,
mockRPC: function (route, args) {
if (route === '/web/dataset/call_kw/partner/write') {
var commands = args.args[1].p;
assert.strictEqual(commands.length, 2,
'should have generated two commands');
assert.ok(commands[0][0] === 4 && commands[0][1] === 2,
'should have generated the command 2 (DELETE) with id 1');
assert.ok(commands[1][0] === 2 && commands[1][1] === 1,
'should have generated the command 2 (DELETE) with id 2');
}
return this._super.apply(this, arguments);
},
});
assert.containsNone(form, '.o_field_one2many .o-kanban-button-new',
'"Create" button should not be visible in readonly');
await testUtils.form.clickEdit(form);
assert.containsOnce(form, '.o_field_one2many .o-kanban-button-new',
'"Create" button should be visible in edit');
assert.strictEqual(form.$('.o_kanban_record:not(.o_kanban_ghost)').length, 2,
"should have 2 records");
// open and delete record
await testUtils.dom.click(form.$('.oe_kanban_global_click').first());
assert.strictEqual($('.modal .modal-footer .o_btn_remove').length, 1,
'there should be a Remove button in the modal footer');
await testUtils.dom.click($('.modal .modal-footer .o_btn_remove'));
assert.strictEqual($('.o_modal').length, 0, "there shoul be no more modal");
assert.strictEqual(form.$('.o_kanban_record:not(.o_kanban_ghost)').length, 1,
'should contain 1 records');
// save and check that the correct command has been generated
await testUtils.form.clickSave(form);
form.destroy();
});
QUnit.module('FieldMany2Many');
QUnit.test('many2many kanban: deletion in mobile', async function (assert) {
assert.expect(8);
this.data.partner.records[0].partner_ids = [2, 4];
var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
arch: '<form string="Partners">' +
'<field name="display_name"/>' +
'<field name="partner_ids">' +
'<kanban>' +
'<field name="display_name"/>' +
'<templates>' +
'<t t-name="kanban-box">' +
'<div class="oe_kanban_global_click">' +
'<span><t t-esc="record.display_name.value"/></span>' +
'</div>' +
'</t>' +
'</templates>' +
'</kanban>' +
'<form string="Partners">' +
'<field name="display_name"/>' +
'</form>' +
'</field>' +
'</form>',
res_id: 1,
mockRPC: function (route, args) {
if (route === '/web/dataset/call_kw/partner/write') {
var commands = args.args[1].partner_ids;
assert.strictEqual(commands.length, 1,
'should have generated one commands');
assert.deepEqual(commands[0], [6, false, [4]] ,
'should properly write ids');
}
return this._super.apply(this, arguments);
},
});
assert.containsNone(form.$('.o_field_many2many .o-kanban-button-new'),
'"Add" button should not be visible in readonly');
await testUtils.form.clickEdit(form);
assert.containsOnce(form, '.o_field_many2many .o-kanban-button-new',
'"Add" button should be visible in edit');
assert.containsN(form, '.o_kanban_record:not(.o_kanban_ghost)', 2,
"should have 2 records");
// open and delete record
await testUtils.dom.click(form.$('.oe_kanban_global_click').first());
assert.strictEqual($('.modal .modal-footer .o_btn_remove').length, 1,
'there should be a modal having "Remove" Button');
await testUtils.dom.click($('.modal .modal-footer .o_btn_remove'));
assert.containsNone($('.o_modal'), "modal should have been closed");
assert.containsOnce(form, '.o_kanban_record:not(.o_kanban_ghost)',
'should contain 1 records');
// save and check that the correct command has been generated
await testUtils.form.clickSave(form);
form.destroy();
});
});
});
});
-1
View File
@@ -753,7 +753,6 @@
<script type="text/javascript" src="/web/static/tests/views/kanban_mobile_tests.js"></script>
<script type="text/javascript" src="/web/static/tests/views/mobile_control_panel_tests.js"></script>
<script type="text/javascript" src="/web/static/tests/fields/basic_fields_mobile_tests.js"></script>
<script type="text/javascript" src="/web/static/tests/fields/relational_fields_mobile_tests.js"></script>
</t>
<div id="qunit"/>