diff options
| author | Christophe Simonis <chs@odoo.com> | 2018-03-21 11:04:48 +0100 |
|---|---|---|
| committer | Christophe Simonis <chs@odoo.com> | 2018-03-21 11:04:48 +0100 |
| commit | b51f2d38c247dce9afc04c29774a77d773e3f393 (patch) | |
| tree | 1133e0dd4c082543d1f361fb7ec160ac0b2cccc6 /addons/web/static/tests/fields/basic_fields_tests.js | |
| parent | c7dff653d56910fd46e4dcf745c2c6088ce9fc58 (diff) | |
| parent | 500e3f497057c5d00ae5cc34da7012c6f31f81d4 (diff) | |
[MERGE] forward port branch saas-11.2 up to 500e3f49705
Diffstat (limited to 'addons/web/static/tests/fields/basic_fields_tests.js')
| -rw-r--r-- | addons/web/static/tests/fields/basic_fields_tests.js | 76 |
1 files changed, 75 insertions, 1 deletions
diff --git a/addons/web/static/tests/fields/basic_fields_tests.js b/addons/web/static/tests/fields/basic_fields_tests.js index 11f39bc8147..cc041c08d7b 100644 --- a/addons/web/static/tests/fields/basic_fields_tests.js +++ b/addons/web/static/tests/fields/basic_fields_tests.js @@ -387,7 +387,6 @@ QUnit.module('basic_fields', { '<field name="bar" widget="toggle_button" ' + 'options="{"active": "Reported in last payslips", "inactive": "To Report in Payslip"}"/>' + '</tree>', - res_id: 2, }); assert.strictEqual(list.$('button i.fa.fa-circle.o_toggle_button_success').length, 4, @@ -411,6 +410,81 @@ QUnit.module('basic_fields', { list.destroy(); }); + QUnit.test('toggle_button in form view (edit mode)', function (assert) { + assert.expect(6); + + var form = createView({ + View: FormView, + model: 'partner', + data: this.data, + arch: '<form>' + + '<field name="bar" widget="toggle_button" ' + + 'options="{\'active\': \'Active value\', \'inactive\': \'Inactive value\'}"/>' + + '</form>', + mockRPC: function (route, args) { + if (args.method === 'write') { + assert.step('write'); + } + return this._super.apply(this, arguments); + }, + res_id: 2, + viewOptions: { + mode: 'edit', + }, + }); + + assert.strictEqual(form.$('.o_field_widget[name=bar] i.o_toggle_button_success:not(.text-muted)').length, + 1, "should be green"); + + // click on the button to toggle the value + form.$('.o_field_widget[name=bar]').click(); + + assert.strictEqual(form.$('.o_field_widget[name=bar] i.text-muted:not(.o_toggle_button_success)').length, + 1, "should be gray"); + assert.verifySteps([]); + + // save + form.$buttons.find('.o_form_button_save').click(); + + assert.strictEqual(form.$('.o_field_widget[name=bar] i.text-muted:not(.o_toggle_button_success)').length, + 1, "should still be gray"); + assert.verifySteps(['write']); + + form.destroy(); + }); + + QUnit.test('toggle_button in form view (readonly mode)', function (assert) { + assert.expect(4); + + var form = createView({ + View: FormView, + model: 'partner', + data: this.data, + arch: '<form>' + + '<field name="bar" widget="toggle_button" ' + + 'options="{\'active\': \'Active value\', \'inactive\': \'Inactive value\'}"/>' + + '</form>', + mockRPC: function (route, args) { + if (args.method === 'write') { + assert.step('write'); + } + return this._super.apply(this, arguments); + }, + res_id: 2, + }); + + assert.strictEqual(form.$('.o_field_widget[name=bar] i.o_toggle_button_success:not(.text-muted)').length, + 1, "should be green"); + + // click on the button to toggle the value + form.$('.o_field_widget[name=bar]').click(); + + assert.strictEqual(form.$('.o_field_widget[name=bar] i.text-muted:not(.o_toggle_button_success)').length, + 1, "should be gray"); + assert.verifySteps(['write']); + + form.destroy(); + }); QUnit.module('FieldFloat'); |
