diff options
Diffstat (limited to 'addons/web/static/tests/fields')
7 files changed, 181 insertions, 236 deletions
diff --git a/addons/web/static/tests/fields/basic_fields_mobile_tests.js b/addons/web/static/tests/fields/basic_fields_mobile_tests.js index 05f1b93226e..fd302ebeb36 100644 --- a/addons/web/static/tests/fields/basic_fields_mobile_tests.js +++ b/addons/web/static/tests/fields/basic_fields_mobile_tests.js @@ -164,7 +164,7 @@ QUnit.module('basic_fields', { }); var val = '<script>throw Error();</script><script>throw Error();</script>'; - testUtils.fields.editInput(form.$('input'), val); + testUtils.fields.editInput(form.$('input.o_field_widget[name="foo"]'), val); // save testUtils.form.clickSave(form); diff --git a/addons/web/static/tests/fields/basic_fields_tests.js b/addons/web/static/tests/fields/basic_fields_tests.js index 32450f3d56b..f5568abe28e 100644 --- a/addons/web/static/tests/fields/basic_fields_tests.js +++ b/addons/web/static/tests/fields/basic_fields_tests.js @@ -18,9 +18,6 @@ var DebouncedField = basicFields.DebouncedField; var JournalDashboardGraph = basicFields.JournalDashboardGraph; var _t = core._t; -var DOM = testUtils.DOM; -var mock = testUtils.mock; - QUnit.module('fields', {}, function () { QUnit.module('basic_fields', { @@ -166,7 +163,7 @@ QUnit.module('basic_fields', { }); // change the value - testUtils.fields.editInput(form.$('input'), 'new value'); + testUtils.fields.editInput(form.$('input[name=foo]'), 'new value'); assert.verifySteps([], "_setValue shouldn't have been called yet"); // save @@ -236,12 +233,12 @@ QUnit.module('basic_fields', { "checkbox should now be unchecked"); // check the checkbox by clicking on label - testUtils.dom.click(form.$('label:first')); + testUtils.dom.click(form.$('.o_form_view label:first')); assert.containsOnce(form, '.o_field_boolean input:checked', "checkbox should now be checked"); // uncheck it back - testUtils.dom.click(form.$('label:first')); + testUtils.dom.click(form.$('.o_form_view label:first')); assert.containsNone(form, '.o_field_boolean input:checked', "checkbox should now be unchecked"); @@ -394,17 +391,17 @@ QUnit.module('basic_fields', { assert.containsOnce(list, 'button i.fa.fa-circle.text-muted', "should have 1 muted button"); - assert.hasAttrValue(list.$('button').first(), 'title', "Reported in last payslips", - "active buttons should have proper tooltip"); - assert.hasAttrValue(list.$('button').last(), 'title', "To Report in Payslip", - "inactive buttons should have proper tooltip"); + assert.hasAttrValue(list.$('.o_list_view button').first(), 'title', + "Reported in last payslips", "active buttons should have proper tooltip"); + assert.hasAttrValue(list.$('.o_list_view button').last(), 'title', + "To Report in Payslip", "inactive buttons should have proper tooltip"); // clicking on first button to check the state is properly changed - testUtils.dom.click(list.$('button').first()); + testUtils.dom.click(list.$('.o_list_view button').first()); assert.containsN(list, 'button i.fa.fa-circle.o_toggle_button_success', 3, "should have 3 green buttons"); - testUtils.dom.click(list.$('button').first()); + testUtils.dom.click(list.$('.o_list_view button').first()); assert.containsN(list, 'button i.fa.fa-circle.o_toggle_button_success', 4, "should have 4 green buttons"); list.destroy(); @@ -553,14 +550,14 @@ QUnit.module('basic_fields', { 'The value should be displayed properly.'); testUtils.form.clickEdit(form); - assert.strictEqual(form.$('input').val(), '0.000', + assert.strictEqual(form.$('input[name=qux]').val(), '0.000', 'The value should be rendered with correct precision.'); - testUtils.fields.editInput(form.$('input'), '108.2458938598598'); - assert.strictEqual(form.$('input').val(), '108.2458938598598', + testUtils.fields.editInput(form.$('input[name=qux]'), '108.2458938598598'); + assert.strictEqual(form.$('input[name=qux]').val(), '108.2458938598598', 'The value should not be formated yet.'); - testUtils.fields.editInput(form.$('input'), '18.8958938598598'); + testUtils.fields.editInput(form.$('input[name=qux]'), '18.8958938598598'); testUtils.form.clickSave(form); assert.strictEqual(form.$('.o_field_widget').first().text(), '18.896', 'The new value should be rounded properly.'); @@ -691,13 +688,13 @@ QUnit.module('basic_fields', { 'The value should be displayed properly.'); testUtils.form.clickEdit(form); - assert.strictEqual(form.$('input').val(), '-8.9', + assert.strictEqual(form.$('.o_field_widget[name=qux] input').val(), '-8.9', 'The input should be rendered without the currency symbol.'); - assert.strictEqual(form.$('input').parent().children().first().text(), '$', + assert.strictEqual(form.$('.o_field_widget[name=qux] input').parent().children().first().text(), '$', 'The input should be preceded by a span containing the currency symbol.'); testUtils.fields.editInput(form.$('.o_field_monetary input'), '109.2458938598598'); - assert.strictEqual(form.$('input').val(), '109.2458938598598', + assert.strictEqual(form.$('.o_field_widget[name=qux] input').val(), '109.2458938598598', 'The value should not be formated yet.'); testUtils.form.clickSave(form); @@ -730,7 +727,7 @@ QUnit.module('basic_fields', { 'Float field with option type must have a type attribute.'); assert.hasAttrValue(form.$('.o_field_widget'), 'type', 'number', 'Float field with option type must have a type attribute equals to "number".'); - testUtils.fields.editInput(form.$('input'), '123456.7890'); + testUtils.fields.editInput(form.$('input[name=qux]'), '123456.7890'); testUtils.form.clickSave(form); testUtils.form.clickEdit(form); assert.strictEqual(form.$('.o_field_widget').val(), '123456.789', @@ -763,7 +760,7 @@ QUnit.module('basic_fields', { assert.hasAttrValue(form.$('.o_field_widget'), 'type', 'text', 'Float field with option type must have a text type (default type).'); - testUtils.fields.editInput(form.$('input'), '123456.7890'); + testUtils.fields.editInput(form.$('input[name=qux]'), '123456.7890'); testUtils.form.clickSave(form); testUtils.form.clickEdit(form); assert.strictEqual(form.$('.o_field_widget').val(), '123,456.8', @@ -1086,7 +1083,7 @@ QUnit.module('basic_fields', { }, }); - testUtils.fields.editInput(form.$('input'), '<script>throw Error();</script>'); + testUtils.fields.editInput(form.$('input[name=foo]'), '<script>throw Error();</script>'); testUtils.form.clickSave(form); assert.strictEqual(form.$('.o_field_widget').text(), '<script>throw Error();</script>', 'the value should have been properly escaped'); @@ -3329,13 +3326,13 @@ QUnit.module('basic_fields', { 'The value should be displayed properly.'); testUtils.form.clickEdit(form); - assert.strictEqual(form.$('input').val(), '9.10', + assert.strictEqual(form.$('.o_field_widget[name=qux] input').val(), '9.10', 'The input should be rendered without the currency symbol.'); - assert.strictEqual(form.$('input').parent().children().first().text(), '$', + assert.strictEqual(form.$('.o_field_widget[name=qux] input').parent().children().first().text(), '$', 'The input should be preceded by a span containing the currency symbol.'); testUtils.fields.editInput(form.$('.o_field_monetary input'), '108.2458938598598'); - assert.strictEqual(form.$('input').val(), '108.2458938598598', + assert.strictEqual(form.$('.o_field_widget[name=qux] input').val(), '108.2458938598598', 'The value should not be formated yet.'); testUtils.form.clickSave(form); @@ -3370,13 +3367,13 @@ QUnit.module('basic_fields', { 'The value should be displayed properly.'); testUtils.form.clickEdit(form); - assert.strictEqual(form.$('input').first().val(), '0.00', + assert.strictEqual(form.$('.o_field_widget[name=qux] input').val(), '0.00', 'The input should be rendered without the currency symbol.'); - assert.strictEqual(form.$('input').parent().children().eq(1).text(), '€', + assert.strictEqual(form.$('.o_field_widget[name=qux] input').parent().children().eq(1).text(), '€', 'The input should be followed by a span containing the currency symbol.'); - testUtils.fields.editInput(form.$('input').first(), '108.2458938598598'); - assert.strictEqual(form.$('input').first().val(), '108.2458938598598', + testUtils.fields.editInput(form.$('.o_field_widget[name=qux] input'), '108.2458938598598'); + assert.strictEqual(form.$('.o_field_widget[name=qux] input').val(), '108.2458938598598', 'The value should not be formated yet.'); testUtils.form.clickSave(form); @@ -3427,13 +3424,13 @@ QUnit.module('basic_fields', { 'The value should be displayed properly.'); testUtils.form.clickEdit(form); - assert.strictEqual(form.$('input').first().val(), '99.1234', + assert.strictEqual(form.$('.o_field_widget[name=qux] input').val(), '99.1234', 'The input should be rendered without the currency symbol.'); - assert.strictEqual(form.$('input').parent().children().eq(1).text(), 'Bs.F', + assert.strictEqual(form.$('.o_field_widget[name=qux] input').parent().children().eq(1).text(), 'Bs.F', 'The input should be followed by a span containing the currency symbol.'); - testUtils.fields.editInput(form.$('input').first(), '99.111111111'); - assert.strictEqual(form.$('input').first().val(), '99.111111111', + testUtils.fields.editInput(form.$('.o_field_widget[name=qux] input'), '99.111111111'); + assert.strictEqual(form.$('.o_field_widget[name=qux] input').val(), '99.111111111', 'The value should not be formated yet.'); testUtils.form.clickSave(form); @@ -3743,11 +3740,11 @@ QUnit.module('basic_fields', { 'Integer field should be considered set for value 0.'); testUtils.form.clickEdit(form); - assert.strictEqual(form.$('input').val(), '0', + assert.strictEqual(form.$('input[name=int_field]').val(), '0', 'The value should be rendered correctly in edit mode.'); - testUtils.fields.editInput(form.$('input'), '-18'); - assert.strictEqual(form.$('input').val(), '-18', + testUtils.fields.editInput(form.$('input[name=int_field]'), '-18'); + assert.strictEqual(form.$('input[name=int_field]').val(), '-18', 'The value should be correctly displayed in the input.'); testUtils.form.clickSave(form); @@ -3831,7 +3828,7 @@ QUnit.module('basic_fields', { assert.hasAttrValue(form.$('.o_field_widget'), 'type', 'number', 'Integer field with option type must have a type attribute equals to "number".'); - testUtils.fields.editInput(form.$('input'), '1234567890'); + testUtils.fields.editInput(form.$('input[name=int_field]'), '1234567890'); testUtils.form.clickSave(form); testUtils.form.clickEdit(form); assert.strictEqual(form.$('.o_field_widget').val(), '1234567890', @@ -3864,7 +3861,7 @@ QUnit.module('basic_fields', { assert.hasAttrValue(form.$('.o_field_widget'), 'type', 'text', 'Integer field without option type must have a text type (default type).'); - testUtils.fields.editInput(form.$('input'), '1234567890'); + testUtils.fields.editInput(form.$('input[name=int_field]'), '1234567890'); testUtils.form.clickSave(form); testUtils.form.clickEdit(form); assert.strictEqual(form.$('.o_field_widget').val(), '1,234,567,890', @@ -3903,11 +3900,11 @@ QUnit.module('basic_fields', { 'The formatted time value should be displayed properly.'); testUtils.form.clickEdit(form); - assert.strictEqual(form.$('input').val(), '09:06', + assert.strictEqual(form.$('input[name=qux]').val(), '09:06', 'The value should be rendered correctly in the input.'); - testUtils.fields.editInput(form.$('input'), '-11:48'); - assert.strictEqual(form.$('input').val(), '-11:48', + testUtils.fields.editInput(form.$('input[name=qux]'), '-11:48'); + assert.strictEqual(form.$('input[name=qux]').val(), '-11:48', 'The new value should be displayed properly in the input.'); testUtils.form.clickSave(form); @@ -3945,10 +3942,10 @@ QUnit.module('basic_fields', { 'The formatted value should be displayed properly.'); testUtils.form.clickEdit(form); - assert.strictEqual(form.$('input').val(), '4.55', + assert.strictEqual(form.$('input[name=qux]').val(), '4.55', 'The value should be rendered correctly in the input.'); - testUtils.fields.editInput(form.$('input'), '2.3'); + testUtils.fields.editInput(form.$('input[name=qux]'), '2.3'); testUtils.form.clickSave(form); assert.strictEqual(form.$('.o_field_widget').first().text(), '2.30', @@ -4057,7 +4054,7 @@ QUnit.module('basic_fields', { View: ListView, model: 'partner', data: this.data, - arch: '<tree editable="bottom"><field name="foo" widget="phone"/></tree>', + arch: '<tree editable="bottom"><field name="foo" widget="phone"/></tree>', config: { device: { size_class: config.device.SIZES.LG, diff --git a/addons/web/static/tests/fields/relational_fields/field_many2many_tests.js b/addons/web/static/tests/fields/relational_fields/field_many2many_tests.js index e6f2c06173f..949af90fafe 100644 --- a/addons/web/static/tests/fields/relational_fields/field_many2many_tests.js +++ b/addons/web/static/tests/fields/relational_fields/field_many2many_tests.js @@ -262,7 +262,7 @@ QUnit.module('fields', {}, function () { 'the removed record should not be in kanban anymore'); // save the record - testUtils.form.clickSave(form);; + testUtils.form.clickSave(form); form.destroy(); }); @@ -431,7 +431,7 @@ QUnit.module('fields', {}, function () { 'the updated row still has the correct values'); // save - testUtils.form.clickSave(form);; + testUtils.form.clickSave(form); assert.containsN(form, '.o_list_view td.o_list_number', 2, 'should contain 2 subrecords'); assert.strictEqual(form.$('.o_list_view .o_data_row td:first').text(), @@ -545,7 +545,7 @@ QUnit.module('fields', {}, function () { 'new name', 'the updated row still has the correct values'); // save - testUtils.form.clickSave(form);; + testUtils.form.clickSave(form); assert.containsN(form, '.o_list_view td.o_list_number', 2, 'should contain 2 subrecords'); assert.strictEqual(form.$('.o_list_view .o_data_row td:first').text(), @@ -687,73 +687,26 @@ QUnit.module('fields', {}, function () { } }); - assert.notOk(form.$('.custom-checkbox input').eq(0).prop('checked'), + assert.notOk(form.$('.o_form_view .custom-checkbox input').eq(0).prop('checked'), "first checkbox should not be checked"); - assert.notOk(form.$('.custom-checkbox input').eq(1).prop('checked'), + assert.notOk(form.$('.o_form_view .custom-checkbox input').eq(1).prop('checked'), "second checkbox should not be checked"); - assert.ok(form.$('.custom-checkbox input').eq(2).prop('checked'), + assert.ok(form.$('.o_form_view .custom-checkbox input').eq(2).prop('checked'), "third checkbox should be checked"); - testUtils.dom.click(form.$('.custom-checkbox input:checked')); - testUtils.dom.click(form.$('.custom-checkbox input').first()); - testUtils.dom.click(form.$('.custom-checkbox input').first()); - testUtils.dom.click(form.$('.custom-checkbox input').first()); + testUtils.dom.click(form.$('.o_form_view .custom-checkbox input:checked')); + testUtils.dom.click(form.$('.o_form_view .custom-checkbox input').first()); + testUtils.dom.click(form.$('.o_form_view .custom-checkbox input').first()); + testUtils.dom.click(form.$('.o_form_view .custom-checkbox input').first()); - assert.ok(form.$('.custom-checkbox input').eq(0).prop('checked'), + assert.ok(form.$('.o_form_view .custom-checkbox input').eq(0).prop('checked'), "first checkbox should be checked"); - assert.notOk(form.$('.custom-checkbox input').eq(1).prop('checked'), + assert.notOk(form.$('.o_form_view .custom-checkbox input').eq(1).prop('checked'), "second checkbox should not be checked"); - assert.notOk(form.$('.custom-checkbox input').eq(2).prop('checked'), + assert.notOk(form.$('.o_form_view .custom-checkbox input').eq(2).prop('checked'), "third checkbox should not be checked"); - testUtils.form.clickSave(form);; - - form.destroy(); - }); - - QUnit.test('many2many checkboxes with default values', function (assert) { - assert.expect(7); - - this.data.partner.fields.turtles.default = [3]; - this.data.partner.fields.turtles.type = "many2many"; - - var form = createView({ - View: FormView, - model: 'partner', - data: this.data, - arch: '<form string="Partners">' + - '<field name="turtles" widget="many2many_checkboxes">' + - '</field>' + - '</form>', - mockRPC: function (route, args) { - if (args.method === 'create') { - assert.deepEqual(args.args[0].turtles, [[6, false, [1]]], - "correct values should have been sent to create"); - } - return this._super.apply(this, arguments); - } - }); - - assert.notOk(form.$('.custom-checkbox input').eq(0).prop('checked'), - "first checkbox should not be checked"); - assert.notOk(form.$('.custom-checkbox input').eq(1).prop('checked'), - "second checkbox should not be checked"); - assert.ok(form.$('.custom-checkbox input').eq(2).prop('checked'), - "third checkbox should be checked"); - - testUtils.dom.click(form.$('.custom-checkbox input:checked')); - testUtils.dom.click(form.$('.custom-checkbox input').first()); - testUtils.dom.click(form.$('.custom-checkbox input').first()); - testUtils.dom.click(form.$('.custom-checkbox input').first()); - - assert.ok(form.$('.custom-checkbox input').eq(0).prop('checked'), - "first checkbox should be checked"); - assert.notOk(form.$('.custom-checkbox input').eq(1).prop('checked'), - "second checkbox should not be checked"); - assert.notOk(form.$('.custom-checkbox input').eq(2).prop('checked'), - "third checkbox should not be checked"); - - testUtils.form.clickSave(form);; + testUtils.form.clickSave(form); form.destroy(); }); @@ -904,7 +857,7 @@ QUnit.module('fields', {}, function () { testUtils.dom.click($('.modal .modal-footer .btn-primary').first()); // there is nothing left to save -> should not do a 'write' RPC - testUtils.form.clickSave(form);; + testUtils.form.clickSave(form); assert.verifySteps([ 'read', // read initial record (on partner) @@ -980,27 +933,27 @@ QUnit.module('fields', {}, function () { assert.strictEqual(form.$('.o_kanban_record:not(".o_kanban_ghost")').length, 40, 'there should be 40 records displayed on page 1'); - testUtils.dom.click(form.$('.o_pager_next')); + testUtils.dom.click(form.$('.o_field_widget[name=timmy] .o_pager_next')); assert.verifySteps(['read', 'onchange', 'read', 'read']); assert.strictEqual(form.$('.o_x2m_control_panel .o_pager_counter').text().trim(), '41-45 / 45', "pager should be correct"); assert.strictEqual(form.$('.o_kanban_record:not(".o_kanban_ghost")').length, 5, 'there should be 5 records displayed on page 2'); - testUtils.form.clickSave(form);; + testUtils.form.clickSave(form); assert.strictEqual(form.$('.o_x2m_control_panel .o_pager_counter').text().trim(), '1-40 / 45', "pager should be correct"); assert.strictEqual(form.$('.o_kanban_record:not(".o_kanban_ghost")').length, 40, 'there should be 40 records displayed on page 1'); - testUtils.dom.click(form.$('.o_pager_next')); + testUtils.dom.click(form.$('.o_field_widget[name=timmy] .o_pager_next')); assert.strictEqual(form.$('.o_x2m_control_panel .o_pager_counter').text().trim(), '41-45 / 45', "pager should be correct"); assert.strictEqual(form.$('.o_kanban_record:not(".o_kanban_ghost")').length, 5, 'there should be 5 records displayed on page 2'); - testUtils.dom.click(form.$('.o_pager_next')); + testUtils.dom.click(form.$('.o_field_widget[name=timmy] .o_pager_next')); assert.strictEqual(form.$('.o_x2m_control_panel .o_pager_counter').text().trim(), '1-40 / 45', "pager should be correct"); assert.strictEqual(form.$('.o_kanban_record:not(".o_kanban_ghost")').length, 40, diff --git a/addons/web/static/tests/fields/relational_fields/field_many2one_tests.js b/addons/web/static/tests/fields/relational_fields/field_many2one_tests.js index 855b7695415..84fac135ad2 100644 --- a/addons/web/static/tests/fields/relational_fields/field_many2one_tests.js +++ b/addons/web/static/tests/fields/relational_fields/field_many2one_tests.js @@ -244,7 +244,7 @@ QUnit.module('fields', {}, function () { // save and close modal testUtils.dom.click($('.modal .modal-footer .btn-primary:first')); // save form - testUtils.form.clickSave(form);; + testUtils.form.clickSave(form); // click next on pager testUtils.dom.click(form.pager.$('.o_pager_next')); @@ -316,7 +316,7 @@ QUnit.module('fields', {}, function () { // save and close modal testUtils.dom.click($('.modal .modal-footer .btn-primary:first')); // save form - testUtils.form.clickSave(form);; + testUtils.form.clickSave(form); // click next on pager testUtils.dom.click(form.pager.$('.o_pager_next')); @@ -562,7 +562,7 @@ QUnit.module('fields', {}, function () { // save the main record, and check that no extra rpcs are done (record // is not dirty, only a related record was modified) - testUtils.form.clickSave(form);; + testUtils.form.clickSave(form); assert.verifySteps(['read', 'get_formview_id', 'load_views', 'read', 'write', 'onchange', 'read']); form.destroy(); }); @@ -681,7 +681,7 @@ QUnit.module('fields', {}, function () { 'value of the m2o should have been correctly updated'); // save - testUtils.form.clickSave(form);; + testUtils.form.clickSave(form); assert.strictEqual(form.$('a.o_form_uri').text(), 'Partner 20', "should display correct value after save"); @@ -709,7 +709,7 @@ QUnit.module('fields', {}, function () { // Remove value from many2one and then save, there should not have href with id and model on m2o anchor testUtils.form.clickEdit(form); form.$('.o_field_many2one input').val('').trigger('keyup').trigger('focusout'); - testUtils.form.clickSave(form);; + testUtils.form.clickSave(form); assert.hasAttrValue(form.$('a.o_form_uri'), 'href', "#", "href should have #"); @@ -795,10 +795,10 @@ QUnit.module('fields', {}, function () { testUtils.form.clickEdit(form); - assert.strictEqual(form.$('input').val(), "first record", + assert.strictEqual(form.$('.o_field_widget[name=trululu] input').val(), "first record", "actual field value should be displayed to be edited"); - testUtils.form.clickSave(form);; + testUtils.form.clickSave(form); assert.ok(form.$('a:contains(and some address)').length, "should still display additional result"); @@ -959,7 +959,7 @@ QUnit.module('fields', {}, function () { }, }); await testUtils.fields.many2one.searchAndClickItem('trululu', 'b'); - testUtils.form.clickSave(form);; + testUtils.form.clickSave(form); assert.verifySteps(['name_create'], "should wait for the name_create before creating the record"); @@ -1059,7 +1059,7 @@ QUnit.module('fields', {}, function () { testUtils.dom.click(form.$('.o_field_x2many_list_row_add a')); await testUtils.fields.many2one.searchAndClickItem('trululu', {search: 'b'}); - testUtils.form.clickSave(form);; + testUtils.form.clickSave(form); assert.verifySteps(['name_create'], "should wait for the name_create before creating the record"); @@ -1138,7 +1138,7 @@ QUnit.module('fields', {}, function () { assert.hasClass(form.$('.o_data_row:nth(1)'),'o_selected_row', "the second row should be in edition"); - testUtils.form.clickSave(form);; + testUtils.form.clickSave(form); assert.containsOnce(form, '.o_data_row', "there should be 1 row saved (the second one was empty and invalid)"); @@ -1674,7 +1674,7 @@ QUnit.module('fields', {}, function () { displayName = 'new value'; testUtils.dom.click(form.$('.o_data_cell')); testUtils.fields.editInput(form.$('.o_data_cell input'), displayName); - testUtils.form.clickSave(form);; + testUtils.form.clickSave(form); form.destroy(); }); @@ -1727,7 +1727,7 @@ QUnit.module('fields', {}, function () { }, }); - testUtils.form.clickSave(form);; + testUtils.form.clickSave(form); form.destroy(); }); @@ -1866,7 +1866,7 @@ QUnit.module('fields', {}, function () { // Saving the modal and then the original model testUtils.dom.click($modal.find('.modal-footer .btn-primary')); - testUtils.form.clickSave(form);; + testUtils.form.clickSave(form); assert.verifySteps(['onchange sequence', 'partner_type write']); @@ -1897,7 +1897,7 @@ QUnit.module('fields', {}, function () { }); testUtils.form.clickEdit(form); - testUtils.dom.click(form.$('input')); + testUtils.dom.click(form.$('.o_field_widget[name=product_id] input')); form.destroy(); }); @@ -1923,7 +1923,7 @@ QUnit.module('fields', {}, function () { }); testUtils.form.clickEdit(form); - testUtils.dom.click(form.$('input:eq(2)')); + testUtils.dom.click(form.$('.o_field_widget[name=trululu] input')); form.destroy(); }); @@ -1956,7 +1956,7 @@ QUnit.module('fields', {}, function () { }); assert.strictEqual(count, 3, "should have done 3 rpcs (default_get, onchange, name_get)"); - assert.strictEqual(form.$('input').val(), 'hello world', + assert.strictEqual(form.$('.o_field_widget[name=trululu] input').val(), 'hello world', "should have taken the correct display name"); form.destroy(); }); @@ -1973,15 +1973,15 @@ QUnit.module('fields', {}, function () { '</form>', res_id: 1, }); - assert.strictEqual(form.$('a').text(), '', 'the tag a should be empty'); + assert.strictEqual(form.$('a[name=product_id]').text(), '', 'the tag a should be empty'); testUtils.form.clickEdit(form); testUtils.fields.many2one.clickOpenDropdown('product_id'); testUtils.fields.many2one.clickItem('product_id','xphone'); - assert.strictEqual(form.$('input').val(), "xphone", "should have selected xphone"); + assert.strictEqual(form.$('.o_field_widget[name=product_id] input').val(), "xphone", "should have selected xphone"); - testUtils.form.clickDiscard(form);; - assert.strictEqual(form.$('a').text(), '', 'the tag a should be empty'); + testUtils.form.clickDiscard(form); + assert.strictEqual(form.$('a[name=product_id]').text(), '', 'the tag a should be empty'); form.destroy(); }); @@ -2103,7 +2103,7 @@ QUnit.module('fields', {}, function () { // select a new value then cancel the creation of the new one --> restore the previous testUtils.fields.many2one.clickOpenDropdown('product_id'); testUtils.fields.many2one.clickItem('product_id','o'); - assert.strictEqual(form.$('input').val(), "xphone", "should have selected xphone"); + assert.strictEqual(form.$('.o_field_many2one 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"); testUtils.dom.click($('.modal .modal-footer .btn:contains(Cancel)')); @@ -2739,7 +2739,7 @@ QUnit.module('fields', {}, function () { 'The display name field should have the right value'); // Save the whole thing - testUtils.form.clickSave(form);; + testUtils.form.clickSave(form); x2mList = form.$('.o_field_x2many_list[name=p]'); diff --git a/addons/web/static/tests/fields/relational_fields/field_one2many_tests.js b/addons/web/static/tests/fields/relational_fields/field_one2many_tests.js index af508179830..56c44731be4 100644 --- a/addons/web/static/tests/fields/relational_fields/field_one2many_tests.js +++ b/addons/web/static/tests/fields/relational_fields/field_one2many_tests.js @@ -370,7 +370,7 @@ QUnit.module('fields', {}, function () { testUtils.fields.editInput($secondTarget, 9); testUtils.fields.editInput($secondTarget, $secondTarget.val() + 9); - testUtils.form.clickSave(form);; + testUtils.form.clickSave(form); form.destroy(); }); @@ -397,6 +397,11 @@ QUnit.module('fields', {}, function () { '</sheet>' + '</form>', res_id: 1, + intercepts: { + load_filters: function (event) { + throw new Error('Should not load filters'); + }, + }, }); @@ -700,7 +705,7 @@ QUnit.module('fields', {}, function () { assert.strictEqual(form.$('td.o_data_cell:not(.o_handle_cell)').text(), "blipyopkawa", "should have the 3 rows in the new order"); - testUtils.form.clickSave(form);; + testUtils.form.clickSave(form); assert.deepEqual(_.map(this.data.turtle.records, function (turtle) { return _.pick(turtle, 'id', 'turtle_foo', 'turtle_int'); @@ -777,7 +782,7 @@ QUnit.module('fields', {}, function () { testUtils.dom.click(form.$('.o_data_cell').eq(1)); var $cell = form.$('.o_selected_row .o_input[name=turtle_foo]'); testUtils.fields.editSelect($cell, "hop"); - testUtils.form.clickSave(form);; + testUtils.form.clickSave(form); form.destroy(); }); @@ -839,7 +844,7 @@ QUnit.module('fields', {}, function () { testUtils.dom.click(form.$('.o_data_cell').eq(1)); var $cell = form.$('.o_selected_row .o_input[name=turtle_foo]'); testUtils.fields.editSelect($cell, "hop"); - testUtils.form.clickSave(form);; + testUtils.form.clickSave(form); assert.deepEqual(form.$('.o_many2many_tags_cell').text().trim().split(/\s+/), ["second", "record", "aaa"], @@ -960,7 +965,7 @@ QUnit.module('fields', {}, function () { "should still have the 3 rows in the correct order"); assert.strictEqual(turtleOnchange, 3, "should update all lines"); - testUtils.form.clickSave(form);; + testUtils.form.clickSave(form); form.destroy(); }); @@ -1004,7 +1009,7 @@ QUnit.module('fields', {}, function () { res_id: 1, }); - testUtils.dom.click(form.$('.o_pager_next')); + testUtils.dom.click(form.$('.o_field_widget[name=turtles] .o_pager_next')); assert.strictEqual(form.$('td.o_data_cell:not(.o_handle_cell)').text(), "yopblipkawa", "should have the 3 rows in the correct order"); @@ -1021,8 +1026,8 @@ QUnit.module('fields', {}, function () { assert.strictEqual(form.$('.o_data_cell').text(), "blurpkawablip", "should display to record in 'turtle_int' order"); - testUtils.form.clickSave(form);; - testUtils.dom.click(form.$('.o_pager_next')); + testUtils.form.clickSave(form); + testUtils.dom.click(form.$('.o_field_widget[name=turtles] .o_pager_next')); assert.strictEqual(form.$('.o_data_cell:not(.o_handle_cell)').text(), "blurpkawablip", "should display to record in 'turtle_int' order"); @@ -1098,7 +1103,7 @@ QUnit.module('fields', {}, function () { testUtils.fields.editInput(form.$('.o_field_one2many .o_list_view tbody tr:first input:first'), 'blurp'); // the domain fail if the widget does not use the allready loaded data. - testUtils.form.clickDiscard(form);; + testUtils.form.clickDiscard(form); assert.equal(form.$('.o_field_one2many td[class="o_data_cell"]').text(), "blurp#21#22#23#24#25#26#27#28#29", "should display the records in order with the changes"); @@ -1130,7 +1135,7 @@ QUnit.module('fields', {}, function () { assert.equal(form.$('.o_field_one2many td[class="o_data_cell"]').text(), "#20#39#40#41#42#43#44#45#46#47", "should display the records in order after resequence (display record with turtle_int=0)"); - testUtils.form.clickDiscard(form);; + testUtils.form.clickDiscard(form); assert.equal(form.$('.o_field_one2many td[class="o_data_cell"]').text(), "#20#39#40#41#42#43#44#45#46#47", "should display the records in order after resequence"); @@ -1184,7 +1189,7 @@ QUnit.module('fields', {}, function () { }); testUtils.form.clickEdit(form); - testUtils.dom.click(form.$('.o_pager_next')); + testUtils.dom.click(form.$('.o_field_widget[name=turtles] .o_pager_next')); testUtils.dom.click(form.$('.o_field_one2many .o_list_view tbody tr:eq(1) td:first')); testUtils.fields.editInput(form.$('.o_field_one2many .o_list_view tbody tr:eq(1) input:first'), 'value 1'); @@ -1259,7 +1264,7 @@ QUnit.module('fields', {}, function () { }); testUtils.form.clickEdit(form); - testUtils.dom.click(form.$('.o_pager_next')); + testUtils.dom.click(form.$('.o_field_widget[name=turtles] .o_pager_next')); testUtils.dom.click(form.$('.o_field_one2many .o_list_view tbody tr:eq(1) td:first')); testUtils.fields.editInput(form.$('.o_field_one2many .o_list_view tbody tr:eq(1) input:first'), 'value 1'); @@ -1693,7 +1698,7 @@ QUnit.module('fields', {}, function () { assert.strictEqual(form.$('tbody tr:first td.o_data_cell:not(.o_handle_cell) input').val(), "blip", "should edit the correct row"); - testUtils.form.clickSave(form);; + testUtils.form.clickSave(form); assert.strictEqual(form.$('td.o_data_cell:not(.o_handle_cell)').text(), "blipMy little Foo Valueyop", "should still have the 3 rows in the new order"); @@ -1904,7 +1909,7 @@ QUnit.module('fields', {}, function () { assert.strictEqual(form.$('.o_kanban_record:first span:contains(new record)').length, 0, 'new record should not be on page 1'); // save - testUtils.form.clickSave(form);; + testUtils.form.clickSave(form); // delete a record on page one checkRead = true; @@ -1920,7 +1925,7 @@ QUnit.module('fields', {}, function () { assert.strictEqual(form.$('.o_x2m_control_panel .o_pager_counter').text().trim(), '1-40 / 45', "pager range should be correct"); // save - testUtils.form.clickSave(form);; + testUtils.form.clickSave(form); // add and delete records in both pages testUtils.form.clickEdit(form); @@ -1956,7 +1961,7 @@ QUnit.module('fields', {}, function () { assert.strictEqual(form.$('.o_kanban_record span:contains(new record page 2)').length, 1, 'new records should be on page 2'); // save - testUtils.form.clickSave(form);; + testUtils.form.clickSave(form); form.destroy(); }); @@ -2088,7 +2093,7 @@ QUnit.module('fields', {}, function () { "first row of o2m should be readonly again"); // discard changes - testUtils.form.clickDiscard(form);; + testUtils.form.clickDiscard(form); assert.strictEqual(form.$('.o_field_one2many tbody td').first().text(), 'new value', "changes shouldn't have been discarded yet, waiting for user confirmation"); testUtils.dom.click($('.modal .modal-footer .btn-primary')); @@ -2100,7 +2105,7 @@ QUnit.module('fields', {}, function () { testUtils.dom.click(form.$('.o_field_one2many tbody td').first()); testUtils.fields.editInput(form.$('.o_field_one2many tbody td').first().find('input'), "new value"); testUtils.dom.click(form.$el); - testUtils.form.clickSave(form);; + testUtils.form.clickSave(form); // FIXME: this next test doesn't pass as the save of updates of // relational data is temporarily disabled // assert.strictEqual(form.$('.o_field_one2many tbody td').first().text(), 'new value', @@ -2191,7 +2196,7 @@ QUnit.module('fields', {}, function () { "should have 1 delete button (another record is supposed to have been unlinked)"); // save and check that the correct command has been generated - testUtils.form.clickSave(form);; + testUtils.form.clickSave(form); form.destroy(); }); @@ -2251,7 +2256,7 @@ QUnit.module('fields', {}, function () { "should have 1 remove button (another record is supposed to have been deleted)"); // save and check that the correct command has been generated - testUtils.form.clickSave(form);; + testUtils.form.clickSave(form); // FIXME: it would be nice to test that the view is re-rendered correctly, // but as the relational data isn't re-fetched, the rendering is ok even @@ -2451,7 +2456,7 @@ QUnit.module('fields', {}, function () { testUtils.dom.click(form.$('.o_field_x2many_list_row_add a')); testUtils.dom.click(form.$el); - assert.strictEqual(form.$('.o_cp_pager').text().trim(), '1-3 / 5', + assert.strictEqual(form.$('.o_field_widget[name=turtles] .o_cp_pager').text().trim(), '1-3 / 5', "pager should display the correct total"); form.destroy(); }); @@ -2522,7 +2527,7 @@ QUnit.module('fields', {}, function () { assert.strictEqual(form.$('.o_list_view tbody td:first()').text(), 'new name', 'the remaining subrecord should be "new name"'); - testUtils.form.clickSave(form);; // save the record + testUtils.form.clickSave(form); // save the record assert.strictEqual(nbWrite, 1, "should have write the changes in DB"); form.destroy(); @@ -2622,7 +2627,7 @@ QUnit.module('fields', {}, function () { // enter another value and save testUtils.fields.editInput(form.$('.o_selected_row > td input'), 'gemuse'); - testUtils.form.clickSave(form);; + testUtils.form.clickSave(form); assert.containsN(form, 'tr.o_data_row', 2, "should have 2 data rows"); assert.strictEqual(form.$('td:contains(kartoffel)').length, 1, "should have one td with the new value"); @@ -2661,7 +2666,7 @@ QUnit.module('fields', {}, function () { "should have 3 data rows"); // cancel the edition - testUtils.form.clickDiscard(form);; + testUtils.form.clickDiscard(form); testUtils.dom.click($('.modal-footer button.btn-primary').first()); assert.containsOnce(form, 'tr.o_data_row', "should have 1 data rows"); @@ -2754,7 +2759,7 @@ QUnit.module('fields', {}, function () { // click on Add an item again, then click on save testUtils.dom.click(form.$('.o_field_x2many_list_row_add a')); - testUtils.form.clickSave(form);; + testUtils.form.clickSave(form); assert.containsNone(form, 'tr.o_data_row', "should still have 0 data rows"); @@ -2785,13 +2790,13 @@ QUnit.module('fields', {}, function () { testUtils.dom.click(form.$('.o_field_x2many_list_row_add a')); // the record currently being added should not count in the pager - assert.ok(!form.$('.o_cp_pager').is(':visible'), - "pager should not be visible"); + assert.isNotVisible(form.$('.o_field_widget[name=turtles] .o_cp_pager')); + form.destroy(); }); QUnit.test('editable one2many list, adding line, then discarding', function (assert) { - assert.expect(1); + assert.expect(2); this.data.turtle.records.push({ id: 4, turtle_foo: 'stephen hawking' }); this.data.partner.records[0].turtles = [1, 2, 3, 4]; @@ -2813,13 +2818,15 @@ QUnit.module('fields', {}, function () { // add a record, then discard testUtils.form.clickEdit(form); testUtils.dom.click(form.$('.o_field_x2many_list_row_add a')); - testUtils.form.clickDiscard(form);; + testUtils.form.clickDiscard(form); // confirm the discard operation testUtils.dom.click($('.modal .modal-footer .btn-primary')); - assert.strictEqual(form.$('.o_cp_pager').text().trim(), '1-3 / 4', - "pager should still be visible"); + assert.isVisible(form.$('.o_field_widget[name=turtles] .o_cp_pager')); + assert.strictEqual(form.$('.o_field_widget[name=turtles] .o_cp_pager').text().trim(), '1-3 / 4', + "pager should display correct values"); + form.destroy(); }); @@ -2849,9 +2856,8 @@ QUnit.module('fields', {}, function () { testUtils.dom.click(form.$('.o_field_x2many_list_row_add a')); // go on next page. The new record is not valid and should be discarded - testUtils.dom.click(form.$('.o_pager_next')); - assert.containsOnce(form, 'tr.o_data_row', - "should have 1 data rows"); + testUtils.dom.click(form.$('.o_field_widget[name=turtles] .o_pager_next')); + assert.containsOnce(form, 'tr.o_data_row'); form.destroy(); }); @@ -2885,15 +2891,15 @@ QUnit.module('fields', {}, function () { // go to next page. The new record is not valid, but dirty. we should // see a confirm dialog - testUtils.dom.click(form.$('.o_pager_next')); + testUtils.dom.click(form.$('.o_field_widget[name=turtles] .o_pager_next')); - assert.strictEqual(form.$('.o_cp_pager').text().trim(), '1-3 / 4', + assert.strictEqual(form.$('.o_field_widget[name=turtles] .o_cp_pager').text().trim(), '1-3 / 4', "pager should still display the correct total"); // click on cancel testUtils.dom.click($('.modal .modal-footer .btn-secondary')); - assert.strictEqual(form.$('.o_cp_pager').text().trim(), '1-3 / 4', + assert.strictEqual(form.$('.o_field_widget[name=turtles] .o_cp_pager').text().trim(), '1-3 / 4', "pager should again display the correct total"); assert.containsOnce(form, '.o_field_one2many input.o_field_invalid', "there should be an invalid input in the one2many"); @@ -2927,16 +2933,14 @@ QUnit.module('fields', {}, function () { testUtils.dom.click(form.$('.o_field_x2many_list_row_add a')); // go on next page - testUtils.dom.click(form.$('.o_pager_next')); + testUtils.dom.click(form.$('.o_field_widget[name=turtles] .o_pager_next')); // discard - testUtils.form.clickDiscard(form);; + testUtils.form.clickDiscard(form); testUtils.dom.click($('.modal .modal-footer .btn-primary')); - assert.containsOnce(form, 'tr.o_data_row', - "should have 1 data row"); - assert.ok(!form.$('.o_cp_pager').is(':visible'), - "pager should not be visible"); + assert.containsOnce(form, 'tr.o_data_row'); + assert.isNotVisible(form.$('.o_field_widget[name=turtles] .o_cp_pager')); form.destroy(); }); @@ -3079,7 +3083,7 @@ QUnit.module('fields', {}, function () { "onchange should have been triggered"); // save and check everything is fine - testUtils.form.clickSave(form);; + testUtils.form.clickSave(form); assert.strictEqual(form.$('.o_data_row td:contains(aubergine)').length, 1, "should have one row with turtle_foo value"); assert.strictEqual(form.$('.o_data_row td:contains(9)').length, 1, @@ -3284,7 +3288,7 @@ QUnit.module('fields', {}, function () { testUtils.form.clickEdit(form); testUtils.dom.click(form.$('.o_field_one2many tbody td').first()); testUtils.fields.editInput(form.$('.o_field_one2many tbody td').first().find('input'), "new value"); - testUtils.form.clickSave(form);; + testUtils.form.clickSave(form); assert.strictEqual(form.$('.o_field_one2many tbody td').first().text(), 'from onchange', "display name of first record in o2m list should be 'new value'"); @@ -3430,7 +3434,7 @@ QUnit.module('fields', {}, function () { testUtils.dom.click($('.bootstrap-datetimepicker-widget .month').eq(1)); testUtils.dom.click($('.day:contains(22)')); - testUtils.form.clickSave(form);; + testUtils.form.clickSave(form); assert.verifySteps(['read', 'read', 'onchange', 'write', 'read', 'read']); form.destroy(); @@ -3501,7 +3505,7 @@ QUnit.module('fields', {}, function () { testUtils.dom.click(form.$('.o_field_x2many_list_row_add a')); testUtils.fields.editInput(form.$('.o_field_widget[name=display_name]'), 'z'); - testUtils.form.clickSave(form);; + testUtils.form.clickSave(form); form.destroy(); }); @@ -3566,7 +3570,7 @@ QUnit.module('fields', {}, function () { testUtils.dom.click(form.$('.o_field_one2many .o_list_view tbody tr:first td:first')); testUtils.fields.editInput(form.$('.o_field_one2many .o_list_view tbody tr:first input:first'), 'blurp'); - testUtils.form.clickSave(form);; + testUtils.form.clickSave(form); form.destroy(); }); @@ -3664,7 +3668,7 @@ QUnit.module('fields', {}, function () { assert.containsN(form, '.o_field_widget', delta, "all (non visible) field widgets should have been destroyed"); - testUtils.form.clickSave(form);; + testUtils.form.clickSave(form); assert.strictEqual(form.$('.o_data_row').text(), "first20second-20", "should correctly refresh the records after save"); @@ -3958,7 +3962,7 @@ QUnit.module('fields', {}, function () { "should display 'xpad' in a td"); // save the record - testUtils.form.clickSave(form);; + testUtils.form.clickSave(form); form.destroy(); }); @@ -4186,7 +4190,7 @@ QUnit.module('fields', {}, function () { "should not have unselected the row after edition"); testUtils.fields.editInput(form.$('td input.o_field_widget'), 'abc'); - testUtils.form.clickSave(form);; + testUtils.form.clickSave(form); assert.strictEqual(form.$('td:contains(abc)').length, 1, "should have a row with the correct value"); @@ -4531,7 +4535,7 @@ QUnit.module('fields', {}, function () { }); testUtils.dom.click(form.$('td.o_field_x2many_list_row_add a')); testUtils.fields.editInput(form.$('td input[name="turtle_foo"]'), 'cat'); - testUtils.form.clickSave(form);; + testUtils.form.clickSave(form); form.destroy(); }); @@ -4768,7 +4772,7 @@ QUnit.module('fields', {}, function () { testUtils.dom.click(form.$('.o_field_one2many .o_list_view tbody tr:eq(0) td:first')); - testUtils.form.clickSave(form);; + testUtils.form.clickSave(form); assert.strictEqual(nbFetchSpecialDomain, 1, "should only fetch special domain once"); form.destroy(); @@ -5068,7 +5072,7 @@ QUnit.module('fields', {}, function () { assert.strictEqual(form.$('.o_data_row').text().replace(/\s+/g, ' '), "firstxenomorphe second record new linexphone first record ", 'should display the name, one2many and many2many value'); - testUtils.form.clickSave(form);; + testUtils.form.clickSave(form); assert.strictEqual(form.$('.o_data_row').text().replace(/\s+/g, ' '), "firstxenomorphe second record new linexphone first record ", 'should display the name, one2many and many2many value after save'); @@ -5263,7 +5267,7 @@ QUnit.module('fields', {}, function () { // confirm the changes in the modal testUtils.dom.click($('.modal .modal-footer .btn-primary')); - testUtils.form.clickSave(form);; + testUtils.form.clickSave(form); form.destroy(); }); @@ -5401,7 +5405,7 @@ QUnit.module('fields', {}, function () { 'My little Foo Value', "should have a value for the foo field"); // save the view to force a create of the new record in the one2many - testUtils.form.clickSave(form);; + testUtils.form.clickSave(form); assert.containsOnce(form, '.o_field_widget .o_kanban_view', "should have one inner kanban view for the one2many field"); assert.strictEqual(form.$('.o_field_widget .o_kanban_view .o_kanban_record:not(.o_kanban_ghost)').length, 1, @@ -5489,7 +5493,7 @@ QUnit.module('fields', {}, function () { assert.hasClass(form.$('tr.o_data_row:first'),'o_selected_row', "first row should be selected"); - testUtils.form.clickSave(form);; + testUtils.form.clickSave(form); form.destroy(); }); @@ -5536,7 +5540,7 @@ QUnit.module('fields', {}, function () { assert.hasClass(form.$('tr.o_data_row:eq(1)'),'o_selected_row', "second row should be selected"); - testUtils.form.clickSave(form);; + testUtils.form.clickSave(form); form.destroy(); }); @@ -6049,7 +6053,7 @@ QUnit.module('fields', {}, function () { testUtils.dom.click(form.$('.o_data_cell:first')); testUtils.fields.editInput(form.$('.o_field_widget[name=display_name]'), 'abc'); - testUtils.form.clickSave(form);; + testUtils.form.clickSave(form); form.destroy(); }); @@ -6254,16 +6258,13 @@ QUnit.module('fields', {}, function () { testUtils.form.clickEdit(form); testUtils.dom.click(form.$('.o_field_x2many_list_row_add a')); - assert.containsN(form, 'tr.o_data_row', 41, - "should have 41 data rows on the current page"); - assert.hasClass(form.$('tr.o_data_row').last(),'o_selected_row', - "last row should be selected"); + assert.containsN(form, 'tr.o_data_row', 41); + assert.hasClass(form.$('tr.o_data_row').last(), 'o_selected_row'); testUtils.fields.editInput(form.$('.o_data_row input[name="turtle_foo"]'), 'rainbow dash'); - testUtils.form.clickSave(form);; + testUtils.form.clickSave(form); - assert.containsN(form, 'tr.o_data_row', 40, - "should have 40 data rows on the current page"); + assert.containsN(form, 'tr.o_data_row', 40); assert.verifySteps(['read', 'read', 'default_get', 'write', 'read', 'read']); form.destroy(); @@ -6342,27 +6343,23 @@ QUnit.module('fields', {}, function () { testUtils.form.clickEdit(form); - testUtils.dom.click(form.$('.o_pager_next')); + testUtils.dom.click(form.$('.o_field_widget[name=turtles] .o_pager_next')); - assert.containsN(form, 'tr.o_data_row', 2, - "should have 2 data rows on the current page"); + assert.containsN(form, 'tr.o_data_row', 2); testUtils.dom.click(form.$('.o_field_x2many_list_row_add a')); - assert.containsN(form, 'tr.o_data_row', 3, - "should have 3 data rows on the current page (2 records and the created line)"); + assert.containsN(form, 'tr.o_data_row', 3); - assert.hasClass(form.$('tr.o_data_row').first(),'o_selected_row', - "first row should be selected"); + assert.hasClass(form.$('tr.o_data_row').first(), 'o_selected_row'); assert.strictEqual(form.$('tr.o_data_row input').val(), 'default foo', "selected input should have correct string"); testUtils.fields.editInput(form.$('.o_data_row input[name="turtle_foo"]'), 'rainbow dash'); - testUtils.form.clickSave(form);; + testUtils.form.clickSave(form); - assert.containsN(form, 'tr.o_data_row', 40, - "should have 40 data rows on the current page"); + assert.containsN(form, 'tr.o_data_row', 40); assert.verifySteps(['read', 'read', 'read', 'default_get', 'write', 'read', 'read']); form.destroy(); @@ -6571,7 +6568,7 @@ QUnit.module('fields', {}, function () { assert.strictEqual(form.$('.o_data_cell').text(), '1 record', "should correctly display the value of the inner o2m"); - testUtils.form.clickSave(form);; + testUtils.form.clickSave(form); form.destroy(); }); @@ -6634,7 +6631,7 @@ QUnit.module('fields', {}, function () { // we make sure here that when we save, the values are the current // values displayed in the field. - testUtils.form.clickSave(form);; + testUtils.form.clickSave(form); form.destroy(); }); @@ -6664,7 +6661,7 @@ QUnit.module('fields', {}, function () { }); testUtils.dom.click(form.$('.o_field_x2many_list_row_add a')); testUtils.fields.editInput(form.$('input[name="turtle_foo"]'), 'pinky pie'); - testUtils.form.clickSave(form);; + testUtils.form.clickSave(form); form.destroy(); }); @@ -6730,7 +6727,7 @@ QUnit.module('fields', {}, function () { "should have added the new row to the nested one2many"); testUtils.dom.clickFirst($('.modal .modal-footer .btn-primary')); - testUtils.form.clickSave(form);; + testUtils.form.clickSave(form); form.destroy(); }); @@ -6857,7 +6854,7 @@ QUnit.module('fields', {}, function () { var inputText = 'ninja'; testUtils.dom.click(form.$('.o_field_x2many_list_row_add a')); testUtils.fields.editInput(form.$('.o_input[name="turtle_foo"]'), inputText); - testUtils.form.clickSave(form);; + testUtils.form.clickSave(form); assert.strictEqual($('.o_data_cell').text(), "blipyopkawa" + inputText); form.destroy(); @@ -6898,7 +6895,7 @@ QUnit.module('fields', {}, function () { var inputText = 'ninja'; testUtils.dom.click(form.$('.o_field_x2many_list_row_add a')); testUtils.fields.editInput(form.$('.o_input[name="turtle_foo"]'), inputText); - testUtils.form.clickSave(form);; + testUtils.form.clickSave(form); assert.strictEqual($('.o_data_cell').text(), inputText + "blipyopkawa"); form.destroy(); @@ -7187,7 +7184,7 @@ QUnit.module('fields', {}, function () { }); assert.strictEqual(form.$('.o_data_row').text(), 'yopblip', 'data has been properly loaded'); - testUtils.form.clickSave(form);; + testUtils.form.clickSave(form); assert.strictEqual(form.$('.o_data_row').text(), 'yopblip', 'data has been properly saved'); @@ -7414,7 +7411,7 @@ QUnit.module('fields', {}, function () { testUtils.dom.click(form.$('.o_field_x2many_list_row_add a:eq(1)')); // click add pasta testUtils.dom.click(form.$('.o_field_x2many_list_row_add a:eq(2)')); - testUtils.form.clickSave(form);; + testUtils.form.clickSave(form); assert.strictEqual($('.o_data_cell').text(), "pizzapasta"); form.destroy(); @@ -7638,7 +7635,7 @@ QUnit.module('fields', {}, function () { // open first partner so changes from previous action are applied testUtils.dom.click(form.$('.o_data_row:eq(0)')); testUtils.dom.click($('.modal .btn-primary')); - testUtils.form.clickSave(form);; + testUtils.form.clickSave(form); assert.strictEqual(numUserOnchange, 2, 'there should 2 and only 2 onchange from closing the partner modal'); @@ -7796,7 +7793,7 @@ QUnit.module('fields', {}, function () { form.$('.o_input[name="turtle_foo"]'), 'ninja', ['input', $.Event('keydown', {which: $.ui.keyCode.TAB, keyCode: $.ui.keyCode.TAB,})] - );; + ); assert.strictEqual(form.$('.o_field_text').text(), 'blipninja', 'current line should be saved'); @@ -7900,11 +7897,11 @@ QUnit.module('fields', {}, function () { testUtils.dom.click(form.$('.o_field_x2many_list_row_add a')); - testUtils.fields.editInput(form.$('input'), 'some foo value'); + testUtils.fields.editInput(form.$('.o_field_widget[name=turtles] input'), 'some foo value'); // click to add a second row to unselect the current one, then save testUtils.dom.click(form.$('.o_field_x2many_list_row_add a')); - testUtils.form.clickSave(form);; + testUtils.form.clickSave(form); assert.containsOnce(form, '.o_form_readonly', "form view should be in readonly"); @@ -7977,7 +7974,7 @@ QUnit.module('fields', {}, function () { 'The display name field should have the right value'); // Save the whole thing - testUtils.form.clickSave(form);; + testUtils.form.clickSave(form); x2mList = form.$('.o_field_x2many_list[name=p]'); diff --git a/addons/web/static/tests/fields/relational_fields_tests.js b/addons/web/static/tests/fields/relational_fields_tests.js index ab7a603fb80..6c3493828ad 100644 --- a/addons/web/static/tests/fields/relational_fields_tests.js +++ b/addons/web/static/tests/fields/relational_fields_tests.js @@ -615,7 +615,7 @@ QUnit.module('relational_fields', { list.destroy(); }); - QUnit.test('widget selection, edition and on many2one field', function (assert) { + QUnit.test('widget selection, edition and on many2one field', function (assert) { assert.expect(18); this.data.partner.onchanges = {product_id: function () {}}; @@ -640,7 +640,7 @@ QUnit.module('relational_fields', { }, }); - assert.ok(!form.$('select').length, "should not have a select tag in dom"); + assert.containsNone(form.$('.o_form_view'), 'select'); assert.strictEqual(form.$('.o_field_widget[name=product_id]').text(), 'xphone', "should have rendered the many2one field correctly"); assert.strictEqual(form.$('.o_field_widget[name=trululu]').text(), '', @@ -650,11 +650,10 @@ QUnit.module('relational_fields', { testUtils.form.clickEdit(form); - assert.containsN(form, 'select', 3, - "should have 3 select tag in dom"); - assert.strictEqual(form.$('select[name="product_id"] option:contains(xphone)').length, 1, + assert.containsN(form.$('.o_form_view'), 'select', 3); + assert.containsOnce(form, 'select[name="product_id"] option:contains(xphone)', "should have fetched xphone option"); - assert.strictEqual(form.$('select[name="product_id"] option:contains(xpad)').length, 1, + assert.containsOnce(form, 'select[name="product_id"] option:contains(xpad)', "should have fetched xpad option"); assert.strictEqual(form.$('select[name="product_id"]').val(), "37", "should have correct product_id value"); @@ -757,7 +756,7 @@ QUnit.module('relational_fields', { }, }); - testUtils.fields.editSelect(form.$('select'), "false"); + testUtils.fields.editSelect(form.$('.o_form_view select'), 'false'); testUtils.form.clickSave(form); form.destroy(); @@ -1297,11 +1296,11 @@ QUnit.module('relational_fields', { // update foo, which will trigger an onchange and update timmy // -> m2mtags input should not have taken the focus - form.$('input:first').focus(); - testUtils.fields.editInput(form.$('input:first'), 'trigger onchange'); + form.$('input[name=foo]').focus(); + testUtils.fields.editInput(form.$('input[name=foo]'), 'trigger onchange'); assert.containsNone(form, '.o_field_many2manytags .badge', "should contain no tags"); - assert.strictEqual(form.$('input:first').get(0), document.activeElement, + assert.strictEqual(form.$('input[name=foo]').get(0), document.activeElement, "foo input should have kept the focus"); // add a tag -> m2mtags input should still have the focus @@ -1864,7 +1863,6 @@ QUnit.module('relational_fields', { QUnit.test('name_create in form dialog', async function (assert) { assert.expect(2); - var form = createView({ View: FormView, model: 'partner', @@ -1891,7 +1889,7 @@ QUnit.module('relational_fields', { testUtils.dom.click(form.$('.o_field_x2many_list_row_add a')); await testUtils.fields.many2one.searchAndClickItem('product_id', - {selector:'.modal', search:'new record'}); + {selector: '.modal', search: 'new record'}); assert.verifySteps(['name_create']); @@ -1922,7 +1920,7 @@ QUnit.module('relational_fields', { res_id: 1, }); - // Cuurent Form + // Current Form assert.equal(form.$('.o_form_uri.o_field_widget[name=reference]').text(), 'xphone', 'the field reference of the form should have the right value'); diff --git a/addons/web/static/tests/fields/special_fields.js b/addons/web/static/tests/fields/special_fields.js index 8654c3e0a9f..6acc2be521b 100644 --- a/addons/web/static/tests/fields/special_fields.js +++ b/addons/web/static/tests/fields/special_fields.js @@ -209,7 +209,7 @@ QUnit.module('special_fields', { '</form>', }); testUtils.form.clickEdit(form); - assert.strictEqual(form.$('select').length, 1, "should have the select field"); + assert.containsOnce(form, 'select[name=tz]'); form.destroy(); }); |
