diff options
| author | Christophe Simonis <chs@odoo.com> | 2017-11-07 15:28:28 +0100 |
|---|---|---|
| committer | Christophe Simonis <chs@odoo.com> | 2017-11-07 15:28:28 +0100 |
| commit | 449ec5e29dab7b4a306c824666160fdf6b79088a (patch) | |
| tree | d6fc7ee2f5e0a41bfe65b6d6ebd090aa7e76051d /addons/web/static/tests/fields | |
| parent | 8670f62e3c1d57371e34836b84a0f5079b2ad0e6 (diff) | |
| parent | 255478acbd66f01daf32422636f09f2014ebc9f8 (diff) | |
[MERGE] forward port branch saas-16 up to 255478acbd6
Diffstat (limited to 'addons/web/static/tests/fields')
| -rw-r--r-- | addons/web/static/tests/fields/relational_fields_tests.js | 32 |
1 files changed, 27 insertions, 5 deletions
diff --git a/addons/web/static/tests/fields/relational_fields_tests.js b/addons/web/static/tests/fields/relational_fields_tests.js index fe98eaaeab2..f665fa160e4 100644 --- a/addons/web/static/tests/fields/relational_fields_tests.js +++ b/addons/web/static/tests/fields/relational_fields_tests.js @@ -1397,7 +1397,7 @@ QUnit.module('relational_fields', { }); QUnit.test('slow create on a many2one', function (assert) { - assert.expect(1); + assert.expect(7); var form = createView({ View: FormView, @@ -1417,12 +1417,34 @@ QUnit.module('relational_fields', { }, }); - form.$('.o_field_many2one input').focus(); - form.$('.o_field_many2one input').val('new partner').trigger('keyup').trigger('focusout'); + // cancel the many2one creation with Cancel button + form.$('.o_field_many2one input').focus().val('new product').trigger('keyup').trigger('blur'); + assert.strictEqual($('.modal').length, 1, "there should be one opened modal"); + $('.modal .modal-footer .btn:contains(Cancel)').click(); + assert.strictEqual(form.$('.o_field_many2one input').val(), "", + 'the many2one should not set a value as its creation has been cancelled (with Cancel button)'); - $('.modal .modal-footer .btn-primary').first().click(); + // cancel the many2one creation with Close button + form.$('.o_field_many2one input').focus().val('new product').trigger('keyup').trigger('blur'); + $('.modal .modal-header button').click(); + assert.strictEqual(form.$('.o_field_many2one input').val(), "", + 'the many2one should not set a value as its creation has been cancelled (with Close button)'); - assert.strictEqual($('.modal:visible:last .o_form_view').length, 1, + // select a new value then cancel the creation of the new one --> restore the previous + form.$('.o_field_many2one input').click(); + form.$('.o_field_many2one input').autocomplete('widget').find('a').first().click(); + assert.strictEqual(form.$('input').val(), "xphone", "should have selected xphone"); + form.$('.o_field_many2one input').focus().val('new product').trigger('keyup').trigger('blur'); + assert.strictEqual($('.modal').length, 1, "there should be one opened modal"); + $('.modal .modal-footer .btn:contains(Cancel)').click(); + assert.strictEqual(form.$('.o_field_many2one input').val(), "xphone", + 'should have restored the many2one with its previous selected value (xphone)'); + + // confirm the many2one creation + form.$('.o_field_many2one input').focus(); + form.$('.o_field_many2one input').val('new partner').trigger('keyup').trigger('blur'); + $('.modal .modal-footer .btn-primary').click(); + assert.strictEqual($('.modal .o_form_view').length, 1, 'a new modal should be opened and contain a form view'); form.destroy(); |
