Skip to content

Commit

Permalink
[REF] web: remove test coverage overlap in mobile test suite
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
pparidans committed Aug 26, 2019
1 parent 0a540e0 commit 96a52da
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 182 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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()'));
Expand All @@ -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();
});

Expand Down
179 changes: 0 additions & 179 deletions addons/web/static/tests/fields/relational_fields_mobile_tests.js

This file was deleted.

1 change: 0 additions & 1 deletion addons/web/views/webclient_templates.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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"/>
Expand Down

0 comments on commit 96a52da

Please sign in to comment.