diff options
| author | Aaron Bohy <aab@odoo.com> | 2018-11-13 12:34:57 +0000 |
|---|---|---|
| committer | Aaron Bohy <aab@odoo.com> | 2018-11-13 19:56:55 +0000 |
| commit | 4df0a1e31a6309404ea4cfcfc3076dbd44282ceb (patch) | |
| tree | 50bcbb6194ac13b5ff46d8f89b30b6c69af30e74 | |
| parent | a172166a8bc7630782409731158812feb2bf957b (diff) | |
[FIX] web: wrong tests
This commit fixes two tests that became meaningless after tweaks
in production code:
- form_tests: use two char fields, as integer fields can't be
unset since rev. c62a4edcb
- pivot_tests: the button is disabled since rev. 4f4f111, but
simulating a click with jQuery bypasses the disabled attribute
This commit also removes unecessary overrides of mockRPC. Those
overrides existed because the attachments part of the sidebar
used to make a search_read RPC, but this has been removed at rev.
1dbb555.
closes odoo/odoo#28650
| -rw-r--r-- | addons/web/static/tests/views/form_tests.js | 59 | ||||
| -rw-r--r-- | addons/web/static/tests/views/list_tests.js | 3 | ||||
| -rw-r--r-- | addons/web/static/tests/views/pivot_tests.js | 12 |
3 files changed, 11 insertions, 63 deletions
diff --git a/addons/web/static/tests/views/form_tests.js b/addons/web/static/tests/views/form_tests.js index 40b62162ddd..fce865ac29f 100644 --- a/addons/web/static/tests/views/form_tests.js +++ b/addons/web/static/tests/views/form_tests.js @@ -797,7 +797,7 @@ QUnit.module('Views', { this.data.partner.fields.foo.default = false; // no default value for this test this.data.partner.records[1].foo = false; // 1 is record with id=2 - this.data.partner.records[1].int_field = false; // 1 is record with id=2 + this.data.partner.records[1].display_name = false; // 1 is record with id=2 var form = createView({ View: FormView, @@ -807,16 +807,16 @@ QUnit.module('Views', { '<sheet>' + '<group>' + '<field name="foo"/>' + - '<field name="int_field" attrs="{\'readonly\': [[\'foo\', \'=\', \'readonly\']]}"/>' + + '<field name="display_name" attrs="{\'readonly\': [[\'foo\', \'=\', \'readonly\']]}"/>' + '</group>' + '</sheet>' + '</form>', res_id: 2, }); - assert.strictEqual(form.$('.o_field_widget.o_field_empty').length, 1, + assert.strictEqual(form.$('.o_field_widget.o_field_empty').length, 2, "should have 1 empty field with correct class"); - assert.strictEqual(form.$('.o_form_label_empty').length, 1, + assert.strictEqual(form.$('.o_form_label_empty').length, 2, "should have 1 muted label (for the empty fied) in readonly"); form.$buttons.find('.o_form_button_edit').click(); @@ -826,10 +826,10 @@ QUnit.module('Views', { assert.strictEqual(form.$('.o_form_label_empty').length, 0, "in edit mode, only labels associated to empty readonly fields should have the o_form_label_empty class"); - form.$('input[name="foo"]').val("readonly").trigger("input"); // int_field is now rerendered as readonly - form.$('input[name="foo"]').val("edit").trigger("input"); // int_field is now rerendered as editable - form.$('input[name="int_field"]').val('1').trigger("input"); // int_field is now set - form.$('input[name="foo"]').val("readonly").trigger("input"); // int_field is now rerendered as readonly + form.$('input[name="foo"]').val("readonly").trigger("input"); // display_name is now rerendered as readonly + form.$('input[name="foo"]').val("edit").trigger("input"); // display_name is now rerendered as editable + form.$('input[name="display_name"]').val('1').trigger("input"); // display_name is now set + form.$('input[name="foo"]').val("readonly").trigger("input"); // display_name is now rerendered as readonly assert.strictEqual(form.$('.o_field_empty').length, 0, "there still should not be any empty class on fields as the readonly one is now set"); @@ -1646,12 +1646,6 @@ QUnit.module('Views', { '</form>', viewOptions: {hasSidebar: true}, res_id: 1, - mockRPC: function (route, args) { - if (args.method === 'search_read' && args.model === 'ir.attachment') { - return $.when([]); - } - return this._super.apply(this, arguments); - }, }); assert.ok(!form.sidebar.$el.hasClass('o_hidden'), 'sidebar should be visible'); @@ -1791,12 +1785,6 @@ QUnit.module('Views', { '</form>', res_id: 1, viewOptions: {hasSidebar: true}, - mockRPC: function (route, args) { - if (args.method === 'search_read' && args.model === 'ir.attachment') { - return $.when([]); - } - return this._super.apply(this, arguments); - }, }); assert.strictEqual(form.get('title'), 'first record', @@ -1829,9 +1817,6 @@ QUnit.module('Views', { assert.strictEqual(args.kwargs.context.hey, 'hoy', "should have send the correct context"); } - if (args.method === 'search_read' && args.model === 'ir.attachment') { - return $.when([]); - } return this._super.apply(this, arguments); }, }); @@ -1853,12 +1838,6 @@ QUnit.module('Views', { '</form>', res_id: 1, viewOptions: {hasSidebar: true}, - mockRPC: function (route, args) { - if (args.method === 'search_read' && args.model === 'ir.attachment') { - return $.when([]); - } - return this._super.apply(this, arguments); - }, }); assert.strictEqual(form.get('title'), 'first record', @@ -2426,12 +2405,6 @@ QUnit.module('Views', { arch: '<form string="Partners"><field name="foo"></field></form>', res_id: 1, viewOptions: {hasSidebar: true}, - mockRPC: function (route, args) { - if (args.method === 'search_read' && args.model === 'ir.attachment') { - return $.when([]); - } - return this._super.apply(this, arguments); - }, }); form.$buttons.find('.o_form_button_edit').click(); @@ -2773,12 +2746,6 @@ QUnit.module('Views', { hasSidebar: true, }, res_id: 1, - mockRPC: function (route, args) { - if (args.method === 'search_read' && args.model === 'ir.attachment') { - return $.when([]); - } - return this._super.apply(this, arguments); - }, }); assert.strictEqual(form.pager.$('.o_pager_value').text(), "1", 'pager value should be 1'); @@ -2818,9 +2785,6 @@ QUnit.module('Views', { }, res_id: 1, mockRPC: function (route, args) { - if (args.method === 'search_read' && args.model === 'ir.attachment') { - return $.when([]); - } assert.step(args.method); return this._super.apply(this, arguments); } @@ -4990,9 +4954,6 @@ QUnit.module('Views', { "the active_ids should be an array with 1 inside."); return $.when({}); } - if (args.method === 'search_read' && args.model === 'ir.attachment') { - return $.when([]); - } return this._super.apply(this, arguments); }, }); @@ -6273,10 +6234,6 @@ QUnit.module('Views', { res_id: 1, viewOptions: {hasSidebar: true}, mockRPC: function (route, args) { - if (args.method === 'search_read' && args.model === 'ir.attachment') { - // rpcs done by the sidebar - return $.when([]); - } var result = this._super.apply(this, arguments); if (args.method === 'copy') { return result.then(function (id) { diff --git a/addons/web/static/tests/views/list_tests.js b/addons/web/static/tests/views/list_tests.js index 4cd4b58ea9e..4540b34c725 100644 --- a/addons/web/static/tests/views/list_tests.js +++ b/addons/web/static/tests/views/list_tests.js @@ -1054,9 +1054,6 @@ QUnit.module('Views', { viewOptions: {hasSidebar: true}, arch: '<tree><field name="foo"/></tree>', mockRPC: function (route) { - if (route === '/web/dataset/call_kw/ir.attachment/search_read') { - return $.when([]); - } assert.step(route); return this._super.apply(this, arguments); }, diff --git a/addons/web/static/tests/views/pivot_tests.js b/addons/web/static/tests/views/pivot_tests.js index fe9e9394b2f..858edcd55e4 100644 --- a/addons/web/static/tests/views/pivot_tests.js +++ b/addons/web/static/tests/views/pivot_tests.js @@ -790,7 +790,7 @@ QUnit.module('Views', { pivot.destroy(); }); - QUnit.test('can download a file without data', function (assert) { + QUnit.test('download button is disabled when there is no data', function (assert) { assert.expect(1); this.data.partner.records = []; @@ -803,16 +803,10 @@ QUnit.module('Views', { '<field name="date" interval="month" type="col"/>' + '<field name="foo" type="measure"/>' + '</pivot>', - session: { - get_file: function (args) { - assert.strictEqual(args.url, '/web/pivot/export_xls', - "should call get_file with correct parameters"); - args.complete(); - }, - }, }); - pivot.$buttons.find('.o_pivot_download').click(); + assert.strictEqual(pivot.$buttons.find('.o_pivot_download').attr('disabled'), 'disabled', + "download button should be disabled"); pivot.destroy(); }); |
