summaryrefslogtreecommitdiff
path: root/addons/web/static/tests/fields/relational_fields/field_one2many_tests.js
diff options
context:
space:
mode:
authorJulien Mougenot <jum@odoo.com>2020-03-11 09:38:30 +0000
committerJulien Mougenot <jum@odoo.com>2020-03-13 14:08:33 +0000
commit804507ef4925cafdf5349a3b7fa1e41dbca87ff7 (patch)
tree09a097ffb347dae1c9dc7879be261ec734f70d4f /addons/web/static/tests/fields/relational_fields/field_one2many_tests.js
parentbb8eb766a84b9fd06007d3fb4ab9a29b70097738 (diff)
[REF] *: Adapt all module tests to the new control panel
Use of the new control panel helpers to increase consistency and change the assertions according to the new DOM/behaviour (e.g. components removed instead of turning invisible). Part of task 2196029 Co-authored-by: Mathieu Duckerts-Antoine <dam@odoo.com>
Diffstat (limited to 'addons/web/static/tests/fields/relational_fields/field_one2many_tests.js')
-rw-r--r--addons/web/static/tests/fields/relational_fields/field_one2many_tests.js33
1 files changed, 15 insertions, 18 deletions
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();
});