diff options
Diffstat (limited to 'addons/web/static/tests/fields/relational_fields')
3 files changed, 30 insertions, 31 deletions
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 a1c306a432c..47fe687d773 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 @@ -3,6 +3,8 @@ odoo.define('web.field_many_to_many_tests', function (require) { var FormView = require('web.FormView'); var testUtils = require('web.test_utils'); + +const cpHelpers = testUtils.controlPanel; var createView = testUtils.createView; QUnit.module('fields', {}, function () { @@ -1003,8 +1005,8 @@ QUnit.module('fields', {}, function () { assert.strictEqual($('.modal .o_data_row').length, 1, "should contain only one row (gold)"); - await testUtils.fields.triggerKey('press', $('.modal .o_searchview_input'), 's'); - await testUtils.fields.triggerKeydown($('.modal .o_searchview_input'), 'enter'); + await cpHelpers.editSearch('.modal', 's'); + await cpHelpers.validateSearch('.modal'); assert.strictEqual($('.modal .o_data_row').length, 0, "should contain no row"); 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 21d74bf0d99..04c934290a1 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 @@ -9,6 +9,7 @@ var StandaloneFieldManagerMixin = require('web.StandaloneFieldManagerMixin'); var testUtils = require('web.test_utils'); var Widget = require('web.Widget'); +const cpHelpers = testUtils.controlPanel; var createView = testUtils.createView; QUnit.module('fields', {}, function () { @@ -244,11 +245,11 @@ QUnit.module('fields', {}, function () { // save form await testUtils.form.clickSave(form); // click next on pager - await testUtils.dom.click(form.pager.$('.o_pager_next')); + await testUtils.dom.click(form.el.querySelector('.o_pager .o_pager_next')); // this checks that the view did not ask for confirmation that the // record is dirty - assert.strictEqual(form.pager.$el.text().trim(), '2 / 2', + assert.strictEqual(form.el.querySelector('.o_pager').innerText.trim(), '2 / 2', 'pager should be at second page'); form.destroy(); }); @@ -316,11 +317,11 @@ QUnit.module('fields', {}, function () { // save form await testUtils.form.clickSave(form); // click next on pager - await testUtils.dom.click(form.pager.$('.o_pager_next')); + await testUtils.dom.click(form.el.querySelector('.o_pager .o_pager_next')); // this checks that the view did not ask for confirmation that the // record is dirty - assert.strictEqual(form.pager.$el.text().trim(), '2 / 2', + assert.strictEqual(form.el.querySelector('.o_pager').innerText.trim(), '2 / 2', 'pager should be at second page'); form.destroy(); }); @@ -506,11 +507,11 @@ QUnit.module('fields', {}, function () { assert.strictEqual($('tr.o_data_row').length, 9, "should display 9 records"); - await testUtils.dom.click($('button:contains(Filters)')); - await testUtils.dom.click($('.o_add_custom_filter:visible')); - assert.strictEqual($('.o_filter_condition select.o_searchview_extended_prop_field').val(), 'datetime', + await cpHelpers.toggleFilterMenu('.modal'); + await cpHelpers.toggleAddCustomFilter('.modal'); + assert.strictEqual(document.querySelector('.modal .o_generator_menu_field').value, 'datetime', "datetime field should be selected"); - await testUtils.dom.click($('.o_apply_filter')); + await cpHelpers.applyFilter('.modal'); assert.strictEqual($('tr.o_data_row').length, 0, "should display 0 records"); form.destroy(); @@ -592,7 +593,6 @@ QUnit.module('fields', {}, function () { assert.containsNone(document.body, '.modal', "No save should be triggered when removing value"); - await testUtils.fields.many2one.clickOpenDropdown('trululu'); await testUtils.fields.many2one.clickHighlightedItem('trululu'); assert.containsOnce(document.body, '.modal', @@ -741,8 +741,8 @@ QUnit.module('fields', {}, function () { assert.ok(!$('.modal .modal-footer .o_select_button').length, "there should be no 'Select' button in the footer"); assert.ok($('.modal tbody tr').length > 10, "list should contain more than 10 records"); - await testUtils.fields.triggerKey('press', $('.modal .o_searchview_input'), 'P'), - await testUtils.fields.triggerKeydown($('.modal .o_searchview_input'), 'enter'); + await cpHelpers.editSearch('.modal', "P"); + await cpHelpers.validateSearch('.modal'); assert.strictEqual($('.modal tbody tr').length, 10, "list should be restricted to records containing a P (10 records)"); // choose a record 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 e24341b1019..e93dc2f39ca 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 @@ -12,6 +12,7 @@ var relationalFields = require('web.relational_fields'); var testUtils = require('web.test_utils'); var fieldUtils = require('web.field_utils'); +const cpHelpers = testUtils.controlPanel; var createView = testUtils.createView; QUnit.module('fields', {}, function () { @@ -1505,7 +1506,7 @@ QUnit.module('fields', {}, function () { "second dialog should be closed"); assert.strictEqual($('.modal .o_data_row').length, 1, "there should be one record in the one2many in the dialog"); - assert.notOk($('.modal .o_x2m_control_panel .o_cp_pager div').is(':visible'), + assert.containsNone($('.modal'), '.o_x2m_control_panel .o_pager', 'm2m pager should be hidden'); // click on 'Save & Close' @@ -1756,16 +1757,14 @@ QUnit.module('fields', {}, function () { // move to record 2, which has 3 related records (and shouldn't contain the // related records of record 1 anymore). Two additional RPCs should have // been done - form.pager.next(); - await testUtils.nextTick(); + await cpHelpers.pagerNext(form); assert.strictEqual(count, 4, 'two RPCs should have been done'); assert.strictEqual(form.$('.o_kanban_record:not(".o_kanban_ghost")').length, 3, 'one2many kanban should contain 3 cards for record 2'); // move back to record 1, which should contain again its first 40 related // records - form.pager.previous(); - await testUtils.nextTick(); + await cpHelpers.pagerPrevious(form); assert.strictEqual(count, 6, 'two RPCs should have been done'); assert.strictEqual(form.$('.o_kanban_record:not(".o_kanban_ghost")').length, 40, 'one2many kanban should contain 40 cards for record 1'); @@ -1778,16 +1777,14 @@ QUnit.module('fields', {}, function () { 'one2many kanban should contain 2 cards for record 1 at page 2'); // move to record 2 again and check that everything is correctly updated - form.pager.next(); - await testUtils.nextTick(); + await cpHelpers.pagerNext(form); assert.strictEqual(count, 9, 'two RPCs should have been done'); assert.strictEqual(form.$('.o_kanban_record:not(".o_kanban_ghost")').length, 3, 'one2many kanban should contain 3 cards for record 2'); // move back to record 1 and move to page 2 again: all data should have // been correctly reloaded - form.pager.previous(); - await testUtils.nextTick(); + await cpHelpers.pagerPrevious(form); assert.strictEqual(count, 11, 'two RPCs should have been done'); await testUtils.dom.click(form.$('.o_x2m_control_panel .o_pager_next')); assert.strictEqual(count, 12, 'one RPC should have been done'); @@ -2565,7 +2562,7 @@ QUnit.module('fields', {}, function () { await testUtils.dom.click(form.$('.o_field_x2many_list_row_add a')); await testUtils.dom.click(form.$el); - assert.strictEqual(form.$('.o_field_widget[name=turtles] .o_cp_pager').text().trim(), '1-3 / 5', + assert.strictEqual(form.$('.o_field_widget[name=turtles] .o_pager').text().trim(), '1-3 / 5', "pager should display the correct total"); form.destroy(); }); @@ -2898,7 +2895,7 @@ QUnit.module('fields', {}, function () { await testUtils.form.clickEdit(form); await testUtils.dom.click(form.$('.o_field_x2many_list_row_add a')); // the record currently being added should not count in the pager - assert.isNotVisible(form.$('.o_field_widget[name=turtles] .o_cp_pager')); + assert.containsNone(form, '.o_field_widget[name=turtles] .o_pager'); form.destroy(); }); @@ -2931,8 +2928,8 @@ QUnit.module('fields', {}, function () { // confirm the discard operation await testUtils.dom.click($('.modal .modal-footer .btn-primary')); - 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', + assert.isVisible(form.$('.o_field_widget[name=turtles] .o_pager')); + assert.strictEqual(form.$('.o_field_widget[name=turtles] .o_pager').text().trim(), '1-3 / 4', "pager should display correct values"); form.destroy(); @@ -3001,13 +2998,13 @@ QUnit.module('fields', {}, function () { // see a confirm dialog await testUtils.dom.click(form.$('.o_field_widget[name=turtles] .o_pager_next')); - assert.strictEqual(form.$('.o_field_widget[name=turtles] .o_cp_pager').text().trim(), '1-3 / 4', + assert.strictEqual(form.$('.o_field_widget[name=turtles] .o_pager').text().trim(), '1-3 / 4', "pager should still display the correct total"); // click on cancel await testUtils.dom.click($('.modal .modal-footer .btn-secondary')); - assert.strictEqual(form.$('.o_field_widget[name=turtles] .o_cp_pager').text().trim(), '1-3 / 4', + assert.strictEqual(form.$('.o_field_widget[name=turtles] .o_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"); @@ -3048,7 +3045,7 @@ QUnit.module('fields', {}, function () { await testUtils.dom.click($('.modal .modal-footer .btn-primary')); assert.containsOnce(form, 'tr.o_data_row'); - assert.isNotVisible(form.$('.o_field_widget[name=turtles] .o_cp_pager')); + assert.containsNone(form, '.o_field_widget[name=turtles] .o_pager'); form.destroy(); }); @@ -3911,14 +3908,14 @@ QUnit.module('fields', {}, function () { '</form>', }); - assert.ok(!form.$('.o_x2m_control_panel .o_cp_pager div').is(':visible'), + assert.containsNone(form, '.o_x2m_control_panel .o_pager', 'o2m pager should be hidden'); // click to create a subrecord await testUtils.dom.click(form.$('tbody td.o_field_x2many_list_row_add a')); assert.containsOnce(form, 'tr.o_data_row'); - assert.ok(!form.$('.o_x2m_control_panel .o_cp_pager div').is(':visible'), + assert.containsNone(form, '.o_x2m_control_panel .o_pager', 'o2m pager should be hidden'); form.destroy(); }); |
