diff options
| author | Christophe Simonis <chs@odoo.com> | 2017-10-20 19:27:04 +0200 |
|---|---|---|
| committer | Christophe Simonis <chs@odoo.com> | 2017-10-20 19:27:04 +0200 |
| commit | 10128fa7e8c743e9c838743204fb8116bcdeefd6 (patch) | |
| tree | 7ffbf2540d01f994886369bd551ea59f7e446040 /addons/web/static/tests/fields/basic_fields_tests.js | |
| parent | 68bef91d733aaf8f08df5f3daf0821a4c59d4d87 (diff) | |
| parent | dc2a6c6cd2a281b7d9e5d33d8e37d2f6b15d7e78 (diff) | |
[MERGE] forward port branch saas-16 up to dc2a6c6cd2a
Diffstat (limited to 'addons/web/static/tests/fields/basic_fields_tests.js')
| -rw-r--r-- | addons/web/static/tests/fields/basic_fields_tests.js | 79 |
1 files changed, 75 insertions, 4 deletions
diff --git a/addons/web/static/tests/fields/basic_fields_tests.js b/addons/web/static/tests/fields/basic_fields_tests.js index c18c8514774..1e623e54d9a 100644 --- a/addons/web/static/tests/fields/basic_fields_tests.js +++ b/addons/web/static/tests/fields/basic_fields_tests.js @@ -1462,6 +1462,42 @@ QUnit.module('basic_fields', { } }); + QUnit.module('FieldImage'); + + QUnit.test('image fields are correctly rendered', function (assert) { + assert.expect(5); + + this.data.partner.records[0].document = 'myimage'; + + var form = createView({ + View: FormView, + model: 'partner', + data: this.data, + arch: '<form string="Partners">' + + '<field name="document" widget="image" options="{\'size\': [90, 90]}"/> ' + + '</form>', + res_id: 1, + mockRPC: function (route) { + if (route === 'data:image/png;base64,myimage') { + assert.ok(true, "should called the correct route"); + return $.when('wow'); + } + return this._super.apply(this, arguments); + }, + }); + + assert.ok(form.$('div[name="document"]').hasClass('o_field_image'), + "the widget should have the correct class"); + assert.strictEqual(form.$('div[name="document"] > img').length, 1, + "the widget should contain an image"); + assert.ok(form.$('div[name="document"] > img').hasClass('img-responsive'), + "the image should have the correct class"); + assert.strictEqual(form.$('div[name="document"] > img').attr('width'), "90", + "the image should correctly set its attributes"); + form.destroy(); + + }); + QUnit.module('JournalDashboardGraph'); QUnit.test('graph dashboard widget is rendered correctly', function (assert) { @@ -1844,6 +1880,39 @@ QUnit.module('basic_fields', { form.destroy(); }); + QUnit.test('do not trigger a field_changed for datetime field with date widget', function (assert) { + assert.expect(3); + + var form = createView({ + View: FormView, + model: 'partner', + data: this.data, + arch:'<form string="Partners"><field name="datetime" widget="date"/></form>', + translateParameters: { // Avoid issues due to localization formats + date_format: '%m/%d/%Y', + time_format: '%H:%M:%S', + }, + res_id: 1, + viewOptions: { + mode: 'edit', + }, + mockRPC: function (route, args) { + assert.step(args.method); + return this._super.apply(this, arguments); + }, + }); + + assert.strictEqual(form.$('.o_datepicker_input').val(), '02/08/2017', + 'the date should be correct'); + + form.$('input[name="datetime"]').val('02/08/2017').trigger('input').trigger('change'); + form.$buttons.find('.o_form_button_save').click(); + + assert.verifySteps(['read']); // should not have save as nothing changed + + form.destroy(); + }); + QUnit.module('FieldDatetime'); QUnit.test('datetime field in form view', function (assert) { @@ -3966,7 +4035,7 @@ QUnit.module('basic_fields', { }); QUnit.test('domain field: handle false domain as []', function (assert) { - assert.expect(2); + assert.expect(3); this.data.partner.records[0].foo = false; this.data.partner.fields.bar.type = "char"; @@ -3992,11 +4061,13 @@ QUnit.module('basic_fields', { return this._super.apply(this, arguments); }, res_id: 1, - viewOptions: { - mode: 'edit', - }, }); + assert.strictEqual(form.$('.o_field_widget[name=foo]:not(.o_field_empty)').length, 1, + "there should be a domain field, not considered empty"); + + form.$buttons.find('.o_form_button_edit').click(); + var $warning = form.$('.o_field_widget[name=foo] .text-warning'); assert.strictEqual($warning.length, 0, "should not display that the domain is invalid"); |
