diff options
Diffstat (limited to 'addons/web/static/tests/fields/relational_fields_tests.js')
| -rw-r--r-- | addons/web/static/tests/fields/relational_fields_tests.js | 32 |
1 files changed, 18 insertions, 14 deletions
diff --git a/addons/web/static/tests/fields/relational_fields_tests.js b/addons/web/static/tests/fields/relational_fields_tests.js index 2f7253abba0..9a326348d2c 100644 --- a/addons/web/static/tests/fields/relational_fields_tests.js +++ b/addons/web/static/tests/fields/relational_fields_tests.js @@ -6033,7 +6033,7 @@ QUnit.module('relational_fields', { QUnit.test('display correct value after validation error', function (assert) { assert.expect(4); - this.data.partner.onchanges.turtles = true; + this.data.partner.onchanges.turtles = function () { }; var form = createView({ View: FormView, @@ -6050,17 +6050,17 @@ QUnit.module('relational_fields', { '</form>', mockRPC: function (route, args) { if (args.method === 'onchange') { - // we simulate a validation error. In the 'real' web client, - // the server error will be used by the session to display - // an error dialog. From the point of view of the basic - // model, the deferred is just rejected. - return $.Deferred().reject(); + if (args.args[1].turtles[0][2].turtle_foo === 'pinky') { + // we simulate a validation error. In the 'real' web client, + // the server error will be used by the session to display + // an error dialog. From the point of view of the basic + // model, the deferred is just rejected. + return $.Deferred().reject(); + } } if (args.method === 'write') { assert.deepEqual(args.args[1].turtles[0], [1,2,{turtle_foo: 'foo'}], - 'should send the "bad" value'); - // we simulate a validation error - return $.Deferred().reject(); + 'should send the "good" value'); } return this._super.apply(this, arguments); }, @@ -6070,21 +6070,25 @@ QUnit.module('relational_fields', { assert.strictEqual(form.$('.o_data_row .o_data_cell:nth(0)').text(), 'blip', "initial text should be correct"); + + // click and edit value to 'foo', which will trigger onchange form.$('.o_data_row .o_data_cell:nth(0)').click(); form.$('.o_field_widget[name=turtle_foo]').val('foo').trigger('input'); + form.$el.click(); + assert.strictEqual(form.$('.o_data_row .o_data_cell:nth(0)').text(), 'foo', + "field should have been changed to foo"); - // we try to validate the line. This triggers an onchange which will be - // rejected. The line will be returned to readonly mode, but with the - // new invalid value. + // click and edit value to 'pinky', which trigger a failed onchange + form.$('.o_data_row .o_data_cell:nth(0)').click(); + form.$('.o_field_widget[name=turtle_foo]').val('pinky').trigger('input'); form.$el.click(); assert.strictEqual(form.$('.o_data_row .o_data_cell:nth(0)').text(), 'foo', - "turtle_foo text should now be foo (invalid value)"); + "turtle_foo text should now be set back to foo"); // we make sure here that when we save, the values are the current // values displayed in the field. form.$buttons.find('.o_form_button_save').click(); - assert.strictEqual(form.mode, 'edit', "form view should still be in edit mode"); form.destroy(); }); |
