summaryrefslogtreecommitdiff
path: root/addons/web/static/tests/fields
diff options
context:
space:
mode:
authorVincent Schippefilt <vsc@odoo.com>2019-03-06 14:02:32 +0100
committerAaron Bohy <aab@odoo.com>2019-03-06 20:07:17 +0100
commitab56e637b7f97ddcdbcc9baea99ae097e342409c (patch)
tree4cb47da9f7ef89b19d18429220a7507470ec12a9 /addons/web/static/tests/fields
parenteeed894fd50e477135e1ac9a82f6e98ce063ab90 (diff)
[REF] web: adapt code after jQuery update
Part of task 1896658 Co-authored-by: Aaron Bohy <aab@odoo.com> Co-authored-by: Christophe Matthieu <chm@odoo.com> Co-authored-by: Mathieu Duckerts-Antoine <dam@odoo.com> Co-authored-by: David Monjoie <dmo@odoo.com> Co-authored-by: Martin Geubelle <mge@odoo.com> Co-authored-by: svs-odoo <svs@odoo.com> Co-authored-by: Vincent Schippefilt <vsc@odoo.com>
Diffstat (limited to 'addons/web/static/tests/fields')
-rw-r--r--addons/web/static/tests/fields/basic_fields_mobile_tests.js28
-rw-r--r--addons/web/static/tests/fields/basic_fields_tests.js1187
-rw-r--r--addons/web/static/tests/fields/relational_fields/field_many2many_tests.js233
-rw-r--r--addons/web/static/tests/fields/relational_fields/field_many2one_tests.js1080
-rw-r--r--addons/web/static/tests/fields/relational_fields/field_one2many_tests.js2021
-rw-r--r--addons/web/static/tests/fields/relational_fields_mobile_tests.js12
-rw-r--r--addons/web/static/tests/fields/relational_fields_tests.js749
-rw-r--r--addons/web/static/tests/fields/special_fields.js29
-rw-r--r--addons/web/static/tests/fields/upgrade_fields_tests.js10
9 files changed, 2628 insertions, 2721 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 fd302ebeb36..a58957ebfca 100644
--- a/addons/web/static/tests/fields/basic_fields_mobile_tests.js
+++ b/addons/web/static/tests/fields/basic_fields_mobile_tests.js
@@ -53,10 +53,10 @@ QUnit.module('basic_fields', {
QUnit.module('PhoneWidget');
- QUnit.test('phone field in form view on extra small screens', function (assert) {
+ QUnit.test('phone field in form view on extra small screens', async function (assert) {
assert.expect(7);
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -79,17 +79,17 @@ QUnit.module('basic_fields', {
"should have proper tel prefix");
// switch to edit mode and check the result
- testUtils.form.clickEdit(form);
+ await testUtils.form.clickEdit(form);
assert.containsOnce(form, 'input[type="text"].o_field_widget',
"should have an int for the phone field");
assert.strictEqual(form.$('input[type="text"].o_field_widget').val(), 'yop',
"input should contain field value in edit mode");
// change value in edit mode
- testUtils.fields.editInput(form.$('input[type="text"].o_field_widget'), 'new');
+ await testUtils.fields.editInput(form.$('input[type="text"].o_field_widget'), 'new');
// save
- testUtils.form.clickSave(form);
+ await testUtils.form.clickSave(form);
$phoneLink = form.$('a.o_form_uri.o_field_widget');
assert.strictEqual($phoneLink.text(), 'new',
"new value should be displayed properly");
@@ -99,10 +99,10 @@ QUnit.module('basic_fields', {
form.destroy();
});
- QUnit.test('phone field in editable list view on extra small screens', function (assert) {
+ QUnit.test('phone field in editable list view on extra small screens', async function (assert) {
assert.expect(10);
- var list = createView({
+ var list = await createView({
View: ListView,
model: 'partner',
data: this.data,
@@ -122,14 +122,14 @@ QUnit.module('basic_fields', {
// Edit a line and check the result
var $cell = list.$('tbody td:not(.o_list_record_selector)').first();
- testUtils.dom.click($cell);
+ await testUtils.dom.click($cell);
assert.hasClass($cell.parent(),'o_selected_row', 'should be set as edit mode');
assert.strictEqual($cell.find('input').val(), 'yop',
'should have the corect value in internal input');
- testUtils.fields.editInput($cell.find('input'), 'new');
+ await testUtils.fields.editInput($cell.find('input'), 'new');
// save
- testUtils.dom.click(list.$buttons.find('.o_list_button_save'));
+ await testUtils.dom.click(list.$buttons.find('.o_list_button_save'));
$cell = list.$('tbody td:not(.o_list_record_selector)').first();
assert.doesNotHaveClass($cell.parent(), 'o_selected_row', 'should not be in edit mode anymore');
assert.strictEqual(list.$('tbody td:not(.o_list_record_selector)').first().text(), 'new',
@@ -143,10 +143,10 @@ QUnit.module('basic_fields', {
list.destroy();
});
- QUnit.test('phone field does not allow html injections', function (assert) {
+ QUnit.test('phone field does not allow html injections', async function (assert) {
assert.expect(1);
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -164,10 +164,10 @@ QUnit.module('basic_fields', {
});
var val = '<script>throw Error();</script><script>throw Error();</script>';
- testUtils.fields.editInput(form.$('input.o_field_widget[name="foo"]'), val);
+ await testUtils.fields.editInput(form.$('input.o_field_widget[name="foo"]'), val);
// save
- testUtils.form.clickSave(form);
+ await testUtils.form.clickSave(form);
assert.strictEqual(form.$('.o_field_widget').text(), val,
"value should have been correctly escaped");
diff --git a/addons/web/static/tests/fields/basic_fields_tests.js b/addons/web/static/tests/fields/basic_fields_tests.js
index 33f18558917..223e1e5764c 100644
--- a/addons/web/static/tests/fields/basic_fields_tests.js
+++ b/addons/web/static/tests/fields/basic_fields_tests.js
@@ -13,7 +13,7 @@ var testUtils = require('web.test_utils');
var field_registry = require('web.field_registry');
var createView = testUtils.createView;
-var createAsyncView = testUtils.createAsyncView;
+var createView = testUtils.createView;
var DebouncedField = basicFields.DebouncedField;
var JournalDashboardGraph = basicFields.JournalDashboardGraph;
var _t = core._t;
@@ -128,11 +128,10 @@ QUnit.module('basic_fields', {
QUnit.module('DebouncedField');
- QUnit.test('debounced fields do not trigger call _setValue once destroyed', function (assert) {
- var done = assert.async();
+ QUnit.test('debounced fields do not trigger call _setValue once destroyed', async function (assert) {
assert.expect(4);
- var def = $.Deferred();
+ var def = testUtils.makeTestPromise();
var _doAction = DebouncedField.prototype._doAction;
DebouncedField.prototype._doAction = function () {
_doAction.apply(this, arguments);
@@ -144,7 +143,7 @@ QUnit.module('basic_fields', {
_setValue.apply(this, arguments);
};
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -167,31 +166,28 @@ QUnit.module('basic_fields', {
assert.verifySteps([], "_setValue shouldn't have been called yet");
// save
- testUtils.form.clickSave(form);
+ await testUtils.form.clickSave(form);
assert.verifySteps(['_setValue'], "_setValue should have been called once");
// destroy the form view
- def = $.Deferred();
+ def = testUtils.makeTestPromise();
form.destroy();
+ await testUtils.nextMicrotaskTick();
// wait for the debounced callback to be called
- def.then(function () {
- assert.verifySteps(['_setValue'],
- "_setValue should not have been called after widget destruction");
-
- DebouncedField.prototype._doAction = _doAction;
- DebouncedField.prototype._setValue = _setValue;
- done();
- });
+ assert.verifySteps([],
+ "_setValue should not have been called after widget destruction");
+ DebouncedField.prototype._doAction = _doAction;
+ DebouncedField.prototype._setValue = _setValue;
});
QUnit.module('FieldBoolean');
- QUnit.test('boolean field in form view', function (assert) {
- assert.expect(12);
+ QUnit.test('boolean field in form view', async function (assert) {
+ assert.expect(13);
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -203,70 +199,73 @@ QUnit.module('basic_fields', {
"checkbox should be checked");
// switch to edit mode and check the result
- testUtils.form.clickEdit(form);
+ await testUtils.form.clickEdit(form);
assert.containsOnce(form, '.o_field_boolean input:checked',
"checkbox should still be checked");
// uncheck the checkbox
- testUtils.dom.click(form.$('.o_field_boolean input:checked'));
+ await testUtils.dom.click(form.$('.o_field_boolean input:checked'));
assert.containsNone(form, '.o_field_boolean input:checked',
"checkbox should no longer be checked");
// save
- testUtils.form.clickSave(form);
+ await testUtils.form.clickSave(form);
assert.containsNone(form, '.o_field_boolean input:checked',
"checkbox should still no longer be checked");
// switch to edit mode and test the opposite change
- testUtils.form.clickEdit(form);
+ await testUtils.form.clickEdit(form);
assert.containsNone(form, '.o_field_boolean input:checked',
"checkbox should still be unchecked");
// check the checkbox
- testUtils.dom.click(form.$('.o_field_boolean input'));
+ await testUtils.dom.click(form.$('.o_field_boolean input'));
assert.containsOnce(form, '.o_field_boolean input:checked',
"checkbox should now be checked");
// uncheck it back
- testUtils.dom.click(form.$('.o_field_boolean input'));
+ await testUtils.dom.click(form.$('.o_field_boolean input'));
assert.containsNone(form, '.o_field_boolean input:checked',
"checkbox should now be unchecked");
// check the checkbox by clicking on label
- testUtils.dom.click(form.$('.o_form_view label:first'));
+ await 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.$('.o_form_view label:first'));
+ await testUtils.dom.click(form.$('.o_form_view label:first'));
assert.containsNone(form, '.o_field_boolean input:checked',
"checkbox should now be unchecked");
// check the checkbox by hitting the "enter" key after focusing it
- form.$('.o_field_boolean input')
- .trigger("focusin")
- .trigger({type: "keydown", which: $.ui.keyCode.ENTER})
- .trigger({type: "keyup", which: $.ui.keyCode.ENTER});
+ await testUtils.dom.triggerEvents(form.$('.o_field_boolean input'), [
+ "focusin",
+ {type: "keydown", which: $.ui.keyCode.ENTER},
+ {type: "keyup", which: $.ui.keyCode.ENTER}]);
assert.containsOnce(form, '.o_field_boolean input:checked',
- "checkbox should now be checked");
+ "checkbox should now be checked");
// blindly press enter again, it should uncheck the checkbox
$(document.activeElement).trigger({type: "keydown", which: $.ui.keyCode.ENTER});
assert.containsNone(form, '.o_field_boolean input:checked',
- "checkbox should not be checked");
+ "checkbox should not be checked");
+ await testUtils.nextTick();
// blindly press enter again, it should check the checkbox back
$(document.activeElement).trigger({type: "keydown", which: $.ui.keyCode.ENTER});
+ assert.containsOnce(form, '.o_field_boolean input:checked',
+ "checkbox should still be checked");
// save
- testUtils.form.clickSave(form);
+ await testUtils.form.clickSave(form);
assert.containsOnce(form, '.o_field_boolean input:checked',
"checkbox should still be checked");
form.destroy();
});
- QUnit.test('boolean field in editable list view', function (assert) {
+ QUnit.test('boolean field in editable list view', async function (assert) {
assert.expect(11);
- var list = createView({
+ var list = await createView({
View: ListView,
model: 'partner',
data: this.data,
@@ -282,13 +281,13 @@ QUnit.module('basic_fields', {
var $cell = list.$('tr.o_data_row:has(.custom-checkbox input:checked) td:not(.o_list_record_selector)').first();
assert.ok($cell.find('.custom-checkbox input:checked').prop('disabled'),
"input should be disabled in readonly mode");
- testUtils.dom.click($cell);
+ await testUtils.dom.click($cell);
assert.ok(!$cell.find('.custom-checkbox input:checked').prop('disabled'),
"input should not have the disabled property in edit mode");
- testUtils.dom.click($cell.find('.custom-checkbox input:checked'));
+ await testUtils.dom.click($cell.find('.custom-checkbox input:checked'));
// save
- testUtils.dom.click(list.$buttons.find('.o_list_button_save'));
+ await testUtils.dom.click(list.$buttons.find('.o_list_button_save'));
$cell = list.$('tr.o_data_row:has(.custom-checkbox input:not(:checked)) td:not(.o_list_record_selector)').first();
assert.ok($cell.find('.custom-checkbox input:not(:checked)').prop('disabled'),
"input should be disabled again");
@@ -298,12 +297,12 @@ QUnit.module('basic_fields', {
"should now have only 3 checked input");
// Re-Edit the line and fake-check the checkbox
- testUtils.dom.click($cell);
- testUtils.dom.click($cell.find('.custom-checkbox input'));
- testUtils.dom.click($cell.find('.custom-checkbox input'));
+ await testUtils.dom.click($cell);
+ await testUtils.dom.click($cell.find('.custom-checkbox input'));
+ await testUtils.dom.click($cell.find('.custom-checkbox input'));
// Save
- testUtils.dom.click(list.$buttons.find('.o_list_button_save'));
+ await testUtils.dom.click(list.$buttons.find('.o_list_button_save'));
assert.strictEqual(list.$('tbody td:not(.o_list_record_selector) .custom-checkbox input').length, 5,
"should still have 5 checkboxes");
assert.strictEqual(list.$('tbody td:not(.o_list_record_selector) .custom-checkbox input:checked').length, 3,
@@ -312,7 +311,7 @@ QUnit.module('basic_fields', {
// Re-Edit the line to check the checkbox back but this time click on
// the checkbox directly in readonly mode !
$cell = list.$('tr.o_data_row:has(.custom-checkbox input:not(:checked)) td:not(.o_list_record_selector)').first();
- testUtils.dom.click($cell.find('.custom-checkbox .custom-control-label'));
+ await testUtils.dom.click($cell.find('.custom-checkbox .custom-control-label'));
assert.strictEqual(list.$('tbody td:not(.o_list_record_selector) .custom-checkbox input').length, 5,
"should still have 5 checkboxes");
@@ -324,7 +323,7 @@ QUnit.module('basic_fields', {
QUnit.module('FieldBooleanButton');
- QUnit.test('use custom terminology in form view', function (assert) {
+ QUnit.test('use custom terminology in form view', async function (assert) {
assert.expect(2);
var terminology = {
string_true: "Production Environment",
@@ -332,7 +331,7 @@ QUnit.module('basic_fields', {
string_false: "Test Environment",
hover_false: "Switch to production environment"
};
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -356,10 +355,10 @@ QUnit.module('basic_fields', {
QUnit.module('FieldBooleanToggle');
- QUnit.test('use boolean toggle widget in form view', function (assert) {
+ QUnit.test('use boolean toggle widget in form view', async function (assert) {
assert.expect(1);
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -373,10 +372,10 @@ QUnit.module('basic_fields', {
QUnit.module('FieldToggleButton');
- QUnit.test('use toggle_button in list view', function (assert) {
+ QUnit.test('use toggle_button in list view', async function (assert) {
assert.expect(6);
- var list = createView({
+ var list = await createView({
View: ListView,
model: 'partner',
data: this.data,
@@ -397,20 +396,20 @@ QUnit.module('basic_fields', {
"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.$('.o_list_view button').first());
+ await 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.$('.o_list_view button').first());
+ await 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();
});
- QUnit.test('toggle_button in form view (edit mode)', function (assert) {
+ QUnit.test('toggle_button in form view (edit mode)', async function (assert) {
assert.expect(6);
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -434,14 +433,14 @@ QUnit.module('basic_fields', {
1, "should be green");
// click on the button to toggle the value
- testUtils.dom.click(form.$('.o_field_widget[name=bar]'));
+ await testUtils.dom.click(form.$('.o_field_widget[name=bar]'));
assert.strictEqual(form.$('.o_field_widget[name=bar] i.text-muted:not(.o_toggle_button_success)').length,
1, "should be gray");
assert.verifySteps([]);
// save
- testUtils.form.clickSave(form);
+ await testUtils.form.clickSave(form);
assert.strictEqual(form.$('.o_field_widget[name=bar] i.text-muted:not(.o_toggle_button_success)').length,
1, "should still be gray");
@@ -450,10 +449,10 @@ QUnit.module('basic_fields', {
form.destroy();
});
- QUnit.test('toggle_button in form view (readonly mode)', function (assert) {
+ QUnit.test('toggle_button in form view (readonly mode)', async function (assert) {
assert.expect(4);
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -474,7 +473,7 @@ QUnit.module('basic_fields', {
1, "should be green");
// click on the button to toggle the value
- testUtils.dom.click(form.$('.o_field_widget[name=bar]'));
+ await testUtils.dom.click(form.$('.o_field_widget[name=bar]'));
assert.strictEqual(form.$('.o_field_widget[name=bar] i.text-muted:not(.o_toggle_button_success)').length,
1, "should be gray");
@@ -485,10 +484,10 @@ QUnit.module('basic_fields', {
QUnit.module('FieldFloat');
- QUnit.test('float field when unset', function (assert) {
+ QUnit.test('float field when unset', async function (assert) {
assert.expect(2);
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -508,10 +507,10 @@ QUnit.module('basic_fields', {
form.destroy();
});
- QUnit.test('float fields use correct digit precision', function (assert) {
+ QUnit.test('float fields use correct digit precision', async function (assert) {
assert.expect(1);
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -529,10 +528,10 @@ QUnit.module('basic_fields', {
form.destroy();
});
- QUnit.test('float field in form view', function (assert) {
+ QUnit.test('float field in form view', async function (assert) {
assert.expect(5);
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -549,26 +548,26 @@ QUnit.module('basic_fields', {
assert.strictEqual(form.$('.o_field_widget').first().text(), '0.000',
'The value should be displayed properly.');
- testUtils.form.clickEdit(form);
+ await testUtils.form.clickEdit(form);
assert.strictEqual(form.$('input[name=qux]').val(), '0.000',
'The value should be rendered with correct precision.');
- testUtils.fields.editInput(form.$('input[name=qux]'), '108.2458938598598');
+ await 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[name=qux]'), '18.8958938598598');
- testUtils.form.clickSave(form);
+ await testUtils.fields.editInput(form.$('input[name=qux]'), '18.8958938598598');
+ await testUtils.form.clickSave(form);
assert.strictEqual(form.$('.o_field_widget').first().text(), '18.896',
'The new value should be rounded properly.');
form.destroy();
});
- QUnit.test('float field in editable list view', function (assert) {
+ QUnit.test('float field in editable list view', async function (assert) {
assert.expect(4);
- var list = createView({
+ var list = await createView({
View: ListView,
model: 'partner',
data: this.data,
@@ -583,29 +582,29 @@ QUnit.module('basic_fields', {
// switch to edit mode
var $cell = list.$('tr.o_data_row td:not(.o_list_record_selector)').first();
- testUtils.dom.click($cell);
+ await testUtils.dom.click($cell);
assert.containsOnce(list, 'input[name="qux"]',
'The view should have 1 input for editable float.');
- testUtils.fields.editInput(list.$('input[name="qux"]'), '108.2458938598598');
+ await testUtils.fields.editInput(list.$('input[name="qux"]'), '108.2458938598598');
assert.strictEqual(list.$('input[name="qux"]').val(), '108.2458938598598',
'The value should not be formated yet.');
- testUtils.fields.editInput(list.$('input[name="qux"]'), '18.8958938598598');
- testUtils.dom.click(list.$buttons.find('.o_list_button_save'));
+ await testUtils.fields.editInput(list.$('input[name="qux"]'), '18.8958938598598');
+ await testUtils.dom.click(list.$buttons.find('.o_list_button_save'));
assert.strictEqual(list.$('.o_field_widget').first().text(), '18.896',
'The new value should be rounded properly.');
list.destroy();
});
- QUnit.test('do not trigger a field_changed if they have not changed', function (assert) {
+ QUnit.test('do not trigger a field_changed if they have not changed', async function (assert) {
assert.expect(2);
this.data.partner.records[1].qux = false;
this.data.partner.records[1].int_field = false;
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -622,22 +621,22 @@ QUnit.module('basic_fields', {
}
});
- testUtils.form.clickEdit(form);
- testUtils.form.clickSave(form);
+ await testUtils.form.clickEdit(form);
+ await testUtils.form.clickSave(form);
assert.verifySteps(['read']); // should not have save as nothing changed
form.destroy();
});
- QUnit.test('float widget on monetary field', function (assert) {
+ QUnit.test('float widget on monetary field', async function (assert) {
assert.expect(1);
this.data.partner.fields.monetary = {string: "Monetary", type: 'monetary'};
this.data.partner.records[0].monetary = 9.99;
this.data.partner.records[0].currency_id = 1;
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -659,7 +658,7 @@ QUnit.module('basic_fields', {
form.destroy();
});
- QUnit.test('float field with monetary widget and decimal precision', function (assert) {
+ QUnit.test('float field with monetary widget and decimal precision', async function (assert) {
assert.expect(5);
this.data.partner.records = [{
@@ -667,7 +666,7 @@ QUnit.module('basic_fields', {
qux: -8.89859,
currency_id: 1,
}];
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -687,17 +686,17 @@ QUnit.module('basic_fields', {
assert.strictEqual(form.$('.o_field_widget').first().text(), '$\u00a0-8.9',
'The value should be displayed properly.');
- testUtils.form.clickEdit(form);
+ await testUtils.form.clickEdit(form);
assert.strictEqual(form.$('.o_field_widget[name=qux] input').val(), '-8.9',
'The input should be rendered without the currency symbol.');
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');
+ await testUtils.fields.editInput(form.$('.o_field_monetary input'), '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);
+ await testUtils.form.clickSave(form);
// Non-breaking space between the currency and the amount
assert.strictEqual(form.$('.o_field_widget').first().text(), '$\u00a0109.2',
'The new value should be rounded properly.');
@@ -705,10 +704,10 @@ QUnit.module('basic_fields', {
form.destroy();
});
- QUnit.test('float field with type number option', function (assert) {
+ QUnit.test('float field with type number option', async function (assert) {
assert.expect(4);
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -722,27 +721,27 @@ QUnit.module('basic_fields', {
},
});
- testUtils.form.clickEdit(form);
+ await testUtils.form.clickEdit(form);
assert.ok(form.$('.o_field_widget')[0].hasAttribute('type'),
'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[name=qux]'), '123456.7890');
- testUtils.form.clickSave(form);
- testUtils.form.clickEdit(form);
+ await testUtils.fields.editInput(form.$('input[name=qux]'), '123456.7890');
+ await testUtils.form.clickSave(form);
+ await testUtils.form.clickEdit(form);
assert.strictEqual(form.$('.o_field_widget').val(), '123456.789',
'Float value must be not formatted if input type is number.');
- testUtils.form.clickSave(form);
+ await testUtils.form.clickSave(form);
assert.strictEqual(form.$('.o_field_widget').text(), '123,456.8',
'Float value must be formatted in readonly view even if the input type is number.');
form.destroy();
});
- QUnit.test('float field without type number option', function (assert) {
+ QUnit.test('float field without type number option', async function (assert) {
assert.expect(2);
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -756,13 +755,13 @@ QUnit.module('basic_fields', {
},
});
- testUtils.form.clickEdit(form);
+ await testUtils.form.clickEdit(form);
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[name=qux]'), '123456.7890');
- testUtils.form.clickSave(form);
- testUtils.form.clickEdit(form);
+ await testUtils.fields.editInput(form.$('input[name=qux]'), '123456.7890');
+ await testUtils.form.clickSave(form);
+ await testUtils.form.clickEdit(form);
assert.strictEqual(form.$('.o_field_widget').val(), '123,456.8',
'Float value must be formatted if input type isn\'t number.');
@@ -772,10 +771,10 @@ QUnit.module('basic_fields', {
QUnit.module('FieldEmail');
- QUnit.test('email field in form view', function (assert) {
+ QUnit.test('email field in form view', async function (assert) {
assert.expect(7);
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -798,17 +797,17 @@ QUnit.module('basic_fields', {
"should have proper mailto prefix");
// switch to edit mode and check the result
- testUtils.form.clickEdit(form);
+ await testUtils.form.clickEdit(form);
assert.containsOnce(form, 'input[type="text"].o_field_widget',
"should have an input for the email field");
assert.strictEqual(form.$('input[type="text"].o_field_widget').val(), 'yop',
"input should contain field value in edit mode");
// change value in edit mode
- testUtils.fields.editInput(form.$('input[type="text"].o_field_widget'), 'new');
+ await testUtils.fields.editInput(form.$('input[type="text"].o_field_widget'), 'new');
// save
- testUtils.form.clickSave(form);
+ await testUtils.form.clickSave(form);
$mailtoLink = form.$('a.o_form_uri.o_field_widget.o_text_overflow');
assert.strictEqual($mailtoLink.text(), 'new',
"new value should be displayed properly");
@@ -818,10 +817,10 @@ QUnit.module('basic_fields', {
form.destroy();
});
- QUnit.test('email field in editable list view', function (assert) {
+ QUnit.test('email field in editable list view', async function (assert) {
assert.expect(10);
- var list = createView({
+ var list = await createView({
View: ListView,
model: 'partner',
data: this.data,
@@ -841,14 +840,14 @@ QUnit.module('basic_fields', {
// Edit a line and check the result
var $cell = list.$('tbody td:not(.o_list_record_selector)').first();
- testUtils.dom.click($cell);
+ await testUtils.dom.click($cell);
assert.hasClass($cell.parent(),'o_selected_row', 'should be set as edit mode');
assert.strictEqual($cell.find('input').val(), 'yop',
'should have the corect value in internal input');
- testUtils.fields.editInput($cell.find('input'), 'new');
+ await testUtils.fields.editInput($cell.find('input'), 'new');
// save
- testUtils.dom.click(list.$buttons.find('.o_list_button_save'));
+ await testUtils.dom.click(list.$buttons.find('.o_list_button_save'));
$cell = list.$('tbody td:not(.o_list_record_selector)').first();
assert.doesNotHaveClass($cell.parent(), 'o_selected_row', 'should not be in edit mode anymore');
assert.strictEqual(list.$('tbody td:not(.o_list_record_selector)').first().text(), 'new',
@@ -865,11 +864,11 @@ QUnit.module('basic_fields', {
QUnit.module('FieldChar');
- QUnit.test('char widget isValid method works', function (assert) {
+ QUnit.test('char widget isValid method works', async function (assert) {
assert.expect(1);
this.data.partner.fields.foo.required = true;
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -884,10 +883,10 @@ QUnit.module('basic_fields', {
form.destroy();
});
- QUnit.test('char field in form view', function (assert) {
+ QUnit.test('char field in form view', async function (assert) {
assert.expect(4);
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -905,26 +904,26 @@ QUnit.module('basic_fields', {
"the value should be displayed properly");
// switch to edit mode and check the result
- testUtils.form.clickEdit(form);
+ await testUtils.form.clickEdit(form);
assert.containsOnce(form, 'input[type="text"].o_field_widget',
"should have an input for the char field");
assert.strictEqual(form.$('input[type="text"].o_field_widget').val(), 'yop',
"input should contain field value in edit mode");
// change value in edit mode
- testUtils.fields.editInput(form.$('input[type="text"].o_field_widget'), 'limbo');
+ await testUtils.fields.editInput(form.$('input[type="text"].o_field_widget'), 'limbo');
// save
- testUtils.form.clickSave(form);
+ await testUtils.form.clickSave(form);
assert.strictEqual(form.$('.o_field_widget').text(), 'limbo',
'the new value should be displayed');
form.destroy();
});
- QUnit.test('setting a char field to empty string is saved as a false value', function (assert) {
+ QUnit.test('setting a char field to empty string is saved as a false value', async function (assert) {
assert.expect(1);
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -946,18 +945,18 @@ QUnit.module('basic_fields', {
}
});
- testUtils.fields.editInput(form.$('input[type="text"].o_field_widget'), '');
+ await testUtils.fields.editInput(form.$('input[type="text"].o_field_widget'), '');
// save
- testUtils.form.clickSave(form);
+ await testUtils.form.clickSave(form);
form.destroy();
});
- QUnit.test('char field with size attribute', function (assert) {
+ QUnit.test('char field with size attribute', async function (assert) {
assert.expect(1);
this.data.partner.fields.foo.size = 5; // max length
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -978,10 +977,10 @@ QUnit.module('basic_fields', {
form.destroy();
});
- QUnit.test('char field in editable list view', function (assert) {
+ QUnit.test('char field in editable list view', async function (assert) {
assert.expect(6);
- var list = createView({
+ var list = await createView({
View: ListView,
model: 'partner',
data: this.data,
@@ -995,14 +994,14 @@ QUnit.module('basic_fields', {
// Edit a line and check the result
var $cell = list.$('tbody td:not(.o_list_record_selector)').first();
- testUtils.dom.click($cell);
+ await testUtils.dom.click($cell);
assert.hasClass($cell.parent(),'o_selected_row', 'should be set as edit mode');
assert.strictEqual($cell.find('input').val(), 'yop',
'should have the corect value in internal input');
- testUtils.fields.editInput($cell.find('input'), 'brolo');
+ await testUtils.fields.editInput($cell.find('input'), 'brolo');
// save
- testUtils.dom.click(list.$buttons.find('.o_list_button_save'));
+ await testUtils.dom.click(list.$buttons.find('.o_list_button_save'));
$cell = list.$('tbody td:not(.o_list_record_selector)').first();
assert.doesNotHaveClass($cell.parent(), 'o_selected_row', 'should not be in edit mode anymore');
assert.strictEqual(list.$('tbody td:not(.o_list_record_selector)').first().text(), 'brolo',
@@ -1010,7 +1009,7 @@ QUnit.module('basic_fields', {
list.destroy();
});
- QUnit.test('char field translatable', function (assert) {
+ QUnit.test('char field translatable', async function (assert) {
assert.expect(3);
this.data.partner.fields.foo.translate = true;
@@ -1018,7 +1017,7 @@ QUnit.module('basic_fields', {
var multiLang = _t.database.multi_lang;
_t.database.multi_lang = true;
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -1033,18 +1032,18 @@ QUnit.module('basic_fields', {
mockRPC: function (route, args) {
if (route === "/web/dataset/call_button" && args.method === 'translate_fields') {
assert.deepEqual(args.args, ["partner",1,"foo",{}], 'should call "call_button" route');
- return $.when();
+ return Promise.resolve();
}
return this._super.apply(this, arguments);
},
});
- testUtils.form.clickEdit(form);
+ await testUtils.form.clickEdit(form);
var $button = form.$('input[type="text"].o_field_char + .o_field_translate');
assert.strictEqual($button.length, 1, "should have a translate button");
- testUtils.dom.click($button);
+ await testUtils.dom.click($button);
form.destroy();
- form = createView({
+ form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -1063,10 +1062,10 @@ QUnit.module('basic_fields', {
_t.database.multi_lang = multiLang;
});
- QUnit.test('char field does not allow html injections', function (assert) {
+ QUnit.test('char field does not allow html injections', async function (assert) {
assert.expect(1);
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -1083,20 +1082,20 @@ QUnit.module('basic_fields', {
},
});
- testUtils.fields.editInput(form.$('input[name=foo]'), '<script>throw Error();</script>');
- testUtils.form.clickSave(form);
+ await testUtils.fields.editInput(form.$('input[name=foo]'), '<script>throw Error();</script>');
+ await testUtils.form.clickSave(form);
assert.strictEqual(form.$('.o_field_widget').text(), '<script>throw Error();</script>',
'the value should have been properly escaped');
form.destroy();
});
- QUnit.test('char field trim (or not) characters', function (assert) {
+ QUnit.test('char field trim (or not) characters', async function (assert) {
assert.expect(2);
this.data.partner.fields.foo2 = {string: "Foo2", type: "char", trim: false};
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -1114,13 +1113,13 @@ QUnit.module('basic_fields', {
},
});
- testUtils.fields.editInput(form.$('input[name="foo"]'), ' abc ');
- testUtils.fields.editInput(form.$('input[name="foo2"]'), ' def ');
+ await testUtils.fields.editInput(form.$('input[name="foo"]'), ' abc ');
+ await testUtils.fields.editInput(form.$('input[name="foo2"]'), ' def ');
- testUtils.form.clickSave(form);
+ await testUtils.form.clickSave(form);
// edit mode
- testUtils.form.clickEdit(form);
+ await testUtils.form.clickEdit(form);
assert.strictEqual(form.$('input[name="foo"]').val(), 'abc', 'Foo value should have been trimmed');
assert.strictEqual(form.$('input[name="foo2"]').val(), ' def ', 'Foo2 value should not have been trimmed');
@@ -1128,7 +1127,7 @@ QUnit.module('basic_fields', {
form.destroy();
});
- QUnit.test('input field: change value before pending onchange returns', function (assert) {
+ QUnit.test('input field: change value before pending onchange returns', async function (assert) {
assert.expect(3);
this.data.partner.onchanges = {
@@ -1136,7 +1135,7 @@ QUnit.module('basic_fields', {
};
var def;
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -1154,7 +1153,7 @@ QUnit.module('basic_fields', {
mockRPC: function (route, args) {
var result = this._super.apply(this, arguments);
if (args.method === "onchange") {
- return $.when(def).then(function () {
+ return Promise.resolve(def).then(function () {
return result;
});
} else {
@@ -1166,29 +1165,31 @@ QUnit.module('basic_fields', {
},
});
- testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
+ await testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
assert.strictEqual(form.$('input[name="foo"]').val(), 'My little Foo Value',
'should contain the default value');
- def = $.Deferred();
+ def = testUtils.makeTestPromise();
- testUtils.fields.many2one.clickOpenDropdown('product_id');
- testUtils.fields.many2one.clickHighlightedItem('product_id');
+ await testUtils.fields.many2one.clickOpenDropdown('product_id');
+ await testUtils.fields.many2one.clickHighlightedItem('product_id');
// set foo before onchange
- testUtils.fields.editInput(form.$('input[name="foo"]'), "tralala");
+ await testUtils.fields.editInput(form.$('input[name="foo"]'), "tralala");
assert.strictEqual(form.$('input[name="foo"]').val(), 'tralala',
'input should contain tralala');
// complete the onchange
def.resolve();
+ await testUtils.nextTick();
+
assert.strictEqual(form.$('input[name="foo"]').val(), 'tralala',
'input should contain the same value as before onchange');
form.destroy();
});
- QUnit.test('input field: change value before pending onchange renaming', function (assert) {
+ QUnit.test('input field: change value before pending onchange renaming', async function (assert) {
assert.expect(3);
this.data.partner.onchanges = {
@@ -1197,8 +1198,8 @@ QUnit.module('basic_fields', {
},
};
- var def = $.Deferred();
- var form = createView({
+ var def = testUtils.makeTestPromise();
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -1212,7 +1213,7 @@ QUnit.module('basic_fields', {
mockRPC: function (route, args) {
var result = this._super.apply(this, arguments);
if (args.method === "onchange") {
- return $.when(def).then(function () {
+ return def.then(function () {
return result;
});
} else {
@@ -1227,8 +1228,8 @@ QUnit.module('basic_fields', {
assert.strictEqual(form.$('input[name="foo"]').val(), 'yop',
'should contain the correct value');
- testUtils.fields.many2one.clickOpenDropdown('product_id');
- testUtils.fields.many2one.clickHighlightedItem('product_id');
+ await testUtils.fields.many2one.clickOpenDropdown('product_id');
+ await testUtils.fields.many2one.clickHighlightedItem('product_id');
// set foo before onchange
testUtils.fields.editInput(form.$('input[name="foo"]'), "tralala");
@@ -1243,10 +1244,10 @@ QUnit.module('basic_fields', {
form.destroy();
});
- QUnit.test('input field: change password value', function (assert) {
+ QUnit.test('input field: change password value', async function (assert) {
assert.expect(4);
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -1261,7 +1262,7 @@ QUnit.module('basic_fields', {
assert.strictEqual(form.$('.o_field_char').text(), "***",
"password field value should be hidden with '*' in read mode");
- testUtils.form.clickEdit(form);
+ await testUtils.form.clickEdit(form);
assert.hasAttrValue(form.$('input.o_field_char'), 'type', 'password',
"password field input should be with type 'password' in edit mode");
@@ -1271,12 +1272,12 @@ QUnit.module('basic_fields', {
form.destroy();
});
- QUnit.test('input field: empty password', function (assert) {
+ QUnit.test('input field: empty password', async function (assert) {
assert.expect(3);
this.data.partner.records[0].foo = false;
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -1289,7 +1290,7 @@ QUnit.module('basic_fields', {
assert.strictEqual(form.$('.o_field_char').text(), "",
"password field value should be empty in read mode");
- testUtils.form.clickEdit(form);
+ await testUtils.form.clickEdit(form);
assert.hasAttrValue(form.$('input.o_field_char'), 'type', 'password',
"password field input should be with type 'password' in edit mode");
@@ -1301,10 +1302,10 @@ QUnit.module('basic_fields', {
QUnit.module('UrlWidget');
- QUnit.test('url widget in form view', function (assert) {
+ QUnit.test('url widget in form view', async function (assert) {
assert.expect(9);
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -1328,7 +1329,7 @@ QUnit.module('basic_fields', {
"the value should be displayed properly");
// switch to edit mode and check the result
- testUtils.form.clickEdit(form);
+ await testUtils.form.clickEdit(form);
assert.containsOnce(form, 'input[type="text"].o_field_widget',
"should have an input for the char field");
assert.strictEqual(form.$('input[type="text"].o_field_widget').val(), 'yop',
@@ -1338,7 +1339,7 @@ QUnit.module('basic_fields', {
testUtils.fields.editInput(form.$('input[type="text"].o_field_widget'), 'limbo');
// save
- testUtils.form.clickSave(form);
+ await testUtils.form.clickSave(form);
assert.containsOnce(form, 'a.o_form_uri.o_field_widget.o_text_overflow',
"should still have a anchor with correct classes");
assert.hasAttrValue(form.$('a.o_form_uri.o_field_widget.o_text_overflow'), 'href', 'limbo',
@@ -1349,10 +1350,10 @@ QUnit.module('basic_fields', {
form.destroy();
});
- QUnit.test('url widget takes text from proper attribute', function (assert) {
+ QUnit.test('url widget takes text from proper attribute', async function (assert) {
assert.expect(1);
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -1367,10 +1368,10 @@ QUnit.module('basic_fields', {
form.destroy();
});
- QUnit.test('char field in editable list view', function (assert) {
+ QUnit.test('char field in editable list view', async function (assert) {
assert.expect(10);
- var list = createView({
+ var list = await createView({
View: ListView,
model: 'partner',
data: this.data,
@@ -1388,14 +1389,14 @@ QUnit.module('basic_fields', {
// Edit a line and check the result
var $cell = list.$('tbody td:not(.o_list_record_selector)').first();
- testUtils.dom.click($cell);
+ await testUtils.dom.click($cell);
assert.hasClass($cell.parent(),'o_selected_row', 'should be set as edit mode');
assert.strictEqual($cell.find('input').val(), 'yop',
'should have the corect value in internal input');
- testUtils.fields.editInput($cell.find('input'), 'brolo');
+ await testUtils.fields.editInput($cell.find('input'), 'brolo');
// save
- testUtils.dom.click(list.$buttons.find('.o_list_button_save'));
+ await testUtils.dom.click(list.$buttons.find('.o_list_button_save'));
$cell = list.$('tbody td:not(.o_list_record_selector)').first();
assert.doesNotHaveClass($cell.parent(), 'o_selected_row', 'should not be in edit mode anymore');
assert.containsN(list, 'a.o_form_uri.o_field_widget.o_text_overflow', 5,
@@ -1426,10 +1427,10 @@ QUnit.module('basic_fields', {
}
});
- QUnit.test('Char & Text Fields: Copy to clipboard button', function (assert) {
+ QUnit.test('Char & Text Fields: Copy to clipboard button', async function (assert) {
assert.expect(2);
var done = assert.async();
- testUtils.createAsyncView({
+ testUtils.createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -1451,11 +1452,11 @@ QUnit.module('basic_fields', {
QUnit.module('FieldText');
- QUnit.test('text fields are correctly rendered', function (assert) {
+ QUnit.test('text fields are correctly rendered', async function (assert) {
assert.expect(7);
this.data.partner.fields.foo.type = 'text';
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -1469,7 +1470,7 @@ QUnit.module('basic_fields', {
assert.ok(form.$('.o_field_text').length, "should have a text area");
assert.strictEqual(form.$('.o_field_text').text(), 'yop', 'should be "yop" in readonly');
- testUtils.form.clickEdit(form);
+ await testUtils.form.clickEdit(form);
var $textarea = form.$('textarea.o_field_text');
assert.ok($textarea.length, "should have a text area");
@@ -1481,19 +1482,19 @@ QUnit.module('basic_fields', {
testUtils.fields.editInput($textarea, 'hello world');
assert.strictEqual($textarea.val(), 'hello world', 'should be "hello world" after second edition');
- testUtils.form.clickSave(form);
+ await testUtils.form.clickSave(form);
assert.strictEqual(form.$('.o_field_text').text(), 'hello world',
'should be "hello world" after save');
form.destroy();
});
- QUnit.test('text fields in edit mode have correct height', function (assert) {
+ QUnit.test('text fields in edit mode have correct height', async function (assert) {
assert.expect(2);
this.data.partner.fields.foo.type = 'text';
this.data.partner.records[0].foo = "f\nu\nc\nk\nm\ni\nl\ng\nr\no\nm";
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -1505,23 +1506,23 @@ QUnit.module('basic_fields', {
var $field = form.$('.o_field_text');
- assert.strictEqual($field.outerHeight(), $field[0].scrollHeight,
+ assert.strictEqual($field[0].offsetHeight, $field[0].scrollHeight,
"text field should not have a scroll bar");
- testUtils.form.clickEdit(form);
+ await testUtils.form.clickEdit(form);
var $textarea = form.$('textarea:first');
// the difference is to take small calculation errors into account
- assert.strictEqual($textarea.innerHeight(), $textarea[0].scrollHeight,
+ assert.strictEqual($textarea[0].clientHeight, $textarea[0].scrollHeight,
"textarea should not have a scroll bar");
form.destroy();
});
- QUnit.test('text fields in edit mode, no vertical resize', function (assert) {
+ QUnit.test('text fields in edit mode, no vertical resize', async function (assert) {
assert.expect(1);
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -1531,7 +1532,7 @@ QUnit.module('basic_fields', {
res_id: 1,
});
- testUtils.form.clickEdit(form);
+ await testUtils.form.clickEdit(form);
var $textarea = form.$('textarea:first');
@@ -1541,12 +1542,12 @@ QUnit.module('basic_fields', {
form.destroy();
});
- QUnit.test('text fields in editable list have correct height', function (assert) {
+ QUnit.test('text fields in editable list have correct height', async function (assert) {
assert.expect(2);
this.data.partner.records[0].txt = "a\nb\nc\nd\ne\nf";
- var list = createView({
+ var list = await createView({
View: ListView,
model: 'partner',
data: this.data,
@@ -1560,20 +1561,20 @@ QUnit.module('basic_fields', {
// the focus on the textarea by clicking on another column.
// The main goal is to test the resize is actually triggered in this
// particular case.
- testUtils.dom.click(list.$('.o_data_cell:first'));
+ await testUtils.dom.click(list.$('.o_data_cell:first'));
var $textarea = list.$('textarea:first');
// make sure the correct data is there
assert.strictEqual($textarea.val(), this.data.partner.records[0].txt);
// make sure there is no scroll bar
- assert.strictEqual($textarea.innerHeight(), $textarea[0].scrollHeight,
+ assert.strictEqual($textarea[0].clientHeight, $textarea[0].scrollHeight,
"textarea should not have a scroll bar");
list.destroy();
});
- QUnit.test('text fields in edit mode should resize on reset', function (assert) {
+ QUnit.test('text fields in edit mode should resize on reset', async function (assert) {
assert.expect(1);
this.data.partner.fields.foo.type = 'text';
@@ -1584,7 +1585,7 @@ QUnit.module('basic_fields', {
},
};
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -1598,9 +1599,9 @@ QUnit.module('basic_fields', {
// edit the form
// trigger a textarea reset (through onchange) by clicking the box
// then check there is no scroll bar
- testUtils.form.clickEdit(form);
+ await testUtils.form.clickEdit(form);
- testUtils.dom.click(form.$('div[name="bar"] input'));
+ await testUtils.dom.click(form.$('div[name="bar"] input'));
var $textarea = form.$('textarea:first');
assert.strictEqual($textarea.innerHeight(), $textarea[0].scrollHeight,
@@ -1609,7 +1610,7 @@ QUnit.module('basic_fields', {
form.destroy();
});
- QUnit.test('text field translatable', function (assert) {
+ QUnit.test('text field translatable', async function (assert) {
assert.expect(3);
this.data.partner.fields.txt.translate = true;
@@ -1617,7 +1618,7 @@ QUnit.module('basic_fields', {
var multiLang = _t.database.multi_lang;
_t.database.multi_lang = true;
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -1632,18 +1633,18 @@ QUnit.module('basic_fields', {
mockRPC: function (route, args) {
if (route === "/web/dataset/call_button" && args.method === 'translate_fields') {
assert.deepEqual(args.args, ["partner",1,"txt",{}], 'should call "call_button" route');
- return $.when();
+ return Promise.resolve();
}
return this._super.apply(this, arguments);
},
});
- testUtils.form.clickEdit(form);
+ await testUtils.form.clickEdit(form);
var $button = form.$('textarea + .o_field_translate');
assert.strictEqual($button.length, 1, "should have a translate button");
- testUtils.dom.click($button);
+ await testUtils.dom.click($button);
form.destroy();
- form = createView({
+ form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -1662,11 +1663,11 @@ QUnit.module('basic_fields', {
_t.database.multi_lang = multiLang;
});
- QUnit.test('go to next line (and not the next row) when pressing enter', function (assert) {
+ QUnit.test('go to next line (and not the next row) when pressing enter', async function (assert) {
assert.expect(4);
this.data.partner.fields.foo.type = 'text';
- var list = createView({
+ var list = await createView({
View: ListView,
model: 'partner',
data: this.data,
@@ -1677,7 +1678,7 @@ QUnit.module('basic_fields', {
'</list>',
});
- testUtils.dom.click(list.$('tbody tr:first .o_list_text'));
+ await testUtils.dom.click(list.$('tbody tr:first .o_list_text'));
var $textarea = list.$('textarea.o_field_text');
assert.strictEqual($textarea.length, 1, "should have a text area");
assert.strictEqual($textarea.val(), 'yop', 'should still be "yop" in edit');
@@ -1699,10 +1700,10 @@ QUnit.module('basic_fields', {
// Firefox-specific
// Copying from <div style="white-space:pre-wrap"> does not keep line breaks
// See https://bugzilla.mozilla.org/show_bug.cgi?id=1390115
- QUnit.test('copying text fields in RO mode should preserve line breaks', function (assert) {
+ QUnit.test('copying text fields in RO mode should preserve line breaks', async function (assert) {
assert.expect(1);
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -1725,7 +1726,7 @@ QUnit.module('basic_fields', {
QUnit.module('FieldBinary');
- QUnit.test('binary fields are correctly rendered', function (assert) {
+ QUnit.test('binary fields are correctly rendered', async function (assert) {
assert.expect(16);
// save the session function
@@ -1736,11 +1737,11 @@ QUnit.module('basic_fields', {
assert.strictEqual(option.data.data, 'coucou==\n',
"we should download the correct data");
option.complete();
- return $.when();
+ return Promise.resolve();
};
this.data.partner.records[0].foo = 'coucou.txt';
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -1758,9 +1759,9 @@ QUnit.module('basic_fields', {
assert.strictEqual(form.$('.o_field_char').text(), 'coucou.txt',
"the filename field should have the file name as value");
- testUtils.dom.click(form.$('a.o_field_widget[name="document"]'));
+ await testUtils.dom.click(form.$('a.o_field_widget[name="document"]'));
- testUtils.form.clickEdit(form);
+ await testUtils.form.clickEdit(form);
assert.containsNone(form, 'a.o_field_widget[name="document"] > .fa-download',
"the binary field should not be rendered as a downloadable link in edit");
@@ -1774,7 +1775,7 @@ QUnit.module('basic_fields', {
"the filename field should have the file name as value");
- testUtils.dom.click(form.$('.o_field_binary_file > .o_clear_file_button'));
+ await testUtils.dom.click(form.$('.o_field_binary_file > .o_clear_file_button'));
assert.isNotVisible(form.$('.o_field_binary_file > input'),
"the input should be hidden");
@@ -1783,7 +1784,7 @@ QUnit.module('basic_fields', {
assert.strictEqual(form.$('input.o_field_char').val(), '',
"the filename field should be empty since we removed the file");
- testUtils.form.clickSave(form);
+ await testUtils.form.clickSave(form);
assert.containsNone(form, 'a.o_field_widget[name="document"] > .fa-download',
"the binary field should not render as a downloadable link since we removed the file");
assert.strictEqual(form.$('a.o_field_widget[name="document"]').text().trim(), '',
@@ -1797,7 +1798,7 @@ QUnit.module('basic_fields', {
session.get_file = oldGetFile;
});
- QUnit.test('binary fields that are readonly in create mode do not download', function (assert) {
+ QUnit.test('binary fields that are readonly in create mode do not download', async function (assert) {
assert.expect(2);
// save the session function
@@ -1815,7 +1816,7 @@ QUnit.module('basic_fields', {
this.data.partner.fields.document.readonly = true;
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -1826,9 +1827,9 @@ QUnit.module('basic_fields', {
res_id: 1,
});
- testUtils.form.clickCreate(form);
- testUtils.fields.many2one.clickOpenDropdown('product_id');
- testUtils.fields.many2one.clickHighlightedItem('product_id');
+ await testUtils.form.clickCreate(form);
+ await testUtils.fields.many2one.clickOpenDropdown('product_id');
+ await testUtils.fields.many2one.clickHighlightedItem('product_id');
assert.containsOnce(form, 'a.o_field_widget[name="document"] > .fa-download',
'The link to download the binary should be present');
@@ -1843,10 +1844,10 @@ QUnit.module('basic_fields', {
QUnit.module('FieldPdfViewer');
- QUnit.test("pdf_viewer without data", function (assert) {
+ QUnit.test("pdf_viewer without data", async function (assert) {
assert.expect(4);
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -1867,10 +1868,10 @@ QUnit.module('basic_fields', {
form.destroy();
});
- QUnit.test("pdf_viewer: basic rendering", function (assert) {
+ QUnit.test("pdf_viewer: basic rendering", async function (assert) {
assert.expect(4);
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -1881,7 +1882,7 @@ QUnit.module('basic_fields', {
'</form>',
mockRPC: function (route) {
if (route.indexOf('/web/static/lib/pdfjs/web/viewer.html') !== -1) {
- return $.when();
+ return Promise.resolve();
}
return this._super.apply(this, arguments);
}
@@ -1899,7 +1900,7 @@ QUnit.module('basic_fields', {
form.destroy();
});
- QUnit.test("pdf_viewer: upload rendering", function (assert) {
+ QUnit.test("pdf_viewer: upload rendering", async function (assert) {
assert.expect(6);
testUtils.mock.patch(field_registry.map.pdf_viewer, {
@@ -1908,7 +1909,7 @@ QUnit.module('basic_fields', {
this._super.apply(this, arguments);
},
_getURI: function (fileURI) {
- var res = this._super.apply(this, arguments);
+ this._super.apply(this, arguments);
assert.step('_getURI');
assert.ok(_.str.startsWith(fileURI, 'blob:'));
this.PDFViewerApplication = {
@@ -1921,7 +1922,7 @@ QUnit.module('basic_fields', {
},
});
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -1936,13 +1937,13 @@ QUnit.module('basic_fields', {
assert.verifySteps(['_getURI']);
// second upload call pdfjs method inside iframe
form.$('input[type="file"]').trigger('change');
- assert.verifySteps(['_getURI', 'open']);
+ assert.verifySteps(['open']);
testUtils.mock.unpatch(field_registry.map.pdf_viewer);
form.destroy();
});
- QUnit.test('text field rendering in list view', function (assert) {
+ QUnit.test('text field rendering in list view', async function (assert) {
assert.expect(1);
var data = {
@@ -1951,7 +1952,7 @@ QUnit.module('basic_fields', {
records: [{id: 1, foo: "some text"}]
},
};
- var list = createView({
+ var list = await createView({
View: ListView,
model: 'foo',
data: data,
@@ -1963,12 +1964,12 @@ QUnit.module('basic_fields', {
list.destroy();
});
- QUnit.test('field text in editable list view', function (assert) {
+ QUnit.test('field text in editable list view', async function (assert) {
assert.expect(1);
this.data.partner.fields.foo.type = 'text';
- var list = createView({
+ var list = await createView({
View: ListView,
model: 'partner',
data: this.data,
@@ -1977,22 +1978,22 @@ QUnit.module('basic_fields', {
'</tree>',
});
- testUtils.dom.click(list.$buttons.find('.o_list_button_add'));
+ await testUtils.dom.click(list.$buttons.find('.o_list_button_add'));
assert.strictEqual(list.$('textarea').first().get(0), document.activeElement,
"text area should have the focus");
list.destroy();
});
- QUnit.test('field changes are correctly debounced in text fields', function (assert) {
+ QUnit.test('field changes are correctly debounced in text fields', async function (assert) {
var done = assert.async();
assert.expect(5);
this.data.partner.fields.foo.type = 'text';
- var def = $.Deferred();
+ var def = testUtils.makeTestPromise();
var nbNotifyChanges = 0;
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -2010,7 +2011,7 @@ QUnit.module('basic_fields', {
def.resolve();
};
- testUtils.form.clickEdit(form);
+ await testUtils.form.clickEdit(form);
testUtils.fields.editInput(form.$('textarea').first(), "1");
assert.strictEqual(nbNotifyChanges, 0,
@@ -2019,13 +2020,12 @@ QUnit.module('basic_fields', {
assert.strictEqual(nbNotifyChanges, 0,
"no event should have been triggered");
- return waitForChangeTriggered().then(function () {
+ return waitForChangeTriggered().then(async function () {
assert.strictEqual(nbNotifyChanges, 1,
"one event should have been triggered");
// add something in the textarea, then focus another input
- testUtils.fields.editInput(form.$('textarea').first(), "123");
- form.$('textarea').first().change();
+ await testUtils.fields.editInput(form.$('textarea').first(), "123");
assert.strictEqual(nbNotifyChanges, 2,
"one event should have been triggered immediately");
@@ -2040,7 +2040,7 @@ QUnit.module('basic_fields', {
function waitForChangeTriggered() {
return def.then(function () {
- def = $.Deferred();
+ def = testUtils.makeTestPromise();
return concurrency.delay(0);
});
}
@@ -2048,13 +2048,13 @@ QUnit.module('basic_fields', {
QUnit.module('FieldImage');
- QUnit.test('image fields are correctly rendered', function (assert) {
+ QUnit.test('image fields are correctly rendered', async function (assert) {
assert.expect(7);
this.data.partner.records[0].__last_update = '2017-02-08 10:00:00';
this.data.partner.records[0].document = 'myimage';
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -2068,7 +2068,7 @@ QUnit.module('basic_fields', {
}
if (route === 'data:image/png;base64,myimage') {
assert.ok(true, "should called the correct route");
- return $.when('wow');
+ return Promise.resolve('wow');
}
return this._super.apply(this, arguments);
},
@@ -2087,7 +2087,7 @@ QUnit.module('basic_fields', {
form.destroy();
});
- QUnit.test('image fields in subviews are loaded correctly', function (assert) {
+ QUnit.test('image fields in subviews are loaded correctly', async function (assert) {
assert.expect(6);
this.data.partner.records[0].__last_update = '2017-02-08 10:00:00';
@@ -2096,7 +2096,7 @@ QUnit.module('basic_fields', {
this.data.partner_type.records[0].image = 'product_image';
this.data.partner.records[0].timmy = [12];
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -2112,14 +2112,14 @@ QUnit.module('basic_fields', {
'</field>' +
'</form>',
res_id: 1,
- mockRPC: function (route, args) {
+ mockRPC: function (route) {
if (route === 'data:image/png;base64,myimage') {
assert.step("The view's image should have been fetched");
- return $.when('wow');
+ return Promise.resolve('wow');
}
if (route === 'data:image/png;base64,product_image') {
assert.step("The dialog's image should have been fetched");
- return $.when();
+ return Promise.resolve();
}
return this._super.apply(this, arguments);
},
@@ -2130,25 +2130,22 @@ QUnit.module('basic_fields', {
'There should be one record in the many2many');
// Actual flow: click on an element of the m2m to get its form view
- testUtils.dom.click(form.$('tbody td:contains(gold)'));
+ await testUtils.dom.click(form.$('tbody td:contains(gold)'));
assert.strictEqual($('.modal').length, 1,
'The modal should have opened');
- assert.verifySteps([
- "The view's image should have been fetched",
- "The dialog's image should have been fetched",
- ]);
+ assert.verifySteps(["The dialog's image should have been fetched"]);
form.destroy();
});
- QUnit.test('image fields in x2many list are loaded correctly', function (assert) {
+ QUnit.test('image fields in x2many list are loaded correctly', async function (assert) {
assert.expect(2);
this.data.partner_type.fields.image = {name: 'image', type: 'binary'};
this.data.partner_type.records[0].image = 'product_image';
this.data.partner.records[0].timmy = [12];
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -2160,10 +2157,10 @@ QUnit.module('basic_fields', {
'</field>' +
'</form>',
res_id: 1,
- mockRPC: function (route, args) {
+ mockRPC: function (route) {
if (route === 'data:image/png;base64,product_image') {
assert.ok(true, "The list's image should have been fetched");
- return $.when();
+ return Promise.resolve();
}
return this._super.apply(this, arguments);
},
@@ -2175,10 +2172,10 @@ QUnit.module('basic_fields', {
form.destroy();
});
- QUnit.test('image fields with required attribute', function (assert) {
+ QUnit.test('image fields with required attribute', async function (assert) {
assert.expect(2);
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -2193,7 +2190,7 @@ QUnit.module('basic_fields', {
},
});
- testUtils.form.clickSave(form);
+ await testUtils.form.clickSave(form);
assert.hasClass(form.$('.o_form_view'),'o_form_editable',
"form view should still be editable");
@@ -2237,7 +2234,7 @@ QUnit.module('basic_fields', {
},
});
- QUnit.test('graph dashboard widget attach/detach callbacks', function (assert) {
+ QUnit.test('graph dashboard widget attach/detach callbacks', async function (assert) {
// This widget is rendered with nvd3, and nvd3 renders the graphs when
// the svg is in the DOM. The intent of this test is to determine when
// the field widgets are in the DOM, so that we can tell nvd3 to render
@@ -2254,7 +2251,7 @@ QUnit.module('basic_fields', {
},
});
- createAsyncView({
+ createView({
View: KanbanView,
model: 'partner',
data: this.data,
@@ -2276,8 +2273,6 @@ QUnit.module('basic_fields', {
kanban.on_detach_callback();
assert.verifySteps([
- 'on_attach_callback',
- 'on_attach_callback',
'on_detach_callback',
'on_detach_callback'
]);
@@ -2288,12 +2283,12 @@ QUnit.module('basic_fields', {
});
});
- QUnit.test('graph dashboard widget is rendered correctly', function (assert) {
+ QUnit.test('graph dashboard widget is rendered correctly', async function (assert) {
var done = assert.async();
assert.expect(4);
var graph_key = JSON.parse(this.data.partner.records[0].graph_data)[0].key;
- createAsyncView({
+ createView({
View: KanbanView,
model: 'partner',
data: this.data,
@@ -2343,7 +2338,7 @@ QUnit.module('basic_fields', {
});
});
- QUnit.test('graph dashboard widget does not need nv to be destroyed', function (assert) {
+ QUnit.test('graph dashboard widget does not need nv to be destroyed', async function (assert) {
// this test ensures that the JournalDashboardGraph widget doesn't crash
// when being destroyed before nv has been loaded
assert.expect(2);
@@ -2358,7 +2353,7 @@ QUnit.module('basic_fields', {
}
});
- var kanban = createView({
+ var kanban = await createView({
View: KanbanView,
model: 'partner',
data: this.data,
@@ -2382,7 +2377,7 @@ QUnit.module('basic_fields', {
return concurrency.delay(0);
});
- QUnit.test('graph dashboard widget can be destroyed when nv is partially loaded', function (assert) {
+ QUnit.test('graph dashboard widget can be destroyed when nv is partially loaded', async function (assert) {
// this test ensures that the JournalDashboardGraph widget doesn't crash
// when being destroyed before nv has been completely loaded
assert.expect(2);
@@ -2400,7 +2395,7 @@ QUnit.module('basic_fields', {
},
});
- var kanban = createView({
+ var kanban = await createView({
View: KanbanView,
model: 'partner',
data: this.data,
@@ -2424,12 +2419,12 @@ QUnit.module('basic_fields', {
return concurrency.delay(0);
});
- QUnit.test('rendering of a field with dashboard_graph widget in an updated kanban view (ungrouped)', function (assert) {
+ QUnit.test('rendering of a field with dashboard_graph widget in an updated kanban view (ungrouped)', async function (assert) {
var done = assert.async();
assert.expect(2);
- createAsyncView({
+ createView({
View: KanbanView,
model: 'partner',
data: this.data,
@@ -2460,12 +2455,12 @@ QUnit.module('basic_fields', {
});
});
- QUnit.test('rendering of a field with dashboard_graph widget in an updated kanban view (grouped)', function (assert) {
+ QUnit.test('rendering of a field with dashboard_graph widget in an updated kanban view (grouped)', async function (assert) {
var done = assert.async();
assert.expect(2);
- createAsyncView({
+ createView({
View: KanbanView,
model: 'partner',
data: this.data,
@@ -2496,12 +2491,12 @@ QUnit.module('basic_fields', {
QUnit.module('AceEditor');
- QUnit.test('ace widget on text fields works', function (assert) {
+ QUnit.test('ace widget on text fields works', async function (assert) {
assert.expect(2);
var done = assert.async();
this.data.partner.fields.foo.type = 'text';
- testUtils.createAsyncView({
+ testUtils.createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -2519,11 +2514,11 @@ QUnit.module('basic_fields', {
QUnit.module('HandleWidget');
- QUnit.test('handle widget in x2m', function (assert) {
+ QUnit.test('handle widget in x2m', async function (assert) {
assert.expect(6);
this.data.partner.records[0].p = [2, 4];
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -2546,7 +2541,7 @@ QUnit.module('basic_fields', {
assert.containsN(form, 'span.o_row_handle', 2, "should have 2 handles");
- testUtils.form.clickEdit(form);
+ await testUtils.form.clickEdit(form);
assert.hasClass(form.$('td:first'),'o_handle_cell',
"column widget should be displayed in css class");
@@ -2560,10 +2555,10 @@ QUnit.module('basic_fields', {
form.destroy();
});
- QUnit.test('handle widget with falsy values', function (assert) {
+ QUnit.test('handle widget with falsy values', async function (assert) {
assert.expect(1);
- var list = createView({
+ var list = await createView({
View: ListView,
model: 'partner',
data: this.data,
@@ -2581,10 +2576,10 @@ QUnit.module('basic_fields', {
QUnit.module('FieldDate');
- QUnit.test('date field: toggle datepicker', function (assert) {
+ QUnit.test('date field: toggle datepicker [REQUIRE FOCUS]', async function (assert) {
assert.expect(3);
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -2597,13 +2592,13 @@ QUnit.module('basic_fields', {
assert.strictEqual($('.bootstrap-datetimepicker-widget:visible').length, 0,
"datepicker should be closed initially");
- testUtils.dom.openDatepicker(form.$('.o_datepicker'));
+ await testUtils.dom.openDatepicker(form.$('.o_datepicker'));
assert.strictEqual($('.bootstrap-datetimepicker-widget:visible').length, 1,
"datepicker should be opened");
// focus another field
- testUtils.dom.click(form.$('.o_field_widget[name=foo]').focus().mouseenter());
+ await testUtils.dom.click(form.$('.o_field_widget[name=foo]').focus().mouseenter());
assert.strictEqual($('.bootstrap-datetimepicker-widget:visible').length, 0,
"datepicker should close itself when the user clicks outside");
@@ -2611,10 +2606,10 @@ QUnit.module('basic_fields', {
form.destroy();
});
- QUnit.test('date field is empty if no date is set', function (assert) {
+ QUnit.test('date field is empty if no date is set', async function (assert) {
assert.expect(2);
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -2627,10 +2622,10 @@ QUnit.module('basic_fields', {
form.destroy();
});
- QUnit.test('date field value should not set on first click', function (assert) {
+ QUnit.test('date field value should not set on first click', async function (assert) {
assert.expect(2);
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -2638,7 +2633,7 @@ QUnit.module('basic_fields', {
res_id: 4,
});
- testUtils.form.clickEdit(form);
+ await testUtils.form.clickEdit(form);
// open datepicker and select a date
testUtils.dom.openDatepicker(form.$('.o_datepicker'));
@@ -2653,10 +2648,10 @@ QUnit.module('basic_fields', {
form.destroy();
});
- QUnit.test('date field in form view (with positive time zone offset)', function (assert) {
+ QUnit.test('date field in form view (with positive time zone offset)', async function (assert) {
assert.expect(8);
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -2682,7 +2677,7 @@ QUnit.module('basic_fields', {
'the date should be correctly displayed in readonly');
// switch to edit mode
- testUtils.form.clickEdit(form);
+ await testUtils.form.clickEdit(form);
assert.strictEqual(form.$('.o_datepicker_input').val(), '02/03/2017',
'the date should be correct in edit mode');
@@ -2700,16 +2695,16 @@ QUnit.module('basic_fields', {
'the selected date should be displayed in the input');
// save
- testUtils.form.clickSave(form);
+ await testUtils.form.clickSave(form);
assert.strictEqual(form.$('.o_field_date').text(), '02/22/2017',
'the selected date should be displayed after saving');
form.destroy();
});
- QUnit.test('date field in form view (with negative time zone offset)', function (assert) {
+ QUnit.test('date field in form view (with negative time zone offset)', async function (assert) {
assert.expect(2);
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -2729,17 +2724,17 @@ QUnit.module('basic_fields', {
'the date should be correctly displayed in readonly');
// switch to edit mode
- testUtils.form.clickEdit(form);
+ await testUtils.form.clickEdit(form);
assert.strictEqual(form.$('.o_datepicker_input').val(), '02/03/2017',
'the date should be correct in edit mode');
form.destroy();
});
- QUnit.test('date field with warn_future option', function (assert) {
+ QUnit.test('date field with warn_future option', async function (assert) {
assert.expect(2);
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -2750,7 +2745,7 @@ QUnit.module('basic_fields', {
});
// switch to edit mode
- testUtils.form.clickEdit(form);
+ await testUtils.form.clickEdit(form);
// open datepicker and select another value
testUtils.dom.openDatepicker(form.$('.o_datepicker'));
testUtils.dom.click($('.bootstrap-datetimepicker-widget .picker-switch').first());
@@ -2770,7 +2765,7 @@ QUnit.module('basic_fields', {
form.destroy();
});
- QUnit.test('date field with warn_future option: do not overwrite datepicker option', function (assert) {
+ QUnit.test('date field with warn_future option: do not overwrite datepicker option', async function (assert) {
assert.expect(2);
// Making sure we don't have a legit default value
@@ -2778,7 +2773,7 @@ QUnit.module('basic_fields', {
this.data.partner.fields.date.default = undefined;
this.data.partner.onchanges = {};
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -2790,15 +2785,15 @@ QUnit.module('basic_fields', {
});
// switch to edit mode
- form.$buttons.find('.o_form_button_edit').click();
+ await testUtils.form.clickEdit(form);
assert.strictEqual(form.$('input[name="date"]').val(), '02/03/2017',
- 'The existing record should have a value for the date field');
+ 'The existing record should have a value for the date field');
// save with no changes
- form.$buttons.find('.o_form_button_save').click();
+ await testUtils.form.clickSave(form);
//Create a new record
- form.$buttons.find('.o_form_button_create').click();
+ await testUtils.form.clickCreate(form);
assert.notOk(form.$('input[name="date"]').val(),
'The new record should not have a value that the framework would have set');
@@ -2806,10 +2801,10 @@ QUnit.module('basic_fields', {
form.destroy();
});
- QUnit.test('date field in editable list view', function (assert) {
+ QUnit.test('date field in editable list view', async function (assert) {
assert.expect(8);
- var list = createView({
+ var list = await createView({
View: ListView,
model: 'partner',
data: this.data,
@@ -2829,7 +2824,7 @@ QUnit.module('basic_fields', {
var $cell = list.$('tr.o_data_row td:not(.o_list_record_selector)').first();
assert.strictEqual($cell.text(), '02/03/2017',
'the date should be displayed correctly in readonly');
- testUtils.dom.click($cell);
+ await testUtils.dom.click($cell);
assert.containsOnce(list, 'input.o_datepicker_input',
"the view should have a date input for editable mode");
@@ -2841,29 +2836,29 @@ QUnit.module('basic_fields', {
'the date should be correct in edit mode');
// open datepicker and select another value
- testUtils.dom.openDatepicker(list.$('.o_datepicker'));
+ await testUtils.dom.openDatepicker(list.$('.o_datepicker'));
assert.ok($('.bootstrap-datetimepicker-widget').length, 'datepicker should be open');
- testUtils.dom.click($('.bootstrap-datetimepicker-widget .picker-switch').first());
- testUtils.dom.click($('.bootstrap-datetimepicker-widget .picker-switch:eq(1)'));
- testUtils.dom.click($('.bootstrap-datetimepicker-widget .year:contains(2017)'));
- testUtils.dom.click($('.bootstrap-datetimepicker-widget .month').eq(1));
- testUtils.dom.click($('.day:contains(22)'));
+ await testUtils.dom.click($('.bootstrap-datetimepicker-widget .picker-switch').first());
+ await testUtils.dom.click($('.bootstrap-datetimepicker-widget .picker-switch:eq(1)'));
+ await testUtils.dom.click($('.bootstrap-datetimepicker-widget .year:contains(2017)'));
+ await testUtils.dom.click($('.bootstrap-datetimepicker-widget .month').eq(1));
+ await testUtils.dom.click($('.day:contains(22)'));
assert.ok(!$('.bootstrap-datetimepicker-widget').length, 'datepicker should be closed');
assert.strictEqual(list.$('.o_datepicker_input').val(), '02/22/2017',
'the selected date should be displayed in the input');
// save
- testUtils.dom.click(list.$buttons.find('.o_list_button_save'));
+ await testUtils.dom.click(list.$buttons.find('.o_list_button_save'));
assert.strictEqual(list.$('tr.o_data_row td:not(.o_list_record_selector)').text(), '02/22/2017',
'the selected date should be displayed after saving');
list.destroy();
});
- QUnit.test('date field remove value', function (assert) {
+ QUnit.test('date field remove value', async function (assert) {
assert.expect(4);
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -2881,7 +2876,7 @@ QUnit.module('basic_fields', {
});
// switch to edit mode
- testUtils.form.clickEdit(form);
+ await testUtils.form.clickEdit(form);
assert.strictEqual(form.$('.o_datepicker_input').val(), '02/03/2017',
'the date should be correct in edit mode');
@@ -2890,17 +2885,17 @@ QUnit.module('basic_fields', {
'should have correctly removed the value');
// save
- testUtils.form.clickSave(form);
+ await testUtils.form.clickSave(form);
assert.strictEqual(form.$('.o_field_date').text(), '',
'the selected date should be displayed after saving');
form.destroy();
});
- QUnit.test('do not trigger a field_changed for datetime field with date widget', function (assert) {
+ QUnit.test('do not trigger a field_changed for datetime field with date widget', async function (assert) {
assert.expect(3);
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -2923,18 +2918,18 @@ QUnit.module('basic_fields', {
'the date should be correct');
testUtils.fields.editAndTrigger(form.$('input[name="datetime"]'),'02/08/2017', ['input', 'change', 'focusout']);
- testUtils.form.clickSave(form);
+ await testUtils.form.clickSave(form);
assert.verifySteps(['read']); // should not have save as nothing changed
form.destroy();
});
- QUnit.test('field date should select its content onclick when there is one', function (assert) {
+ QUnit.test('field date should select its content onclick when there is one', async function (assert) {
assert.expect(2);
var done = assert.async();
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -2962,7 +2957,7 @@ QUnit.module('basic_fields', {
form.destroy();
});
- QUnit.test('date field support internalization', function (assert) {
+ QUnit.test('date field support internalization', async function (assert) {
assert.expect(2);
var originalLocale = moment.locale();
@@ -2976,7 +2971,7 @@ QUnit.module('basic_fields', {
ordinal: '%d.',
});
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -2985,14 +2980,14 @@ QUnit.module('basic_fields', {
});
var dateViewForm = form.$('.o_field_date').text();
- testUtils.dom.click(form.$buttons.find('.o_form_button_edit'));
- testUtils.openDatepicker(form.$('.o_datepicker'));
+ await testUtils.dom.click(form.$buttons.find('.o_form_button_edit'));
+ await testUtils.openDatepicker(form.$('.o_datepicker'));
assert.strictEqual(form.$('.o_datepicker_input').val(), dateViewForm,
"input date field should be the same as it was in the view form");
- testUtils.dom.click($('.day:contains(30)'));
- var dateEditForm = form.$('.o_datepicker_input').val()
- testUtils.dom.click(form.$buttons.find('.o_form_button_save'));
+ await testUtils.dom.click($('.day:contains(30)'));
+ var dateEditForm = form.$('.o_datepicker_input').val();
+ await testUtils.dom.click(form.$buttons.find('.o_form_button_save'));
assert.strictEqual(form.$('.o_field_date').text(), dateEditForm,
"date field should be the same as the one selected in the view form");
@@ -3005,10 +3000,10 @@ QUnit.module('basic_fields', {
QUnit.module('FieldDatetime');
- QUnit.test('datetime field in form view', function (assert) {
+ QUnit.test('datetime field in form view', async function (assert) {
assert.expect(6);
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -3030,23 +3025,23 @@ QUnit.module('basic_fields', {
'the datetime should be correctly displayed in readonly');
// switch to edit mode
- testUtils.form.clickEdit(form);
+ await testUtils.form.clickEdit(form);
assert.strictEqual(form.$('.o_datepicker_input').val(), expectedDateString,
'the datetime should be correct in edit mode');
// select 22 February at 8:23:33
assert.ok($('.bootstrap-datetimepicker-widget').length, 'datepicker should be open');
- testUtils.dom.click($('.bootstrap-datetimepicker-widget .picker-switch').first());
- testUtils.dom.click($('.bootstrap-datetimepicker-widget .picker-switch:eq(1)'));
- testUtils.dom.click($('.bootstrap-datetimepicker-widget .year:contains(2017)'));
- testUtils.dom.click($('.bootstrap-datetimepicker-widget .month').eq(3));
- testUtils.dom.click($('.bootstrap-datetimepicker-widget .day:contains(22)'));
- testUtils.dom.click($('.bootstrap-datetimepicker-widget .fa-clock-o'));
- testUtils.dom.click($('.bootstrap-datetimepicker-widget .timepicker-hour'));
- testUtils.dom.click($('.bootstrap-datetimepicker-widget .hour:contains(08)'));
- testUtils.dom.click($('.bootstrap-datetimepicker-widget .timepicker-minute'));
- testUtils.dom.click($('.bootstrap-datetimepicker-widget .minute:contains(25)'));
- testUtils.dom.click($('.bootstrap-datetimepicker-widget .timepicker-second'));
- testUtils.dom.click($('.bootstrap-datetimepicker-widget .second:contains(35)'));
+ await testUtils.dom.click($('.bootstrap-datetimepicker-widget .picker-switch').first());
+ await testUtils.dom.click($('.bootstrap-datetimepicker-widget .picker-switch:eq(1)'));
+ await testUtils.dom.click($('.bootstrap-datetimepicker-widget .year:contains(2017)'));
+ await testUtils.dom.click($('.bootstrap-datetimepicker-widget .month').eq(3));
+ await testUtils.dom.click($('.bootstrap-datetimepicker-widget .day:contains(22)'));
+ await testUtils.dom.click($('.bootstrap-datetimepicker-widget .fa-clock-o'));
+ await testUtils.dom.click($('.bootstrap-datetimepicker-widget .timepicker-hour'));
+ await testUtils.dom.click($('.bootstrap-datetimepicker-widget .hour:contains(08)'));
+ await testUtils.dom.click($('.bootstrap-datetimepicker-widget .timepicker-minute'));
+ await testUtils.dom.click($('.bootstrap-datetimepicker-widget .minute:contains(25)'));
+ await testUtils.dom.click($('.bootstrap-datetimepicker-widget .timepicker-second'));
+ await testUtils.dom.click($('.bootstrap-datetimepicker-widget .second:contains(35)'));
assert.ok(!$('.bootstrap-datetimepicker-widget').length, 'datepicker should be closed');
var newExpectedDateString = "04/22/2017 08:25:35";
@@ -3054,7 +3049,7 @@ QUnit.module('basic_fields', {
'the selected date should be displayed in the input');
// save
- testUtils.form.clickSave(form);
+ await testUtils.form.clickSave(form);
assert.strictEqual(form.$('.o_field_date').text(), newExpectedDateString,
'the selected date should be displayed after saving');
@@ -3062,10 +3057,10 @@ QUnit.module('basic_fields', {
});
- QUnit.test('datetime field not visible in form view should not capture the focus on keyboard navigation', function (assert) {
+ QUnit.test('datetime field not visible in form view should not capture the focus on keyboard navigation', async function (assert) {
assert.expect(1);
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -3086,13 +3081,13 @@ QUnit.module('basic_fields', {
form.destroy();
});
- QUnit.test('datetime field with datetime formatted without second', function (assert) {
+ QUnit.test('datetime field with datetime formatted without second', async function (assert) {
assert.expect(2);
this.data.partner.fields.datetime.default = "2017-08-02 12:00:05";
this.data.partner.fields.datetime.required = true;
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -3107,7 +3102,7 @@ QUnit.module('basic_fields', {
assert.strictEqual(form.$('.o_field_date input').val(), expectedDateString,
'the datetime should be correctly displayed in readonly');
- testUtils.form.clickDiscard(form);
+ await testUtils.form.clickDiscard(form);
assert.strictEqual($('.modal').length, 0,
"there should not be a Warning dialog");
@@ -3115,10 +3110,10 @@ QUnit.module('basic_fields', {
form.destroy();
});
- QUnit.test('datetime field in editable list view', function (assert) {
+ QUnit.test('datetime field in editable list view', async function (assert) {
assert.expect(8);
- var list = createView({
+ var list = await createView({
View: ListView,
model: 'partner',
data: this.data,
@@ -3142,7 +3137,7 @@ QUnit.module('basic_fields', {
'the datetime should be correctly displayed in readonly');
// switch to edit mode
- testUtils.dom.click($cell);
+ await testUtils.dom.click($cell);
assert.containsOnce(list, 'input.o_datepicker_input',
"the view should have a date input for editable mode");
@@ -3154,18 +3149,18 @@ QUnit.module('basic_fields', {
// select 22 February at 8:23:33
assert.ok($('.bootstrap-datetimepicker-widget').length, 'datepicker should be open');
- testUtils.dom.click($('.bootstrap-datetimepicker-widget .picker-switch').first());
- testUtils.dom.click($('.bootstrap-datetimepicker-widget .picker-switch:eq(1)'));
- testUtils.dom.click($('.bootstrap-datetimepicker-widget .year:contains(2017)'));
- testUtils.dom.click($('.bootstrap-datetimepicker-widget .month').eq(3));
- testUtils.dom.click($('.bootstrap-datetimepicker-widget .day:contains(22)'));
- testUtils.dom.click($('.bootstrap-datetimepicker-widget .fa-clock-o'));
- testUtils.dom.click($('.bootstrap-datetimepicker-widget .timepicker-hour'));
- testUtils.dom.click($('.bootstrap-datetimepicker-widget .hour:contains(08)'));
- testUtils.dom.click($('.bootstrap-datetimepicker-widget .timepicker-minute'));
- testUtils.dom.click($('.bootstrap-datetimepicker-widget .minute:contains(25)'));
- testUtils.dom.click($('.bootstrap-datetimepicker-widget .timepicker-second'));
- testUtils.dom.click($('.bootstrap-datetimepicker-widget .second:contains(35)'));
+ await testUtils.dom.click($('.bootstrap-datetimepicker-widget .picker-switch').first());
+ await testUtils.dom.click($('.bootstrap-datetimepicker-widget .picker-switch:eq(1)'));
+ await testUtils.dom.click($('.bootstrap-datetimepicker-widget .year:contains(2017)'));
+ await testUtils.dom.click($('.bootstrap-datetimepicker-widget .month').eq(3));
+ await testUtils.dom.click($('.bootstrap-datetimepicker-widget .day:contains(22)'));
+ await testUtils.dom.click($('.bootstrap-datetimepicker-widget .fa-clock-o'));
+ await testUtils.dom.click($('.bootstrap-datetimepicker-widget .timepicker-hour'));
+ await testUtils.dom.click($('.bootstrap-datetimepicker-widget .hour:contains(08)'));
+ await testUtils.dom.click($('.bootstrap-datetimepicker-widget .timepicker-minute'));
+ await testUtils.dom.click($('.bootstrap-datetimepicker-widget .minute:contains(25)'));
+ await testUtils.dom.click($('.bootstrap-datetimepicker-widget .timepicker-second'));
+ await testUtils.dom.click($('.bootstrap-datetimepicker-widget .second:contains(35)'));
assert.ok(!$('.bootstrap-datetimepicker-widget').length, 'datepicker should be closed');
var newExpectedDateString = "04/22/2017 08:25:35";
@@ -3173,17 +3168,17 @@ QUnit.module('basic_fields', {
'the selected datetime should be displayed in the input');
// save
- testUtils.dom.click(list.$buttons.find('.o_list_button_save'));
+ await testUtils.dom.click(list.$buttons.find('.o_list_button_save'));
assert.strictEqual(list.$('tr.o_data_row td:not(.o_list_record_selector)').text(), newExpectedDateString,
'the selected datetime should be displayed after saving');
list.destroy();
});
- QUnit.test('datetime field remove value', function (assert) {
+ QUnit.test('datetime field remove value', async function (assert) {
assert.expect(4);
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -3207,29 +3202,29 @@ QUnit.module('basic_fields', {
});
// switch to edit mode
- testUtils.form.clickEdit(form);
+ await testUtils.form.clickEdit(form);
assert.strictEqual(form.$('.o_datepicker_input').val(), '02/08/2017 12:00:00',
'the date time should be correct in edit mode');
- testUtils.fields.editAndTrigger($('.o_datepicker_input'), '', ['input', 'change', 'focusout']);
+ await testUtils.fields.editAndTrigger($('.o_datepicker_input'), '', ['input', 'change', 'focusout']);
assert.strictEqual(form.$('.o_datepicker_input').val(), '',
"should have an empty input");
// save
- testUtils.form.clickSave(form);
+ await testUtils.form.clickSave(form);
assert.strictEqual(form.$('.o_field_date').text(), '',
'the selected date should be displayed after saving');
form.destroy();
});
- QUnit.test('datetime field with date/datetime widget (with day change)', function (assert) {
+ QUnit.test('datetime field with date/datetime widget (with day change)', async function (assert) {
assert.expect(2);
this.data.partner.records[0].p = [2];
this.data.partner.records[1].datetime = "2017-02-08 02:00:00"; // UTC
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -3260,20 +3255,20 @@ QUnit.module('basic_fields', {
'the datetime (datetime widget) should be correctly displayed in tree view');
// switch to form view
- testUtils.dom.click(form.$('.o_field_widget[name=p] .o_data_row'));
+ await testUtils.dom.click(form.$('.o_field_widget[name=p] .o_data_row'));
assert.strictEqual($('.modal .o_field_date[name=datetime]').text(), '02/07/2017',
'the datetime (date widget) should be correctly displayed in form view');
form.destroy();
});
- QUnit.test('datetime field with date/datetime widget (without day change)', function (assert) {
+ QUnit.test('datetime field with date/datetime widget (without day change)', async function (assert) {
assert.expect(2);
this.data.partner.records[0].p = [2];
this.data.partner.records[1].datetime = "2017-02-08 10:00:00"; // without timezone
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -3304,20 +3299,20 @@ QUnit.module('basic_fields', {
'the datetime (datetime widget) should be correctly displayed in tree view');
// switch to form view
- testUtils.dom.click(form.$('.o_field_widget[name=p] .o_data_row'));
+ await testUtils.dom.click(form.$('.o_field_widget[name=p] .o_data_row'));
assert.strictEqual($('.modal .o_field_date[name=datetime]').text(), '02/08/2017',
'the datetime (date widget) should be correctly displayed in form view');
form.destroy();
});
- QUnit.test('datepicker option: daysOfWeekDisabled', function (assert) {
+ QUnit.test('datepicker option: daysOfWeekDisabled', async function (assert) {
assert.expect(42);
this.data.partner.fields.datetime.default = "2017-08-02 12:00:05";
this.data.partner.fields.datetime.required = true;
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -3328,7 +3323,7 @@ QUnit.module('basic_fields', {
res_id: 1,
});
- testUtils.form.clickCreate(form);
+ await testUtils.form.clickCreate(form);
$.each($('.day:last-child(),.day:nth-child(2)'), function (index, value) {
assert.hasClass(value, 'disabled', 'first and last days must be disabled');
});
@@ -3343,10 +3338,10 @@ QUnit.module('basic_fields', {
QUnit.module('FieldMonetary');
- QUnit.test('monetary field in form view', function (assert) {
+ QUnit.test('monetary field in form view', async function (assert) {
assert.expect(5);
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -3366,17 +3361,17 @@ QUnit.module('basic_fields', {
assert.strictEqual(form.$('.o_field_widget').first().text(), '$\u00a09.10',
'The value should be displayed properly.');
- testUtils.form.clickEdit(form);
+ await testUtils.form.clickEdit(form);
assert.strictEqual(form.$('.o_field_widget[name=qux] input').val(), '9.10',
'The input should be rendered without the currency symbol.');
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');
+ await testUtils.fields.editInput(form.$('.o_field_monetary 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);
+ await testUtils.form.clickSave(form);
// Non-breaking space between the currency and the amount
assert.strictEqual(form.$('.o_field_widget').first().text(), '$\u00a0108.25',
'The new value should be rounded properly.');
@@ -3384,10 +3379,10 @@ QUnit.module('basic_fields', {
form.destroy();
});
- QUnit.test('monetary field with currency symbol after', function (assert) {
+ QUnit.test('monetary field with currency symbol after', async function (assert) {
assert.expect(5);
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -3407,17 +3402,17 @@ QUnit.module('basic_fields', {
assert.strictEqual(form.$('.o_field_widget').first().text(), '0.00\u00a0€',
'The value should be displayed properly.');
- testUtils.form.clickEdit(form);
+ await testUtils.form.clickEdit(form);
assert.strictEqual(form.$('.o_field_widget[name=qux] input').val(), '0.00',
'The input should be rendered without the currency symbol.');
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.$('.o_field_widget[name=qux] input'), '108.2458938598598');
+ await 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);
+ await testUtils.form.clickSave(form);
// Non-breaking space between the currency and the amount
assert.strictEqual(form.$('.o_field_widget').first().text(), '108.25\u00a0€',
'The new value should be rounded properly.');
@@ -3425,7 +3420,7 @@ QUnit.module('basic_fields', {
form.destroy();
});
- QUnit.test('monetary field with currency digits != 2', function (assert) {
+ QUnit.test('monetary field with currency digits != 2', async function (assert) {
assert.expect(5);
this.data.partner.records = [{
@@ -3444,7 +3439,7 @@ QUnit.module('basic_fields', {
digits: [16, 4],
}];
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -3464,17 +3459,17 @@ QUnit.module('basic_fields', {
assert.strictEqual(form.$('.o_field_widget').first().text(), '99.1234\u00a0Bs.F',
'The value should be displayed properly.');
- testUtils.form.clickEdit(form);
+ await testUtils.form.clickEdit(form);
assert.strictEqual(form.$('.o_field_widget[name=qux] input').val(), '99.1234',
'The input should be rendered without the currency symbol.');
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.$('.o_field_widget[name=qux] input'), '99.111111111');
+ await 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);
+ await testUtils.form.clickSave(form);
// Non-breaking space between the currency and the amount
assert.strictEqual(form.$('.o_field_widget').first().text(), '99.1111\u00a0Bs.F',
'The new value should be rounded properly.');
@@ -3482,10 +3477,10 @@ QUnit.module('basic_fields', {
form.destroy();
});
- QUnit.test('monetary field in editable list view', function (assert) {
+ QUnit.test('monetary field in editable list view', async function (assert) {
assert.expect(9);
- var list = createView({
+ var list = await createView({
View: ListView,
model: 'partner',
data: this.data,
@@ -3512,7 +3507,7 @@ QUnit.module('basic_fields', {
// switch to edit mode
var $cell = list.$('tr.o_data_row td:not(.o_list_record_selector):contains($)');
- testUtils.dom.click($cell);
+ await testUtils.dom.click($cell);
assert.strictEqual($cell.children().length, 1,
'The cell td should only contain the special div of monetary widget.');
@@ -3523,18 +3518,18 @@ QUnit.module('basic_fields', {
assert.strictEqual(list.$('[name="qux"] input').parent().children().first().text(), '$',
'The input should be preceded by a span containing the currency symbol.');
- testUtils.fields.editInput(list.$('[name="qux"] input'), '108.2458938598598');
+ await testUtils.fields.editInput(list.$('[name="qux"] input'), '108.2458938598598');
assert.strictEqual(list.$('[name="qux"] input').val(), '108.2458938598598',
'The typed value should be correctly displayed.');
- testUtils.dom.click(list.$buttons.find('.o_list_button_save'));
+ await testUtils.dom.click(list.$buttons.find('.o_list_button_save'));
assert.strictEqual(list.$('tr.o_data_row td:not(.o_list_record_selector):contains($)').text(), '$\u00a0108.25',
'The new value should be rounded properly.');
list.destroy();
});
- QUnit.test('monetary field with real monetary field in model', function (assert) {
+ QUnit.test('monetary field with real monetary field in model', async function (assert) {
assert.expect(7);
this.data.partner.fields.qux.type = "monetary";
@@ -3542,7 +3537,7 @@ QUnit.module('basic_fields', {
string: "Quux", type: "monetary", digits: [16,1], searchable: true, readonly: true,
};
- (_.find(this.data.partner.records, function (record) { return record.id === 5 })).quux = 4.2;
+ (_.find(this.data.partner.records, function (record) { return record.id === 5; })).quux = 4.2;
this.data.partner.onchanges = {
bar: function (obj) {
@@ -3550,7 +3545,7 @@ QUnit.module('basic_fields', {
},
};
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -3573,19 +3568,19 @@ QUnit.module('basic_fields', {
assert.strictEqual(form.$('.o_field_monetary').first().next().html(), "$&nbsp;4.20",
"readonly value should contain the currency");
- testUtils.form.clickEdit(form);
+ await testUtils.form.clickEdit(form);
assert.strictEqual(form.$('.o_field_monetary > input').val(), "9.10",
"input value in edition should only contain the value, without the currency");
- testUtils.dom.click(form.$('input[type="checkbox"]'));
+ await testUtils.dom.click(form.$('input[type="checkbox"]'));
assert.containsOnce(form, '.o_field_monetary > input',
"After the onchange, the monetary <input/> should not have been duplicated");
assert.containsOnce(form, '.o_field_monetary[name=quux]',
"After the onchange, the monetary readonly field should not have been duplicated");
- testUtils.fields.many2one.clickOpenDropdown('currency_id');
- testUtils.fields.many2one.clickItem('currency_id','€');
+ await testUtils.fields.many2one.clickOpenDropdown('currency_id');
+ await testUtils.fields.many2one.clickItem('currency_id','€');
assert.strictEqual(form.$('.o_field_monetary > span').html(), "€",
"After currency change, the monetary field currency should have been updated");
assert.strictEqual(form.$('.o_field_monetary').first().next().html(), "4.20&nbsp;€",
@@ -3594,7 +3589,7 @@ QUnit.module('basic_fields', {
form.destroy();
});
- QUnit.test('monetary field with monetary field given in options', function (assert) {
+ QUnit.test('monetary field with monetary field given in options', async function (assert) {
assert.expect(1);
this.data.partner.fields.qux.type = "monetary";
@@ -3603,7 +3598,7 @@ QUnit.module('basic_fields', {
};
this.data.partner.records[4].company_currency_id = 2;
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -3625,14 +3620,14 @@ QUnit.module('basic_fields', {
form.destroy();
});
- QUnit.test('should keep the focus when being edited in x2many lists', function (assert) {
+ QUnit.test('should keep the focus when being edited in x2many lists', async function (assert) {
assert.expect(6);
this.data.partner.fields.currency_id.default = 1;
this.data.partner.fields.m2m = {
string: "m2m", type: "many2many", relation: 'partner', default: [[6, false, [2]]],
};
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -3655,30 +3650,30 @@ QUnit.module('basic_fields', {
// test the monetary field inside the one2many
var $o2m = form.$('.o_field_widget[name=p]');
- testUtils.dom.click($o2m.find('.o_field_x2many_list_row_add a'));
- testUtils.fields.editInput($o2m.find('.o_field_widget input'), "22");
+ await testUtils.dom.click($o2m.find('.o_field_x2many_list_row_add a'));
+ await testUtils.fields.editInput($o2m.find('.o_field_widget input'), "22");
assert.strictEqual($o2m.find('.o_field_widget input').get(0), document.activeElement,
"the focus should still be on the input");
assert.strictEqual($o2m.find('.o_field_widget input').val(), "22",
"the value should not have been formatted yet");
- testUtils.dom.click(form.$el);
+ await testUtils.dom.click(form.$el);
assert.strictEqual($o2m.find('.o_field_widget[name=qux]').html(), "$&nbsp;22.00",
"the value should have been formatted after losing the focus");
// test the monetary field inside the many2many
var $m2m = form.$('.o_field_widget[name=m2m]');
- testUtils.dom.click($m2m.find('.o_data_row td:first'));
- testUtils.fields.editInput($m2m.find('.o_field_widget input'), "22");
+ await testUtils.dom.click($m2m.find('.o_data_row td:first'));
+ await testUtils.fields.editInput($m2m.find('.o_field_widget input'), "22");
assert.strictEqual($m2m.find('.o_field_widget input').get(0), document.activeElement,
"the focus should still be on the input");
assert.strictEqual($m2m.find('.o_field_widget input').val(), "22",
"the value should not have been formatted yet");
- testUtils.dom.click(form.$el);
+ await testUtils.dom.click(form.$el);
assert.strictEqual($m2m.find('.o_field_widget[name=qux]').html(), "22.00&nbsp;€",
"the value should have been formatted after losing the focus");
@@ -3698,7 +3693,7 @@ QUnit.module('basic_fields', {
},
};
- var list = createView({
+ var list = await createView({
View: ListView,
model: 'partner',
data: this.data,
@@ -3712,33 +3707,32 @@ QUnit.module('basic_fields', {
},
});
- testUtils.dom.click(list.$buttons.find('.o_list_button_add'));
+ await testUtils.dom.click(list.$buttons.find('.o_list_button_add'));
assert.containsOnce(list, 'div.o_field_widget[name=qux] input',
"monetary field should have been rendered correctly (without currency)");
assert.containsNone(list, '.o_field_widget[name=qux] span',
"monetary field should have been rendered correctly (without currency)");
// set a value for int_field -> should set the currency and re-render qux
- testUtils.fields.editInput(list.$('.o_field_widget[name=int_field]'),'7');
+ await testUtils.fields.editInput(list.$('.o_field_widget[name=int_field]'),'7');
assert.containsOnce(list, 'div.o_field_widget[name=qux] input',
"monetary field should have been re-rendered correctly (with currency)");
assert.strictEqual(list.$('.o_field_widget[name=qux] span:contains(€)').length, 1,
"monetary field should have been re-rendered correctly (with currency)");
var $quxInput = list.$('.o_field_widget[name=qux] input');
- testUtils.dom.click($quxInput);
+ await testUtils.dom.click($quxInput);
assert.strictEqual(document.activeElement, $quxInput[0],
"focus should be on the qux field's input");
// unset the value of int_field -> should unset the currency and re-render qux
- testUtils.dom.click(list.$('.o_field_widget[name=int_field]'));
- testUtils.fields.editInput(list.$('.o_field_widget[name=int_field]'),'0');
+ await testUtils.dom.click(list.$('.o_field_widget[name=int_field]'));
+ await testUtils.fields.editInput(list.$('.o_field_widget[name=int_field]'),'0');
$quxInput = list.$('div.o_field_widget[name=qux] input');
assert.strictEqual($quxInput.length, 1,
"monetary field should have been re-rendered correctly (without currency)");
assert.containsNone(list, '.o_field_widget[name=qux] span',
"monetary field should have been re-rendered correctly (without currency)");
- await concurrency.delay(0);
- testUtils.dom.click($quxInput);
+ await testUtils.dom.click($quxInput);
assert.strictEqual(document.activeElement, $quxInput[0],
"focus should be on the qux field's input");
@@ -3747,10 +3741,10 @@ QUnit.module('basic_fields', {
QUnit.module('FieldInteger');
- QUnit.test('integer field when unset', function (assert) {
+ QUnit.test('integer field when unset', async function (assert) {
assert.expect(2);
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -3766,10 +3760,10 @@ QUnit.module('basic_fields', {
form.destroy();
});
- QUnit.test('integer field in form view', function (assert) {
+ QUnit.test('integer field in form view', async function (assert) {
assert.expect(4);
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -3780,22 +3774,22 @@ QUnit.module('basic_fields', {
assert.doesNotHaveClass(form.$('.o_field_widget'), 'o_field_empty',
'Integer field should be considered set for value 0.');
- testUtils.form.clickEdit(form);
+ await testUtils.form.clickEdit(form);
assert.strictEqual(form.$('input[name=int_field]').val(), '0',
'The value should be rendered correctly in edit mode.');
- testUtils.fields.editInput(form.$('input[name=int_field]'), '-18');
+ await 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);
+ await testUtils.form.clickSave(form);
assert.strictEqual(form.$('.o_field_widget').text(), '-18',
'The new value should be saved and displayed properly.');
form.destroy();
});
- QUnit.test('integer field in form view with virtual id', function (assert) {
+ QUnit.test('integer field in form view with virtual id', async function (assert) {
assert.expect(1);
var params = {
View: FormView,
@@ -3805,17 +3799,17 @@ QUnit.module('basic_fields', {
};
params.res_id = this.data.partner.records[1].id = "2-20170808020000";
- var form = createView(params);
+ var form = await createView(params);
assert.strictEqual(form.$('.o_field_widget').text(), "2-20170808020000",
"Should display virtual id");
form.destroy();
});
- QUnit.test('integer field in editable list view', function (assert) {
+ QUnit.test('integer field in editable list view', async function (assert) {
assert.expect(4);
- var list = createView({
+ var list = await createView({
View: ListView,
model: 'partner',
data: this.data,
@@ -3830,26 +3824,26 @@ QUnit.module('basic_fields', {
// switch to edit mode
var $cell = list.$('tr.o_data_row td:not(.o_list_record_selector)').first();
- testUtils.dom.click($cell);
+ await testUtils.dom.click($cell);
assert.containsOnce(list, 'input[name="int_field"]',
'The view should have 1 input for editable integer.');
- testUtils.fields.editInput(list.$('input[name="int_field"]'), '-28');
+ await testUtils.fields.editInput(list.$('input[name="int_field"]'), '-28');
assert.strictEqual(list.$('input[name="int_field"]').val(), '-28',
'The value should be displayed properly in the input.');
- testUtils.dom.click(list.$buttons.find('.o_list_button_save'));
+ await testUtils.dom.click(list.$buttons.find('.o_list_button_save'));
assert.strictEqual(list.$('td:not(.o_list_record_selector)').first().text(), '-28',
'The new value should be saved and displayed properly.');
list.destroy();
});
- QUnit.test('integer field with type number option', function (assert) {
+ QUnit.test('integer field with type number option', async function (assert) {
assert.expect(4);
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -3863,28 +3857,28 @@ QUnit.module('basic_fields', {
},
});
- testUtils.form.clickEdit(form);
+ await testUtils.form.clickEdit(form);
assert.ok(form.$('.o_field_widget')[0].hasAttribute('type'),
'Integer field with option type must have a type attribute.');
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[name=int_field]'), '1234567890');
- testUtils.form.clickSave(form);
- testUtils.form.clickEdit(form);
+ await testUtils.fields.editInput(form.$('input[name=int_field]'), '1234567890');
+ await testUtils.form.clickSave(form);
+ await testUtils.form.clickEdit(form);
assert.strictEqual(form.$('.o_field_widget').val(), '1234567890',
'Integer value must be not formatted if input type is number.');
- testUtils.form.clickSave(form);
+ await testUtils.form.clickSave(form);
assert.strictEqual(form.$('.o_field_widget').text(), '1,234,567,890',
'Integer value must be formatted in readonly view even if the input type is number.');
form.destroy();
});
- QUnit.test('integer field without type number option', function (assert) {
+ QUnit.test('integer field without type number option', async function (assert) {
assert.expect(2);
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -3898,13 +3892,13 @@ QUnit.module('basic_fields', {
},
});
- testUtils.form.clickEdit(form);
+ await testUtils.form.clickEdit(form);
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[name=int_field]'), '1234567890');
- testUtils.form.clickSave(form);
- testUtils.form.clickEdit(form);
+ await testUtils.fields.editInput(form.$('input[name=int_field]'), '1234567890');
+ await testUtils.form.clickSave(form);
+ await testUtils.form.clickEdit(form);
assert.strictEqual(form.$('.o_field_widget').val(), '1,234,567,890',
'Integer value must be formatted if input type isn\'t number.');
@@ -3914,10 +3908,10 @@ QUnit.module('basic_fields', {
QUnit.module('FieldFloatTime');
- QUnit.test('float_time field in form view', function (assert) {
+ QUnit.test('float_time field in form view', async function (assert) {
assert.expect(5);
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -3940,15 +3934,15 @@ QUnit.module('basic_fields', {
assert.strictEqual(form.$('.o_field_widget').first().text(), '09:06',
'The formatted time value should be displayed properly.');
- testUtils.form.clickEdit(form);
+ await testUtils.form.clickEdit(form);
assert.strictEqual(form.$('input[name=qux]').val(), '09:06',
'The value should be rendered correctly in the input.');
- testUtils.fields.editInput(form.$('input[name=qux]'), '-11:48');
+ await 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);
+ await testUtils.form.clickSave(form);
assert.strictEqual(form.$('.o_field_widget').first().text(), '-11:48',
'The new value should be saved and displayed properly.');
@@ -3958,10 +3952,10 @@ QUnit.module('basic_fields', {
QUnit.module('FieldFloatFactor');
- QUnit.test('float_factor field in form view', function (assert) {
+ QUnit.test('float_factor field in form view', async function (assert) {
assert.expect(4);
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -3982,13 +3976,13 @@ QUnit.module('basic_fields', {
assert.strictEqual(form.$('.o_field_widget').first().text(), '4.55', // 9.1 / 0.5
'The formatted value should be displayed properly.');
- testUtils.form.clickEdit(form);
+ await testUtils.form.clickEdit(form);
assert.strictEqual(form.$('input[name=qux]').val(), '4.55',
'The value should be rendered correctly in the input.');
- testUtils.fields.editInput(form.$('input[name=qux]'), '2.3');
+ await testUtils.fields.editInput(form.$('input[name=qux]'), '2.3');
- testUtils.form.clickSave(form);
+ await testUtils.form.clickSave(form);
assert.strictEqual(form.$('.o_field_widget').first().text(), '2.30',
'The new value should be saved and displayed properly.');
@@ -3997,10 +3991,10 @@ QUnit.module('basic_fields', {
QUnit.module('FieldFloatToggle');
- QUnit.test('float_toggle field in form view', function (assert) {
+ QUnit.test('float_toggle field in form view', async function (assert) {
assert.expect(5);
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -4021,17 +4015,17 @@ QUnit.module('basic_fields', {
assert.strictEqual(form.$('.o_field_widget').first().text(), '0.056',
'The formatted time value should be displayed properly.');
- testUtils.form.clickEdit(form);
+ await testUtils.form.clickEdit(form);
assert.strictEqual(form.$('button.o_field_float_toggle').text(), '0.056',
'The value should be rendered correctly on the button.');
- testUtils.dom.click(form.$('button.o_field_float_toggle'));
+ await testUtils.dom.click(form.$('button.o_field_float_toggle'));
assert.strictEqual(form.$('button.o_field_float_toggle').text(), '1.000',
'The value should be rendered correctly on the button.');
- testUtils.form.clickSave(form);
+ await testUtils.form.clickSave(form);
assert.strictEqual(form.$('.o_field_widget').first().text(), '1.000',
'The new value should be saved and displayed properly.');
@@ -4042,10 +4036,10 @@ QUnit.module('basic_fields', {
QUnit.module('PhoneWidget');
- QUnit.test('phone field in form view on normal screens', function (assert) {
+ QUnit.test('phone field in form view on normal screens', async function (assert) {
assert.expect(5);
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -4071,27 +4065,27 @@ QUnit.module('basic_fields', {
"value should be displayed properly");
// switch to edit mode and check the result
- testUtils.form.clickEdit(form);
+ await testUtils.form.clickEdit(form);
assert.containsOnce(form, 'input[type="text"].o_field_widget',
"should have an input for the phone field");
assert.strictEqual(form.$('input[type="text"].o_field_widget').val(), 'yop',
"input should contain field value in edit mode");
// change value in edit mode
- testUtils.fields.editInput(form.$('input[type="text"].o_field_widget'), 'new');
+ await testUtils.fields.editInput(form.$('input[type="text"].o_field_widget'), 'new');
// save
- testUtils.form.clickSave(form);
+ await testUtils.form.clickSave(form);
assert.strictEqual(form.$('a.o_field_widget.o_form_uri').text(), 'new',
"new value should be displayed properly");
form.destroy();
});
- QUnit.test('phone field in editable list view on normal screens', function (assert) {
+ QUnit.test('phone field in editable list view on normal screens', async function (assert) {
assert.expect(8);
- var list = createView({
+ var list = await createView({
View: ListView,
model: 'partner',
data: this.data,
@@ -4103,8 +4097,7 @@ QUnit.module('basic_fields', {
},
});
- assert.strictEqual(list.$('tbody td:not(.o_list_record_selector)').length, 5,
- "should have 5 cells");
+ assert.containsN(list, 'tbody td:not(.o_list_record_selector)', 5);
assert.strictEqual(list.$('tbody td:not(.o_list_record_selector)').first().text(), 'yop',
"value should be displayed properly");
@@ -4113,14 +4106,14 @@ QUnit.module('basic_fields', {
// Edit a line and check the result
var $cell = list.$('tbody td:not(.o_list_record_selector)').first();
- testUtils.dom.click($cell);
+ await testUtils.dom.click($cell);
assert.hasClass($cell.parent(),'o_selected_row', 'should be set as edit mode');
assert.strictEqual($cell.find('input').val(), 'yop',
'should have the corect value in internal input');
- testUtils.fields.editInput($cell.find('input'), 'new');
+ await testUtils.fields.editInput($cell.find('input'), 'new');
// save
- testUtils.dom.click(list.$buttons.find('.o_list_button_save'));
+ await testUtils.dom.click(list.$buttons.find('.o_list_button_save'));
$cell = list.$('tbody td:not(.o_list_record_selector)').first();
assert.doesNotHaveClass($cell.parent(), 'o_selected_row', 'should not be in edit mode anymore');
assert.strictEqual(list.$('tbody td:not(.o_list_record_selector)').first().text(), 'new',
@@ -4131,10 +4124,10 @@ QUnit.module('basic_fields', {
list.destroy();
});
- QUnit.test('use TAB to navigate to a phone field', function (assert) {
+ QUnit.test('use TAB to navigate to a phone field', async function (assert) {
assert.expect(2);
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -4160,10 +4153,10 @@ QUnit.module('basic_fields', {
QUnit.module('PriorityWidget');
- QUnit.test('priority widget when not set', function (assert) {
+ QUnit.test('priority widget when not set', async function (assert) {
assert.expect(4);
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -4189,10 +4182,10 @@ QUnit.module('basic_fields', {
form.destroy();
});
- QUnit.test('priority widget in form view', function (assert) {
+ QUnit.test('priority widget in form view', async function (assert) {
assert.expect(22);
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -4228,7 +4221,7 @@ QUnit.module('basic_fields', {
// occurs in a setTimeout after 200ms so it's not trivial to test it here.
// switch to edit mode and check the result
- testUtils.form.clickEdit(form);
+ await testUtils.form.clickEdit(form);
assert.strictEqual(form.$('.o_field_widget.o_priority').find('a.o_priority_star').length, 2,
"should still have two stars");
assert.strictEqual(form.$('.o_field_widget.o_priority').find('a.o_priority_star.fa-star').length, 1,
@@ -4237,7 +4230,7 @@ QUnit.module('basic_fields', {
"should still have one empty star since the value is the second value");
// save
- testUtils.form.clickSave(form);
+ await testUtils.form.clickSave(form);
assert.strictEqual(form.$('.o_field_widget.o_priority').find('a.o_priority_star').length, 2,
"should still have two stars");
assert.strictEqual(form.$('.o_field_widget.o_priority').find('a.o_priority_star.fa-star').length, 1,
@@ -4246,7 +4239,7 @@ QUnit.module('basic_fields', {
"should still have one empty star since the value is the second value");
// switch to edit mode to check that the new value was properly written
- testUtils.form.clickEdit(form);
+ await testUtils.form.clickEdit(form);
assert.strictEqual(form.$('.o_field_widget.o_priority').find('a.o_priority_star').length, 2,
"should still have two stars");
assert.strictEqual(form.$('.o_field_widget.o_priority').find('a.o_priority_star.fa-star').length, 1,
@@ -4255,7 +4248,7 @@ QUnit.module('basic_fields', {
"should still have one empty star since the value is the second value");
// click on the second star in edit mode
- testUtils.dom.click(form.$('.o_field_widget.o_priority a.o_priority_star.fa-star-o').last());
+ await testUtils.dom.click(form.$('.o_field_widget.o_priority a.o_priority_star.fa-star-o').last());
assert.strictEqual(form.$('.o_field_widget.o_priority').find('a.o_priority_star').length, 2,
"should still have two stars");
@@ -4265,7 +4258,7 @@ QUnit.module('basic_fields', {
"should now have no empty star since the value is the third value");
// save
- testUtils.form.clickSave(form);
+ await testUtils.form.clickSave(form);
assert.strictEqual(form.$('.o_field_widget.o_priority').find('a.o_priority_star').length, 2,
"should still have two stars");
assert.strictEqual(form.$('.o_field_widget.o_priority').find('a.o_priority_star.fa-star').length, 2,
@@ -4276,10 +4269,10 @@ QUnit.module('basic_fields', {
form.destroy();
});
- QUnit.test('priority widget in editable list view', function (assert) {
+ QUnit.test('priority widget in editable list view', async function (assert) {
assert.expect(25);
- var list = createView({
+ var list = await createView({
View: ListView,
model: 'partner',
data: this.data,
@@ -4300,7 +4293,7 @@ QUnit.module('basic_fields', {
// switch to edit mode and check the result
var $cell = list.$('tbody td:not(.o_list_record_selector)').first();
- testUtils.dom.click($cell);
+ await testUtils.dom.click($cell);
assert.strictEqual(list.$('.o_data_row').first().find('.o_priority a.o_priority_star').length, 2,
"should have two stars for representing each possible value: no star, one star and two stars");
assert.strictEqual(list.$('.o_data_row').first().find('.o_priority a.o_priority_star.fa-star').length, 1,
@@ -4309,7 +4302,7 @@ QUnit.module('basic_fields', {
"should have one empty star since the value is the second value");
// save
- testUtils.dom.click(list.$buttons.find('.o_list_button_save'));
+ await testUtils.dom.click(list.$buttons.find('.o_list_button_save'));
assert.strictEqual(list.$('.o_data_row').first().find('.o_priority a.o_priority_star').length, 2,
"should have two stars for representing each possible value: no star, one star and two stars");
assert.strictEqual(list.$('.o_data_row').first().find('.o_priority a.o_priority_star.fa-star').length, 1,
@@ -4327,7 +4320,7 @@ QUnit.module('basic_fields', {
"should temporary have no empty star since we are hovering the third value");
// click on the first star in readonly mode
- testUtils.dom.click(list.$('.o_priority a.o_priority_star.fa-star').first());
+ await testUtils.dom.click(list.$('.o_priority a.o_priority_star.fa-star').first());
assert.strictEqual(list.$('.o_data_row').first().find('.o_priority a.o_priority_star').length, 2,
"should still have two stars");
@@ -4338,7 +4331,7 @@ QUnit.module('basic_fields', {
// re-enter edit mode to force re-rendering the widget to check if the value was correctly saved
$cell = list.$('tbody td:not(.o_list_record_selector)').first();
- testUtils.dom.click($cell);
+ await testUtils.dom.click($cell);
assert.strictEqual(list.$('.o_data_row').first().find('.o_priority a.o_priority_star').length, 2,
"should still have two stars");
@@ -4348,7 +4341,7 @@ QUnit.module('basic_fields', {
"should now have two empty stars since the value is the first value");
// Click on second star in edit mode
- testUtils.dom.click(list.$('.o_priority a.o_priority_star.fa-star-o').last());
+ await testUtils.dom.click(list.$('.o_priority a.o_priority_star.fa-star-o').last());
assert.strictEqual(list.$('.o_data_row').last().find('.o_priority a.o_priority_star').length, 2,
"should still have two stars");
@@ -4358,7 +4351,7 @@ QUnit.module('basic_fields', {
"should now have no empty star since the value is the third value");
// save
- testUtils.dom.click(list.$buttons.find('.o_list_button_save'));
+ await testUtils.dom.click(list.$buttons.find('.o_list_button_save'));
assert.strictEqual(list.$('.o_data_row').last().find('.o_priority a.o_priority_star').length, 2,
"should still have two stars");
assert.strictEqual(list.$('.o_data_row').last().find('.o_priority a.o_priority_star.fa-star').length, 2,
@@ -4372,10 +4365,10 @@ QUnit.module('basic_fields', {
QUnit.module('StateSelection Widget');
- QUnit.test('state_selection widget in form view', function (assert) {
+ QUnit.test('state_selection widget in form view', async function (assert) {
assert.expect(21);
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -4400,14 +4393,14 @@ QUnit.module('basic_fields', {
"there should not be a dropdown");
// Click on the status button to make the dropdown appear
- testUtils.dom.click(form.$('.o_field_widget.o_selection .o_status').first());
+ await testUtils.dom.click(form.$('.o_field_widget.o_selection .o_status').first());
assert.containsOnce(form, '.dropdown-menu.state:visible',
"there should be a dropdown");
assert.containsN(form, '.dropdown-menu.state:visible .dropdown-item', 2,
"there should be two options in the dropdown");
// Click on the first option, "Normal"
- testUtils.dom.click(form.$('.dropdown-menu.state:visible .dropdown-item').first());
+ await testUtils.dom.click(form.$('.dropdown-menu.state:visible .dropdown-item').first());
assert.containsNone(form, '.dropdown-menu.state:visible',
"there should not be a dropdown anymore");
assert.containsNone(form, '.o_field_widget.o_selection > a span.o_status.o_status_red',
@@ -4418,7 +4411,7 @@ QUnit.module('basic_fields', {
"should have one grey status since selection is the first, normal state");
// switch to edit mode and check the result
- testUtils.form.clickEdit(form);
+ await testUtils.form.clickEdit(form);
assert.containsNone(form, '.dropdown-menu.state:visible',
"there should still not be a dropdown");
assert.containsNone(form, '.o_field_widget.o_selection > a span.o_status.o_status_red',
@@ -4429,14 +4422,14 @@ QUnit.module('basic_fields', {
"should still have one grey status since selection is the first, normal state");
// Click on the status button to make the dropdown appear
- testUtils.dom.click(form.$('.o_field_widget.o_selection .o_status').first());
+ await testUtils.dom.click(form.$('.o_field_widget.o_selection .o_status').first());
assert.containsOnce(form, '.dropdown-menu.state:visible',
"there should be a dropdown");
assert.containsN(form, '.dropdown-menu.state:visible .dropdown-item', 2,
"there should be two options in the dropdown");
// Click on the last option, "Done"
- testUtils.dom.click(form.$('.dropdown-menu.state:visible .dropdown-item').last());
+ await testUtils.dom.click(form.$('.dropdown-menu.state:visible .dropdown-item').last());
assert.containsNone(form, '.dropdown-menu.state:visible',
"there should not be a dropdown anymore");
assert.containsNone(form, '.o_field_widget.o_selection > a span.o_status.o_status_red',
@@ -4445,7 +4438,7 @@ QUnit.module('basic_fields', {
"should have one green status since selection is the third, done state");
// save
- testUtils.form.clickSave(form);
+ await testUtils.form.clickSave(form);
assert.containsNone(form, '.dropdown-menu.state:visible',
"there should still not be a dropdown anymore");
assert.containsNone(form, '.o_field_widget.o_selection > a span.o_status.o_status_red',
@@ -4456,10 +4449,10 @@ QUnit.module('basic_fields', {
form.destroy();
});
- QUnit.test('state_selection widget with readonly modifier', function (assert) {
+ QUnit.test('state_selection widget with readonly modifier', async function (assert) {
assert.expect(4);
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -4471,16 +4464,16 @@ QUnit.module('basic_fields', {
assert.hasClass(form.$('.o_selection > a'), 'disabled');
assert.isNotVisible(form.$('.dropdown-menu.state'));
- testUtils.dom.click(form.$('.o_selection > a'));
+ await testUtils.dom.click(form.$('.o_selection > a'));
assert.isNotVisible(form.$('.dropdown-menu.state'));
form.destroy();
});
- QUnit.test('state_selection widget in editable list view', function (assert) {
+ QUnit.test('state_selection widget in editable list view', async function (assert) {
assert.expect(32);
- var list = createView({
+ var list = await createView({
View: ListView,
model: 'partner',
data: this.data,
@@ -4501,7 +4494,7 @@ QUnit.module('basic_fields', {
// Click on the status button to make the dropdown appear
var $cell = list.$('tbody td.o_state_selection_cell').first();
- testUtils.dom.click(list.$('.o_state_selection_cell .o_selection > a span.o_status').first());
+ await testUtils.dom.click(list.$('.o_state_selection_cell .o_selection > a span.o_status').first());
assert.doesNotHaveClass($cell.parent(), 'o_selected_row',
'should not be in edit mode since we clicked on the state selection widget');
assert.containsOnce(list, '.dropdown-menu.state:visible',
@@ -4510,7 +4503,7 @@ QUnit.module('basic_fields', {
"there should be two options in the dropdown");
// Click on the first option, "Normal"
- testUtils.dom.click(list.$('.dropdown-menu.state:visible .dropdown-item').first());
+ await testUtils.dom.click(list.$('.dropdown-menu.state:visible .dropdown-item').first());
assert.containsN(list, '.o_state_selection_cell .o_selection > a span.o_status', 5,
"should still have five status selection widgets");
assert.containsNone(list, '.o_state_selection_cell .o_selection > a span.o_status.o_status_red',
@@ -4522,7 +4515,7 @@ QUnit.module('basic_fields', {
// switch to edit mode and check the result
$cell = list.$('tbody td.o_state_selection_cell').first();
- testUtils.dom.click($cell);
+ await testUtils.dom.click($cell);
assert.hasClass($cell.parent(),'o_selected_row',
'should now be in edit mode');
assert.containsN(list, '.o_state_selection_cell .o_selection > a span.o_status', 5,
@@ -4535,7 +4528,7 @@ QUnit.module('basic_fields', {
"there should not be a dropdown");
// Click on the status button to make the dropdown appear
- testUtils.dom.click(list.$('.o_state_selection_cell .o_selection > a span.o_status').first());
+ await testUtils.dom.click(list.$('.o_state_selection_cell .o_selection > a span.o_status').first());
assert.containsOnce(list, '.dropdown-menu.state:visible',
"there should be a dropdown");
assert.containsN(list, '.dropdown-menu.state:visible .dropdown-item', 2,
@@ -4543,7 +4536,7 @@ QUnit.module('basic_fields', {
// Click on another row
var $lastCell = list.$('tbody td.o_state_selection_cell').last();
- testUtils.dom.click($lastCell);
+ await testUtils.dom.click($lastCell);
assert.containsNone(list, '.dropdown-menu.state:visible',
"there should not be a dropdown anymore");
var $firstCell = list.$('tbody td.o_state_selection_cell').first();
@@ -4553,14 +4546,14 @@ QUnit.module('basic_fields', {
'last row should be in edit mode');
// Click on the last status button to make the dropdown appear
- testUtils.dom.click(list.$('.o_state_selection_cell .o_selection > a span.o_status').last());
+ await testUtils.dom.click(list.$('.o_state_selection_cell .o_selection > a span.o_status').last());
assert.containsOnce(list, '.dropdown-menu.state:visible',
"there should be a dropdown");
assert.containsN(list, '.dropdown-menu.state:visible .dropdown-item', 2,
"there should be two options in the dropdown");
// Click on the last option, "Done"
- testUtils.dom.click(list.$('.dropdown-menu.state:visible .dropdown-item').last());
+ await testUtils.dom.click(list.$('.dropdown-menu.state:visible .dropdown-item').last());
assert.containsNone(list, '.dropdown-menu.state:visible',
"there should not be a dropdown anymore");
assert.containsN(list, '.o_state_selection_cell .o_selection > a span.o_status', 5,
@@ -4573,7 +4566,7 @@ QUnit.module('basic_fields', {
"there should not be a dropdown");
// save
- testUtils.dom.click(list.$buttons.find('.o_list_button_save'));
+ await testUtils.dom.click(list.$buttons.find('.o_list_button_save'));
assert.containsN(list, '.o_state_selection_cell .o_selection > a span.o_status', 5,
"should have five status selection widgets");
assert.containsNone(list, '.o_state_selection_cell .o_selection > a span.o_status.o_status_red',
@@ -4589,10 +4582,10 @@ QUnit.module('basic_fields', {
QUnit.module('FavoriteWidget');
- QUnit.test('favorite widget in kanban view', function (assert) {
+ QUnit.test('favorite widget in kanban view', async function (assert) {
assert.expect(4);
- var kanban = createView({
+ var kanban = await createView({
View: KanbanView,
model: 'partner',
data: this.data,
@@ -4614,7 +4607,7 @@ QUnit.module('basic_fields', {
'the label should say "Remove from Favorites"');
// click on favorite
- testUtils.dom.click(kanban.$('.o_field_widget.o_favorite'));
+ await testUtils.dom.click(kanban.$('.o_field_widget.o_favorite'));
assert.containsNone(kanban, '.o_kanban_record .o_field_widget.o_favorite > a i.fa.fa-star',
'should not be favorite');
assert.strictEqual(kanban.$('.o_kanban_record .o_field_widget.o_favorite > a').text(), ' Add to Favorites',
@@ -4623,10 +4616,10 @@ QUnit.module('basic_fields', {
kanban.destroy();
});
- QUnit.test('favorite widget in form view', function (assert) {
+ QUnit.test('favorite widget in form view', async function (assert) {
assert.expect(10);
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -4646,28 +4639,28 @@ QUnit.module('basic_fields', {
'the label should say "Remove from Favorites"');
// click on favorite
- testUtils.dom.click(form.$('.o_field_widget.o_favorite'));
+ await testUtils.dom.click(form.$('.o_field_widget.o_favorite'));
assert.containsNone(form, '.o_field_widget.o_favorite > a i.fa.fa-star',
'should not be favorite');
assert.strictEqual(form.$('.o_field_widget.o_favorite > a').text(), ' Add to Favorites',
'the label should say "Add to Favorites"');
// switch to edit mode
- testUtils.form.clickEdit(form);
+ await testUtils.form.clickEdit(form);
assert.containsOnce(form, '.o_field_widget.o_favorite > a i.fa.fa-star-o',
'should not be favorite');
assert.strictEqual(form.$('.o_field_widget.o_favorite > a').text(), ' Add to Favorites',
'the label should say "Add to Favorites"');
// click on favorite
- testUtils.dom.click(form.$('.o_field_widget.o_favorite'));
+ await testUtils.dom.click(form.$('.o_field_widget.o_favorite'));
assert.containsOnce(form, '.o_field_widget.o_favorite > a i.fa.fa-star',
'should be favorite');
assert.strictEqual(form.$('.o_field_widget.o_favorite > a').text(), ' Remove from Favorites',
'the label should say "Remove from Favorites"');
// save
- testUtils.form.clickSave(form);
+ await testUtils.form.clickSave(form);
assert.containsOnce(form, '.o_field_widget.o_favorite > a i.fa.fa-star',
'should be favorite');
assert.strictEqual(form.$('.o_field_widget.o_favorite > a').text(), ' Remove from Favorites',
@@ -4676,10 +4669,10 @@ QUnit.module('basic_fields', {
form.destroy();
});
- QUnit.test('favorite widget in editable list view without label', function (assert) {
+ QUnit.test('favorite widget in editable list view without label', async function (assert) {
assert.expect(4);
- var list = createView({
+ var list = await createView({
View: ListView,
model: 'partner',
data: this.data,
@@ -4692,17 +4685,17 @@ QUnit.module('basic_fields', {
'should be favorite');
// switch to edit mode
- testUtils.dom.click(list.$('tbody td:not(.o_list_record_selector)').first());
+ await testUtils.dom.click(list.$('tbody td:not(.o_list_record_selector)').first());
assert.containsOnce(list, '.o_data_row:first .o_field_widget.o_favorite > a i.fa.fa-star',
'should be favorite');
// click on favorite
- testUtils.dom.click(list.$('.o_data_row:first .o_field_widget.o_favorite'));
+ await testUtils.dom.click(list.$('.o_data_row:first .o_field_widget.o_favorite'));
assert.containsNone(list, '.o_data_row:first .o_field_widget.o_favorite > a i.fa.fa-star',
'should not be favorite');
// save
- testUtils.dom.click(list.$buttons.find('.o_list_button_save'));
+ await testUtils.dom.click(list.$buttons.find('.o_list_button_save'));
assert.containsOnce(list, '.o_data_row:first .o_field_widget.o_favorite > a i.fa.fa-star-o',
'should not be favorite');
@@ -4712,10 +4705,10 @@ QUnit.module('basic_fields', {
QUnit.module('LabelSelectionWidget');
- QUnit.test('label_selection widget in form view', function (assert) {
+ QUnit.test('label_selection widget in form view', async function (assert) {
assert.expect(12);
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -4740,7 +4733,7 @@ QUnit.module('basic_fields', {
"the label should say 'Blocked' since this is the label value for that state");
// // switch to edit mode and check the result
- testUtils.form.clickEdit(form);
+ await testUtils.form.clickEdit(form);
assert.containsOnce(form, '.o_field_widget.badge.badge-warning',
"should have a warning status label since selection is the second, blocked state");
assert.containsNone(form, '.o_field_widget.badge.badge-secondary',
@@ -4751,7 +4744,7 @@ QUnit.module('basic_fields', {
"the label should say 'Blocked' since this is the label value for that state");
// save
- testUtils.form.clickSave(form);
+ await testUtils.form.clickSave(form);
assert.containsOnce(form, '.o_field_widget.badge.badge-warning',
"should have a warning status label since selection is the second, blocked state");
assert.containsNone(form, '.o_field_widget.badge.badge-secondary',
@@ -4764,10 +4757,10 @@ QUnit.module('basic_fields', {
form.destroy();
});
- QUnit.test('label_selection widget in editable list view', function (assert) {
+ QUnit.test('label_selection widget in editable list view', async function (assert) {
assert.expect(21);
- var list = createView({
+ var list = await createView({
View: ListView,
model: 'partner',
data: this.data,
@@ -4794,7 +4787,7 @@ QUnit.module('basic_fields', {
"the success label should read 'Done'");
// switch to edit mode and check the result
- testUtils.dom.click(list.$('tbody td:not(.o_list_record_selector)').first());
+ await testUtils.dom.clickFirst(list.$('tbody td:not(.o_list_record_selector)'));
assert.strictEqual(list.$('.o_field_widget.badge:not(:empty)').length, 3,
"should have three visible status labels");
assert.containsOnce(list, '.o_field_widget.badge.badge-warning',
@@ -4811,7 +4804,7 @@ QUnit.module('basic_fields', {
"the success label should read 'Done'");
// save and check the result
- testUtils.dom.click(list.$buttons.find('.o_list_button_save'));
+ await testUtils.dom.click(list.$buttons.find('.o_list_button_save'));
assert.strictEqual(list.$('.o_field_widget.badge:not(:empty)').length, 3,
"should have three visible status labels");
assert.containsOnce(list, '.o_field_widget.badge.badge-warning',
@@ -4833,7 +4826,7 @@ QUnit.module('basic_fields', {
QUnit.module('StatInfo');
- QUnit.test('statinfo widget formats decimal precision', function (assert) {
+ QUnit.test('statinfo widget formats decimal precision', async function (assert) {
// sometimes the round method can return numbers such as 14.000001
// when asked to round a number to 2 decimals, as such is the behaviour of floats.
// we check that even in that eventuality, only two decimals are displayed
@@ -4843,7 +4836,7 @@ QUnit.module('basic_fields', {
this.data.partner.records[0].monetary = 9.999999;
this.data.partner.records[0].currency_id = 1;
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -4867,10 +4860,10 @@ QUnit.module('basic_fields', {
form.destroy();
});
- QUnit.test('statinfo widget in form view', function (assert) {
+ QUnit.test('statinfo widget in form view', async function (assert) {
assert.expect(9);
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -4897,7 +4890,7 @@ QUnit.module('basic_fields', {
'int_field', "should have 'int_field' as text");
// switch to edit mode and check the result
- testUtils.form.clickEdit(form);
+ await testUtils.form.clickEdit(form);
assert.containsOnce(form, '.oe_stat_button .o_field_widget.o_stat_info',
"should still have one stat button");
assert.strictEqual(form.$('.oe_stat_button .o_field_widget.o_stat_info .o_stat_value').text(),
@@ -4906,7 +4899,7 @@ QUnit.module('basic_fields', {
'int_field', "should have 'int_field' as text");
// save
- testUtils.form.clickSave(form);
+ await testUtils.form.clickSave(form);
assert.containsOnce(form, '.oe_stat_button .o_field_widget.o_stat_info',
"should have one stat button");
assert.strictEqual(form.$('.oe_stat_button .o_field_widget.o_stat_info .o_stat_value').text(),
@@ -4917,10 +4910,10 @@ QUnit.module('basic_fields', {
form.destroy();
});
- QUnit.test('statinfo widget in form view with specific label_field', function (assert) {
+ QUnit.test('statinfo widget in form view with specific label_field', async function (assert) {
assert.expect(9);
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -4949,7 +4942,7 @@ QUnit.module('basic_fields', {
'yop', "should have 'yop' as text, since it is the value of field foo");
// switch to edit mode and check the result
- testUtils.form.clickEdit(form);
+ await testUtils.form.clickEdit(form);
assert.containsOnce(form, '.oe_stat_button .o_field_widget.o_stat_info',
"should still have one stat button");
assert.strictEqual(form.$('.oe_stat_button .o_field_widget.o_stat_info .o_stat_value').text(),
@@ -4958,7 +4951,7 @@ QUnit.module('basic_fields', {
'yop', "should have 'yop' as text, since it is the value of field foo");
// save
- testUtils.form.clickSave(form);
+ await testUtils.form.clickSave(form);
assert.containsOnce(form, '.oe_stat_button .o_field_widget.o_stat_info',
"should have one stat button");
assert.strictEqual(form.$('.oe_stat_button .o_field_widget.o_stat_info .o_stat_value').text(),
@@ -4969,10 +4962,10 @@ QUnit.module('basic_fields', {
form.destroy();
});
- QUnit.test('statinfo widget in form view with no label', function (assert) {
+ QUnit.test('statinfo widget in form view with no label', async function (assert) {
assert.expect(9);
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -5000,7 +4993,7 @@ QUnit.module('basic_fields', {
'', "should not have any label");
// switch to edit mode and check the result
- testUtils.form.clickEdit(form);
+ await testUtils.form.clickEdit(form);
assert.containsOnce(form, '.oe_stat_button .o_field_widget.o_stat_info',
"should still have one stat button");
assert.strictEqual(form.$('.oe_stat_button .o_field_widget.o_stat_info .o_stat_value').text(),
@@ -5009,7 +5002,7 @@ QUnit.module('basic_fields', {
'', "should not have any label");
// save
- testUtils.form.clickSave(form);
+ await testUtils.form.clickSave(form);
assert.containsOnce(form, '.oe_stat_button .o_field_widget.o_stat_info',
"should have one stat button");
assert.strictEqual(form.$('.oe_stat_button .o_field_widget.o_stat_info .o_stat_value').text(),
@@ -5023,10 +5016,10 @@ QUnit.module('basic_fields', {
QUnit.module('PercentPie');
- QUnit.test('percentpie widget in form view with value < 50%', function (assert) {
+ QUnit.test('percentpie widget in form view with value < 50%', async function (assert) {
assert.expect(12);
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -5050,7 +5043,7 @@ QUnit.module('basic_fields', {
'transform: rotate(36deg);'), "right mask should be rotated from 360*(10/100) = 36 degrees");
// switch to edit mode and check the result
- testUtils.form.clickEdit(form);
+ await testUtils.form.clickEdit(form);
assert.containsOnce(form, '.o_field_percent_pie.o_field_widget .o_pie',
"should have a pie chart");
assert.strictEqual(form.$('.o_field_percent_pie.o_field_widget .o_pie .o_pie_value').text(),
@@ -5061,7 +5054,7 @@ QUnit.module('basic_fields', {
'transform: rotate(36deg);'), "right mask should be rotated from 360*(10/100) = 36 degrees");
// save
- testUtils.form.clickSave(form);
+ await testUtils.form.clickSave(form);
assert.containsOnce(form, '.o_field_percent_pie.o_field_widget .o_pie',
"should have a pie chart");
assert.strictEqual(form.$('.o_field_percent_pie.o_field_widget .o_pie .o_pie_value').text(),
@@ -5074,10 +5067,10 @@ QUnit.module('basic_fields', {
form.destroy();
});
- QUnit.test('percentpie widget in form view with value > 50%', function (assert) {
+ QUnit.test('percentpie widget in form view with value > 50%', async function (assert) {
assert.expect(12);
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -5101,7 +5094,7 @@ QUnit.module('basic_fields', {
"right mask should be hidden since the value > 50%");
// switch to edit mode and check the result
- testUtils.form.clickEdit(form);
+ await testUtils.form.clickEdit(form);
assert.containsOnce(form, '.o_field_percent_pie.o_field_widget .o_pie',
"should have a pie chart");
assert.strictEqual(form.$('.o_field_percent_pie.o_field_widget .o_pie .o_pie_value').text(),
@@ -5112,7 +5105,7 @@ QUnit.module('basic_fields', {
"right mask should be hidden since the value > 50%");
// save
- testUtils.form.clickSave(form);
+ await testUtils.form.clickSave(form);
assert.containsOnce(form, '.o_field_percent_pie.o_field_widget .o_pie',
"should have a pie chart");
assert.strictEqual(form.$('.o_field_percent_pie.o_field_widget .o_pie .o_pie_value').text(),
@@ -5131,10 +5124,10 @@ QUnit.module('basic_fields', {
// applies inside the form view, the widget is unusable. This test can
// be uncommented when we refactor the scss files so that this widget
// stylesheet applies in both form and list view.
- // QUnit.test('percentpie widget in editable list view', function(assert) {
+ // QUnit.test('percentpie widget in editable list view', async function(assert) {
// assert.expect(10);
//
- // var list = createView({
+ // var list = await createView({
// View: ListView,
// model: 'partner',
// data: this.data,
@@ -5177,14 +5170,14 @@ QUnit.module('basic_fields', {
QUnit.module('FieldDomain');
- QUnit.test('The domain editor should not crash the view when given a dynamic filter', function (assert) {
+ QUnit.test('The domain editor should not crash the view when given a dynamic filter', async function (assert) {
//dynamic filters (containing variables, such as uid, parent or today)
//are not handled by the domain editor, but it shouldn't crash the view
assert.expect(1);
this.data.partner.records[0].foo = '[["int_field", "=", uid]]';
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -5204,12 +5197,12 @@ QUnit.module('basic_fields', {
form.destroy();
});
- QUnit.test('basic domain field usage is ok', function (assert) {
+ QUnit.test('basic domain field usage is ok', async function (assert) {
assert.expect(7);
this.data.partner.records[0].foo = "[]";
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -5223,7 +5216,7 @@ QUnit.module('basic_fields', {
'</form>',
res_id: 1,
});
- testUtils.form.clickEdit(form);
+ await testUtils.form.clickEdit(form);
// As the domain is empty, there should be a button to add the first
// domain part
@@ -5234,14 +5227,14 @@ QUnit.module('basic_fields', {
// Clicking on the button should add the [["id", "=", "1"]] domain, so
// there should be a field selector in the DOM
- testUtils.dom.click($domainAddFirstNodeButton);
+ await testUtils.dom.click($domainAddFirstNodeButton);
var $fieldSelector = $domain.find(".o_field_selector");
assert.equal($fieldSelector.length, 1,
"there should be a field selector");
// Focusing the field selector input should open the field selector
// popover
- $fieldSelector.trigger('focusin');
+ await testUtils.dom.triggerEvents($fieldSelector, ['focusin']);
var $fieldSelectorPopover = $fieldSelector.find(".o_field_selector_popover");
assert.ok($fieldSelectorPopover.is(":visible"),
"field selector popover should be visible");
@@ -5264,28 +5257,28 @@ QUnit.module('basic_fields', {
// Clicking on this field should close the popover, then changing the
// associated value should reveal one matched record
- testUtils.dom.click($colorIndex);
- $domain.find(".o_domain_leaf_value_input").val(2).change();
+ await testUtils.dom.click($colorIndex);
+ await testUtils.fields.editAndTrigger($('.o_domain_leaf_value_input'), 2, ['change']);
assert.equal($domain.find(".o_domain_show_selection_button").text().trim().substr(0, 2), "1 ",
"changing color value to 2 should reveal only one record");
// Saving the form view should show a readonly domain containing the
// "color" field
- testUtils.form.clickSave(form);
+ await testUtils.form.clickSave(form);
$domain = form.$(".o_field_domain");
assert.ok($domain.html().indexOf("Color index") >= 0,
"field selector readonly value should now contain 'Color index'");
form.destroy();
});
- QUnit.test('domain field is correctly reset on every view change', function (assert) {
+ QUnit.test('domain field is correctly reset on every view change', async function (assert) {
assert.expect(7);
this.data.partner.records[0].foo = '[["id","=",1]]';
this.data.partner.fields.bar.type = "char";
this.data.partner.records[0].bar = "product";
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -5300,7 +5293,7 @@ QUnit.module('basic_fields', {
'</form>',
res_id: 1,
});
- testUtils.form.clickEdit(form);
+ await testUtils.form.clickEdit(form);
// As the domain is equal to [["id", "=", 1]] there should be a field
// selector to change this
@@ -5310,7 +5303,7 @@ QUnit.module('basic_fields', {
"there should be a field selector");
// Focusing its input should open the field selector popover
- $fieldSelector.trigger('focusin');
+ await testUtils.dom.triggerEvents($fieldSelector, ['focusin']);
var $fieldSelectorPopover = $fieldSelector.find(".o_field_selector_popover");
assert.ok($fieldSelectorPopover.is(":visible"),
"field selector popover should be visible");
@@ -5331,8 +5324,8 @@ QUnit.module('basic_fields', {
"field selector popover should contain 'Product Name' field");
// Now change the value of the "bar" field to "partner_type"
- testUtils.dom.click(form.$("input.o_field_widget"));
- testUtils.fields.editInput(form.$("input.o_field_widget"), "partner_type");
+ await testUtils.dom.click(form.$("input.o_field_widget"));
+ await testUtils.fields.editInput(form.$("input.o_field_widget"), "partner_type");
// Refocusing the field selector input should open the popover again
$fieldSelector = form.$(".o_field_selector");
@@ -5357,7 +5350,7 @@ QUnit.module('basic_fields', {
form.destroy();
});
- QUnit.test('domain field can be reset with a new domain (from onchange)', function (assert) {
+ QUnit.test('domain field can be reset with a new domain (from onchange)', async function (assert) {
assert.expect(2);
this.data.partner.records[0].foo = '[]';
@@ -5367,7 +5360,7 @@ QUnit.module('basic_fields', {
},
};
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -5386,7 +5379,7 @@ QUnit.module('basic_fields', {
"the domain being empty, there should be 5 records");
// update display_name to trigger the onchange and reset foo
- testUtils.fields.editInput(form.$('.o_field_widget[name=display_name]'), 'new value');
+ await testUtils.fields.editInput(form.$('.o_field_widget[name=display_name]'), 'new value');
assert.equal(form.$('.o_domain_show_selection_button').text().trim(), '1 record(s)',
"the domain has changed, there should be only 1 record");
@@ -5394,14 +5387,14 @@ QUnit.module('basic_fields', {
form.destroy();
});
- QUnit.test('domain field: handle false domain as []', function (assert) {
+ QUnit.test('domain field: handle false domain as []', async function (assert) {
assert.expect(3);
this.data.partner.records[0].foo = false;
this.data.partner.fields.bar.type = "char";
this.data.partner.records[0].bar = "product";
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -5426,7 +5419,7 @@ QUnit.module('basic_fields', {
assert.strictEqual(form.$('.o_field_widget[name=foo]:not(.o_field_empty)').length, 1,
"there should be a domain field, not considered empty");
- testUtils.form.clickEdit(form);
+ await testUtils.form.clickEdit(form);
var $warning = form.$('.o_field_widget[name=foo] .text-warning');
assert.strictEqual($warning.length, 0, "should not display that the domain is invalid");
@@ -5434,12 +5427,12 @@ QUnit.module('basic_fields', {
form.destroy();
});
- QUnit.test('basic domain field: show the selection', function (assert) {
+ QUnit.test('basic domain field: show the selection', async function (assert) {
assert.expect(2);
this.data.partner.records[0].foo = "[]";
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -5462,21 +5455,21 @@ QUnit.module('basic_fields', {
"selection should contain 2 records");
// open the selection
- testUtils.dom.click(form.$(".o_domain_show_selection_button"));
+ await testUtils.dom.click(form.$(".o_domain_show_selection_button"));
assert.strictEqual($('.modal .o_list_view .o_data_row').length, 2,
"should have open a list view with 2 records in a dialog");
// click on a record -> should not open the record
// we don't actually check that it doesn't open the record because even
// if it tries to, it will crash as we don't define an arch in this test
- testUtils.dom.click($('.modal .o_list_view .o_data_row:first .o_data_cell'));
+ await testUtils.dom.click($('.modal .o_list_view .o_data_row:first .o_data_cell'));
form.destroy();
});
QUnit.module('FieldProgressBar');
- QUnit.test('Field ProgressBar: max_value should update', function (assert) {
+ QUnit.test('Field ProgressBar: max_value should update', async function (assert) {
assert.expect(2);
this.data.partner.records = this.data.partner.records.slice(0,1);
@@ -5489,7 +5482,7 @@ QUnit.module('basic_fields', {
}
};
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -5508,7 +5501,7 @@ QUnit.module('basic_fields', {
'The initial value of the progress bar should be correct');
// trigger the onchange
- form.$('.o_input[name=display_name]').val('new name').trigger('input');
+ await testUtils.fields.editInput(form.$('.o_input[name=display_name]'), 'new name');
assert.strictEqual(form.$('.o_progressbar_value').text(), '999 / 5',
'The value of the progress bar should be correct after the update');
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 949af90fafe..e20ad604c98 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
@@ -111,11 +111,11 @@ QUnit.module('fields', {}, function () {
}]
},
};
- }
+ },
}, function () {
QUnit.module('FieldMany2Many');
- QUnit.test('many2many kanban: edition', function (assert) {
+ QUnit.test('many2many kanban: edition', async function (assert) {
assert.expect(32);
this.data.partner.records[0].timmy = [12, 14];
@@ -123,7 +123,7 @@ QUnit.module('fields', {}, function () {
this.data.partner_type.records.push({ id: 18, display_name: "yellow", color: 4 });
this.data.partner_type.records.push({ id: 21, display_name: "blue", color: 1 });
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -187,7 +187,7 @@ QUnit.module('fields', {}, function () {
assert.ok(!form.$('.o_field_many2many .o-kanban-button-new').length,
'"Add" button should not be visible in readonly');
- testUtils.form.clickEdit(form);
+ await testUtils.form.clickEdit(form);
assert.strictEqual(form.$('.o_kanban_record:not(.o_kanban_ghost)').length, 2,
'should contain 2 records');
@@ -201,20 +201,20 @@ QUnit.module('fields', {}, function () {
'Create button should have "Add" label');
// edit existing subrecord
- testUtils.dom.click(form.$('.oe_kanban_global_click:first()'));
+ await testUtils.dom.click(form.$('.oe_kanban_global_click:first()'));
- testUtils.fields.editInput($('.modal .o_form_view input'), 'new name');
- testUtils.dom.click($('.modal .modal-footer .btn-primary'));
+ await testUtils.fields.editInput($('.modal .o_form_view input'), 'new name');
+ await testUtils.dom.click($('.modal .modal-footer .btn-primary'));
assert.strictEqual(form.$('.o_kanban_record:first() span').text(), 'new name',
'value of subrecord should have been updated');
// add subrecords
// -> single select
- testUtils.dom.click(form.$('.o_field_many2many .o-kanban-button-new'));
+ await testUtils.dom.click(form.$('.o_field_many2many .o-kanban-button-new'));
assert.ok($('.modal .o_list_view').length, "should have opened a list view in a modal");
assert.strictEqual($('.modal .o_list_view tbody .o_list_record_selector').length, 3,
"list view should contain 3 records");
- testUtils.dom.click($('.modal .o_list_view tbody tr:contains(red)'));
+ await testUtils.dom.click($('.modal .o_list_view tbody tr:contains(red)'));
assert.ok(!$('.modal .o_list_view').length, "should have closed the modal");
assert.strictEqual(form.$('.o_kanban_record:not(.o_kanban_ghost)').length, 3,
'kanban should now contain 3 records');
@@ -222,23 +222,23 @@ QUnit.module('fields', {}, function () {
'record "red" should be in the kanban');
// -> multiple select
- testUtils.dom.click(form.$('.o_field_many2many .o-kanban-button-new'));
+ await testUtils.dom.click(form.$('.o_field_many2many .o-kanban-button-new'));
assert.ok($('.modal .o_select_button').prop('disabled'), "select button should be disabled");
assert.strictEqual($('.modal .o_list_view tbody .o_list_record_selector').length, 2,
"list view should contain 2 records");
- testUtils.dom.click($('.modal .o_list_view thead .o_list_record_selector input'));
- testUtils.dom.click($('.modal .o_select_button'));
+ await testUtils.dom.click($('.modal .o_list_view thead .o_list_record_selector input'));
+ await testUtils.dom.click($('.modal .o_select_button'));
assert.ok(!$('.modal .o_select_button').prop('disabled'), "select button should be enabled");
assert.ok(!$('.modal .o_list_view').length, "should have closed the modal");
assert.strictEqual(form.$('.o_kanban_record:not(.o_kanban_ghost)').length, 5,
'kanban should now contain 5 records');
// -> created record
- testUtils.dom.click(form.$('.o_field_many2many .o-kanban-button-new'));
- testUtils.dom.click($('.modal .modal-footer .btn-primary:nth(1)'));
+ await testUtils.dom.click(form.$('.o_field_many2many .o-kanban-button-new'));
+ await testUtils.dom.click($('.modal .modal-footer .btn-primary:nth(1)'));
assert.ok($('.modal .o_form_view.o_form_editable').length,
"should have opened a form view in edit mode, in a modal");
- testUtils.fields.editInput($('.modal .o_form_view input'), 'A new type');
- testUtils.dom.click($('.modal:nth(1) footer .btn-primary:first()'));
+ await testUtils.fields.editInput($('.modal .o_form_view input'), 'A new type');
+ await testUtils.dom.click($('.modal:nth(1) footer .btn-primary:first()'));
assert.ok(!$('.modal').length, "should have closed both modals");
assert.strictEqual(form.$('.o_kanban_record:not(.o_kanban_ghost)').length, 6,
'kanban should now contain 6 records');
@@ -246,32 +246,32 @@ QUnit.module('fields', {}, function () {
'the newly created type should be in the kanban');
// delete subrecords
- testUtils.dom.click(form.$('.o_kanban_record:contains(silver)'));
+ await testUtils.dom.click(form.$('.o_kanban_record:contains(silver)'));
assert.strictEqual($('.modal .modal-footer .o_btn_remove').length, 1,
'There should be a modal having Remove Button');
- testUtils.dom.click($('.modal .modal-footer .o_btn_remove'));
+ await testUtils.dom.click($('.modal .modal-footer .o_btn_remove'));
assert.strictEqual(form.$('.o_kanban_record:not(.o_kanban_ghost)').length, 5,
'should contain 5 records');
assert.ok(!form.$('.o_kanban_record:contains(silver)').length,
'the removed record should not be in kanban anymore');
- testUtils.dom.click(form.$('.o_kanban_record:contains(blue) .delete_icon'));
+ await testUtils.dom.click(form.$('.o_kanban_record:contains(blue) .delete_icon'));
assert.strictEqual(form.$('.o_kanban_record:not(.o_kanban_ghost)').length, 4,
'should contain 4 records');
assert.ok(!form.$('.o_kanban_record:contains(blue)').length,
'the removed record should not be in kanban anymore');
// save the record
- testUtils.form.clickSave(form);
+ await testUtils.form.clickSave(form);
form.destroy();
});
- QUnit.test('many2many kanban(editable): properly handle create_text node option', function (assert) {
+ QUnit.test('many2many kanban(editable): properly handle create_text node option', async function (assert) {
assert.expect(1);
this.data.partner.records[0].timmy = [12];
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -291,19 +291,19 @@ QUnit.module('fields', {}, function () {
res_id: 1,
});
- testUtils.form.clickEdit(form);
+ await testUtils.form.clickEdit(form);
assert.strictEqual(form.$('.o_field_many2many[name="timmy"] .o-kanban-button-new').text().trim(),
"Add timmy", "In M2M Kanban, Add button should have 'Add timmy' label");
form.destroy();
});
- QUnit.test('many2many kanban: create action disabled', function (assert) {
+ QUnit.test('many2many kanban: create action disabled', async function (assert) {
assert.expect(4);
this.data.partner.records[0].timmy = [12, 14];
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -335,27 +335,27 @@ QUnit.module('fields', {}, function () {
assert.ok(!form.$('.o-kanban-button-new').length,
'"Add" button should not be available in readonly');
- testUtils.form.clickEdit(form);
+ await testUtils.form.clickEdit(form);
assert.ok(form.$('.o-kanban-button-new').length,
'"Add" button should be available in edit');
assert.ok(form.$('.o_kanban_view .delete_icon').length,
'delete icon should be visible in edit');
- testUtils.dom.click(form.$('.o-kanban-button-new'));
+ await testUtils.dom.click(form.$('.o-kanban-button-new'));
assert.strictEqual($('.modal .modal-footer .btn-primary').length, 1, // only button 'Select'
'"Create" button should not be available in the modal');
form.destroy();
});
- QUnit.test('many2many list (non editable): edition', function (assert) {
+ QUnit.test('many2many list (non editable): edition', async function (assert) {
assert.expect(27);
this.data.partner.records[0].timmy = [12, 14];
this.data.partner_type.records.push({ id: 15, display_name: "bronze", color: 6 });
this.data.partner_type.fields.float_field = { string: 'Float', type: 'float' };
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -392,7 +392,7 @@ QUnit.module('fields', {}, function () {
assert.ok(!form.$('.o_field_x2many_list_row_add').length,
'"Add an item" should not be visible in readonly');
- testUtils.form.clickEdit(form);
+ await testUtils.form.clickEdit(form);
assert.containsN(form, '.o_list_view td.o_list_number', 2,
'should contain 2 records');
@@ -404,34 +404,34 @@ QUnit.module('fields', {}, function () {
'"Add an item" should be visible in edit');
// edit existing subrecord
- testUtils.dom.click(form.$('.o_list_view tbody tr:first()'));
+ await testUtils.dom.click(form.$('.o_list_view tbody tr:first()'));
- testUtils.fields.editInput($('.modal .o_form_view input'), 'new name');
- testUtils.dom.click($('.modal .modal-footer .btn-primary'));
+ await testUtils.fields.editInput($('.modal .o_form_view input'), 'new name');
+ await testUtils.dom.click($('.modal .modal-footer .btn-primary'));
assert.strictEqual(form.$('.o_list_view tbody td:first()').text(), 'new name',
'value of subrecord should have been updated');
// add new subrecords
- testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
+ await testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
assert.strictEqual($('.modal .o_list_view').length, 1,
"a modal should be open");
assert.strictEqual($('.modal .o_list_view .o_data_row').length, 1,
"the list should contain one row");
- testUtils.dom.click($('.modal .o_list_view .o_data_row'));
+ await testUtils.dom.click($('.modal .o_list_view .o_data_row'));
assert.strictEqual($('.modal .o_list_view').length, 0,
"the modal should be closed");
assert.containsN(form, '.o_list_view td.o_list_number', 3,
'should contain 3 subrecords');
// remove subrecords
- testUtils.dom.click(form.$('.o_list_record_remove:nth(1)'));
+ await testUtils.dom.click(form.$('.o_list_record_remove:nth(1)'));
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(), 'new name',
'the updated row still has the correct values');
// save
- testUtils.form.clickSave(form);
+ await 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(),
@@ -453,13 +453,13 @@ QUnit.module('fields', {}, function () {
form.destroy();
});
- QUnit.test('many2many list (editable): edition', function (assert) {
+ QUnit.test('many2many list (editable): edition', async function (assert) {
assert.expect(31);
this.data.partner.records[0].timmy = [12, 14];
this.data.partner_type.records.push({ id: 15, display_name: "bronze", color: 6 });
this.data.partner_type.fields.float_field = { string: 'Float', type: 'float' };
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -494,7 +494,7 @@ QUnit.module('fields', {}, function () {
assert.ok(!form.$('.o_field_x2many_list_row_add').length,
'"Add an item" should not be visible in readonly');
- testUtils.form.clickEdit(form);
+ await testUtils.form.clickEdit(form);
assert.containsN(form, '.o_list_view td.o_list_number', 2,
'should contain 2 records');
@@ -508,17 +508,17 @@ QUnit.module('fields', {}, function () {
'"Add an item" should not visible in edit');
// edit existing subrecord
- testUtils.dom.click(form.$('.o_list_view tbody td:first()'));
+ await testUtils.dom.click(form.$('.o_list_view tbody td:first()'));
assert.ok(!$('.modal').length,
'in edit, clicking on a subrecord should not open a dialog');
assert.hasClass(form.$('.o_list_view tbody tr:first()'),'o_selected_row',
'first row should be in edition');
- testUtils.fields.editInput(form.$('.o_list_view input:first()'), 'new name');
+ await testUtils.fields.editInput(form.$('.o_list_view input:first()'), 'new name');
assert.hasClass(form.$('.o_list_view .o_data_row:first'),'o_selected_row',
'first row should still be in edition');
assert.strictEqual(form.$('.o_list_view input[name=display_name]').get(0),
document.activeElement, 'edited field should still have the focus');
- testUtils.dom.click(form.$el);
+ await testUtils.dom.click(form.$el);
assert.doesNotHaveClass(form.$('.o_list_view tbody tr:first'), 'o_selected_row',
'first row should not be in edition anymore');
assert.strictEqual(form.$('.o_list_view tbody td:first()').text(), 'new name',
@@ -526,34 +526,32 @@ QUnit.module('fields', {}, function () {
assert.verifySteps(['read', 'read']);
// add new subrecords
- testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
+ await testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
assert.strictEqual($('.modal .o_list_view').length, 1,
"a modal should be open");
assert.strictEqual($('.modal .o_list_view .o_data_row').length, 1,
"the list should contain one row");
- testUtils.dom.click($('.modal .o_list_view .o_data_row'));
+ await testUtils.dom.click($('.modal .o_list_view .o_data_row'));
assert.strictEqual($('.modal .o_list_view').length, 0,
"the modal should be closed");
assert.containsN(form, '.o_list_view td.o_list_number', 3,
'should contain 3 subrecords');
// remove subrecords
- testUtils.dom.click(form.$('.o_list_record_remove:nth(1)'));
+ await testUtils.dom.click(form.$('.o_list_record_remove:nth(1)'));
assert.containsN(form, '.o_list_view td.o_list_number', 2,
'should contain 2 subrecord');
assert.strictEqual(form.$('.o_list_view tbody .o_data_row td:first').text(),
'new name', 'the updated row still has the correct values');
// save
- testUtils.form.clickSave(form);
+ await 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(),
'new name', 'the updated row still has the correct values');
assert.verifySteps([
- 'read', // main record
- 'read', // relational field
'search_read', // list view in dialog
'read', // relational field (updated)
'write', // save main record
@@ -564,12 +562,12 @@ QUnit.module('fields', {}, function () {
form.destroy();
});
- QUnit.test('many2many: create & delete attributes', function (assert) {
+ QUnit.test('many2many: create & delete attributes', async function (assert) {
assert.expect(4);
this.data.partner.records[0].timmy = [12, 14];
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -583,14 +581,14 @@ QUnit.module('fields', {}, function () {
res_id: 1,
});
- testUtils.form.clickEdit(form);
+ await testUtils.form.clickEdit(form);
assert.containsOnce(form, '.o_field_x2many_list_row_add', "should have the 'Add an item' link");
assert.containsN(form, '.o_list_record_remove', 2, "should have the 'Add an item' link");
form.destroy();
- form = createView({
+ form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -604,7 +602,7 @@ QUnit.module('fields', {}, function () {
res_id: 1,
});
- testUtils.form.clickEdit(form);
+ await testUtils.form.clickEdit(form);
assert.containsNone(form, '.o_field_x2many_list_row_add', "should not have the 'Add an item' link");
assert.containsNone(form, '.o_list_record_remove', "should not have the 'Add an item' link");
@@ -612,9 +610,9 @@ QUnit.module('fields', {}, function () {
form.destroy();
});
- QUnit.test('many2many list: create action disabled', function (assert) {
+ QUnit.test('many2many list: create action disabled', async function (assert) {
assert.expect(2);
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -631,7 +629,7 @@ QUnit.module('fields', {}, function () {
assert.ok(!form.$('.o_field_x2many_list_row_add').length,
'"Add an item" link should not be available in readonly');
- testUtils.form.clickEdit(form);
+ await testUtils.form.clickEdit(form);
assert.ok(!form.$('.o_field_x2many_list_row_add').length,
'"Add an item" link should not be available in edit either');
@@ -639,13 +637,13 @@ QUnit.module('fields', {}, function () {
form.destroy();
});
- QUnit.test('many2many list: list of id as default value', function (assert) {
+ QUnit.test('many2many list: list of id as default value', async function (assert) {
assert.expect(1);
this.data.partner.fields.turtles.default = [2, 3];
this.data.partner.fields.turtles.type = "many2many";
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -664,13 +662,13 @@ QUnit.module('fields', {}, function () {
form.destroy();
});
- QUnit.test('many2many checkboxes with default values', function (assert) {
+ QUnit.test('many2many checkboxes with default values', async function (assert) {
assert.expect(7);
this.data.partner.fields.turtles.default = [3];
this.data.partner.fields.turtles.type = "many2many";
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -694,10 +692,10 @@ QUnit.module('fields', {}, function () {
assert.ok(form.$('.o_form_view .custom-checkbox input').eq(2).prop('checked'),
"third checkbox should be checked");
- 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());
+ await testUtils.dom.click(form.$('.o_form_view .custom-checkbox input:checked'));
+ await testUtils.dom.click(form.$('.o_form_view .custom-checkbox input').first());
+ await testUtils.dom.click(form.$('.o_form_view .custom-checkbox input').first());
+ await testUtils.dom.click(form.$('.o_form_view .custom-checkbox input').first());
assert.ok(form.$('.o_form_view .custom-checkbox input').eq(0).prop('checked'),
"first checkbox should be checked");
@@ -706,12 +704,12 @@ QUnit.module('fields', {}, function () {
assert.notOk(form.$('.o_form_view .custom-checkbox input').eq(2).prop('checked'),
"third checkbox should not be checked");
- testUtils.form.clickSave(form);
+ await testUtils.form.clickSave(form);
form.destroy();
});
- QUnit.test('many2many list with x2many: add a record', function (assert) {
+ QUnit.test('many2many list with x2many: add a record', async function (assert) {
assert.expect(18);
this.data.partner_type.fields.m2m = {
@@ -720,7 +718,7 @@ QUnit.module('fields', {}, function () {
this.data.partner_type.records[0].m2m = [1, 2];
this.data.partner_type.records[1].m2m = [2, 3];
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -742,7 +740,7 @@ QUnit.module('fields', {}, function () {
assert.step(_.last(route.split('/')) + ' on ' + args.model);
}
if (args.model === 'turtle') {
- assert.step(args.args[0]); // the read ids
+ assert.step(JSON.stringify(args.args[0])); // the read ids
}
return this._super.apply(this, arguments);
},
@@ -751,16 +749,16 @@ QUnit.module('fields', {}, function () {
},
});
- testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
- testUtils.dom.click($('.modal .o_data_row:first'));
+ await testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
+ await testUtils.dom.click($('.modal .o_data_row:first'));
assert.containsOnce(form, '.o_data_row',
"the record should have been added to the relation");
assert.strictEqual(form.$('.o_data_row:first .o_badge_text').text(), 'leonardodonatello',
"inner m2m should have been fetched and correctly displayed");
- testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
- testUtils.dom.click($('.modal .o_data_row:first'));
+ await testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
+ await testUtils.dom.click($('.modal .o_data_row:first'));
assert.containsN(form, '.o_data_row', 2,
"the second record should have been added to the relation");
@@ -771,27 +769,27 @@ QUnit.module('fields', {}, function () {
'read on partner',
'search_read on partner_type',
'read on turtle',
- [1, 2, 3],
+ '[1,2,3]',
'read on partner_type',
'read on turtle',
- [1, 2],
+ '[1,2]',
'search_read on partner_type',
'read on turtle',
- [2, 3],
+ '[2,3]',
'read on partner_type',
'read on turtle',
- [2, 3],
+ '[2,3]',
]);
form.destroy();
});
- QUnit.test('many2many with a domain', function (assert) {
+ QUnit.test('many2many with a domain', async function (assert) {
// The domain specified on the field should not be replaced by the potential
// domain the user writes in the dialog, they should rather be concatenated
assert.expect(2);
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -812,24 +810,24 @@ QUnit.module('fields', {}, function () {
},
});
- testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
+ await testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
assert.strictEqual($('.modal .o_data_row').length, 1,
"should contain only one row (gold)");
- $('.modal .o_searchview_input').trigger({ type: 'keypress', which: 115 }); // s
- $('.modal .o_searchview_input').trigger({ type: 'keydown', which: 13 }); // enter
+ await testUtils.fields.triggerKey('press', $('.modal .o_searchview_input'), 's');
+ await testUtils.fields.triggerKeydown($('.modal .o_searchview_input'), 'enter');
assert.strictEqual($('.modal .o_data_row').length, 0, "should contain no row");
form.destroy();
});
- QUnit.test('many2many list with onchange and edition of a record', function (assert) {
+ QUnit.test('many2many list with onchange and edition of a record', async function (assert) {
assert.expect(8);
this.data.partner.fields.turtles.type = "many2many";
this.data.partner.onchanges.turtles = function () { };
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -850,14 +848,14 @@ QUnit.module('fields', {}, function () {
},
});
- testUtils.form.clickEdit(form);
- testUtils.dom.click(form.$('td.o_data_cell:first'));
+ await testUtils.form.clickEdit(form);
+ await testUtils.dom.click(form.$('td.o_data_cell:first'));
- testUtils.dom.click($('.modal-body input[type="checkbox"]'));
- testUtils.dom.click($('.modal .modal-footer .btn-primary').first());
+ await testUtils.dom.click($('.modal-body input[type="checkbox"]'));
+ await 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);
+ await testUtils.form.clickSave(form);
assert.verifySteps([
'read', // read initial record (on partner)
@@ -872,10 +870,10 @@ QUnit.module('fields', {}, function () {
form.destroy();
});
- QUnit.test('onchange with 40+ commands for a many2many', function (assert) {
+ QUnit.test('onchange with 40+ commands for a many2many', async function (assert) {
// this test ensures that the basic_model correctly handles more LINK_TO
// commands than the limit of the dataPoint (40 for x2many kanban)
- assert.expect(23);
+ assert.expect(24);
// create a lot of partner_types that will be linked by the onchange
var commands = [[5]];
@@ -890,7 +888,7 @@ QUnit.module('fields', {}, function () {
},
};
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -925,44 +923,45 @@ QUnit.module('fields', {}, function () {
assert.verifySteps(['read']);
- testUtils.fields.editInput(form.$('.o_field_widget[name=foo]'), 'trigger onchange');
+ await testUtils.fields.editInput(form.$('.o_field_widget[name=foo]'), 'trigger onchange');
- assert.verifySteps(['read', 'onchange', 'read']);
+ assert.verifySteps(['onchange', 'read']);
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_field_widget[name=timmy] .o_pager_next'));
- assert.verifySteps(['read', 'onchange', 'read', 'read']);
+ await testUtils.dom.click(form.$('.o_field_widget[name=timmy] .o_pager_next'));
+ assert.verifySteps(['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);
+ await 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_field_widget[name=timmy] .o_pager_next'));
+ await 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_field_widget[name=timmy] .o_pager_next'));
+ await 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,
'there should be 40 records displayed on page 1');
+ assert.verifySteps(['write', 'read', 'read', 'read']);
form.destroy();
});
- QUnit.test('default_get, onchange, onchange on m2m', function (assert) {
+ QUnit.test('default_get, onchange, onchange on m2m', async function (assert) {
assert.expect(1);
this.data.partner.onchanges.int_field = function (obj) {
@@ -978,7 +977,7 @@ QUnit.module('fields', {}, function () {
];
};
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -994,15 +993,15 @@ QUnit.module('fields', {}, function () {
'</form>',
});
- testUtils.fields.editInput(form.$('.o_field_widget[name=int_field]'), 2);
+ await testUtils.fields.editInput(form.$('.o_field_widget[name=int_field]'), 2);
form.destroy();
});
- QUnit.test('widget many2many_tags', function (assert) {
+ QUnit.test('widget many2many_tags', async function (assert) {
assert.expect(1);
this.data.turtle.records[0].partner_ids = [2];
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'turtle',
data: this.data,
@@ -1023,7 +1022,7 @@ QUnit.module('fields', {}, function () {
form.destroy();
});
- QUnit.test('many2many list add *many* records, remove, re-add', function (assert) {
+ QUnit.test('many2many list add *many* records, remove, re-add', async function (assert) {
assert.expect(5);
this.data.partner.fields.timmy.domain = [['color', '=', 2]];
@@ -1035,7 +1034,7 @@ QUnit.module('fields', {}, function () {
this.data.partner_type.records.push(new_record_partner_type);
}
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -1055,52 +1054,52 @@ QUnit.module('fields', {}, function () {
mockRPC: function (route, args) {
if (args.method === 'get_formview_id') {
assert.deepEqual(args.args[0], [1], "should call get_formview_id with correct id");
- return $.when(false);
+ return Promise.resolve(false);
}
return this._super(route, args);
},
});
// First round: add 51 records in batch
- testUtils.dom.click(form.$buttons.find('.btn.btn-primary.o_form_button_edit'));
- testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
+ await testUtils.dom.click(form.$buttons.find('.btn.btn-primary.o_form_button_edit'));
+ await testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
var $modal = $('.modal-lg');
assert.equal($modal.length, 1,
'There should be one modal');
- testUtils.dom.click($modal.find('thead input[type=checkbox]'));
+ await testUtils.dom.click($modal.find('thead input[type=checkbox]'));
- testUtils.dom.click($modal.find('.btn.btn-primary.o_select_button'));
+ await testUtils.dom.click($modal.find('.btn.btn-primary.o_select_button'));
var m2m_records = form.$('.o_field_many2many.o_field_widget.o_field_x2many.o_field_x2many_list .o_data_cell:not(.o_many2many_tags_cell)');
assert.equal(m2m_records.length, 51,
'We should have added all the records present in the search view to the m2m field'); // the 50 in batch + 'gold'
- testUtils.dom.click(form.$buttons.find('.btn.btn-primary.o_form_button_save'));
+ await testUtils.dom.click(form.$buttons.find('.btn.btn-primary.o_form_button_save'));
// Secound round: remove one record
- testUtils.dom.click(form.$buttons.find('.btn.btn-primary.o_form_button_edit'));
+ await testUtils.dom.click(form.$buttons.find('.btn.btn-primary.o_form_button_edit'));
var trash_buttons = form.$('.o_field_many2many.o_field_widget.o_field_x2many.o_field_x2many_list .o_list_record_remove');
- testUtils.dom.click(trash_buttons.first());
+ await testUtils.dom.click(trash_buttons.first());
var pager_limit = form.$('.o_field_many2many.o_field_widget.o_field_x2many.o_field_x2many_list .o_pager_limit');
assert.equal(pager_limit.text(), '50',
'We should have 50 records in the m2m field');
// Third round: re-add 1 records
- testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
+ await testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
$modal = $('.modal-lg');
assert.equal($modal.length, 1,
'There should be one modal');
- testUtils.dom.click($modal.find('thead input[type=checkbox]'));
+ await testUtils.dom.click($modal.find('thead input[type=checkbox]'));
- testUtils.dom.click($modal.find('.btn.btn-primary.o_select_button'));
+ await testUtils.dom.click($modal.find('.btn.btn-primary.o_select_button'));
pager_limit = form.$('.o_field_many2many.o_field_widget.o_field_x2many.o_field_x2many_list .o_pager_limit');
assert.equal(pager_limit.text(), '51',
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 04b58b017ba..4f2a3d03bed 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
@@ -150,13 +150,13 @@ QUnit.module('fields', {}, function () {
}]
},
};
- }
+ },
}, function () {
QUnit.module('FieldMany2One');
- QUnit.test('many2ones in form views', function (assert) {
+ QUnit.test('many2ones in form views', async function (assert) {
assert.expect(5);
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -174,7 +174,7 @@ QUnit.module('fields', {}, function () {
mockRPC: function (route, args) {
if (args.method === 'get_formview_action') {
assert.deepEqual(args.args[0], [4], "should call get_formview_action with correct id");
- return $.when({
+ return Promise.resolve({
res_id: 17,
type: 'ir.actions.act_window',
target: 'current',
@@ -183,7 +183,7 @@ QUnit.module('fields', {}, function () {
}
if (args.method === 'get_formview_id') {
assert.deepEqual(args.args[0], [4], "should call get_formview_id with correct id");
- return $.when(false);
+ return Promise.resolve(false);
}
return this._super(route, args);
},
@@ -196,23 +196,22 @@ QUnit.module('fields', {}, function () {
assert.strictEqual(form.$('a.o_form_uri:contains(aaa)').length, 1,
"should contain a link");
- testUtils.dom.click(form.$('a.o_form_uri'));
+ await testUtils.dom.click(form.$('a.o_form_uri'));
- testUtils.form.clickEdit(form);
-
- testUtils.dom.click(form.$('.o_external_button'));
+ await testUtils.form.clickEdit(form);
+ await testUtils.dom.click(form.$('.o_external_button'));
assert.strictEqual($('.modal .modal-title').text().trim(), 'Open: custom label',
"dialog title should display the custom string label");
- // TODO: test that we can edit the record in the dialog, and that the value is correctly
- // updated on close
+ // TODO: test that we can edit the record in the dialog, and that
+ // the value is correctly updated on close
form.destroy();
});
- QUnit.test('editing a many2one, but not changing anything', function (assert) {
+ QUnit.test('editing a many2one, but not changing anything', async function (assert) {
assert.expect(2);
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -228,7 +227,7 @@ QUnit.module('fields', {}, function () {
mockRPC: function (route, args) {
if (args.method === 'get_formview_id') {
assert.deepEqual(args.args[0], [4], "should call get_formview_id with correct id");
- return $.when(false);
+ return Promise.resolve(false);
}
return this._super(route, args);
},
@@ -237,16 +236,16 @@ QUnit.module('fields', {}, function () {
},
});
- testUtils.form.clickEdit(form);
+ await testUtils.form.clickEdit(form);
// click on the external button (should do an RPC)
- testUtils.dom.click(form.$('.o_external_button'));
+ await testUtils.dom.click(form.$('.o_external_button'));
// save and close modal
- testUtils.dom.click($('.modal .modal-footer .btn-primary:first'));
+ await testUtils.dom.click($('.modal .modal-footer .btn-primary:first'));
// save form
- testUtils.form.clickSave(form);
+ await testUtils.form.clickSave(form);
// click next on pager
- testUtils.dom.click(form.pager.$('.o_pager_next'));
+ await testUtils.dom.click(form.pager.$('.o_pager_next'));
// this checks that the view did not ask for confirmation that the
// record is dirty
@@ -255,13 +254,13 @@ QUnit.module('fields', {}, function () {
form.destroy();
});
- QUnit.test('context in many2one and default get', function (assert) {
+ QUnit.test('context in many2one and default get', async function (assert) {
assert.expect(1);
this.data.partner.fields.int_field.default = 14;
this.data.partner.fields.trululu.default = 2;
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -280,9 +279,9 @@ QUnit.module('fields', {}, function () {
form.destroy();
});
- QUnit.test('editing a many2one (with form view opened with external button)', function (assert) {
+ QUnit.test('editing a many2one (with form view opened with external button)', async function (assert) {
assert.expect(1);
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -297,7 +296,7 @@ QUnit.module('fields', {}, function () {
res_id: 1,
mockRPC: function (route, args) {
if (args.method === 'get_formview_id') {
- return $.when(false);
+ return Promise.resolve(false);
}
return this._super(route, args);
},
@@ -306,19 +305,19 @@ QUnit.module('fields', {}, function () {
},
});
- testUtils.form.clickEdit(form);
+ await testUtils.form.clickEdit(form);
// click on the external button (should do an RPC)
- testUtils.dom.click(form.$('.o_external_button'));
+ await testUtils.dom.click(form.$('.o_external_button'));
- testUtils.fields.editInput($('.modal input[name="foo"]'), 'brandon');
+ await testUtils.fields.editInput($('.modal input[name="foo"]'), 'brandon');
// save and close modal
- testUtils.dom.click($('.modal .modal-footer .btn-primary:first'));
+ await testUtils.dom.click($('.modal .modal-footer .btn-primary:first'));
// save form
- testUtils.form.clickSave(form);
+ await testUtils.form.clickSave(form);
// click next on pager
- testUtils.dom.click(form.pager.$('.o_pager_next'));
+ await testUtils.dom.click(form.pager.$('.o_pager_next'));
// this checks that the view did not ask for confirmation that the
// record is dirty
@@ -327,9 +326,9 @@ QUnit.module('fields', {}, function () {
form.destroy();
});
- QUnit.test('many2ones in form views with show_adress', function (assert) {
+ QUnit.test('many2ones in form views with show_adress', async function (assert) {
assert.expect(4);
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -359,7 +358,7 @@ QUnit.module('fields', {}, function () {
assert.strictEqual($('a.o_form_uri').html(), 'aaa<br>Street<br>City ZIP',
"input should have a multi-line content in readonly due to show_address");
- testUtils.form.clickEdit(form);
+ await testUtils.form.clickEdit(form);
assert.containsOnce(form, 'button.o_external_button:visible',
"should have an open record button");
@@ -374,12 +373,12 @@ QUnit.module('fields', {}, function () {
form.destroy();
});
- QUnit.test('show_address works in a view embedded in a view of another type', function (assert) {
+ QUnit.test('show_address works in a view embedded in a view of another type', async function (assert) {
assert.expect(1);
this.data.turtle.records[1].turtle_trululu = 2;
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -410,19 +409,19 @@ QUnit.module('fields', {}, function () {
},
});
// click the turtle field, opens a modal with the turtle form view
- testUtils.dom.click(form.$('.o_data_row:first td.o_data_cell'));
+ await testUtils.dom.click(form.$('.o_data_row:first td.o_data_cell'));
assert.strictEqual($('[name="turtle_trululu"]').text(), "second recordrue morgueparis 75013",
"The partner's address should be displayed");
form.destroy();
});
- QUnit.test('many2one data is reloaded if there is a context to take into account', function (assert) {
+ QUnit.test('many2one data is reloaded if there is a context to take into account', async function (assert) {
assert.expect(1);
this.data.turtle.records[1].turtle_trululu = 2;
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -454,14 +453,14 @@ QUnit.module('fields', {}, function () {
},
});
// click the turtle field, opens a modal with the turtle form view
- testUtils.dom.click(form.$('.o_data_row:first'));
+ await testUtils.dom.click(form.$('.o_data_row:first'));
assert.strictEqual($('.modal [name=turtle_trululu]').text(), "second recordrue morgueparis 75013",
"The partner's address should be displayed");
form.destroy();
});
- QUnit.test('many2ones in form views with search more', function (assert) {
+ QUnit.test('many2ones in form views with search more', async function (assert) {
assert.expect(3);
this.data.partner.records.push({
id: 5,
@@ -483,7 +482,7 @@ QUnit.module('fields', {}, function () {
display_name: "Partner 9",
});
this.data.partner.fields.datetime.searchable = true;
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -501,29 +500,29 @@ QUnit.module('fields', {}, function () {
res_id: 1,
});
- testUtils.form.clickEdit(form);
+ await testUtils.form.clickEdit(form);
- testUtils.fields.many2one.clickOpenDropdown('trululu');
- testUtils.fields.many2one.clickItem('trululu', 'Search');
+ await testUtils.fields.many2one.clickOpenDropdown('trululu');
+ await testUtils.fields.many2one.clickItem('trululu', 'Search');
assert.strictEqual($('tr.o_data_row').length, 9, "should display 9 records");
- testUtils.dom.click($('button:contains(Filters)'));
- testUtils.dom.click($('.o_add_custom_filter:visible'));
+ 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',
"datetime field should be selected");
- testUtils.dom.click($('.o_apply_filter'));
+ await testUtils.dom.click($('.o_apply_filter'));
assert.strictEqual($('tr.o_data_row').length, 0, "should display 0 records");
form.destroy();
});
- QUnit.test('onchanges on many2ones trigger when editing record in form view', function (assert) {
+ QUnit.test('onchanges on many2ones trigger when editing record in form view', async function (assert) {
assert.expect(10);
this.data.partner.onchanges.user_id = function () { };
this.data.user.fields.other_field = { string: "Other Field", type: "char" };
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -541,7 +540,7 @@ QUnit.module('fields', {}, function () {
mockRPC: function (route, args) {
assert.step(args.method);
if (args.method === 'get_formview_id') {
- return $.when(false);
+ return Promise.resolve(false);
}
if (args.method === 'onchange') {
assert.strictEqual(args.args[1].user_id, 17,
@@ -552,25 +551,25 @@ QUnit.module('fields', {}, function () {
});
// open the many2one in form view and change something
- testUtils.form.clickEdit(form);
- testUtils.dom.click(form.$('.o_external_button'));
- testUtils.fields.editInput($('.modal-body input[name="other_field"]'), 'wood');
+ await testUtils.form.clickEdit(form);
+ await testUtils.dom.click(form.$('.o_external_button'));
+ await testUtils.fields.editInput($('.modal-body input[name="other_field"]'), 'wood');
// save the modal and make sure an onchange is triggered
- testUtils.dom.click($('.modal .modal-footer .btn-primary').first());
+ await testUtils.dom.click($('.modal .modal-footer .btn-primary').first());
assert.verifySteps(['read', 'get_formview_id', 'load_views', 'read', 'write', 'onchange', 'read']);
// 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);
- assert.verifySteps(['read', 'get_formview_id', 'load_views', 'read', 'write', 'onchange', 'read']);
+ await testUtils.form.clickSave(form);
+ assert.verifySteps([]);
form.destroy();
});
- QUnit.test('many2one fields with option "no_open"', function (assert) {
+ QUnit.test('many2one fields with option "no_open"', async function (assert) {
assert.expect(3);
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -588,13 +587,13 @@ QUnit.module('fields', {}, function () {
"should be displayed inside a span (sanity check)");
assert.containsNone(form, 'span.o_form_uri', "should not have an anchor");
- testUtils.form.clickEdit(form);
+ await testUtils.form.clickEdit(form);
assert.containsNone(form, '.o_field_widget[name=trululu] .o_external_button', "should not have the button to open the record");
form.destroy();
});
- QUnit.test('many2one in edit mode', function (assert) {
+ QUnit.test('many2one in edit mode', async function (assert) {
assert.expect(16);
// create 10 partners to have the 'Search More' option in the autocomplete dropdown
@@ -603,7 +602,7 @@ QUnit.module('fields', {}, function () {
this.data.partner.records.push({ id: id, display_name: "Partner " + id });
}
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -635,11 +634,11 @@ QUnit.module('fields', {}, function () {
event.data.callback({ user_context: {} });
});
- testUtils.form.clickEdit(form);
+ await testUtils.form.clickEdit(form);
var $dropdown = form.$('.o_field_many2one input').autocomplete('widget');
- testUtils.fields.many2one.clickOpenDropdown('trululu');
+ await testUtils.fields.many2one.clickOpenDropdown('trululu');
assert.ok($dropdown.is(':visible'),
'clicking on the m2o input should open the dropdown if it is not open yet');
assert.strictEqual($dropdown.find('li:not(.o_m2o_dropdown_option)').length, 7,
@@ -647,51 +646,50 @@ QUnit.module('fields', {}, function () {
assert.strictEqual($dropdown.find('li.o_m2o_dropdown_option').length, 2,
'autocomplete should contain "Search More" and Create and Edit..."');
- testUtils.fields.many2one.clickOpenDropdown('trululu');
+ await testUtils.fields.many2one.clickOpenDropdown('trululu');
assert.ok(!$dropdown.is(':visible'),
'clicking on the m2o input should close the dropdown if it is open');
// change the value of the m2o with a suggestion of the dropdown
- testUtils.fields.many2one.clickOpenDropdown('trululu');
- testUtils.fields.many2one.clickHighlightedItem('trululu');
+ await testUtils.fields.many2one.clickOpenDropdown('trululu');
+ await testUtils.fields.many2one.clickHighlightedItem('trululu');
assert.ok(!$dropdown.is(':visible'), 'clicking on a value should close the dropdown');
assert.strictEqual(form.$('.o_field_many2one input').val(), 'first record',
'value of the m2o should have been correctly updated');
// change the value of the m2o with a record in the 'Search More' modal
- testUtils.fields.many2one.clickOpenDropdown('trululu');
+ await testUtils.fields.many2one.clickOpenDropdown('trululu');
// click on 'Search More' (mouseenter required by ui-autocomplete)
- testUtils.fields.many2one.clickItem('trululu', 'Search');
+ await testUtils.fields.many2one.clickItem('trululu', 'Search');
assert.ok($('.modal .o_list_view').length, "should have opened a list view in a modal");
assert.ok(!$('.modal .o_list_view .o_list_record_selector').length,
"there should be no record selector in the list view");
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");
- // filter the list using the searchview
- $('.modal .o_searchview_input').trigger({ type: 'keypress', which: 80 }); // P
- $('.modal .o_searchview_input').trigger({ type: 'keydown', which: 13 }); // enter
+ await testUtils.fields.triggerKey('press', $('.modal .o_searchview_input'), 'P'),
+ await testUtils.fields.triggerKeydown($('.modal .o_searchview_input'), 'enter');
assert.strictEqual($('.modal tbody tr').length, 10,
"list should be restricted to records containing a P (10 records)");
// choose a record
- testUtils.dom.click($('.modal tbody tr:contains(Partner 20)'));
+ await testUtils.dom.click($('.modal tbody tr:contains(Partner 20)'));
assert.ok(!$('.modal').length, "should have closed the modal");
assert.ok(!$dropdown.is(':visible'), 'should have closed the dropdown');
assert.strictEqual(form.$('.o_field_many2one input').val(), 'Partner 20',
'value of the m2o should have been correctly updated');
// save
- testUtils.form.clickSave(form);
+ await testUtils.form.clickSave(form);
assert.strictEqual(form.$('a.o_form_uri').text(), 'Partner 20',
"should display correct value after save");
form.destroy();
});
- QUnit.test('many2one in non edit mode', function (assert) {
+ QUnit.test('many2one in non edit mode', async function (assert) {
assert.expect(3);
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -707,9 +705,9 @@ QUnit.module('fields', {}, function () {
"href should contain id and model");
// Remove value from many2one and then save, there should not have href with id and model on m2o anchor
- testUtils.form.clickEdit(form);
+ await testUtils.form.clickEdit(form);
form.$('.o_field_many2one input').val('').trigger('keyup').trigger('focusout');
- testUtils.form.clickSave(form);
+ await testUtils.form.clickSave(form);
assert.hasAttrValue(form.$('a.o_form_uri'), 'href', "#",
"href should have #");
@@ -717,14 +715,13 @@ QUnit.module('fields', {}, function () {
form.destroy();
});
- QUnit.test('many2one searches with correct value', function (assert) {
- var done = assert.async();
+ QUnit.test('many2one searches with correct value', async function (assert) {
assert.expect(6);
var M2O_DELAY = relationalFields.FieldMany2One.prototype.AUTOCOMPLETE_DELAY;
relationalFields.FieldMany2One.prototype.AUTOCOMPLETE_DELAY = 0;
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -748,31 +745,27 @@ QUnit.module('fields', {}, function () {
assert.strictEqual(form.$('.o_field_many2one input').val(), 'aaa',
"should be initially set to 'aaa'");
- testUtils.dom.click(form.$('.o_field_many2one input'));
+ await testUtils.dom.click(form.$('.o_field_many2one input'));
// unset the many2one -> should search again with ''
form.$('.o_field_many2one input').val('').trigger('keydown');
- concurrency.delay(0).then(function () {
- // write 'p' -> should search with 'p'
- form.$('.o_field_many2one input').val('p').trigger('keydown').trigger('keyup');
+ await testUtils.nextTick();
+ form.$('.o_field_many2one input').val('p').trigger('keydown').trigger('keyup');
+ await testUtils.nextTick();
- return concurrency.delay(0);
- }).then(function () {
- // close and re-open the dropdown -> should search with 'p' again
- testUtils.dom.click(form.$('.o_field_many2one input'));
- testUtils.dom.click(form.$('.o_field_many2one input'));
+ // close and re-open the dropdown -> should search with 'p' again
+ await testUtils.dom.click(form.$('.o_field_many2one input'));
+ await testUtils.dom.click(form.$('.o_field_many2one input'));
- assert.verifySteps(['search: ', 'search: ', 'search: p', 'search: p']);
+ assert.verifySteps(['search: ', 'search: ', 'search: p', 'search: p']);
- relationalFields.FieldMany2One.prototype.AUTOCOMPLETE_DELAY = M2O_DELAY;
- form.destroy();
- done();
- });
+ relationalFields.FieldMany2One.prototype.AUTOCOMPLETE_DELAY = M2O_DELAY;
+ form.destroy();
});
- QUnit.test('many2one field with option always_reload', function (assert) {
+ QUnit.test('many2one field with option always_reload', async function (assert) {
assert.expect(4);
var count = 0;
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -783,7 +776,7 @@ QUnit.module('fields', {}, function () {
mockRPC: function (route, args) {
if (args.method === 'name_get') {
count++;
- return $.when([[1, "first record\nand some address"]]);
+ return Promise.resolve([[1, "first record\nand some address"]]);
}
return this._super(route, args);
},
@@ -793,22 +786,22 @@ QUnit.module('fields', {}, function () {
assert.ok(form.$('a:contains(and some address)').length,
"should display additional result");
- testUtils.form.clickEdit(form);
+ await testUtils.form.clickEdit(form);
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);
+ await testUtils.form.clickSave(form);
assert.ok(form.$('a:contains(and some address)').length,
"should still display additional result");
form.destroy();
});
- QUnit.test('many2one field and list navigation', function (assert) {
+ QUnit.test('many2one field and list navigation', async function (assert) {
assert.expect(3);
- var list = createView({
+ var list = await createView({
View: ListView,
model: 'partner',
data: this.data,
@@ -816,14 +809,11 @@ QUnit.module('fields', {}, function () {
});
// edit first input, to trigger autocomplete
- testUtils.dom.click(list.$('.o_data_row .o_data_cell').first());
- testUtils.fields.editInput(list.$('.o_data_cell input'), '');
+ await testUtils.dom.click(list.$('.o_data_row .o_data_cell').first());
+ await testUtils.fields.editInput(list.$('.o_data_cell input'), '');
// press keydown, to select first choice
- list.$('.o_data_cell input').focus().trigger($.Event('keydown', {
- which: $.ui.keyCode.DOWN,
- keyCode: $.ui.keyCode.DOWN,
- }));
+ await testUtils.fields.triggerKeydown(list.$('.o_data_cell input').focus(), 'down');
// we now check that the dropdown is open (and that the focus did not go
// to the next line)
@@ -839,7 +829,6 @@ QUnit.module('fields', {}, function () {
QUnit.test('standalone many2one field', async function (assert) {
assert.expect(4);
- var done = assert.async();
var M2O_DELAY = relationalFields.FieldMany2One.prototype.AUTOCOMPLETE_DELAY;
relationalFields.FieldMany2One.prototype.AUTOCOMPLETE_DELAY = 0;
@@ -851,54 +840,53 @@ QUnit.module('fields', {}, function () {
Model: BasicModel,
data: this.data,
});
-
+ var record;
model.makeRecord('coucou', [{
name: 'partner_id',
relation: 'partner',
type: 'many2one',
value: [1, 'first partner'],
}]).then(function (recordID) {
- var record = model.get(recordID);
- // create a new widget that uses the StandaloneFieldManagerMixin
- var StandaloneWidget = Widget.extend(StandaloneFieldManagerMixin, {
- init: function (parent) {
- this._super.apply(this, arguments);
- StandaloneFieldManagerMixin.init.call(this, parent);
- },
- });
- var parent = new StandaloneWidget(model);
- testUtils.mock.addMockEnvironment(parent, {
- data: self.data,
- mockRPC: function (route, args) {
- assert.step(args.method);
- return this._super.apply(this, arguments);
- },
- });
+ record = model.get(recordID);
+ });
+ await testUtils.nextTick();
+ // create a new widget that uses the StandaloneFieldManagerMixin
+ var StandaloneWidget = Widget.extend(StandaloneFieldManagerMixin, {
+ init: function (parent) {
+ this._super.apply(this, arguments);
+ StandaloneFieldManagerMixin.init.call(this, parent);
+ },
+ });
+ var parent = new StandaloneWidget(model);
+ testUtils.mock.addMockEnvironment(parent, {
+ data: self.data,
+ mockRPC: function (route, args) {
+ assert.step(args.method);
+ return this._super.apply(this, arguments);
+ },
+ });
- var relField = new relationalFields.FieldMany2One(parent, 'partner_id', record, {
- mode: 'edit',
- noOpen: true,
- });
+ var relField = new relationalFields.FieldMany2One(parent, 'partner_id', record, {
+ mode: 'edit',
+ noOpen: true,
+ });
- relField.appendTo(fixture);
- testUtils.fields.editInput($('input.o_input'), 'xyzzrot');
+ relField.appendTo(fixture);
+ await testUtils.nextTick();
+ await testUtils.fields.editInput($('input.o_input'), 'xyzzrot');
- concurrency.delay(0).then(function () {
- testUtils.fields.many2one.clickItem('partner_id', 'Create');
+ await testUtils.fields.many2one.clickItem('partner_id', 'Create');
- assert.containsNone(relField, '.o_external_button',
- "should not have the button to open the record");
- assert.verifySteps(['name_search', 'name_create']);
+ assert.containsNone(relField, '.o_external_button',
+ "should not have the button to open the record");
+ assert.verifySteps(['name_search', 'name_create']);
- parent.destroy();
- model.destroy();
- relationalFields.FieldMany2One.prototype.AUTOCOMPLETE_DELAY = M2O_DELAY;
- done();
- });
- });
+ parent.destroy();
+ model.destroy();
+ relationalFields.FieldMany2One.prototype.AUTOCOMPLETE_DELAY = M2O_DELAY;
});
- // QUnit.test('onchange on a many2one to a different model', function (assert) {
+ // QUnit.test('onchange on a many2one to a different model', async function (assert) {
// This test is commented because the mock server does not give the correct response.
// It should return a couple [id, display_name], but I don't know the logic used
// by the server, so it's hard to emulate it correctly
@@ -911,7 +899,7 @@ QUnit.module('fields', {}, function () {
// },
// };
- // var form = createView({
+ // var form = await createView({
// View: FormView,
// model: 'partner',
// data: this.data,
@@ -921,7 +909,7 @@ QUnit.module('fields', {}, function () {
// '</form>',
// res_id: 1,
// });
- // testUtils.form.clickEdit(form);
+ // await testUtils.form.clickEdit(form);
// assert.strictEqual(form.$('input').eq(1).val(), 'xpad', "initial product_id val should be xpad");
// testUtils.fields.editInput(form.$('input').eq(0), "let us trigger an onchange");
@@ -932,9 +920,9 @@ QUnit.module('fields', {}, function () {
QUnit.test('form: quick create then save directly', async function (assert) {
assert.expect(5);
- var def = $.Deferred();
+ var prom = testUtils.makeTestPromise();
var newRecordID;
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -945,7 +933,7 @@ QUnit.module('fields', {}, function () {
var result = this._super.apply(this, arguments);
if (args.method === 'name_create') {
assert.step('name_create');
- return def.then(_.constant(result)).then(function (nameGet) {
+ return prom.then(_.constant(result)).then(function (nameGet) {
newRecordID = nameGet[0];
return nameGet;
});
@@ -959,23 +947,24 @@ QUnit.module('fields', {}, function () {
},
});
await testUtils.fields.many2one.searchAndClickItem('trululu', {search: 'b'});
- testUtils.form.clickSave(form);
+ await testUtils.form.clickSave(form);
assert.verifySteps(['name_create'],
"should wait for the name_create before creating the record");
- def.resolve();
+ await prom.resolve();
+ await testUtils.nextTick();
- assert.verifySteps(['name_create', 'create']);
+ assert.verifySteps(['create']);
form.destroy();
});
QUnit.test('list: quick create then save directly', async function (assert) {
assert.expect(8);
- var def = $.Deferred();
+ var prom = testUtils.makeTestPromise();
var newRecordID;
- var list = createView({
+ var list = await createView({
View: ListView,
model: 'partner',
data: this.data,
@@ -986,7 +975,7 @@ QUnit.module('fields', {}, function () {
var result = this._super.apply(this, arguments);
if (args.method === 'name_create') {
assert.step('name_create');
- return def.then(_.constant(result)).then(function (nameGet) {
+ return prom.then(_.constant(result)).then(function (nameGet) {
newRecordID = nameGet[0];
return nameGet;
});
@@ -1000,7 +989,7 @@ QUnit.module('fields', {}, function () {
},
});
- testUtils.dom.click(list.$buttons.find('.o_list_button_add'));
+ await testUtils.dom.click(list.$buttons.find('.o_list_button_add'));
await testUtils.fields.many2one.searchAndClickItem('trululu', {search:'b'});
list.$buttons.find('.o_list_button_add').show();
@@ -1011,9 +1000,10 @@ QUnit.module('fields', {}, function () {
assert.containsN(list, '.o_data_row', 4,
"should wait for the name_create before adding the new row");
- def.resolve();
+ await prom.resolve();
+ await testUtils.nextTick();
- assert.verifySteps(['name_create', 'create']);
+ assert.verifySteps(['create']);
assert.strictEqual(list.$('.o_data_row:nth(1) .o_data_cell').text(), 'b',
"created row should have the correct m2o value");
assert.containsN(list, '.o_data_row', 5, "should have added the fifth row");
@@ -1024,9 +1014,9 @@ QUnit.module('fields', {}, function () {
QUnit.test('list in form: quick create then save directly', async function (assert) {
assert.expect(6);
- var def = $.Deferred();
+ var prom = testUtils.makeTestPromise();
var newRecordID;
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -1043,7 +1033,7 @@ QUnit.module('fields', {}, function () {
var result = this._super.apply(this, arguments);
if (args.method === 'name_create') {
assert.step('name_create');
- return def.then(_.constant(result)).then(function (nameGet) {
+ return prom.then(_.constant(result)).then(function (nameGet) {
newRecordID = nameGet[0];
return nameGet;
});
@@ -1057,28 +1047,28 @@ QUnit.module('fields', {}, function () {
},
});
- testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
+ await testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
await testUtils.fields.many2one.searchAndClickItem('trululu', {search: 'b'});
- testUtils.form.clickSave(form);
+ await testUtils.form.clickSave(form);
assert.verifySteps(['name_create'],
"should wait for the name_create before creating the record");
- def.resolve();
+ await prom.resolve();
+ await testUtils.nextTick();
- assert.verifySteps(['name_create', 'create']);
+ assert.verifySteps(['create']);
assert.strictEqual(form.$('.o_data_row:first .o_data_cell').text(), 'b',
"first row should have the correct m2o value");
form.destroy();
});
- QUnit.test('list in form: quick create then add a new line directly', function (assert) {
+ QUnit.test('list in form: quick create then add a new line directly', async function (assert) {
// required many2one inside a one2many list: directly after quick creating
// a new many2one value (before the name_create returns), click on add an item:
// at this moment, the many2one has still no value, and as it is required,
// the row is discarded if a saveLine is requested. However, it should
// wait for the name_create to return before trying to save the line.
- var done = assert.async();
assert.expect(8);
this.data.partner.onchanges = {
@@ -1088,9 +1078,9 @@ QUnit.module('fields', {}, function () {
var M2O_DELAY = relationalFields.FieldMany2One.prototype.AUTOCOMPLETE_DELAY;
relationalFields.FieldMany2One.prototype.AUTOCOMPLETE_DELAY = 0;
- var def = $.Deferred();
+ var prom = testUtils.makeTestPromise();
var newRecordID;
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -1106,7 +1096,7 @@ QUnit.module('fields', {}, function () {
mockRPC: function (route, args) {
var result = this._super.apply(this, arguments);
if (args.method === 'name_create') {
- return def.then(_.constant(result)).then(function (nameGet) {
+ return prom.then(_.constant(result)).then(function (nameGet) {
newRecordID = nameGet[0];
return nameGet;
});
@@ -1118,43 +1108,42 @@ QUnit.module('fields', {}, function () {
},
});
- testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
- form.$('.o_field_many2one input').val('b').trigger('keydown');
- concurrency.delay(0).then(function () {
- testUtils.fields.many2one.clickHighlightedItem('trululu');
- testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
+ await testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
+ await testUtils.fields.editAndTrigger(form.$('.o_field_many2one input'),
+ 'b', 'keydown');
+ await testUtils.fields.many2one.clickHighlightedItem('trululu');
+ await testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
- assert.containsOnce(form, '.o_data_row',
- "there should still be only one row");
- assert.hasClass(form.$('.o_data_row'),'o_selected_row',
- "the row should still be in edition");
+ assert.containsOnce(form, '.o_data_row',
+ "there should still be only one row");
+ assert.hasClass(form.$('.o_data_row'),'o_selected_row',
+ "the row should still be in edition");
- def.resolve();
+ await prom.resolve();
+ await testUtils.nextTick();
- assert.strictEqual(form.$('.o_data_row:first .o_data_cell').text(), 'b',
- "first row should have the correct m2o value");
- assert.containsN(form, '.o_data_row', 2,
- "there should now be 2 rows");
- assert.hasClass(form.$('.o_data_row:nth(1)'),'o_selected_row',
- "the second row should be in edition");
+ assert.strictEqual(form.$('.o_data_row:first .o_data_cell').text(), 'b',
+ "first row should have the correct m2o value");
+ assert.containsN(form, '.o_data_row', 2,
+ "there should now be 2 rows");
+ assert.hasClass(form.$('.o_data_row:nth(1)'),'o_selected_row',
+ "the second row should be in edition");
- testUtils.form.clickSave(form);
+ await testUtils.form.clickSave(form);
- assert.containsOnce(form, '.o_data_row',
- "there should be 1 row saved (the second one was empty and invalid)");
- assert.strictEqual(form.$('.o_data_row .o_data_cell').text(), 'b',
- "should have the correct m2o value");
+ assert.containsOnce(form, '.o_data_row',
+ "there should be 1 row saved (the second one was empty and invalid)");
+ assert.strictEqual(form.$('.o_data_row .o_data_cell').text(), 'b',
+ "should have the correct m2o value");
- relationalFields.FieldMany2One.prototype.AUTOCOMPLETE_DELAY = M2O_DELAY;
- form.destroy();
- done();
- });
+ relationalFields.FieldMany2One.prototype.AUTOCOMPLETE_DELAY = M2O_DELAY;
+ form.destroy();
});
- QUnit.test('list in form: create with one2many with many2one', function (assert) {
+ QUnit.test('list in form: create with one2many with many2one', async function (assert) {
assert.expect(1);
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -1170,7 +1159,7 @@ QUnit.module('fields', {}, function () {
'</form>',
mockRPC: function (route, args) {
if (args.method === 'default_get') {
- return $.when({ p: [[0, 0, { display_name: 'new record' }]] });
+ return Promise.resolve({ p: [[0, 0, { display_name: 'new record' }]] });
} else if (args.method === 'name_get') {
// This should not be called at all and thus is not accounted for
// in the assert.expect. If this is called, you broke this test.
@@ -1187,13 +1176,13 @@ QUnit.module('fields', {}, function () {
form.destroy();
});
- QUnit.test('list in form: create with one2many with many2one (version 2)', function (assert) {
+ QUnit.test('list in form: create with one2many with many2one (version 2)', async function (assert) {
// This test simulates the exact same scenario as the previous one,
// except that the value for the many2one is explicitely set to false,
// which is stupid, but this happens, so we have to handle it
assert.expect(1);
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -1209,7 +1198,7 @@ QUnit.module('fields', {}, function () {
'</form>',
mockRPC: function (route, args) {
if (args.method === 'default_get') {
- return $.when({ p: [[0, 0, { display_name: 'new record', trululu: false }]] });
+ return Promise.resolve({ p: [[0, 0, { display_name: 'new record', trululu: false }]] });
} else if (args.method === 'name_get') {
// This should not be called at all and thus is not accounted for
// in the assert.expect. If this is called, you broke this test.
@@ -1226,14 +1215,14 @@ QUnit.module('fields', {}, function () {
form.destroy();
});
- QUnit.test('item not dropped on discard with empty required field (default_get)', function (assert) {
+ QUnit.test('item not dropped on discard with empty required field (default_get)', async function (assert) {
// This test simulates discarding a record that has been created with
// one of its required field that is empty. When we discard the changes
// on this empty field, it should not assume that this record should be
// abandonned, since it has been added (even though it is a new record).
assert.expect(8);
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -1249,7 +1238,7 @@ QUnit.module('fields', {}, function () {
'</form>',
mockRPC: function (route, args) {
if (args.method === 'default_get') {
- return $.when({ p: [[0, 0, { display_name: 'new record', trululu: false }]] });
+ return Promise.resolve({ p: [[0, 0, { display_name: 'new record', trululu: false }]] });
}
return this._super.apply(this, arguments);
},
@@ -1284,12 +1273,12 @@ QUnit.module('fields', {}, function () {
form.destroy();
});
- QUnit.test('list in form: name_get with unique ids (default_get)', function (assert) {
+ QUnit.test('list in form: name_get with unique ids (default_get)', async function (assert) {
assert.expect(2);
this.data.partner.records[0].display_name = "MyTrululu";
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -1304,7 +1293,7 @@ QUnit.module('fields', {}, function () {
'</form>',
mockRPC: function (route, args) {
if (args.method === 'default_get') {
- return $.when({
+ return Promise.resolve({
p: [
[0, 0, { trululu: 1 }],
[0, 0, { trululu: 1 }]
@@ -1325,10 +1314,10 @@ QUnit.module('fields', {}, function () {
form.destroy();
});
- QUnit.test('list in form: show name of many2one fields in multi-page (default_get)', function (assert) {
+ QUnit.test('list in form: show name of many2one fields in multi-page (default_get)', async function (assert) {
assert.expect(4);
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -1344,7 +1333,7 @@ QUnit.module('fields', {}, function () {
'</form>',
mockRPC: function (route, args) {
if (args.method === 'default_get') {
- return $.when({
+ return Promise.resolve({
p: [
[0, 0, { display_name: 'record1', trululu: 1 }],
[0, 0, { display_name: 'record2', trululu: 2 }]
@@ -1360,7 +1349,7 @@ QUnit.module('fields', {}, function () {
assert.strictEqual(form.$('td.o_data_cell').first().next().text(),
"first record", "should show display_name of trululu of 1st record");
- testUtils.dom.click(form.$('button.o_pager_next'));
+ await testUtils.dom.click(form.$('button.o_pager_next'));
assert.strictEqual(form.$('td.o_data_cell').first().text(),
"record2", "should show display_name of 2nd record");
@@ -1370,7 +1359,7 @@ QUnit.module('fields', {}, function () {
form.destroy();
});
- QUnit.test('list in form: item not dropped on discard with empty required field (onchange in default_get)', function (assert) {
+ QUnit.test('list in form: item not dropped on discard with empty required field (onchange in default_get)', async function (assert) {
// variant of the test "list in form: discard newly added element with
// empty required field (default_get)", in which the `default_get`
// performs an `onchange` at the same time. This `onchange` may create
@@ -1389,7 +1378,7 @@ QUnit.module('fields', {}, function () {
},
};
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -1404,7 +1393,7 @@ QUnit.module('fields', {}, function () {
'</form>',
mockRPC: function (route, args) {
if (args.method === 'default_get') {
- return $.when({
+ return Promise.resolve({
product_id: 37,
});
}
@@ -1440,7 +1429,7 @@ QUnit.module('fields', {}, function () {
form.destroy();
});
- QUnit.test('list in form: item not dropped on discard with empty required field (onchange on list after default_get)', function (assert) {
+ QUnit.test('list in form: item not dropped on discard with empty required field (onchange on list after default_get)', async function (assert) {
// discarding a record from an `onchange` in a `default_get` should not
// abandon the record. This should not be the case for following
// `onchange`, except if an onchange make some changes on the list:
@@ -1459,7 +1448,7 @@ QUnit.module('fields', {}, function () {
},
};
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -1479,8 +1468,8 @@ QUnit.module('fields', {}, function () {
"should have no row in the editable list");
// select product_id to force on_change in editable list
- testUtils.dom.click(form.$('.o_field_widget[name="product_id"] .o_input'));
- testUtils.dom.click($('.ui-menu-item').first());
+ await testUtils.dom.click(form.$('.o_field_widget[name="product_id"] .o_input'));
+ await testUtils.dom.click($('.ui-menu-item').first());
// check that there is a record in the editable list with empty string as required field
assert.containsOnce(form, '.o_data_row',
@@ -1494,9 +1483,9 @@ QUnit.module('fields', {}, function () {
"should have empty string in the required field on this record");
// click on empty required field in editable list record
- testUtils.dom.click(requiredField);
+ await testUtils.dom.click(requiredField);
// click off so that the required field still stay empty
- testUtils.dom.click($('body'));
+ await testUtils.dom.click($('body'));
// record should not be dropped
assert.containsOnce(form, '.o_data_row',
@@ -1510,13 +1499,13 @@ QUnit.module('fields', {}, function () {
form.destroy();
});
- QUnit.test('item dropped on discard with empty required field with "Add an item" (invalid on "ADD")', function (assert) {
+ QUnit.test('item dropped on discard with empty required field with "Add an item" (invalid on "ADD")', async function (assert) {
// when a record in a list is added with "Add an item", it should
// always be dropped on discard if some required field are empty
// at the record creation.
assert.expect(6);
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -1531,7 +1520,7 @@ QUnit.module('fields', {}, function () {
});
// Click on "Add an item"
- testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
+ await testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
var charField = form.$('.o_field_widget.o_field_char[name="display_name"]');
var requiredField = form.$('.o_field_widget.o_required_modifier[name="trululu"]');
charField.val("some text");
@@ -1547,9 +1536,9 @@ QUnit.module('fields', {}, function () {
"should have empty string in the required field on this record");
// click on empty required field in editable list record
- testUtils.dom.click(requiredField);
+ await testUtils.dom.click(requiredField);
// click off so that the required field still stay empty
- testUtils.dom.click($('body'));
+ await testUtils.dom.click($('body'));
// record should be dropped
assert.containsNone(form, '.o_data_row',
@@ -1558,7 +1547,7 @@ QUnit.module('fields', {}, function () {
form.destroy();
});
- QUnit.test('item not dropped on discard with empty required field with "Add an item" (invalid on "UPDATE")', function (assert) {
+ QUnit.test('item not dropped on discard with empty required field with "Add an item" (invalid on "UPDATE")', async function (assert) {
// when a record in a list is added with "Add an item", it should
// be temporarily added to the list when it is valid (e.g. required
// fields are non-empty). If the record is updated so that the required
@@ -1569,7 +1558,7 @@ QUnit.module('fields', {}, function () {
var M2O_DELAY = relationalFields.FieldMany2One.prototype.AUTOCOMPLETE_DELAY;
relationalFields.FieldMany2One.prototype.AUTOCOMPLETE_DELAY = 0;
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -1587,7 +1576,7 @@ QUnit.module('fields', {}, function () {
"should initially not have any record in the list");
// Click on "Add an item"
- testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
+ await testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
assert.containsOnce(form, '.o_data_row',
"should have a temporary record in the list");
@@ -1598,9 +1587,9 @@ QUnit.module('fields', {}, function () {
"should have empty string in the required field on this record");
// add something to required field and leave edit mode of the record
- testUtils.dom.click($inputEditMode);
- testUtils.dom.click($('li.ui-menu-item').first());
- testUtils.dom.click($('body'));
+ await testUtils.dom.click($inputEditMode);
+ await testUtils.dom.click($('li.ui-menu-item').first());
+ await testUtils.dom.click($('body'));
var $inputReadonlyMode = form.$('.o_data_cell.o_required_modifier');
assert.containsOnce(form, '.o_data_row',
@@ -1609,7 +1598,7 @@ QUnit.module('fields', {}, function () {
"should have put some content in the required field on this record");
// remove the required field and leave edit mode of the record
- testUtils.dom.click($('.o_data_row'));
+ await testUtils.dom.click($('.o_data_row'));
assert.containsOnce(form, '.o_data_row',
"should not have dropped record in the list on discard (invalid on UPDATE)");
assert.strictEqual($inputReadonlyMode.text(), "first record",
@@ -1619,7 +1608,7 @@ QUnit.module('fields', {}, function () {
form.destroy();
});
- QUnit.test('list in form: default_get with x2many create', function (assert) {
+ QUnit.test('list in form: default_get with x2many create', async function (assert) {
assert.expect(5);
var displayName = 'brandon is the new timmy';
@@ -1634,7 +1623,7 @@ QUnit.module('fields', {}, function () {
obj.int_field = obj.timmy.length;
};
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -1650,7 +1639,7 @@ QUnit.module('fields', {}, function () {
'</form>',
mockRPC: function (route, args) {
if (args.method === 'default_get') {
- return $.when({ timmy: [[0, 0, { display_name: 'brandon is the new timmy', name: 'brandon' }]] });
+ return Promise.resolve({ timmy: [[0, 0, { display_name: 'brandon is the new timmy', name: 'brandon' }]] });
}
if (args.method === 'create') {
assert.deepEqual(args.args[0], {
@@ -1672,14 +1661,14 @@ QUnit.module('fields', {}, function () {
// edit the subrecord and save
displayName = 'new value';
- testUtils.dom.click(form.$('.o_data_cell'));
- testUtils.fields.editInput(form.$('.o_data_cell input'), displayName);
- testUtils.form.clickSave(form);
+ await testUtils.dom.click(form.$('.o_data_cell'));
+ await testUtils.fields.editInput(form.$('.o_data_cell input'), displayName);
+ await testUtils.form.clickSave(form);
form.destroy();
});
- QUnit.test('list in form: default_get with x2many create and onchange', function (assert) {
+ QUnit.test('list in form: default_get with x2many create and onchange', async function (assert) {
assert.expect(2);
this.data.partner.onchanges.turtles = function (obj) {
@@ -1694,7 +1683,7 @@ QUnit.module('fields', {}, function () {
"should have properly created the x2many command list");
};
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -1710,7 +1699,7 @@ QUnit.module('fields', {}, function () {
'</form>',
mockRPC: function (route, args) {
if (args.method === 'default_get') {
- return $.when({ turtles: [[6, 0, [2, 3]]] });
+ return Promise.resolve({ turtles: [[6, 0, [2, 3]]] });
}
if (args.method === 'create') {
// it would be even better if we did not send the current
@@ -1727,16 +1716,16 @@ QUnit.module('fields', {}, function () {
},
});
- testUtils.form.clickSave(form);
+ await testUtils.form.clickSave(form);
form.destroy();
});
- QUnit.test('list in form: call button in sub view', function (assert) {
+ QUnit.test('list in form: call button in sub view', async function (assert) {
assert.expect(6);
this.data.partner.records[0].p = [2];
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -1752,7 +1741,7 @@ QUnit.module('fields', {}, function () {
res_id: 1,
mockRPC: function (route, args) {
if (route === '/web/dataset/call_kw/product/get_formview_id') {
- return $.when(false);
+ return Promise.resolve(false);
}
return this._super.apply(this, arguments);
},
@@ -1777,16 +1766,16 @@ QUnit.module('fields', {}, function () {
},
});
- testUtils.form.clickEdit(form);
- testUtils.dom.click(form.$('td.o_data_cell:first'));
- testUtils.dom.click(form.$('.o_external_button'));
- testUtils.dom.click($('button:contains("Just do it !")'));
- testUtils.dom.click($('button:contains("Just don\'t do it !")'));
+ await testUtils.form.clickEdit(form);
+ await testUtils.dom.click(form.$('td.o_data_cell:first'));
+ await testUtils.dom.click(form.$('.o_external_button'));
+ await testUtils.dom.click($('button:contains("Just do it !")'));
+ await testUtils.dom.click($('button:contains("Just don\'t do it !")'));
form.destroy();
});
- QUnit.test('X2Many sequence list in modal', function (assert) {
+ QUnit.test('X2Many sequence list in modal', async function (assert) {
assert.expect(5);
this.data.partner.fields.sequence = { string: 'Sequence', type: 'integer' };
@@ -1810,7 +1799,7 @@ QUnit.module('fields', {}, function () {
this.data.partner_type.fields.partner_ids = { string: "Partner", type: "one2many", relation: 'partner' };
this.data.partner_type.records[0].partner_ids = [1, 2];
- testUtils.createAsyncView({
+ var form = await createView({
View: FormView,
model: 'product',
data: this.data,
@@ -1832,52 +1821,52 @@ QUnit.module('fields', {}, function () {
res_id: 37,
mockRPC: function (route, args) {
if (route === '/web/dataset/call_kw/product/read') {
- return $.when([{ id: 37, name: 'xphone', display_name: 'leonardo', turtle_ids: [1] }]);
+ return Promise.resolve([{ id: 37, name: 'xphone', display_name: 'leonardo', turtle_ids: [1] }]);
}
if (route === '/web/dataset/call_kw/turtle/read') {
- return $.when([{ id: 1, type_id: [12, 'gold'] }]);
+ return Promise.resolve([{ id: 1, type_id: [12, 'gold'] }]);
}
if (route === '/web/dataset/call_kw/partner_type/get_formview_id') {
- return $.when(false);
+ return Promise.resolve(false);
}
if (route === '/web/dataset/call_kw/partner_type/read') {
- return $.when([{ id: 12, partner_ids: [1, 2], display_name: 'gold' }]);
+ return Promise.resolve([{ id: 12, partner_ids: [1, 2], display_name: 'gold' }]);
}
if (route === '/web/dataset/call_kw/partner_type/write') {
assert.step('partner_type write');
}
return this._super.apply(this, arguments);
},
- }).then(function (form) {
- testUtils.form.clickEdit(form);
- testUtils.dom.click(form.$('.o_data_cell'));
- testUtils.dom.click(form.$('.o_external_button'));
+ });
- var $modal = $('.modal');
- assert.equal($modal.length, 1,
- 'There should be 1 modal opened');
+ await testUtils.form.clickEdit(form);
+ await testUtils.dom.click(form.$('.o_data_cell'));
+ await testUtils.dom.click(form.$('.o_external_button'));
- var $handles = $modal.find('.ui-sortable-handle');
- assert.equal($handles.length, 2,
- 'There should be 2 sequence handlers');
+ var $modal = $('.modal');
+ assert.equal($modal.length, 1,
+ 'There should be 1 modal opened');
- testUtils.dom.dragAndDrop($handles.eq(1), $modal.find('tbody tr').first(),
- { position: 'top' });
+ var $handles = $modal.find('.ui-sortable-handle');
+ assert.equal($handles.length, 2,
+ 'There should be 2 sequence handlers');
- // Saving the modal and then the original model
- testUtils.dom.click($modal.find('.modal-footer .btn-primary'));
- testUtils.form.clickSave(form);
+ await testUtils.dom.dragAndDrop($handles.eq(1),
+ $modal.find('tbody tr').first(), { position: 'top' });
- assert.verifySteps(['onchange sequence', 'partner_type write']);
+ // Saving the modal and then the original model
+ await testUtils.dom.click($modal.find('.modal-footer .btn-primary'));
+ await testUtils.form.clickSave(form);
- form.destroy();
- });
+ assert.verifySteps(['onchange sequence', 'partner_type write']);
+
+ form.destroy();
});
- QUnit.test('autocompletion in a many2one, in form view with a domain', function (assert) {
+ QUnit.test('autocompletion in a many2one, in form view with a domain', async function (assert) {
assert.expect(1);
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -1895,16 +1884,16 @@ QUnit.module('fields', {}, function () {
return this._super(route, args);
}
});
- testUtils.form.clickEdit(form);
+ await testUtils.form.clickEdit(form);
testUtils.dom.click(form.$('.o_field_widget[name=product_id] input'));
form.destroy();
});
- QUnit.test('autocompletion in a many2one, in form view with a date field', function (assert) {
+ QUnit.test('autocompletion in a many2one, in form view with a date field', async function (assert) {
assert.expect(1);
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -1921,13 +1910,13 @@ QUnit.module('fields', {}, function () {
return this._super(route, args);
},
});
- testUtils.form.clickEdit(form);
+ await testUtils.form.clickEdit(form);
testUtils.dom.click(form.$('.o_field_widget[name=trululu] input'));
form.destroy();
});
- QUnit.test('creating record with many2one with option always_reload', function (assert) {
+ QUnit.test('creating record with many2one with option always_reload', async function (assert) {
assert.expect(2);
this.data.partner.fields.trululu.default = 1;
@@ -1939,7 +1928,7 @@ QUnit.module('fields', {}, function () {
var count = 0;
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -1949,7 +1938,7 @@ QUnit.module('fields', {}, function () {
mockRPC: function (route, args) {
count++;
if (args.method === 'name_get' && args.args[0][0] === 2) {
- return $.when([[2, "hello world\nso much noise"]]);
+ return Promise.resolve([[2, "hello world\nso much noise"]]);
}
return this._super(route, args);
},
@@ -1961,10 +1950,10 @@ QUnit.module('fields', {}, function () {
form.destroy();
});
- QUnit.test('selecting a many2one, then discarding', function (assert) {
+ QUnit.test('selecting a many2one, then discarding', async function (assert) {
assert.expect(3);
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -1974,23 +1963,23 @@ QUnit.module('fields', {}, function () {
res_id: 1,
});
assert.strictEqual(form.$('a[name=product_id]').text(), '', 'the tag a should be empty');
- testUtils.form.clickEdit(form);
+ await testUtils.form.clickEdit(form);
- testUtils.fields.many2one.clickOpenDropdown('product_id');
- testUtils.fields.many2one.clickItem('product_id','xphone');
+ await testUtils.fields.many2one.clickOpenDropdown('product_id');
+ await testUtils.fields.many2one.clickItem('product_id','xphone');
assert.strictEqual(form.$('.o_field_widget[name=product_id] input').val(), "xphone", "should have selected xphone");
- testUtils.form.clickDiscard(form);
+ await testUtils.form.clickDiscard(form);
assert.strictEqual(form.$('a[name=product_id]').text(), '', 'the tag a should be empty');
form.destroy();
});
- QUnit.test('domain and context are correctly used when doing a name_search in a m2o', function (assert) {
+ QUnit.test('domain and context are correctly used when doing a name_search in a m2o', async function (assert) {
assert.expect(4);
this.data.partner.records[0].timmy = [12];
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -2016,20 +2005,20 @@ QUnit.module('fields', {}, function () {
{ hey: "ho", hello: "world", test: "yop" },
'the field attr context should have been used for the ' +
'RPC (evaluated and merged with the session one)');
- return $.when([]);
+ return Promise.resolve([]);
}
if (args.method === 'name_search' && args.model === 'partner') {
assert.deepEqual(args.kwargs.args, [['id', 'in', [12]]],
'the field attr domain should have been used for the RPC (and evaluated)');
assert.deepEqual(args.kwargs.context, { hey: 'ho', timmy: [[6, false, [12]]] },
'the field attr context should have been used for the RPC (and evaluated)');
- return $.when([]);
+ return Promise.resolve([]);
}
return this._super.apply(this, arguments);
},
});
- testUtils.form.clickEdit(form);
+ await testUtils.form.clickEdit(form);
testUtils.dom.click(form.$('.o_field_widget[name=product_id] input'));
testUtils.dom.click(form.$('.o_field_widget[name=trululu] input'));
@@ -2037,10 +2026,10 @@ QUnit.module('fields', {}, function () {
form.destroy();
});
- QUnit.test('quick create on a many2one', function (assert) {
+ QUnit.test('quick create on a many2one', async function (assert) {
assert.expect(1);
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -2059,17 +2048,17 @@ QUnit.module('fields', {}, function () {
});
form.$('.o_field_many2one input').focus();
- form.$('.o_field_many2one input').val('new partner').trigger('keyup').trigger('focusout');
-
- testUtils.dom.click($('.modal .modal-footer .btn-primary').first());
+ await testUtils.fields.editAndTrigger(form.$('.o_field_many2one input'),
+ 'new partner', ['keyup', 'focusout']);
+ await testUtils.dom.click($('.modal .modal-footer .btn-primary').first());
form.destroy();
});
- QUnit.test('slow create on a many2one', function (assert) {
- assert.expect(7);
+ QUnit.test('slow create on a many2one', async function (assert) {
+ assert.expect(11);
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -2089,41 +2078,55 @@ QUnit.module('fields', {}, function () {
// cancel the many2one creation with Cancel button
form.$('.o_field_many2one input').focus().val('new product').trigger('keyup').trigger('blur');
+ await testUtils.nextTick();
assert.strictEqual($('.modal').length, 1, "there should be one opened modal");
- testUtils.dom.click($('.modal .modal-footer .btn:contains(Cancel)'));
+
+ await testUtils.dom.click($('.modal .modal-footer .btn:contains(Cancel)'));
+ assert.strictEqual($('.modal').length, 0, "the modal should be closed");
assert.strictEqual(form.$('.o_field_many2one input').val(), "",
'the many2one should not set a value as its creation has been cancelled (with Cancel button)');
// cancel the many2one creation with Close button
- form.$('.o_field_many2one input').focus().val('new product').trigger('keyup').trigger('blur');
- testUtils.dom.click($('.modal .modal-header button'));
+ await testUtils.fields.editAndTrigger(form.$('.o_field_many2one input'),
+ 'new product', ['keyup', 'blur']);
+ assert.strictEqual($('.modal').length, 1, "there should be one opened modal");
+ await testUtils.dom.click($('.modal .modal-header button'));
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').length, 0, "the modal should be closed");
// 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');
+ await testUtils.fields.many2one.clickOpenDropdown('product_id');
+ await testUtils.fields.many2one.clickItem('product_id','o');
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');
+ await testUtils.nextTick();
assert.strictEqual($('.modal').length, 1, "there should be one opened modal");
- testUtils.dom.click($('.modal .modal-footer .btn:contains(Cancel)'));
+
+ await testUtils.dom.click($('.modal .modal-footer .btn:contains(Cancel)'));
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');
- testUtils.dom.clickFirst($('.modal .modal-footer .btn-primary'));
+ form.$('.o_field_many2one input').focus().val('new partner').trigger('keyup').trigger('blur');
+ await testUtils.nextTick();
+ assert.strictEqual($('.modal').length, 1, "there should be one opened modal");
+
+ await testUtils.dom.click($('.modal .modal-footer .btn-primary:contains(Create and edit)'));
+ await testUtils.nextTick();
assert.strictEqual($('.modal .o_form_view').length, 1,
'a new modal should be opened and contain a form view');
+ await testUtils.dom.click($('.modal .o_form_button_cancel'));
+
form.destroy();
});
- QUnit.test('no_create option on a many2one', function (assert) {
+ QUnit.test('no_create option on a many2one', async function (assert) {
assert.expect(1);
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -2134,14 +2137,14 @@ QUnit.module('fields', {}, function () {
'</form>',
});
- form.$('.o_field_many2one input').focus();
- form.$('.o_field_many2one input').val('new partner').trigger('keyup').trigger('focusout');
-
+ await testUtils.fields.editAndTrigger(form.$('.o_field_many2one input'),
+ 'new partner', ['keyup', 'focusout']);
+ await testUtils.nextTick();
assert.strictEqual($('.modal').length, 0, "should not display the create modal");
form.destroy();
});
- QUnit.test('can_create and can_write option on a many2one', function (assert) {
+ QUnit.test('can_create and can_write option on a many2one', async function (assert) {
assert.expect(5);
this.data.product.options = {
@@ -2149,7 +2152,7 @@ QUnit.module('fields', {}, function () {
can_write: "false",
};
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -2163,117 +2166,98 @@ QUnit.module('fields', {}, function () {
},
mockRPC: function (route) {
if (route === '/web/dataset/call_kw/product/get_formview_id') {
- return $.when(false);
+ return Promise.resolve(false);
}
return this._super.apply(this, arguments);
},
});
- testUtils.dom.click(form.$('.o_field_many2one input'));
+ await testUtils.dom.click(form.$('.o_field_many2one input'));
assert.strictEqual($('.ui-autocomplete .o_m2o_dropdown_option:contains(Create)').length, 0,
"there shouldn't be any option to search and create");
- testUtils.dom.click($('.ui-autocomplete li:contains(xpad)').mouseenter());
+ await testUtils.dom.click($('.ui-autocomplete li:contains(xpad)').mouseenter());
assert.strictEqual(form.$('.o_field_many2one input').val(), "xpad",
"the correct record should be selected");
assert.containsOnce(form, '.o_field_many2one .o_external_button',
"there should be an external button displayed");
- testUtils.dom.click(form.$('.o_field_many2one .o_external_button'));
+ await testUtils.dom.click(form.$('.o_field_many2one .o_external_button'));
assert.strictEqual($('.modal .o_form_view.o_form_readonly').length, 1,
"there should be a readonly form view opened");
- testUtils.dom.click($('.modal .o_form_button_cancel'));
-
- form.$('.o_field_many2one input').val('new product').trigger('keyup').trigger('focusout');
+ await testUtils.dom.click($('.modal .o_form_button_cancel'));
+ await testUtils.fields.editAndTrigger(form.$('.o_field_many2one input'),
+ 'new product', ['keyup', 'focusout']);
assert.strictEqual($('.modal').length, 0, "should not display the create modal");
form.destroy();
});
- QUnit.test('pressing enter in a m2o in an editable list', function (assert) {
+ QUnit.test('pressing enter in a m2o in an editable list', async function (assert) {
assert.expect(9);
- var done = assert.async();
var M2O_DELAY = relationalFields.FieldMany2One.prototype.AUTOCOMPLETE_DELAY;
relationalFields.FieldMany2One.prototype.AUTOCOMPLETE_DELAY = 0;
- var list = createView({
+ var list = await createView({
View: ListView,
model: 'partner',
data: this.data,
arch: '<tree editable="bottom"><field name="product_id"/></tree>',
});
- testUtils.dom.click(list.$('td.o_data_cell:first'));
+ await testUtils.dom.click(list.$('td.o_data_cell:first'));
assert.containsOnce(list, '.o_selected_row',
"should have a row in edit mode");
// we now write 'a' and press enter to check that the selection is
// working, and prevent the navigation
- testUtils.fields.editInput(list.$('td.o_data_cell input:first'), 'a');
- concurrency.delay(0).then(function () {
- var $input = list.$('td.o_data_cell input:first');
- var $dropdown = $input.autocomplete('widget');
- assert.ok($dropdown.is(':visible'), "autocomplete dropdown should be visible");
-
- // we now trigger ENTER to select first choice
- $input.trigger($.Event('keydown', {
- which: $.ui.keyCode.ENTER,
- keyCode: $.ui.keyCode.ENTER,
- }));
- assert.strictEqual($input[0], document.activeElement,
- "input should still be focused");
-
- // we now trigger again ENTER to make sure we can move to next line
- $input.trigger($.Event('keydown', {
- which: $.ui.keyCode.ENTER,
- keyCode: $.ui.keyCode.ENTER,
- }));
-
- assert.notOk(document.contains($input[0]),
- "input should no longer be in dom");
- assert.hasClass(list.$('tr.o_data_row:eq(1)'),'o_selected_row',
- "second row should now be selected");
-
- // we now write again 'a' in the cell to select xpad. We will now
- // test with the tab key
- testUtils.fields.editInput(list.$('td.o_data_cell input:first'), 'a');
- return concurrency.delay(0);
- }).then(function () {
- var $input = list.$('td.o_data_cell input:first');
- var $dropdown = $input.autocomplete('widget');
- assert.ok($dropdown.is(':visible'), "autocomplete dropdown should be visible");
- $input.trigger($.Event('keydown', {
- which: $.ui.keyCode.TAB,
- keyCode: $.ui.keyCode.TAB,
- }));
- assert.strictEqual($input[0], document.activeElement,
- "input should still be focused");
-
- // we now trigger again ENTER to make sure we can move to next line
- $input.trigger($.Event('keydown', {
- which: $.ui.keyCode.TAB,
- keyCode: $.ui.keyCode.TAB,
- }));
-
- assert.notOk(document.contains($input[0]),
- "input should no longer be in dom");
- assert.hasClass(list.$('tr.o_data_row:eq(2)'),'o_selected_row',
- "third row should now be selected");
- list.destroy();
- relationalFields.FieldMany2One.prototype.AUTOCOMPLETE_DELAY = M2O_DELAY;
- done();
- });
+ await testUtils.fields.editInput(list.$('td.o_data_cell input:first'), 'a');
+ var $input = list.$('td.o_data_cell input:first');
+ var $dropdown = $input.autocomplete('widget');
+ assert.ok($dropdown.is(':visible'), "autocomplete dropdown should be visible");
+
+ // we now trigger ENTER to select first choice
+ await testUtils.fields.triggerKeydown($input, 'enter');
+ assert.strictEqual($input[0], document.activeElement,
+ "input should still be focused");
+
+ // we now trigger again ENTER to make sure we can move to next line
+ await testUtils.fields.triggerKeydown($input, 'enter');
+
+ assert.notOk(document.contains($input[0]),
+ "input should no longer be in dom");
+ assert.hasClass(list.$('tr.o_data_row:eq(1)'),'o_selected_row',
+ "second row should now be selected");
+
+ // we now write again 'a' in the cell to select xpad. We will now
+ // test with the tab key
+ await testUtils.fields.editInput(list.$('td.o_data_cell input:first'), 'a');
+ var $input = list.$('td.o_data_cell input:first');
+ var $dropdown = $input.autocomplete('widget');
+ assert.ok($dropdown.is(':visible'), "autocomplete dropdown should be visible");
+ await testUtils.fields.triggerKeydown($input, 'tab');
+ assert.strictEqual($input[0], document.activeElement,
+ "input should still be focused");
+
+ // we now trigger again ENTER to make sure we can move to next line
+ await testUtils.fields.triggerKeydown($input, 'tab');
+
+ assert.notOk(document.contains($input[0]),
+ "input should no longer be in dom");
+ assert.hasClass(list.$('tr.o_data_row:eq(2)'),'o_selected_row',
+ "third row should now be selected");
+ list.destroy();
+ relationalFields.FieldMany2One.prototype.AUTOCOMPLETE_DELAY = M2O_DELAY;
});
- QUnit.test('pressing ENTER on a \'no_quick_create\' many2one should open a M2ODialog', function (assert) {
- var done = assert.async();
+ QUnit.test('pressing ENTER on a \'no_quick_create\' many2one should open a M2ODialog', async function (assert) {
assert.expect(2);
var M2O_DELAY = relationalFields.FieldMany2One.prototype.AUTOCOMPLETE_DELAY;
relationalFields.FieldMany2One.prototype.AUTOCOMPLETE_DELAY = 0;
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -2287,47 +2271,33 @@ QUnit.module('fields', {}, function () {
});
var $input = form.$('.o_field_many2one input');
- testUtils.fields.editInput($input, "Something that does not exist");
+ await testUtils.fields.editInput($input, "Something that does not exist");
$('.ui-autocomplete .ui-menu-item a:contains(Create and)').trigger('mouseenter');
- concurrency.delay(0).then(function () {
- $input.trigger($.Event('keydown', {
- which: $.ui.keyCode.ENTER,
- keyCode: $.ui.keyCode.ENTER,
- }));
- $input.trigger($.Event('keypress', {
- which: $.ui.keyCode.ENTER,
- keyCode: $.ui.keyCode.ENTER,
- }));
- $input.trigger($.Event('keyup', {
- which: $.ui.keyCode.ENTER,
- keyCode: $.ui.keyCode.ENTER,
- }));
- concurrency.delay(0).then(function () {
- $input.blur();
- assert.strictEqual($('.modal').length, 1,
- "should have one modal in body");
- // Check that discarding clears $input
- testUtils.dom.click($('.modal .o_form_button_cancel'));
- assert.strictEqual($input.val(), '',
- "the field should be empty");
- form.destroy();
- relationalFields.FieldMany2One.prototype.AUTOCOMPLETE_DELAY = M2O_DELAY;
- done();
- });
- });
+ await testUtils.nextTick();
+ await testUtils.fields.triggerKey('down', $input, 'enter')
+ await testUtils.fields.triggerKey('press', $input, 'enter')
+ await testUtils.fields.triggerKey('up', $input, 'enter')
+ $input.blur();
+ assert.strictEqual($('.modal').length, 1,
+ "should have one modal in body");
+ // Check that discarding clears $input
+ await testUtils.dom.click($('.modal .o_form_button_cancel'));
+ assert.strictEqual($input.val(), '',
+ "the field should be empty");
+ form.destroy();
+ relationalFields.FieldMany2One.prototype.AUTOCOMPLETE_DELAY = M2O_DELAY;
});
- QUnit.test('select a value by pressing TAB on a many2one with onchange', function (assert) {
- var done = assert.async();
+ QUnit.test('select a value by pressing TAB on a many2one with onchange', async function (assert) {
assert.expect(3);
this.data.partner.onchanges.trululu = function () { };
var M2O_DELAY = relationalFields.FieldMany2One.prototype.AUTOCOMPLETE_DELAY;
relationalFields.FieldMany2One.prototype.AUTOCOMPLETE_DELAY = 0;
- var def = $.Deferred();
+ var prom = testUtils.makeTestPromise();
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -2338,7 +2308,7 @@ QUnit.module('fields', {}, function () {
mockRPC: function (route, args) {
var result = this._super.apply(this, arguments);
if (args.method === 'onchange') {
- return $.when(def).then(_.constant(result));
+ return prom.then(_.constant(result));
}
return result;
},
@@ -2349,39 +2319,32 @@ QUnit.module('fields', {}, function () {
});
var $input = form.$('.o_field_many2one input');
- testUtils.fields.editInput($input, "first");
- concurrency.delay(0).then(function () {
- var evOptions = {
- which: $.ui.keyCode.TAB,
- keyCode: $.ui.keyCode.TAB,
- };
- $input.trigger($.Event('keydown', evOptions));
- $input.trigger($.Event('keypress', evOptions));
- $input.trigger($.Event('keyup', evOptions));
-
- // simulate a focusout (e.g. because the user clicks outside)
- // before the onchange returns
- form.$('.o_field_char').focus();
-
- assert.strictEqual($('.modal').length, 0,
- "there shouldn't be any modal in body");
-
- // unlock the onchange
- def.resolve();
-
- assert.strictEqual($input.val(), 'first record',
- "first record should have been selected");
- assert.strictEqual($('.modal').length, 0,
- "there shouldn't be any modal in body");
- relationalFields.FieldMany2One.prototype.AUTOCOMPLETE_DELAY = M2O_DELAY;
- form.destroy();
- done();
- });
+ await testUtils.fields.editInput($input, "first");
+ await testUtils.fields.triggerKey('down', $input, 'tab');
+ await testUtils.fields.triggerKey('press', $input, 'tab');
+ await testUtils.fields.triggerKey('up', $input, 'tab');
+
+ // simulate a focusout (e.g. because the user clicks outside)
+ // before the onchange returns
+ form.$('.o_field_char').focus();
+
+ assert.strictEqual($('.modal').length, 0,
+ "there shouldn't be any modal in body");
+
+ // unlock the onchange
+ prom.resolve();
+ await testUtils.nextTick();
+
+ assert.strictEqual($input.val(), 'first record',
+ "first record should have been selected");
+ assert.strictEqual($('.modal').length, 0,
+ "there shouldn't be any modal in body");
+ relationalFields.FieldMany2One.prototype.AUTOCOMPLETE_DELAY = M2O_DELAY;
+ form.destroy();
});
- QUnit.test('many2one in editable list + onchange, with enter [REQUIRE FOCUS]', function (assert) {
+ QUnit.test('many2one in editable list + onchange, with enter [REQUIRE FOCUS]', async function (assert) {
assert.expect(6);
- var done = assert.async();
var M2O_DELAY = relationalFields.FieldMany2One.prototype.AUTOCOMPLETE_DELAY;
relationalFields.FieldMany2One.prototype.AUTOCOMPLETE_DELAY = 0;
@@ -2389,9 +2352,9 @@ QUnit.module('fields', {}, function () {
obj.int_field = obj.product_id || 0;
};
- var def = $.Deferred();
+ var prom = testUtils.makeTestPromise();
- var list = createView({
+ var list = await createView({
View: ListView,
model: 'partner',
data: this.data,
@@ -2402,42 +2365,30 @@ QUnit.module('fields', {}, function () {
}
var result = this._super.apply(this, arguments);
if (args.method === 'onchange') {
- return def.then(_.constant(result));
+ return prom.then(_.constant(result));
}
return result;
},
});
- testUtils.dom.click(list.$('td.o_data_cell:first'));
- testUtils.fields.editInput(list.$('td.o_data_cell input:first'), 'a');
- concurrency.delay(0).then(function () {
- var $input = list.$('td.o_data_cell input:first');
- $input.trigger($.Event('keydown', {
- which: $.ui.keyCode.ENTER,
- keyCode: $.ui.keyCode.ENTER,
- }));
- $input.trigger($.Event('keyup', {
- which: $.ui.keyCode.ENTER,
- keyCode: $.ui.keyCode.ENTER,
- }));
- def.resolve();
- $input.trigger($.Event('keydown', {
- which: $.ui.keyCode.ENTER,
- keyCode: $.ui.keyCode.ENTER,
- }));
- assert.strictEqual($('.modal').length, 0, "should not have any modal in DOM");
- assert.verifySteps(['name_search', 'onchange', 'write', 'read']);
- list.destroy();
- relationalFields.FieldMany2One.prototype.AUTOCOMPLETE_DELAY = M2O_DELAY;
- done();
- });
+ await testUtils.dom.click(list.$('td.o_data_cell:first'));
+ await testUtils.fields.editInput(list.$('td.o_data_cell input:first'), 'a');
+ var $input = list.$('td.o_data_cell input:first');
+ await testUtils.fields.triggerKeydown($input, 'enter');
+ await testUtils.fields.triggerKey('up', $input, 'enter');
+ prom.resolve();
+ await testUtils.nextTick();
+ await testUtils.fields.triggerKeydown($input, 'enter');
+ assert.strictEqual($('.modal').length, 0, "should not have any modal in DOM");
+ assert.verifySteps(['name_search', 'onchange', 'write', 'read']);
+ list.destroy();
+ relationalFields.FieldMany2One.prototype.AUTOCOMPLETE_DELAY = M2O_DELAY;
});
- QUnit.test('many2one in editable list + onchange, with enter, part 2 [REQUIRE FOCUS]', function (assert) {
+ QUnit.test('many2one in editable list + onchange, with enter, part 2 [REQUIRE FOCUS]', async function (assert) {
// this is the same test as the previous one, but the onchange is just
// resolved slightly later
assert.expect(6);
- var done = assert.async();
var M2O_DELAY = relationalFields.FieldMany2One.prototype.AUTOCOMPLETE_DELAY;
relationalFields.FieldMany2One.prototype.AUTOCOMPLETE_DELAY = 0;
@@ -2445,9 +2396,9 @@ QUnit.module('fields', {}, function () {
obj.int_field = obj.product_id || 0;
};
- var def = $.Deferred();
+ var prom = testUtils.makeTestPromise();
- var list = createView({
+ var list = await createView({
View: ListView,
model: 'partner',
data: this.data,
@@ -2458,38 +2409,27 @@ QUnit.module('fields', {}, function () {
}
var result = this._super.apply(this, arguments);
if (args.method === 'onchange') {
- return def.then(_.constant(result));
+ return prom.then(_.constant(result));
}
return result;
},
});
- testUtils.dom.click(list.$('td.o_data_cell:first'));
- testUtils.fields.editInput(list.$('td.o_data_cell input:first'), 'a');
- concurrency.delay(0).then(function () {
- var $input = list.$('td.o_data_cell input:first');
- $input.trigger($.Event('keydown', {
- which: $.ui.keyCode.ENTER,
- keyCode: $.ui.keyCode.ENTER,
- }));
- $input.trigger($.Event('keyup', {
- which: $.ui.keyCode.ENTER,
- keyCode: $.ui.keyCode.ENTER,
- }));
- $input.trigger($.Event('keydown', {
- which: $.ui.keyCode.ENTER,
- keyCode: $.ui.keyCode.ENTER,
- }));
- def.resolve();
- assert.strictEqual($('.modal').length, 0, "should not have any modal in DOM");
- assert.verifySteps(['name_search', 'onchange', 'write', 'read']);
- list.destroy();
- relationalFields.FieldMany2One.prototype.AUTOCOMPLETE_DELAY = M2O_DELAY;
- done();
- });
+ await testUtils.dom.click(list.$('td.o_data_cell:first'));
+ await testUtils.fields.editInput(list.$('td.o_data_cell input:first'), 'a');
+ var $input = list.$('td.o_data_cell input:first');
+ await testUtils.fields.triggerKeydown($input, 'enter');
+ await testUtils.fields.triggerKey('up', $input, 'enter');
+ await testUtils.fields.triggerKeydown($input, 'enter');
+ prom.resolve();
+ await testUtils.nextTick();
+ assert.strictEqual($('.modal').length, 0, "should not have any modal in DOM");
+ assert.verifySteps(['name_search', 'onchange', 'write', 'read']);
+ list.destroy();
+ relationalFields.FieldMany2One.prototype.AUTOCOMPLETE_DELAY = M2O_DELAY;
});
- QUnit.test('many2one: domain updated by an onchange', function (assert) {
+ QUnit.test('many2one: domain updated by an onchange', async function (assert) {
assert.expect(2);
this.data.partner.onchanges = {
@@ -2497,7 +2437,7 @@ QUnit.module('fields', {}, function () {
};
var domain = [];
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -2509,7 +2449,7 @@ QUnit.module('fields', {}, function () {
mockRPC: function (route, args) {
if (args.method === 'onchange') {
domain = [['id', 'in', [10]]];
- return $.when({
+ return Promise.resolve({
domain: {
trululu: domain,
unexisting_field: domain,
@@ -2528,18 +2468,18 @@ QUnit.module('fields', {}, function () {
});
// trigger a name_search (domain should be [])
- testUtils.dom.click(form.$('.o_field_widget[name=trululu] input'));
+ await testUtils.dom.click(form.$('.o_field_widget[name=trululu] input'));
// close the dropdown
- testUtils.dom.click(form.$('.o_field_widget[name=trululu] input'));
+ await testUtils.dom.click(form.$('.o_field_widget[name=trululu] input'));
// trigger an onchange that will update the domain
- testUtils.fields.editInput(form.$('.o_field_widget[name=int_field]'), 2);
+ await testUtils.fields.editInput(form.$('.o_field_widget[name=int_field]'), 2);
// trigger a name_search (domain should be [['id', 'in', [10]]])
- testUtils.dom.click(form.$('.o_field_widget[name=trululu] input'));
+ await testUtils.dom.click(form.$('.o_field_widget[name=trululu] input'));
form.destroy();
});
- QUnit.test('many2one in one2many: domain updated by an onchange', function (assert) {
+ QUnit.test('many2one in one2many: domain updated by an onchange', async function (assert) {
assert.expect(3);
this.data.partner.onchanges = {
@@ -2547,7 +2487,7 @@ QUnit.module('fields', {}, function () {
};
var domain = [];
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -2561,7 +2501,7 @@ QUnit.module('fields', {}, function () {
res_id: 1,
mockRPC: function (route, args) {
if (args.method === 'onchange') {
- return $.when({
+ return Promise.resolve({
domain: {
trululu: domain,
},
@@ -2580,18 +2520,18 @@ QUnit.module('fields', {}, function () {
// add a first row with a specific domain for the m2o
domain = [['id', 'in', [10]]]; // domain for subrecord 1
- testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
- testUtils.dom.click(form.$('.o_field_widget[name=trululu] input'));
+ await testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
+ await testUtils.dom.click(form.$('.o_field_widget[name=trululu] input'));
// add a second row with another domain for the m2o
domain = [['id', 'in', [5]]]; // domain for subrecord 2
- testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
- testUtils.dom.click(form.$('.o_field_widget[name=trululu] input'));
+ await testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
+ await testUtils.dom.click(form.$('.o_field_widget[name=trululu] input'));
// check again the first row to ensure that the domain hasn't change
domain = [['id', 'in', [10]]]; // domain for subrecord 1 should have been kept
- testUtils.dom.click(form.$('.o_data_row:first .o_data_cell'));
- testUtils.dom.click(form.$('.o_field_widget[name=trululu] input'));
+ await testUtils.dom.click(form.$('.o_data_row:first .o_data_cell'));
+ await testUtils.dom.click(form.$('.o_field_widget[name=trululu] input'));
form.destroy();
});
@@ -2606,7 +2546,7 @@ QUnit.module('fields', {}, function () {
this.data.partner.records.push({id: 100 + i, display_name: 'test_' + i});
}
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -2652,7 +2592,7 @@ QUnit.module('fields', {}, function () {
}
var expectedDomain;
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -2682,7 +2622,7 @@ QUnit.module('fields', {}, function () {
// remove the filter on ids
expectedDomain = [];
- testUtils.dom.click($('.modal .o_cp_searchview .o_facet_remove'));
+ await testUtils.dom.click($('.modal .o_cp_searchview .o_facet_remove'));
assert.verifySteps([
'default_get',
@@ -2697,12 +2637,12 @@ QUnit.module('fields', {}, function () {
form.destroy();
});
- QUnit.test('updating a many2one from a many2many', function (assert) {
+ QUnit.test('updating a many2one from a many2many', async function (assert) {
assert.expect(4);
this.data.turtle.records[1].turtle_trululu = 1;
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -2723,22 +2663,22 @@ QUnit.module('fields', {}, function () {
mockRPC: function (route, args) {
if (args.method === 'get_formview_id') {
assert.deepEqual(args.args[0], [1], "should call get_formview_id with correct id");
- return $.when(false);
+ return Promise.resolve(false);
}
return this._super(route, args);
},
});
// Opening the modal
- testUtils.form.clickEdit(form);
- testUtils.dom.click(form.$('.o_data_row td:contains(first record)'));
- testUtils.dom.click(form.$('.o_external_button'));
+ await testUtils.form.clickEdit(form);
+ await testUtils.dom.click(form.$('.o_data_row td:contains(first record)'));
+ await testUtils.dom.click(form.$('.o_external_button'));
assert.strictEqual($('.modal').length, 1,
"should have one modal in body");
// Changing the 'trululu' value
- testUtils.fields.editInput($('.modal input[name="display_name"]'), 'test');
- testUtils.dom.click($('.modal button.btn-primary'));
+ await testUtils.fields.editInput($('.modal input[name="display_name"]'), 'test');
+ await testUtils.dom.click($('.modal button.btn-primary'));
// Test whether the value has changed
assert.strictEqual($('.modal').length, 0,
@@ -2749,13 +2689,13 @@ QUnit.module('fields', {}, function () {
form.destroy();
});
- QUnit.test('x2many list sorted by many2one', function (assert) {
+ QUnit.test('x2many list sorted by many2one', async function (assert) {
assert.expect(3);
this.data.partner.records[0].p = [1, 2, 4];
this.data.partner.fields.trululu.sortable = true;
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -2773,12 +2713,12 @@ QUnit.module('fields', {}, function () {
assert.strictEqual(form.$('.o_data_row .o_list_number').text(), '124',
"should have correct order initially");
- testUtils.dom.click(form.$('.o_list_view thead th:nth(1)'));
+ await testUtils.dom.click(form.$('.o_list_view thead th:nth(1)'));
assert.strictEqual(form.$('.o_data_row .o_list_number').text(), '412',
"should have correct order (ASC)");
- testUtils.dom.click(form.$('.o_list_view thead th:nth(1)'));
+ await testUtils.dom.click(form.$('.o_list_view thead th:nth(1)'));
assert.strictEqual(form.$('.o_data_row .o_list_number').text(), '214',
"should have correct order (DESC)");
@@ -2786,10 +2726,10 @@ QUnit.module('fields', {}, function () {
form.destroy();
});
- QUnit.test('one2many with extra field from server not in form', function (assert) {
+ QUnit.test('one2many with extra field from server not in form', async function (assert) {
assert.expect(6);
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -2814,20 +2754,20 @@ QUnit.module('fields', {}, function () {
}
});
- testUtils.form.clickEdit(form);
+ await testUtils.form.clickEdit(form);
var x2mList = form.$('.o_field_x2many_list[name=p]');
// Add a record in the list
- testUtils.dom.click(x2mList.find('.o_field_x2many_list_row_add a'));
+ await testUtils.dom.click(x2mList.find('.o_field_x2many_list_row_add a'));
var modal = $('.modal-lg');
var nameInput = modal.find('input.o_input[name=display_name]');
- testUtils.fields.editInput(nameInput, 'michelangelo');
+ await testUtils.fields.editInput(nameInput, 'michelangelo');
// Save the record in the modal (though it is still virtual)
- testUtils.dom.click(modal.find('.btn-primary').first());
+ await testUtils.dom.click(modal.find('.btn-primary').first());
assert.equal(x2mList.find('.o_data_row').length, 1,
'There should be 1 records in the x2m list');
@@ -2840,7 +2780,7 @@ QUnit.module('fields', {}, function () {
'The display name field should have the right value');
// Save the whole thing
- testUtils.form.clickSave(form);
+ await testUtils.form.clickSave(form);
x2mList = form.$('.o_field_x2many_list[name=p]');
@@ -2858,10 +2798,10 @@ QUnit.module('fields', {}, function () {
form.destroy();
});
- QUnit.test('one2many with extra field from server not in (inline) form', function (assert) {
+ QUnit.test('one2many with extra field from server not in (inline) form', async function (assert) {
assert.expect(1);
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -2885,15 +2825,15 @@ QUnit.module('fields', {}, function () {
var x2mList = form.$('.o_field_x2many_list[name=p]');
// Add a record in the list
- testUtils.dom.click(x2mList.find('.o_field_x2many_list_row_add a'));
+ await testUtils.dom.click(x2mList.find('.o_field_x2many_list_row_add a'));
var modal = $('.modal-lg');
var nameInput = modal.find('input.o_input[name=display_name]');
- testUtils.fields.editInput(nameInput, 'michelangelo');
+ await testUtils.fields.editInput(nameInput, 'michelangelo');
// Save the record in the modal (though it is still virtual)
- testUtils.dom.click(modal.find('.btn-primary').first());
+ await testUtils.dom.click(modal.find('.btn-primary').first());
assert.equal(x2mList.find('.o_data_row').length, 1,
'There should be 1 records in the x2m list');
@@ -2901,10 +2841,10 @@ QUnit.module('fields', {}, function () {
form.destroy();
});
- QUnit.test('one2many with extra X2many field from server not in inline form', function (assert) {
+ QUnit.test('one2many with extra X2many field from server not in inline form', async function (assert) {
assert.expect(1);
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -2928,13 +2868,13 @@ QUnit.module('fields', {}, function () {
var x2mList = form.$('.o_field_x2many_list[name=p]');
// Add a first record in the list
- testUtils.dom.click(x2mList.find('.o_field_x2many_list_row_add a'));
+ await testUtils.dom.click(x2mList.find('.o_field_x2many_list_row_add a'));
// Save & New
- testUtils.dom.click($('.modal-lg').find('.btn-primary').eq(1));
+ await testUtils.dom.click($('.modal-lg').find('.btn-primary').eq(1));
// Save & Close
- testUtils.dom.click($('.modal-lg').find('.btn-primary').eq(0));
+ await testUtils.dom.click($('.modal-lg').find('.btn-primary').eq(0));
assert.equal(x2mList.find('.o_data_row').length, 2,
'There should be 2 records in the x2m list');
@@ -2942,11 +2882,11 @@ QUnit.module('fields', {}, function () {
form.destroy();
});
- QUnit.test('one2many invisible depends on parent field', function (assert) {
+ QUnit.test('one2many invisible depends on parent field', async function (assert) {
assert.expect(4);
this.data.partner.records[0].p = [2];
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -2972,21 +2912,22 @@ QUnit.module('fields', {}, function () {
});
assert.containsN(form, 'th', 2,
"should be 2 columns in the one2many");
- testUtils.form.clickEdit(form);
- testUtils.dom.click(form.$('.o_field_many2one[name="product_id"] input'));
- testUtils.dom.click($('li.ui-menu-item a:contains(xpad)').trigger('mouseenter'));
+ await testUtils.form.clickEdit(form);
+ await testUtils.dom.click(form.$('.o_field_many2one[name="product_id"] input'));
+ await testUtils.dom.click($('li.ui-menu-item a:contains(xpad)').trigger('mouseenter'));
assert.containsOnce(form, 'th',
"should be 1 column when the product_id is set");
- form.$('.o_field_many2one[name="product_id"] input').val('').trigger('keyup');
+ await testUtils.fields.editAndTrigger(form.$('.o_field_many2one[name="product_id"] input'),
+ '', 'keyup');
assert.containsN(form, 'th', 2,
"should be 2 columns in the one2many when product_id is not set");
- testUtils.dom.click(form.$('.o_field_boolean[name="bar"] input'));
+ await testUtils.dom.click(form.$('.o_field_boolean[name="bar"] input'));
assert.containsOnce(form, 'th',
"should be 1 column after the value change");
form.destroy();
});
- QUnit.test('one2many column visiblity depends on onchange of parent field', function (assert) {
+ QUnit.test('one2many column visiblity depends on onchange of parent field', async function (assert) {
assert.expect(3);
this.data.partner.records[0].p = [2];
@@ -2999,7 +2940,7 @@ QUnit.module('fields', {}, function () {
}
};
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -3020,24 +2961,24 @@ QUnit.module('fields', {}, function () {
"should be only 1 column ('foo') in the one2many");
assert.containsOnce(form, '.o_list_view .o_data_row', "should contain one row");
- testUtils.form.clickEdit(form);
+ await testUtils.form.clickEdit(form);
// add a new o2m record
- testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
+ await testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
form.$('.o_field_one2many input:first').focus();
- testUtils.fields.editInput(form.$('.o_field_one2many input:first'), 'New line');
- testUtils.dom.click(form.$el);
+ await testUtils.fields.editInput(form.$('.o_field_one2many input:first'), 'New line');
+ await testUtils.dom.click(form.$el);
assert.containsN(form, 'th', 2, "should be 2 columns('foo' + 'int_field')");
form.destroy();
});
- QUnit.test('one2many column_invisible on view not inline', function (assert) {
+ QUnit.test('one2many column_invisible on view not inline', async function (assert) {
assert.expect(4);
this.data.partner.records[0].p = [2];
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -3064,15 +3005,16 @@ QUnit.module('fields', {}, function () {
});
assert.containsN(form, 'th', 2,
"should be 2 columns in the one2many");
- testUtils.form.clickEdit(form);
- testUtils.dom.click(form.$('.o_field_many2one[name="product_id"] input'));
- testUtils.dom.click($('li.ui-menu-item a:contains(xpad)').trigger('mouseenter'));
+ await testUtils.form.clickEdit(form);
+ await testUtils.dom.click(form.$('.o_field_many2one[name="product_id"] input'));
+ await testUtils.dom.click($('li.ui-menu-item a:contains(xpad)').trigger('mouseenter'));
assert.containsOnce(form, 'th',
"should be 1 column when the product_id is set");
- form.$('.o_field_many2one[name="product_id"] input').val('').trigger('keyup');
+ await testUtils.fields.editAndTrigger(form.$('.o_field_many2one[name="product_id"] input'),
+ '', 'keyup');
assert.containsN(form, 'th', 2,
"should be 2 columns in the one2many when product_id is not set");
- testUtils.dom.click(form.$('.o_field_boolean[name="bar"] input'));
+ await testUtils.dom.click(form.$('.o_field_boolean[name="bar"] input'));
assert.containsOnce(form, 'th',
"should be 1 column after the value change");
form.destroy();
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 18581b88078..c29bf4f1ec9 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
@@ -159,7 +159,7 @@ QUnit.module('fields', {}, function () {
}, function () {
QUnit.module('FieldOne2Many');
- QUnit.test('New record with a o2m also with 2 new records, ordered, and resequenced', function (assert) {
+ QUnit.test('New record with a o2m also with 2 new records, ordered, and resequenced', async function (assert) {
assert.expect(3);
// Needed to have two new records in a single stroke
@@ -169,11 +169,11 @@ QUnit.module('fields', {}, function () {
[5],
[0, 0, { trululu: false }],
[0, 0, { trululu: false }],
- ]
+ ];
}
};
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -190,7 +190,7 @@ QUnit.module('fields', {}, function () {
mode: 'create',
},
mockRPC: function (route, args) {
- assert.step(args.method + ' ' + args.model)
+ assert.step(args.method + ' ' + args.model);
return this._super(route, args);
},
});
@@ -198,7 +198,7 @@ QUnit.module('fields', {}, function () {
// change the int_field through drag and drop
// that way, we'll trigger the sorting and the name_get
// of the lines of "p"
- testUtils.dom.dragAndDrop(
+ await testUtils.dom.dragAndDrop(
form.$('.ui-sortable-handle').eq(1),
form.$('tbody tr').first(),
{ position: 'top' }
@@ -211,7 +211,7 @@ QUnit.module('fields', {}, function () {
form.destroy();
});
- QUnit.test('O2M List with pager, decoration and default_order: add and cancel adding', function (assert) {
+ QUnit.test('O2M List with pager, decoration and default_order: add and cancel adding', async function (assert) {
assert.expect(3);
// The decoration on the list implies that its condition will be evaluated
@@ -222,7 +222,7 @@ QUnit.module('fields', {}, function () {
// and evaluation of the decoration against *visible records*
this.data.partner.records[0].p = [2, 4];
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -240,30 +240,25 @@ QUnit.module('fields', {}, function () {
},
});
- testUtils.dom.click(form.$('.o_field_x2many_list .o_field_x2many_list_row_add a'));
+ await testUtils.dom.click(form.$('.o_field_x2many_list .o_field_x2many_list_row_add a'));
- var $dataRows = form.$('.o_field_x2many_list .o_data_row');
- assert.equal($dataRows.length, 2,
+ assert.containsN(form, '.o_field_x2many_list .o_data_row', 2,
'There should be 2 rows');
- var $expectedSelectedRow = $dataRows.eq(1);
+ var $expectedSelectedRow = form.$('.o_field_x2many_list .o_data_row').eq(1);
var $actualSelectedRow = form.$('.o_selected_row');
assert.equal($actualSelectedRow[0], $expectedSelectedRow[0],
'The selected row should be the new one');
// Cancel Creation
- var escapeKey = $.ui.keyCode.ESCAPE;
- $actualSelectedRow.find('input').trigger(
- $.Event('keydown', { which: escapeKey, keyCode: escapeKey }));
-
- $dataRows = form.$('.o_field_x2many_list .o_data_row');
- assert.equal($dataRows.length, 1,
+ await testUtils.fields.triggerKeydown($actualSelectedRow.find('input'), 'escape');
+ assert.containsOnce(form, '.o_field_x2many_list .o_data_row',
'There should be 1 row');
form.destroy();
});
- QUnit.test('O2M with parented m2o and domain on parent.m2o', function (assert) {
+ QUnit.test('O2M with parented m2o and domain on parent.m2o', async function (assert) {
assert.expect(3);
/* records in an o2m can have a m2o pointing to themselves
@@ -272,7 +267,7 @@ QUnit.module('fields', {}, function () {
*/
this.data.turtle.fields.parent_id = { string: "Parent", type: "many2one", relation: 'turtle' };
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -297,31 +292,31 @@ QUnit.module('fields', {}, function () {
},
});
- testUtils.dom.click(form.$('.o_field_x2many_list[name=turtles] .o_field_x2many_list_row_add a'));
+ await testUtils.dom.click(form.$('.o_field_x2many_list[name=turtles] .o_field_x2many_list_row_add a'));
- testUtils.fields.many2one.clickOpenDropdown('parent_id');
- testUtils.fields.many2one.clickHighlightedItem('parent_id');
+ await testUtils.fields.many2one.clickOpenDropdown('parent_id');
+ await testUtils.fields.many2one.clickHighlightedItem('parent_id');
var $modal = $('.modal-content');
- testUtils.dom.click($modal.eq(1).find('.modal-footer .btn-primary').eq(0));
- testUtils.dom.click($modal.eq(0).find('.modal-footer .btn-primary').eq(1));
+ await testUtils.dom.click($modal.eq(1).find('.modal-footer .btn-primary').eq(0));
+ await testUtils.dom.click($modal.eq(0).find('.modal-footer .btn-primary').eq(1));
- assert.equal(form.$('.o_data_row').length, 1,
+ assert.containsOnce(form, '.o_data_row',
'The main record should have the new record in its o2m');
$modal = $('.modal-content');
- testUtils.dom.click($modal.find('.o_field_many2one input'));
+ await testUtils.dom.click($modal.find('.o_field_many2one input'));
form.destroy();
});
- QUnit.test('one2many list editable with cell readonly modifier', function (assert) {
+ QUnit.test('one2many list editable with cell readonly modifier', async function (assert) {
assert.expect(4);
this.data.partner.records[0].p = [2];
this.data.partner.records[1].turtles = [1, 2];
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -344,22 +339,22 @@ QUnit.module('fields', {}, function () {
}
});
- testUtils.form.clickEdit(form);
- testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
+ await testUtils.form.clickEdit(form);
+ await testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
var $targetInput = $('.o_selected_row .o_input[name=foo]');
assert.equal($targetInput[0], document.activeElement,
'The first input of the line should have the focus');
// Simulating hitting the 'f' key twice
- testUtils.fields.editInput($targetInput, 'f');
- testUtils.fields.editInput($targetInput, $targetInput.val() + 'f');
+ await testUtils.fields.editInput($targetInput, 'f');
+ await testUtils.fields.editInput($targetInput, $targetInput.val() + 'f');
assert.equal($targetInput[0], document.activeElement,
'The first input of the line should still have the focus');
// Simulating a TAB key
- $targetInput.trigger($.Event('keydown', { which: 9, keyCode: 9 }));
+ await testUtils.fields.triggerKeydown($targetInput, 'tab');
var $secondTarget = $('.o_selected_row .o_input[name=qux]');
@@ -367,19 +362,19 @@ QUnit.module('fields', {}, function () {
'The second input of the line should have the focus after the TAB press');
- testUtils.fields.editInput($secondTarget, 9);
- testUtils.fields.editInput($secondTarget, $secondTarget.val() + 9);
+ await testUtils.fields.editInput($secondTarget, 9);
+ await testUtils.fields.editInput($secondTarget, $secondTarget.val() + 9);
- testUtils.form.clickSave(form);
+ await testUtils.form.clickSave(form);
form.destroy();
});
- QUnit.test('one2many basic properties', function (assert) {
+ QUnit.test('one2many basic properties', async function (assert) {
assert.expect(6);
this.data.partner.records[0].p = [2];
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -412,7 +407,7 @@ QUnit.module('fields', {}, function () {
assert.ok(!form.$('td.o_list_record_remove').length,
"embedded one2many records should not have a remove icon");
- testUtils.form.clickEdit(form);
+ await testUtils.form.clickEdit(form);
assert.ok(form.$('.o_field_x2many_list_row_add').length,
"embedded one2many should now be editable");
@@ -425,10 +420,10 @@ QUnit.module('fields', {}, function () {
form.destroy();
});
- QUnit.test('transferring class attributes in one2many sub fields', function (assert) {
+ QUnit.test('transferring class attributes in one2many sub fields', async function (assert) {
assert.expect(3);
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -445,12 +440,12 @@ QUnit.module('fields', {}, function () {
assert.containsOnce(form, 'td.hey',
'should have a td with the desired class');
- testUtils.form.clickEdit(form);
+ await testUtils.form.clickEdit(form);
assert.containsOnce(form, 'td.hey',
'should have a td with the desired class');
- testUtils.dom.click(form.$('td.o_data_cell'));
+ await testUtils.dom.click(form.$('td.o_data_cell'));
assert.containsOnce(form, 'input[name="turtle_foo"].hey',
'should have an input with the desired class');
@@ -458,11 +453,11 @@ QUnit.module('fields', {}, function () {
form.destroy();
});
- QUnit.test('one2many with date and datetime', function (assert) {
+ QUnit.test('one2many with date and datetime', async function (assert) {
assert.expect(2);
this.data.partner.records[0].p = [2];
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -494,11 +489,11 @@ QUnit.module('fields', {}, function () {
form.destroy();
});
- QUnit.test('rendering with embedded one2many', function (assert) {
+ QUnit.test('rendering with embedded one2many', async function (assert) {
assert.expect(2);
this.data.partner.records[0].p = [2];
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -526,11 +521,11 @@ QUnit.module('fields', {}, function () {
form.destroy();
});
- QUnit.test('use the limit attribute in arch (in field o2m inline tree view)', function (assert) {
+ QUnit.test('use the limit attribute in arch (in field o2m inline tree view)', async function (assert) {
assert.expect(2);
this.data.partner.records[0].turtles = [1, 2, 3];
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -556,11 +551,11 @@ QUnit.module('fields', {}, function () {
form.destroy();
});
- QUnit.test('use the limit attribute in arch (in field o2m non inline tree view)', function (assert) {
+ QUnit.test('use the limit attribute in arch (in field o2m non inline tree view)', async function (assert) {
assert.expect(2);
this.data.partner.records[0].turtles = [1, 2, 3];
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -585,11 +580,11 @@ QUnit.module('fields', {}, function () {
form.destroy();
});
- QUnit.test('one2many with default_order on view not inline', function (assert) {
+ QUnit.test('one2many with default_order on view not inline', async function (assert) {
assert.expect(1);
this.data.partner.records[0].turtles = [1, 2, 3];
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -615,11 +610,11 @@ QUnit.module('fields', {}, function () {
form.destroy();
});
- QUnit.test('embedded one2many with widget', function (assert) {
+ QUnit.test('embedded one2many with widget', async function (assert) {
assert.expect(1);
this.data.partner.records[0].p = [2];
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -644,7 +639,7 @@ QUnit.module('fields', {}, function () {
form.destroy();
});
- QUnit.test('embedded one2many with handle widget', function (assert) {
+ QUnit.test('embedded one2many with handle widget', async function (assert) {
assert.expect(10);
var nbConfirmChange = 0;
@@ -657,7 +652,7 @@ QUnit.module('fields', {}, function () {
this.data.partner.records[0].turtles = [1, 2, 3];
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -685,14 +680,14 @@ QUnit.module('fields', {}, function () {
assert.strictEqual(form.$('td.o_data_cell:not(.o_handle_cell)').text(), "yopblipkawa",
"should have the 3 rows in the correct order");
- testUtils.form.clickEdit(form);
+ await testUtils.form.clickEdit(form);
assert.strictEqual(form.$('td.o_data_cell:not(.o_handle_cell)').text(), "yopblipkawa",
"should still have the 3 rows in the correct order");
assert.strictEqual(nbConfirmChange, 0, "should not have confirmed any change yet");
// Drag and drop the second line in first position
- testUtils.dom.dragAndDrop(
+ await testUtils.dom.dragAndDrop(
form.$('.ui-sortable-handle').eq(1),
form.$('tbody tr').first(),
{ position: 'top' }
@@ -705,7 +700,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);
+ await testUtils.form.clickSave(form);
assert.deepEqual(_.map(this.data.turtle.records, function (turtle) {
return _.pick(turtle, 'id', 'turtle_foo', 'turtle_int');
@@ -723,7 +718,7 @@ QUnit.module('fields', {}, function () {
form.destroy();
});
- QUnit.test('onchange for embedded one2many in a one2many with a second page', function (assert) {
+ QUnit.test('onchange for embedded one2many in a one2many with a second page', async function (assert) {
assert.expect(1);
this.data.turtle.fields.partner_ids.type = 'one2many';
@@ -747,7 +742,7 @@ QUnit.module('fields', {}, function () {
},
};
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -778,16 +773,16 @@ QUnit.module('fields', {}, function () {
}
});
- testUtils.form.clickEdit(form);
- testUtils.dom.click(form.$('.o_data_cell').eq(1));
+ await testUtils.form.clickEdit(form);
+ await 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);
+ await testUtils.fields.editSelect($cell, "hop");
+ await testUtils.form.clickSave(form);
form.destroy();
});
- QUnit.test('onchange for embedded one2many in a one2many updated by server', function (assert) {
+ QUnit.test('onchange for embedded one2many in a one2many updated by server', async function (assert) {
// here we test that after an onchange, the embedded one2many field has
// been updated by a new list of ids by the server response, to this new
// list should be correctly sent back at save time
@@ -809,7 +804,7 @@ QUnit.module('fields', {}, function () {
},
};
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -840,11 +835,11 @@ QUnit.module('fields', {}, function () {
assert.deepEqual(form.$('.o_many2many_tags_cell').text().trim(), "second record",
"the partner_ids should be as specified at initialization");
- testUtils.form.clickEdit(form);
- testUtils.dom.click(form.$('.o_data_cell').eq(1));
+ await testUtils.form.clickEdit(form);
+ await 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);
+ await testUtils.fields.editSelect($cell, "hop");
+ await testUtils.form.clickSave(form);
assert.deepEqual(form.$('.o_many2many_tags_cell').text().trim().split(/\s+/),
["second", "record", "aaa"],
@@ -853,24 +848,24 @@ QUnit.module('fields', {}, function () {
form.destroy();
});
- QUnit.test('onchange for embedded one2many with handle widget', function (assert) {
+ QUnit.test('onchange for embedded one2many with handle widget', async function (assert) {
assert.expect(2);
this.data.partner.records[0].turtles = [1, 2, 3];
var partnerOnchange = 0;
this.data.partner.onchanges = {
- turtles: function (obj) {
+ turtles: function () {
partnerOnchange++;
},
};
var turtleOnchange = 0;
this.data.turtle.onchanges = {
- turtle_int: function (obj) {
+ turtle_int: function () {
turtleOnchange++;
},
};
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -891,10 +886,10 @@ QUnit.module('fields', {}, function () {
res_id: 1,
});
- testUtils.form.clickEdit(form);
+ await testUtils.form.clickEdit(form);
// Drag and drop the second line in first position
- testUtils.dom.dragAndDrop(
+ await testUtils.dom.dragAndDrop(
form.$('.ui-sortable-handle').eq(1),
form.$('tbody tr').first(),
{ position: 'top' }
@@ -906,7 +901,7 @@ QUnit.module('fields', {}, function () {
form.destroy();
});
- QUnit.test('onchange for embedded one2many with handle widget using same sequence', function (assert) {
+ QUnit.test('onchange for embedded one2many with handle widget using same sequence', async function (assert) {
assert.expect(4);
this.data.turtle.records[0].turtle_int = 1;
@@ -920,7 +915,7 @@ QUnit.module('fields', {}, function () {
},
};
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -948,14 +943,14 @@ QUnit.module('fields', {}, function () {
},
});
- testUtils.form.clickEdit(form);
+ await testUtils.form.clickEdit(form);
assert.strictEqual(form.$('td.o_data_cell:not(.o_handle_cell)').text(), "yopblipkawa",
"should have the 3 rows in the correct order");
// Drag and drop the second line in first position
- testUtils.dom.dragAndDrop(
+ await testUtils.dom.dragAndDrop(
form.$('.ui-sortable-handle').eq(1),
form.$('tbody tr').first(),
{ position: 'top' }
@@ -965,11 +960,11 @@ 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);
+ await testUtils.form.clickSave(form);
form.destroy();
});
- QUnit.test('onchange (with command 5) for embedded one2many with handle widget', function (assert) {
+ QUnit.test('onchange (with command 5) for embedded one2many with handle widget', async function (assert) {
assert.expect(3);
var ids = [];
@@ -990,7 +985,7 @@ QUnit.module('fields', {}, function () {
},
};
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -1009,16 +1004,16 @@ QUnit.module('fields', {}, function () {
res_id: 1,
});
- testUtils.dom.click(form.$('.o_field_widget[name=turtles] .o_pager_next'));
+ await 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");
- testUtils.form.clickEdit(form);
- 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');
+ await testUtils.form.clickEdit(form);
+ await testUtils.dom.click(form.$('.o_field_one2many .o_list_view tbody tr:first td:first'));
+ await testUtils.fields.editInput(form.$('.o_field_one2many .o_list_view tbody tr:first input:first'), 'blurp');
// Drag and drop the third line in second position
- testUtils.dom.dragAndDrop(
+ await testUtils.dom.dragAndDrop(
form.$('.ui-sortable-handle').eq(2),
form.$('.o_field_one2many tbody tr').eq(1),
{ position: 'top' }
@@ -1026,8 +1021,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_field_widget[name=turtles] .o_pager_next'));
+ await testUtils.form.clickSave(form);
+ await 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");
@@ -1035,7 +1030,7 @@ QUnit.module('fields', {}, function () {
form.destroy();
});
- QUnit.test('onchange with modifiers for embedded one2many on the second page', function (assert) {
+ QUnit.test('onchange with modifiers for embedded one2many on the second page', async function (assert) {
assert.expect(7);
var data = this.data;
@@ -1074,7 +1069,7 @@ QUnit.module('fields', {}, function () {
},
};
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: data,
@@ -1094,29 +1089,29 @@ QUnit.module('fields', {}, function () {
res_id: 1,
});
- testUtils.form.clickEdit(form);
+ await testUtils.form.clickEdit(form);
assert.equal(form.$('.o_field_one2many td[class="o_data_cell"]').text(), "#20#21#22#23#24#25#26#27#28#29",
"should display the records in order");
- 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');
+ await testUtils.dom.click(form.$('.o_field_one2many .o_list_view tbody tr:first td:first'));
+ await 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);
+ await 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");
- testUtils.dom.click($('.modal .modal-footer button:first'));
+ await testUtils.dom.click($('.modal .modal-footer button:first'));
assert.equal(form.$('.o_field_one2many td[class="o_data_cell"]').text(), "#20#21#22#23#24#25#26#27#28#29",
"should cancel changes and display the records in order");
- testUtils.form.clickEdit(form);
+ await testUtils.form.clickEdit(form);
// Drag and drop the third line in second position
- testUtils.dom.dragAndDrop(
+ await testUtils.dom.dragAndDrop(
form.$('.ui-sortable-handle').eq(2),
form.$('.o_field_one2many tbody tr').eq(1),
{ position: 'top' }
@@ -1126,7 +1121,7 @@ QUnit.module('fields', {}, function () {
"should display the records in order after resequence (display record with turtle_int=0)");
// Drag and drop the third line in second position
- testUtils.dom.dragAndDrop(
+ await testUtils.dom.dragAndDrop(
form.$('.ui-sortable-handle').eq(2),
form.$('.o_field_one2many tbody tr').eq(1),
{ position: 'top' }
@@ -1135,12 +1130,12 @@ 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);
+ await 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");
- testUtils.dom.click($('.modal .modal-footer button:first'));
+ await testUtils.dom.click($('.modal .modal-footer button:first'));
assert.equal(form.$('.o_field_one2many td[class="o_data_cell"]').text(), "#20#21#22#23#24#25#26#27#28#29",
"should cancel changes and display the records in order");
@@ -1148,7 +1143,7 @@ QUnit.module('fields', {}, function () {
form.destroy();
});
- QUnit.test('onchange followed by edition on the second page', function (assert) {
+ QUnit.test('onchange followed by edition on the second page', async function (assert) {
assert.expect(12);
var ids = [];
@@ -1169,7 +1164,7 @@ QUnit.module('fields', {}, function () {
},
};
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -1188,30 +1183,30 @@ QUnit.module('fields', {}, function () {
res_id: 1,
});
- testUtils.form.clickEdit(form);
- testUtils.dom.click(form.$('.o_field_widget[name=turtles] .o_pager_next'));
+ await testUtils.form.clickEdit(form);
+ await 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');
- testUtils.dom.click(form.$('.o_field_one2many .o_list_view tbody tr:eq(2) td:first'));
- testUtils.fields.editInput(form.$('.o_field_one2many .o_list_view tbody tr:eq(2) input:first'), 'value 2');
+ await testUtils.dom.click(form.$('.o_field_one2many .o_list_view tbody tr:eq(1) td:first'));
+ await testUtils.fields.editInput(form.$('.o_field_one2many .o_list_view tbody tr:eq(1) input:first'), 'value 1');
+ await testUtils.dom.click(form.$('.o_field_one2many .o_list_view tbody tr:eq(2) td:first'));
+ await testUtils.fields.editInput(form.$('.o_field_one2many .o_list_view tbody tr:eq(2) input:first'), 'value 2');
assert.containsN(form, '.o_data_row', 40, "should display 40 records");
assert.strictEqual(form.$('.o_data_row:has(.o_data_cell:contains(#39))').index(), 0, "should display '#39' at the first line");
- testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
+ await testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
assert.containsN(form, '.o_data_row', 40, "should display 39 records and the create line");
assert.containsOnce(form, '.o_data_row:first .o_field_char', "should display the create line in first position");
assert.strictEqual(form.$('.o_data_row:first .o_field_char').val(), "", "should an empty input");
assert.strictEqual(form.$('.o_data_row:has(.o_data_cell:contains(#39))').index(), 1, "should display '#39' at the second line");
- testUtils.fields.editInput(form.$('.o_data_row input:first'), 'value 3');
+ await testUtils.fields.editInput(form.$('.o_data_row input:first'), 'value 3');
assert.containsOnce(form, '.o_data_row:first .o_field_char', "should display the create line in first position after onchange");
assert.strictEqual(form.$('.o_data_row:has(.o_data_cell:contains(#39))').index(), 1, "should display '#39' at the second line after onchange");
- testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
+ await testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
assert.containsN(form, '.o_data_row', 40, "should display 39 records and the create line");
assert.containsOnce(form, '.o_data_row:first .o_field_char', "should display the create line in first position");
@@ -1221,7 +1216,7 @@ QUnit.module('fields', {}, function () {
form.destroy();
});
- QUnit.test('onchange followed by edition on the second page (part 2)', function (assert) {
+ QUnit.test('onchange followed by edition on the second page (part 2)', async function (assert) {
assert.expect(8);
var ids = [];
@@ -1244,7 +1239,7 @@ QUnit.module('fields', {}, function () {
// bottom order
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -1263,25 +1258,25 @@ QUnit.module('fields', {}, function () {
res_id: 1,
});
- testUtils.form.clickEdit(form);
- testUtils.dom.click(form.$('.o_field_widget[name=turtles] .o_pager_next'));
+ await testUtils.form.clickEdit(form);
+ await 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');
- testUtils.dom.click(form.$('.o_field_one2many .o_list_view tbody tr:eq(2) td:first'));
- testUtils.fields.editInput(form.$('.o_field_one2many .o_list_view tbody tr:eq(2) input:first'), 'value 2');
+ await testUtils.dom.click(form.$('.o_field_one2many .o_list_view tbody tr:eq(1) td:first'));
+ await testUtils.fields.editInput(form.$('.o_field_one2many .o_list_view tbody tr:eq(1) input:first'), 'value 1');
+ await testUtils.dom.click(form.$('.o_field_one2many .o_list_view tbody tr:eq(2) td:first'));
+ await testUtils.fields.editInput(form.$('.o_field_one2many .o_list_view tbody tr:eq(2) input:first'), 'value 2');
assert.containsN(form, '.o_data_row', 40, "should display 40 records");
assert.strictEqual(form.$('.o_data_row:has(.o_data_cell:contains(#77))').index(), 39, "should display '#77' at the last line");
- testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
+ await testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
assert.containsN(form, '.o_data_row', 41, "should display 41 records and the create line");
assert.strictEqual(form.$('.o_data_row:has(.o_data_cell:contains(#76))').index(), 38, "should display '#76' at the penultimate line");
assert.strictEqual(form.$('.o_data_row:has(.o_field_char)').index(), 40, "should display the create line at the last position");
- testUtils.fields.editInput(form.$('.o_data_row input:first'), 'value 3');
- testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
+ await testUtils.fields.editInput(form.$('.o_data_row input:first'), 'value 3');
+ await testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
assert.containsN(form, '.o_data_row', 42, "should display 42 records and the create line");
assert.strictEqual(form.$('.o_data_row:has(.o_data_cell:contains(#76))').index(), 38, "should display '#76' at the penultimate line");
@@ -1290,7 +1285,7 @@ QUnit.module('fields', {}, function () {
form.destroy();
});
- QUnit.test('onchange returning a command 6 for an x2many', function (assert) {
+ QUnit.test('onchange returning a command 6 for an x2many', async function (assert) {
assert.expect(2);
this.data.partner.onchanges = {
@@ -1299,7 +1294,7 @@ QUnit.module('fields', {}, function () {
},
};
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -1321,7 +1316,7 @@ QUnit.module('fields', {}, function () {
"there should be one record in the relation");
// change the value of foo to trigger the onchange
- testUtils.fields.editInput(form.$('.o_field_widget[name=foo]'), 'some value');
+ await testUtils.fields.editInput(form.$('.o_field_widget[name=foo]'), 'some value');
assert.containsN(form, '.o_data_row', 3,
"there should be three records in the relation");
@@ -1329,7 +1324,7 @@ QUnit.module('fields', {}, function () {
form.destroy();
});
- QUnit.test('x2many fields inside x2manys are fetched after an onchange', function (assert) {
+ QUnit.test('x2many fields inside x2manys are fetched after an onchange', async function (assert) {
assert.expect(6);
this.data.turtle.records[0].partner_ids = [1];
@@ -1340,7 +1335,7 @@ QUnit.module('fields', {}, function () {
};
var checkRPC = false;
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -1379,7 +1374,7 @@ QUnit.module('fields', {}, function () {
// change the value of foo to trigger the onchange
checkRPC = true; // enable flag to check read RPC for the m2m field
- testUtils.fields.editInput(form.$('.o_field_widget[name=foo]'), 'some value');
+ await testUtils.fields.editInput(form.$('.o_field_widget[name=foo]'), 'some value');
assert.containsN(form, '.o_data_row', 3,
"there should be three records in the relation");
@@ -1389,7 +1384,7 @@ QUnit.module('fields', {}, function () {
form.destroy();
});
- QUnit.test('reference fields inside x2manys are fetched after an onchange', function (assert) {
+ QUnit.test('reference fields inside x2manys are fetched after an onchange', async function (assert) {
assert.expect(5);
this.data.turtle.records[1].turtle_ref = 'product,41';
@@ -1400,7 +1395,7 @@ QUnit.module('fields', {}, function () {
};
var checkRPC = false;
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -1437,7 +1432,7 @@ QUnit.module('fields', {}, function () {
// change the value of foo to trigger the onchange
checkRPC = true; // enable flag to check read RPC for reference field
- testUtils.fields.editInput(form.$('.o_field_widget[name=foo]'), 'some value');
+ await testUtils.fields.editInput(form.$('.o_field_widget[name=foo]'), 'some value');
assert.containsN(form, '.o_data_row', 3,
"there should be three records in the relation");
@@ -1447,7 +1442,7 @@ QUnit.module('fields', {}, function () {
form.destroy();
});
- QUnit.test('onchange on one2many containing x2many in form view', function (assert) {
+ QUnit.test('onchange on one2many containing x2many in form view', async function (assert) {
assert.expect(16);
this.data.partner.onchanges = {
@@ -1456,7 +1451,7 @@ QUnit.module('fields', {}, function () {
},
};
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -1486,20 +1481,20 @@ QUnit.module('fields', {}, function () {
// open the created o2m record in a form view, and add a m2m subrecord
// in its relation
- testUtils.dom.click(form.$('.o_data_row'));
+ await testUtils.dom.click(form.$('.o_data_row'));
assert.strictEqual($('.modal').length, 1, "should have opened a dialog");
assert.strictEqual($('.modal .o_data_row').length, 0,
"there should be no record in the one2many in the dialog");
// add a many2many subrecord
- testUtils.dom.click($('.modal .o_field_x2many_list_row_add a'));
+ await testUtils.dom.click($('.modal .o_field_x2many_list_row_add a'));
assert.strictEqual($('.modal').length, 2,
"should have opened a second dialog");
// select a many2many subrecord
- testUtils.dom.click($('.modal:nth(1) .o_list_view .o_data_cell:first'));
+ await testUtils.dom.click($('.modal:nth(1) .o_list_view .o_data_cell:first'));
assert.strictEqual($('.modal').length, 1,
"second dialog should be closed");
@@ -1509,25 +1504,25 @@ QUnit.module('fields', {}, function () {
'm2m pager should be hidden');
// click on 'Save & Close'
- testUtils.dom.click($('.modal-footer .btn-primary:first'));
+ await testUtils.dom.click($('.modal-footer .btn-primary:first'));
assert.strictEqual($('.modal').length, 0, "dialog should be closed");
// reopen o2m record, and another m2m subrecord in its relation, but
// discard the changes
- testUtils.dom.click(form.$('.o_data_row'));
+ await testUtils.dom.click(form.$('.o_data_row'));
assert.strictEqual($('.modal').length, 1, "should have opened a dialog");
assert.strictEqual($('.modal .o_data_row').length, 1,
"there should be one record in the one2many in the dialog");
// add another m2m subrecord
- testUtils.dom.click($('.modal .o_field_x2many_list_row_add a'));
+ await testUtils.dom.click($('.modal .o_field_x2many_list_row_add a'));
assert.strictEqual($('.modal').length, 2,
"should have opened a second dialog");
- testUtils.dom.click($('.modal:nth(1) .o_list_view .o_data_cell:first'));
+ await testUtils.dom.click($('.modal:nth(1) .o_list_view .o_data_cell:first'));
assert.strictEqual($('.modal').length, 1,
"second dialog should be closed");
@@ -1535,12 +1530,12 @@ QUnit.module('fields', {}, function () {
"there should be two records in the one2many in the dialog");
// click on 'Discard'
- testUtils.dom.clickFirst($('.modal-footer .btn-secondary'));
+ await testUtils.dom.clickFirst($('.modal-footer .btn-secondary'));
assert.strictEqual($('.modal').length, 0, "dialog should be closed");
// reopen o2m record to check that second changes have properly been discarded
- testUtils.dom.click(form.$('.o_data_row'));
+ await testUtils.dom.click(form.$('.o_data_row'));
assert.strictEqual($('.modal').length, 1, "should have opened a dialog");
assert.strictEqual($('.modal .o_data_row').length, 1,
@@ -1549,7 +1544,7 @@ QUnit.module('fields', {}, function () {
form.destroy();
});
- QUnit.test('embedded one2many with handle widget with minimum setValue calls', function (assert) {
+ QUnit.test('embedded one2many with handle widget with minimum setValue calls', async function (assert) {
var done = assert.async();
assert.expect(20);
@@ -1574,7 +1569,7 @@ QUnit.module('fields', {}, function () {
});
this.data.partner.records[0].turtles = [1, 2, 3, 4, 5, 6, 7];
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -1596,28 +1591,26 @@ QUnit.module('fields', {}, function () {
});
testUtils.mock.intercept(form, "field_changed", function (event) {
- assert.step(form.model.get(event.data.changes.turtles.id).res_id);
+ assert.step(String(form.model.get(event.data.changes.turtles.id).res_id));
}, true);
- testUtils.form.clickEdit(form);
+ await testUtils.form.clickEdit(form);
- var steps = [];
var positions = [
- [6, 0, 'top', [3, 6, 1, 2, 5, 7, 4]], // move the last to the first line
- [5, 1, 'top', [7, 6, 1, 2, 5]], // move the penultimate to the second line
- [2, 5, 'center', [1, 2, 5, 6]], // move the third to the penultimate line
+ [6, 0, 'top', ['3', '6', '1', '2', '5', '7', '4']], // move the last to the first line
+ [5, 1, 'top', ['7', '6', '1', '2', '5']], // move the penultimate to the second line
+ [2, 5, 'center', ['1', '2', '5', '6']], // move the third to the penultimate line
];
- function dragAndDrop() {
+ async function dragAndDrop() {
var pos = positions.shift();
- testUtils.dom.dragAndDrop(
+ await testUtils.dom.dragAndDrop(
form.$('.ui-sortable-handle').eq(pos[0]),
form.$('tbody tr').eq(pos[1]),
{ position: pos[2] }
);
- steps = steps.concat(pos[3]);
- assert.verifySteps(steps,
+ assert.verifySteps(pos[3],
"sequences values should be apply from the begin index to the drop index");
if (positions.length) {
@@ -1644,11 +1637,11 @@ QUnit.module('fields', {}, function () {
dragAndDrop();
});
- QUnit.test('embedded one2many (editable list) with handle widget', function (assert) {
+ QUnit.test('embedded one2many (editable list) with handle widget', async function (assert) {
assert.expect(8);
this.data.partner.records[0].p = [1, 2, 4];
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -1676,12 +1669,12 @@ QUnit.module('fields', {}, function () {
assert.strictEqual(form.$('td.o_data_cell:not(.o_handle_cell)').text(), "My little Foo Valueblipyop",
"should have the 3 rows in the correct order");
- testUtils.form.clickEdit(form);
+ await testUtils.form.clickEdit(form);
assert.strictEqual(form.$('td.o_data_cell:not(.o_handle_cell)').text(), "My little Foo Valueblipyop",
"should still have the 3 rows in the correct order");
// Drag and drop the second line in first position
- testUtils.dom.dragAndDrop(
+ await testUtils.dom.dragAndDrop(
form.$('.ui-sortable-handle').eq(1),
form.$('tbody tr').first(),
{ position: 'top' }
@@ -1693,19 +1686,19 @@ QUnit.module('fields', {}, function () {
assert.strictEqual(form.$('td.o_data_cell:not(.o_handle_cell)').text(), "blipMy little Foo Valueyop",
"should have the 3 rows in the new order");
- testUtils.dom.click(form.$('tbody tr:first td:first'));
+ await testUtils.dom.click(form.$('tbody tr:first td:first'));
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);
+ await 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");
form.destroy();
});
- QUnit.test('one2many field when using the pager', function (assert) {
+ QUnit.test('one2many field when using the pager', async function (assert) {
assert.expect(13);
var ids = [];
@@ -1721,7 +1714,7 @@ QUnit.module('fields', {}, function () {
this.data.partner.records[1].p = ids.slice(42);
var count = 0;
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -1759,6 +1752,7 @@ QUnit.module('fields', {}, function () {
// related records of record 1 anymore). Two additional RPCs should have
// been done
form.pager.next();
+ await testUtils.nextTick();
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');
@@ -1766,19 +1760,21 @@ QUnit.module('fields', {}, function () {
// move back to record 1, which should contain again its first 40 related
// records
form.pager.previous();
+ await testUtils.nextTick();
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');
// move to the second page of the o2m: 1 RPC should have been done to fetch
// the 2 subrecords of page 2, and those records should now be displayed
- testUtils.dom.click(form.$('.o_x2m_control_panel .o_pager_next'));
+ await testUtils.dom.click(form.$('.o_x2m_control_panel .o_pager_next'));
assert.strictEqual(count, 7, 'one RPC should have been done');
assert.strictEqual(form.$('.o_kanban_record:not(".o_kanban_ghost")').length, 2,
'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();
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');
@@ -1786,15 +1782,16 @@ QUnit.module('fields', {}, function () {
// move back to record 1 and move to page 2 again: all data should have
// been correctly reloaded
form.pager.previous();
+ await testUtils.nextTick();
assert.strictEqual(count, 11, 'two RPCs should have been done');
- testUtils.dom.click(form.$('.o_x2m_control_panel .o_pager_next'));
+ await testUtils.dom.click(form.$('.o_x2m_control_panel .o_pager_next'));
assert.strictEqual(count, 12, 'one RPC should have been done');
assert.strictEqual(form.$('.o_kanban_record:not(".o_kanban_ghost")').length, 2,
'one2many kanban should contain 2 cards for record 1 at page 2');
form.destroy();
});
- QUnit.test('edition of one2many field with pager', function (assert) {
+ QUnit.test('edition of one2many field with pager', async function (assert) {
assert.expect(31);
var ids = [];
@@ -1811,7 +1808,7 @@ QUnit.module('fields', {}, function () {
var saveCount = 0;
var checkRead = false;
var readIDs;
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -1894,10 +1891,10 @@ QUnit.module('fields', {}, function () {
// add a record on page one
checkRead = true;
- testUtils.form.clickEdit(form);
- testUtils.dom.click(form.$('.o-kanban-button-new'));
- testUtils.fields.editInput($('.modal input'), 'new record');
- testUtils.dom.click($('.modal .modal-footer .btn-primary:first'));
+ await testUtils.form.clickEdit(form);
+ await testUtils.dom.click(form.$('.o-kanban-button-new'));
+ await testUtils.fields.editInput($('.modal input'), 'new record');
+ await testUtils.dom.click($('.modal .modal-footer .btn-primary:first'));
// checks
assert.strictEqual(readIDs, undefined, "should not have read any record");
assert.strictEqual(form.$('span:contains(new record)').length, 0,
@@ -1909,14 +1906,14 @@ 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);
+ await testUtils.form.clickSave(form);
// delete a record on page one
checkRead = true;
- testUtils.form.clickEdit(form);
+ await testUtils.form.clickEdit(form);
assert.strictEqual(form.$('.o_kanban_record:first span:contains(relational record 10)').length,
1, 'first record should be the one with id 10 (next checks rely on that)');
- testUtils.dom.click(form.$('.delete_icon:first'));
+ await testUtils.dom.click(form.$('.delete_icon:first'));
// checks
assert.deepEqual(readIDs, [50],
"should have read a record (to display 40 records on page 1)");
@@ -1925,31 +1922,31 @@ 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);
+ await testUtils.form.clickSave(form);
// add and delete records in both pages
- testUtils.form.clickEdit(form);
+ await testUtils.form.clickEdit(form);
checkRead = true;
readIDs = undefined;
// add and delete a record in page 1
- testUtils.dom.click(form.$('.o-kanban-button-new'));
- testUtils.fields.editInput($('.modal input'), 'new record page 1');
- testUtils.dom.click($('.modal .modal-footer .btn-primary:first'));
+ await testUtils.dom.click(form.$('.o-kanban-button-new'));
+ await testUtils.fields.editInput($('.modal input'), 'new record page 1');
+ await testUtils.dom.click($('.modal .modal-footer .btn-primary:first'));
assert.strictEqual(form.$('.o_kanban_record:first span:contains(relational record 11)').length,
1, 'first record should be the one with id 11 (next checks rely on that)');
- testUtils.dom.click(form.$('.delete_icon:first'));
+ await testUtils.dom.click(form.$('.delete_icon:first'));
assert.deepEqual(readIDs, [51],
"should have read a record (to display 40 records on page 1)");
// add and delete a record in page 2
- testUtils.dom.click(form.$('.o_x2m_control_panel .o_pager_next'));
+ await testUtils.dom.click(form.$('.o_x2m_control_panel .o_pager_next'));
assert.strictEqual(form.$('.o_kanban_record:first span:contains(relational record 52)').length,
1, 'first record should be the one with id 52 (next checks rely on that)');
checkRead = true;
readIDs = undefined;
- testUtils.dom.click(form.$('.delete_icon:first'));
- testUtils.dom.click(form.$('.o-kanban-button-new'));
- testUtils.fields.editInput($('.modal input'), 'new record page 2');
- testUtils.dom.click($('.modal .modal-footer .btn-primary:first'));
+ await testUtils.dom.click(form.$('.delete_icon:first'));
+ await testUtils.dom.click(form.$('.o-kanban-button-new'));
+ await testUtils.fields.editInput($('.modal input'), 'new record page 2');
+ await testUtils.dom.click($('.modal .modal-footer .btn-primary:first'));
assert.strictEqual(readIDs, undefined, "should not have read any record");
// checks
assert.strictEqual(form.$('.o_kanban_record:not(".o_kanban_ghost")').length, 5,
@@ -1961,12 +1958,12 @@ 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);
+ await testUtils.form.clickSave(form);
form.destroy();
});
- QUnit.test('edition of one2many field, with onchange and not inline sub view', function (assert) {
+ QUnit.test('edition of one2many field, with onchange and not inline sub view', async function (assert) {
assert.expect(2);
this.data.turtle.onchanges.turtle_int = function (obj) {
@@ -1974,7 +1971,7 @@ QUnit.module('fields', {}, function () {
};
this.data.partner.onchanges.turtles = function () { };
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -1985,27 +1982,27 @@ QUnit.module('fields', {}, function () {
'turtle,false,list': '<tree><field name="turtle_foo"/></tree>',
'turtle,false,form': '<form><group><field name="turtle_foo"/><field name="turtle_int"/></group></form>',
},
- mockRPC: function (route, args) {
+ mockRPC: function () {
return this._super.apply(this, arguments);
},
res_id: 1,
});
- testUtils.form.clickEdit(form);
- testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
- testUtils.fields.editInput($('input[name="turtle_int"]'), '5');
- testUtils.dom.click($('.modal-footer button.btn-primary').first());
+ await testUtils.form.clickEdit(form);
+ await testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
+ await testUtils.fields.editInput($('input[name="turtle_int"]'), '5');
+ await testUtils.dom.click($('.modal-footer button.btn-primary').first());
assert.strictEqual(form.$('tbody tr:eq(1) td.o_data_cell').text(), '5',
'should display 5 in the foo field');
- testUtils.dom.click(form.$('tbody tr:eq(1) td.o_data_cell'));
+ await testUtils.dom.click(form.$('tbody tr:eq(1) td.o_data_cell'));
- testUtils.fields.editInput($('input[name="turtle_int"]'), '3');
- testUtils.dom.click($('.modal-footer button.btn-primary').first());
+ await testUtils.fields.editInput($('input[name="turtle_int"]'), '3');
+ await testUtils.dom.click($('.modal-footer button.btn-primary').first());
assert.strictEqual(form.$('tbody tr:eq(1) td.o_data_cell').text(), '3',
'should now display 3 in the foo field');
form.destroy();
});
- QUnit.test('sorting one2many fields', function (assert) {
+ QUnit.test('sorting one2many fields', async function (assert) {
assert.expect(4);
this.data.partner.fields.foo.sortable = true;
@@ -2015,7 +2012,7 @@ QUnit.module('fields', {}, function () {
this.data.partner.records[0].p = [23, 24, 25];
var rpcCount = 0;
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -2040,20 +2037,20 @@ QUnit.module('fields', {}, function () {
throw "should not render the whole form";
};
- testUtils.dom.click(form.$('table thead th:contains(Foo)'));
+ await testUtils.dom.click(form.$('table thead th:contains(Foo)'));
assert.strictEqual(rpcCount, 0,
'sort should be in memory, no extra RPCs should have been done');
assert.ok(form.$('table tbody tr:eq(2) td:contains(xyz)').length,
"the 3rd record is the one with 'xyz' value");
- testUtils.dom.click(form.$('table thead th:contains(Foo)'));
+ await testUtils.dom.click(form.$('table thead th:contains(Foo)'));
assert.ok(form.$('table tbody tr:eq(2) td:contains(abc)').length,
"the 3rd record is the one with 'abc' value");
form.destroy();
});
- QUnit.test('one2many list field edition', function (assert) {
+ QUnit.test('one2many list field edition', async function (assert) {
assert.expect(6);
this.data.partner.records.push({
@@ -2062,7 +2059,7 @@ QUnit.module('fields', {}, function () {
});
this.data.partner.records[1].p = [3];
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -2079,33 +2076,33 @@ QUnit.module('fields', {}, function () {
// edit the first line of the o2m
assert.strictEqual(form.$('.o_field_one2many tbody td').first().text(), 'relational record 1',
"display name of first record in o2m list should be 'relational record 1'");
- testUtils.form.clickEdit(form);
- testUtils.dom.click(form.$('.o_field_one2many tbody td').first());
+ await testUtils.form.clickEdit(form);
+ await testUtils.dom.click(form.$('.o_field_one2many tbody td').first());
assert.hasClass(form.$('.o_field_one2many tbody td').first().parent(),'o_selected_row',
"first row of o2m should be in edition");
- testUtils.fields.editInput(form.$('.o_field_one2many tbody td').first().find('input'), "new value");
+ await testUtils.fields.editInput(form.$('.o_field_one2many tbody td').first().find('input'), "new value");
assert.hasClass(form.$('.o_field_one2many tbody td').first().parent(),'o_selected_row',
"first row of o2m should still be in edition");
// // leave o2m edition
- testUtils.dom.click(form.$el);
+ await testUtils.dom.click(form.$el);
assert.doesNotHaveClass(form.$('.o_field_one2many tbody td').first().parent(), 'o_selected_row',
"first row of o2m should be readonly again");
// discard changes
- testUtils.form.clickDiscard(form);
+ await 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'));
+ await testUtils.dom.click($('.modal .modal-footer .btn-primary'));
assert.strictEqual(form.$('.o_field_one2many tbody td').first().text(), 'relational record 1',
"display name of first record in o2m list should be 'relational record 1'");
// edit again and save
- 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.dom.click(form.$el);
- testUtils.form.clickSave(form);
+ await testUtils.form.clickEdit(form);
+ await testUtils.dom.click(form.$('.o_field_one2many tbody td').first());
+ await testUtils.fields.editInput(form.$('.o_field_one2many tbody td').first().find('input'), "new value");
+ await testUtils.dom.click(form.$el);
+ await 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',
@@ -2114,9 +2111,9 @@ QUnit.module('fields', {}, function () {
form.destroy();
});
- QUnit.test('one2many list: create action disabled', function (assert) {
+ QUnit.test('one2many list: create action disabled', async function (assert) {
assert.expect(2);
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -2133,17 +2130,17 @@ QUnit.module('fields', {}, function () {
assert.ok(!form.$('.o_field_x2many_list_row_add').length,
'"Add an item" link should not be available in readonly');
- testUtils.form.clickEdit(form);
+ await testUtils.form.clickEdit(form);
assert.ok(!form.$('.o_field_x2many_list_row_add').length,
'"Add an item" link should not be available in readonly');
form.destroy();
});
- QUnit.test('one2many list: unlink two records', function (assert) {
+ QUnit.test('one2many list: unlink two records', async function (assert) {
assert.expect(9);
this.data.partner.records[0].p = [1, 2, 4];
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -2174,7 +2171,7 @@ QUnit.module('fields', {}, function () {
'<form string="Partner"><field name="display_name"/></form>',
},
});
- testUtils.form.clickEdit(form);
+ await testUtils.form.clickEdit(form);
assert.containsN(form, 'td.o_list_record_remove button', 3,
"should have 3 remove buttons");
@@ -2182,28 +2179,28 @@ QUnit.module('fields', {}, function () {
assert.hasClass(form.$('td.o_list_record_remove button').first(),'fa fa-times',
"should have X icons to remove (unlink) records");
- testUtils.dom.click(form.$('td.o_list_record_remove button').first());
+ await testUtils.dom.click(form.$('td.o_list_record_remove button').first());
assert.containsN(form, 'td.o_list_record_remove button', 2,
"should have 2 remove buttons (a record is supposed to have been unlinked)");
- testUtils.dom.click(form.$('tr.o_data_row').first());
+ await testUtils.dom.click(form.$('tr.o_data_row').first());
assert.strictEqual($('.modal .modal-footer .o_btn_remove').length, 1,
'there should be a modal having Remove Button');
- testUtils.dom.click($('.modal .modal-footer .o_btn_remove'));
+ await testUtils.dom.click($('.modal .modal-footer .o_btn_remove'));
assert.containsOnce(form, 'td.o_list_record_remove button',
"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);
+ await testUtils.form.clickSave(form);
form.destroy();
});
- QUnit.test('one2many list: deleting two records', function (assert) {
+ QUnit.test('one2many list: deleting two records', async function (assert) {
assert.expect(9);
this.data.partner.records[0].p = [1, 2, 4];
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -2234,7 +2231,7 @@ QUnit.module('fields', {}, function () {
'<form string="Partner"><field name="display_name"/></form>',
},
});
- testUtils.form.clickEdit(form);
+ await testUtils.form.clickEdit(form);
assert.containsN(form, 'td.o_list_record_remove button', 3,
"should have 3 remove buttons");
@@ -2242,21 +2239,21 @@ QUnit.module('fields', {}, function () {
assert.hasClass(form.$('td.o_list_record_remove button').first(),'fa fa-trash-o',
"should have trash bin icons to remove (delete) records");
- testUtils.dom.click(form.$('td.o_list_record_remove button').first());
+ await testUtils.dom.click(form.$('td.o_list_record_remove button').first());
assert.containsN(form, 'td.o_list_record_remove button', 2,
"should have 2 remove buttons (a record is supposed to have been deleted)");
- testUtils.dom.click(form.$('tr.o_data_row').first());
+ await testUtils.dom.click(form.$('tr.o_data_row').first());
assert.strictEqual($('.modal .modal-footer .o_btn_remove').length, 1,
'there should be a modal having Remove Button');
- testUtils.dom.click($('.modal .modal-footer .o_btn_remove'));
+ await testUtils.dom.click($('.modal .modal-footer .o_btn_remove'));
assert.containsOnce(form, 'td.o_list_record_remove button',
"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);
+ await 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
@@ -2264,11 +2261,11 @@ QUnit.module('fields', {}, function () {
form.destroy();
});
- QUnit.test('one2many kanban: edition', function (assert) {
+ QUnit.test('one2many kanban: edition', async function (assert) {
assert.expect(17);
this.data.partner.records[0].p = [2];
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -2303,7 +2300,7 @@ QUnit.module('fields', {}, function () {
assert.ok(!form.$('.o_field_one2many .o-kanban-button-new').length,
'"Create" button should not be visible in readonly');
- testUtils.form.clickEdit(form);
+ await testUtils.form.clickEdit(form);
assert.strictEqual(form.$('.o_kanban_record:not(.o_kanban_ghost)').length, 1,
'should contain 1 record');
@@ -2321,40 +2318,40 @@ QUnit.module('fields', {}, function () {
'Create button should have "Add" label');
// edit existing subrecord
- testUtils.dom.click(form.$('.oe_kanban_global_click'));
+ await testUtils.dom.click(form.$('.oe_kanban_global_click'));
- testUtils.fields.editInput($('.modal .o_form_view input').first(), 'new name');
- testUtils.dom.click($('.modal .modal-footer .btn-primary'));
+ await testUtils.fields.editInput($('.modal .o_form_view input').first(), 'new name');
+ await testUtils.dom.click($('.modal .modal-footer .btn-primary'));
assert.strictEqual(form.$('.o_kanban_record span:first').text(), 'new name',
'value of subrecord should have been updated');
// create a new subrecord
- testUtils.dom.click(form.$('.o-kanban-button-new'));
- testUtils.fields.editInput($('.modal .o_form_view input').first(), 'new subrecord 1');
- testUtils.dom.clickFirst($('.modal .modal-footer .btn-primary'));
+ await testUtils.dom.click(form.$('.o-kanban-button-new'));
+ await testUtils.fields.editInput($('.modal .o_form_view input').first(), 'new subrecord 1');
+ await testUtils.dom.clickFirst($('.modal .modal-footer .btn-primary'));
assert.strictEqual(form.$('.o_kanban_record:not(.o_kanban_ghost)').length, 2,
'should contain 2 records');
assert.strictEqual(form.$('.o_kanban_record:nth(1) span').text(), 'new subrecord 1',
'value of newly created subrecord should be "new subrecord 1"');
// create two new subrecords
- testUtils.dom.click(form.$('.o-kanban-button-new'));
- testUtils.fields.editInput($('.modal .o_form_view input').first(), 'new subrecord 2');
- testUtils.dom.click($('.modal .modal-footer .btn-primary:nth(1)'));
- testUtils.fields.editInput($('.modal .o_form_view input').first(), 'new subrecord 3');
- testUtils.dom.clickFirst($('.modal .modal-footer .btn-primary'));
+ await testUtils.dom.click(form.$('.o-kanban-button-new'));
+ await testUtils.fields.editInput($('.modal .o_form_view input').first(), 'new subrecord 2');
+ await testUtils.dom.click($('.modal .modal-footer .btn-primary:nth(1)'));
+ await testUtils.fields.editInput($('.modal .o_form_view input').first(), 'new subrecord 3');
+ await testUtils.dom.clickFirst($('.modal .modal-footer .btn-primary'));
assert.strictEqual(form.$('.o_kanban_record:not(.o_kanban_ghost)').length, 4,
'should contain 4 records');
// delete subrecords
- testUtils.dom.click(form.$('.oe_kanban_global_click').first());
+ await testUtils.dom.click(form.$('.oe_kanban_global_click').first());
assert.strictEqual($('.modal .modal-footer .o_btn_remove').length, 1,
'There should be a modal having Remove Button');
- testUtils.dom.click($('.modal .modal-footer .o_btn_remove'));
+ await testUtils.dom.click($('.modal .modal-footer .o_btn_remove'));
assert.strictEqual(form.$('.o_kanban_record:not(.o_kanban_ghost)').length, 3,
'should contain 3 records');
- testUtils.dom.click(form.$('.o_kanban_view .delete_icon:first()'));
- testUtils.dom.click(form.$('.o_kanban_view .delete_icon:first()'));
+ await testUtils.dom.click(form.$('.o_kanban_view .delete_icon:first()'));
+ await testUtils.dom.click(form.$('.o_kanban_view .delete_icon:first()'));
assert.strictEqual(form.$('.o_kanban_record:not(.o_kanban_ghost)').length, 1,
'should contain 1 records');
assert.strictEqual(form.$('.o_kanban_record span:first').text(), 'new subrecord 3',
@@ -2362,10 +2359,10 @@ QUnit.module('fields', {}, function () {
form.destroy();
});
- QUnit.test('one2many kanban (editable): properly handle create_text node option', function (assert) {
+ QUnit.test('one2many kanban (editable): properly handle create_text node option', async function (assert) {
assert.expect(1);
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -2385,19 +2382,19 @@ QUnit.module('fields', {}, function () {
res_id: 1,
});
- testUtils.form.clickEdit(form);
+ await testUtils.form.clickEdit(form);
assert.strictEqual(form.$('.o_field_one2many[name="turtles"] .o-kanban-button-new').text().trim(),
"Add turtle", "In O2M Kanban, Add button should have 'Add turtle' label");
form.destroy();
});
- QUnit.test('one2many kanban: create action disabled', function (assert) {
+ QUnit.test('one2many kanban: create action disabled', async function (assert) {
assert.expect(3);
this.data.partner.records[0].p = [4];
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -2422,7 +2419,7 @@ QUnit.module('fields', {}, function () {
assert.ok(!form.$('.o-kanban-button-new').length,
'"Add" button should not be available in readonly');
- testUtils.form.clickEdit(form);
+ await testUtils.form.clickEdit(form);
assert.ok(!form.$('.o-kanban-button-new').length,
'"Add" button should not be available in edit');
@@ -2431,13 +2428,13 @@ QUnit.module('fields', {}, function () {
form.destroy();
});
- QUnit.test('editable one2many list, pager is updated', function (assert) {
+ QUnit.test('editable one2many list, pager is updated', async function (assert) {
assert.expect(1);
this.data.turtle.records.push({ id: 4, turtle_foo: 'stephen hawking' });
this.data.partner.records[0].turtles = [1, 2, 3, 4];
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -2452,21 +2449,21 @@ QUnit.module('fields', {}, function () {
});
// add a record, then click in form view to confirm it
- testUtils.form.clickEdit(form);
- testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
- testUtils.dom.click(form.$el);
+ await testUtils.form.clickEdit(form);
+ 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',
"pager should display the correct total");
form.destroy();
});
- QUnit.test('one2many list (non editable): edition', function (assert) {
+ QUnit.test('one2many list (non editable): edition', async function (assert) {
assert.expect(12);
var nbWrite = 0;
this.data.partner.records[0].p = [2, 4];
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -2497,7 +2494,7 @@ QUnit.module('fields', {}, function () {
assert.ok(!form.$('.o_field_x2many_list_row_add').length,
'"Add an item" should not be visible in readonly');
- testUtils.form.clickEdit(form);
+ await testUtils.form.clickEdit(form);
assert.containsN(form, '.o_list_view td.o_list_number', 2,
'should contain 2 records');
@@ -2509,10 +2506,10 @@ QUnit.module('fields', {}, function () {
'"Add an item" should not visible in edit');
// edit existing subrecord
- testUtils.dom.click(form.$('.o_list_view tbody tr:first() td:eq(1)'));
+ await testUtils.dom.click(form.$('.o_list_view tbody tr:first() td:eq(1)'));
- testUtils.fields.editInput($('.modal .o_form_view input'), 'new name');
- testUtils.dom.click($('.modal .modal-footer .btn-primary'));
+ await testUtils.fields.editInput($('.modal .o_form_view input'), 'new name');
+ await testUtils.dom.click($('.modal .modal-footer .btn-primary'));
assert.strictEqual(form.$('.o_list_view tbody td:first()').text(), 'new name',
'value of subrecord should have been updated');
assert.strictEqual(nbWrite, 0, "should not have write anything in DB");
@@ -2521,23 +2518,23 @@ QUnit.module('fields', {}, function () {
// TODO when 'Add an item' will be implemented
// remove subrecords
- testUtils.dom.click(form.$('.o_list_record_remove:nth(1)'));
+ await testUtils.dom.click(form.$('.o_list_record_remove:nth(1)'));
assert.containsOnce(form, '.o_list_view td.o_list_number',
'should contain 1 subrecord');
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
+ await testUtils.form.clickSave(form); // save the record
assert.strictEqual(nbWrite, 1, "should have write the changes in DB");
form.destroy();
});
- QUnit.test('one2many list (editable): edition', function (assert) {
+ QUnit.test('one2many list (editable): edition', async function (assert) {
assert.expect(7);
this.data.partner.records[0].p = [2, 4];
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -2557,25 +2554,25 @@ QUnit.module('fields', {}, function () {
assert.ok(!form.$('.o_field_x2many_list_row_add').length,
'"Add an item" link should not be available in readonly');
- testUtils.dom.click(form.$('.o_list_view tbody td:first()'));
+ await testUtils.dom.click(form.$('.o_list_view tbody td:first()'));
assert.ok($('.modal .o_form_readonly').length,
'in readonly, clicking on a subrecord should open it in readonly in a dialog');
- testUtils.dom.click($('.modal .o_form_button_cancel'));
+ await testUtils.dom.click($('.modal .o_form_button_cancel'));
- testUtils.form.clickEdit(form);
+ await testUtils.form.clickEdit(form);
assert.ok(form.$('.o_field_x2many_list_row_add').length,
'"Add an item" link should be available in edit');
// edit existing subrecord
- testUtils.dom.click(form.$('.o_list_view tbody td:first()'));
+ await testUtils.dom.click(form.$('.o_list_view tbody td:first()'));
assert.strictEqual($('.modal').length, 0,
'in edit, clicking on a subrecord should not open a dialog');
assert.hasClass(form.$('.o_list_view tbody tr:first()'),'o_selected_row',
'first row should be in edition');
- testUtils.fields.editInput(form.$('.o_list_view input:first()'), 'new name');
+ await testUtils.fields.editInput(form.$('.o_list_view input:first()'), 'new name');
- testUtils.dom.click(form.$('.o_list_view tbody tr:nth(1) td:first'));
+ await testUtils.dom.click(form.$('.o_list_view tbody tr:nth(1) td:first'));
assert.doesNotHaveClass(form.$('.o_list_view tbody tr:first'), 'o_selected_row',
'first row should not be in edition anymore');
assert.strictEqual(form.$('.o_list_view tbody td:first').text(), 'new name',
@@ -2586,10 +2583,10 @@ QUnit.module('fields', {}, function () {
form.destroy();
});
- QUnit.test('one2many list (editable): edition, part 2', function (assert) {
+ QUnit.test('one2many list (editable): edition, part 2', async function (assert) {
assert.expect(8);
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -2613,12 +2610,12 @@ QUnit.module('fields', {}, function () {
});
// edit mode, then click on Add an item and enter a value
- testUtils.form.clickEdit(form);
- testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
- testUtils.fields.editInput(form.$('.o_selected_row > td input'), 'kartoffel');
+ await testUtils.form.clickEdit(form);
+ await testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
+ await testUtils.fields.editInput(form.$('.o_selected_row > td input'), 'kartoffel');
// click again on Add an item
- testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
+ await testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
assert.strictEqual(form.$('td:contains(kartoffel)').length, 1,
"should have one td with the new value");
assert.containsOnce(form, '.o_selected_row > td input',
@@ -2626,8 +2623,8 @@ QUnit.module('fields', {}, function () {
assert.containsN(form, 'tr.o_data_row', 2, "should have 2 data rows");
// enter another value and save
- testUtils.fields.editInput(form.$('.o_selected_row > td input'), 'gemuse');
- testUtils.form.clickSave(form);
+ await testUtils.fields.editInput(form.$('.o_selected_row > td input'), 'gemuse');
+ await 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");
@@ -2637,10 +2634,10 @@ QUnit.module('fields', {}, function () {
form.destroy();
});
- QUnit.test('one2many list (editable): edition, part 3', function (assert) {
+ QUnit.test('one2many list (editable): edition, part 3', async function (assert) {
assert.expect(3);
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -2659,22 +2656,22 @@ QUnit.module('fields', {}, function () {
// edit mode, then click on Add an item 2 times
assert.containsOnce(form, 'tr.o_data_row',
"should have 1 data rows");
- testUtils.form.clickEdit(form);
- testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
- testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
+ await testUtils.form.clickEdit(form);
+ await testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
+ await testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
assert.containsN(form, 'tr.o_data_row', 3,
"should have 3 data rows");
// cancel the edition
- testUtils.form.clickDiscard(form);
- testUtils.dom.click($('.modal-footer button.btn-primary').first());
+ await testUtils.form.clickDiscard(form);
+ await testUtils.dom.click($('.modal-footer button.btn-primary').first());
assert.containsOnce(form, 'tr.o_data_row',
"should have 1 data rows");
form.destroy();
});
- QUnit.test('one2many list (editable): edition, part 4', function (assert) {
+ QUnit.test('one2many list (editable): edition, part 4', async function (assert) {
assert.expect(3);
var i = 0;
@@ -2687,7 +2684,7 @@ QUnit.module('fields', {}, function () {
},
};
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -2707,26 +2704,26 @@ QUnit.module('fields', {}, function () {
// edit mode, then click on Add an item
assert.containsNone(form, 'tr.o_data_row',
"should have 0 data rows");
- testUtils.form.clickEdit(form);
- testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
+ await testUtils.form.clickEdit(form);
+ await testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
assert.strictEqual(form.$('textarea').val(), "",
"field turtle_description should be empty");
// add a value in the turtle_trululu field to trigger an onchange
- testUtils.fields.many2one.clickOpenDropdown('turtle_trululu');
- testUtils.fields.many2one.clickHighlightedItem('turtle_trululu');
+ await testUtils.fields.many2one.clickOpenDropdown('turtle_trululu');
+ await testUtils.fields.many2one.clickHighlightedItem('turtle_trululu');
assert.strictEqual(form.$('textarea').val(), "Some Description",
"field turtle_description should be set to the result of the onchange");
form.destroy();
});
- QUnit.test('one2many list (editable): discarding required empty data', function (assert) {
+ QUnit.test('one2many list (editable): discarding required empty data', async function (assert) {
assert.expect(7);
this.data.turtle.fields.turtle_foo.required = true;
delete this.data.turtle.fields.turtle_foo.default;
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -2751,15 +2748,15 @@ QUnit.module('fields', {}, function () {
// edit mode, then click on Add an item, then click elsewhere
assert.containsNone(form, 'tr.o_data_row',
"should have 0 data rows");
- testUtils.form.clickEdit(form);
- testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
- testUtils.dom.click(form.$('label.o_form_label').first());
+ await testUtils.form.clickEdit(form);
+ await testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
+ await testUtils.dom.click(form.$('label.o_form_label').first());
assert.containsNone(form, 'tr.o_data_row',
"should still have 0 data rows");
// 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);
+ await testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
+ await testUtils.form.clickSave(form);
assert.containsNone(form, 'tr.o_data_row',
"should still have 0 data rows");
@@ -2767,11 +2764,11 @@ QUnit.module('fields', {}, function () {
form.destroy();
});
- QUnit.test('editable one2many list, adding line when only one page', function (assert) {
+ QUnit.test('editable one2many list, adding line when only one page', async function (assert) {
assert.expect(1);
this.data.partner.records[0].turtles = [1, 2, 3];
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -2786,22 +2783,21 @@ QUnit.module('fields', {}, function () {
});
// add a record, to reach the page size limit
- testUtils.form.clickEdit(form);
- testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
-
+ 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'));
form.destroy();
});
- QUnit.test('editable one2many list, adding line, then discarding', function (assert) {
+ QUnit.test('editable one2many list, adding line, then discarding', async function (assert) {
assert.expect(2);
this.data.turtle.records.push({ id: 4, turtle_foo: 'stephen hawking' });
this.data.partner.records[0].turtles = [1, 2, 3, 4];
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -2816,12 +2812,12 @@ 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);
+ await testUtils.form.clickEdit(form);
+ await testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
+ await testUtils.form.clickDiscard(form);
// confirm the discard operation
- testUtils.dom.click($('.modal .modal-footer .btn-primary'));
+ 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',
@@ -2830,14 +2826,14 @@ QUnit.module('fields', {}, function () {
form.destroy();
});
- QUnit.test('editable one2many list, required field and pager', function (assert) {
+ QUnit.test('editable one2many list, required field and pager', async function (assert) {
assert.expect(1);
this.data.turtle.records.push({ id: 4, turtle_foo: 'stephen hawking' });
this.data.turtle.fields.turtle_foo.required = true;
this.data.partner.records[0].turtles = [1, 2, 3, 4];
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -2852,24 +2848,24 @@ QUnit.module('fields', {}, function () {
});
// add a (empty) record
- testUtils.form.clickEdit(form);
- testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
+ await testUtils.form.clickEdit(form);
+ await 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_field_widget[name=turtles] .o_pager_next'));
+ await testUtils.dom.click(form.$('.o_field_widget[name=turtles] .o_pager_next'));
assert.containsOnce(form, 'tr.o_data_row');
form.destroy();
});
- QUnit.test('editable one2many list, required field, pager and confirm discard', function (assert) {
+ QUnit.test('editable one2many list, required field, pager and confirm discard', async function (assert) {
assert.expect(3);
this.data.turtle.records.push({ id: 4, turtle_foo: 'stephen hawking' });
this.data.turtle.fields.turtle_foo.required = true;
this.data.partner.records[0].turtles = [1, 2, 3, 4];
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -2885,19 +2881,19 @@ QUnit.module('fields', {}, function () {
});
// add a record with a dirty state, but not valid
- testUtils.form.clickEdit(form);
- testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
- testUtils.fields.editInput(form.$('input[name="turtle_int"]'), 4321);
+ await testUtils.form.clickEdit(form);
+ await testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
+ await testUtils.fields.editInput(form.$('input[name="turtle_int"]'), 4321);
// go to next page. The new record is not valid, but dirty. we should
// see a confirm dialog
- testUtils.dom.click(form.$('.o_field_widget[name=turtles] .o_pager_next'));
+ 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',
"pager should still display the correct total");
// click on cancel
- testUtils.dom.click($('.modal .modal-footer .btn-secondary'));
+ 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',
"pager should again display the correct total");
@@ -2906,12 +2902,12 @@ QUnit.module('fields', {}, function () {
form.destroy();
});
- QUnit.test('editable one2many list, adding, discarding, and pager', function (assert) {
+ QUnit.test('editable one2many list, adding, discarding, and pager', async function (assert) {
assert.expect(2);
this.data.partner.records[0].turtles = [1];
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -2926,18 +2922,18 @@ QUnit.module('fields', {}, function () {
});
// add a 4 records record (to make the pager appear)
- testUtils.form.clickEdit(form);
- testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
- testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
- testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
- testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
+ await testUtils.form.clickEdit(form);
+ await testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
+ await testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
+ await testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
+ await testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
// go on next page
- testUtils.dom.click(form.$('.o_field_widget[name=turtles] .o_pager_next'));
+ await testUtils.dom.click(form.$('.o_field_widget[name=turtles] .o_pager_next'));
// discard
- testUtils.form.clickDiscard(form);
- testUtils.dom.click($('.modal .modal-footer .btn-primary'));
+ await testUtils.form.clickDiscard(form);
+ 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'));
@@ -2945,13 +2941,13 @@ QUnit.module('fields', {}, function () {
form.destroy();
});
- QUnit.test('unselecting a line with missing required data', function (assert) {
+ QUnit.test('unselecting a line with missing required data', async function (assert) {
assert.expect(5);
this.data.turtle.fields.turtle_foo.required = true;
delete this.data.turtle.fields.turtle_foo.default;
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -2971,40 +2967,40 @@ QUnit.module('fields', {}, function () {
// edit mode, then click on Add an item, then click elsewhere
assert.containsNone(form, 'tr.o_data_row',
"should have 0 data rows");
- testUtils.form.clickEdit(form);
- testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
+ await testUtils.form.clickEdit(form);
+ await testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
assert.containsOnce(form, 'tr.o_data_row',
"should have 1 data rows");
// adding a value in the non required field, so it is dirty, but with
// a missing required field
- testUtils.fields.editInput(form.$('input[name="turtle_int"]'), '12345');
+ await testUtils.fields.editInput(form.$('input[name="turtle_int"]'), '12345');
// click elsewhere,
- testUtils.dom.click(form.$('label.o_form_label'));
+ await testUtils.dom.click(form.$('label.o_form_label'));
assert.strictEqual($('.modal').length, 1,
'a confirmation model should be opened');
// click on cancel, the line should still be selected
- testUtils.dom.click($('.modal .modal-footer button.btn-secondary'));
+ await testUtils.dom.click($('.modal .modal-footer button.btn-secondary'));
assert.containsOnce(form, 'tr.o_data_row.o_selected_row',
"should still have 1 selected data row");
// click elsewhere, and click on ok (on the confirmation dialog)
- testUtils.dom.click(form.$('label.o_form_label'));
- testUtils.dom.click($('.modal .modal-footer button.btn-primary'));
+ await testUtils.dom.click(form.$('label.o_form_label'));
+ await testUtils.dom.click($('.modal .modal-footer button.btn-primary'));
assert.containsNone(form, 'tr.o_data_row',
"should have 0 data rows (invalid line has been discarded");
form.destroy();
});
- QUnit.test('pressing enter in a o2m with a required empty field', function (assert) {
+ QUnit.test('pressing enter in a o2m with a required empty field', async function (assert) {
assert.expect(4);
this.data.turtle.fields.turtle_foo.required = true;
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -3025,19 +3021,16 @@ QUnit.module('fields', {}, function () {
});
// edit mode, then click on Add an item, then click elsewhere
- testUtils.form.clickEdit(form);
- testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
- form.$('input[name="turtle_foo"]').trigger($.Event('keydown', {
- which: $.ui.keyCode.ENTER,
- keyCode: $.ui.keyCode.ENTER,
- }));
+ await testUtils.form.clickEdit(form);
+ await testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
+ await testUtils.fields.triggerKeydown(form.$('input[name="turtle_foo"]'), 'enter');
assert.hasClass(form.$('input[name="turtle_foo"]'),'o_field_invalid',
"input should be marked invalid");
assert.verifySteps(['read', 'default_get']);
form.destroy();
});
- QUnit.test('editing a o2m, with required field and onchange', function (assert) {
+ QUnit.test('editing a o2m, with required field and onchange', async function (assert) {
assert.expect(12);
this.data.turtle.fields.turtle_foo.required = true;
@@ -3048,7 +3041,7 @@ QUnit.module('fields', {}, function () {
},
};
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -3074,16 +3067,16 @@ QUnit.module('fields', {}, function () {
// edit mode, then click on Add an item
assert.containsNone(form, 'tr.o_data_row',
"should have 0 data rows");
- testUtils.form.clickEdit(form);
- testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
+ await testUtils.form.clickEdit(form);
+ await testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
// input some text in required turtle_foo field
- testUtils.fields.editInput(form.$('input[name="turtle_foo"]'), 'aubergine');
+ await testUtils.fields.editInput(form.$('input[name="turtle_foo"]'), 'aubergine');
assert.strictEqual(form.$('input[name="turtle_int"]').val(), "9",
"onchange should have been triggered");
// save and check everything is fine
- testUtils.form.clickSave(form);
+ await 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,
@@ -3093,10 +3086,10 @@ QUnit.module('fields', {}, function () {
form.destroy();
});
- QUnit.test('editable o2m, pressing ESC discard current changes', function (assert) {
+ QUnit.test('editable o2m, pressing ESC discard current changes', async function (assert) {
assert.expect(5);
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -3114,24 +3107,24 @@ QUnit.module('fields', {}, function () {
},
});
- testUtils.form.clickEdit(form);
- testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
+ await testUtils.form.clickEdit(form);
+ await testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
assert.containsOnce(form, 'tr.o_data_row',
"there should be one data row");
- form.$('input[name="turtle_foo"]').trigger({ type: 'keydown', which: $.ui.keyCode.ESCAPE });
+ await testUtils.fields.triggerKeydown(form.$('input[name="turtle_foo"]'), 'escape');
assert.containsNone(form, 'tr.o_data_row',
"data row should have been discarded");
assert.verifySteps(['read', 'default_get']);
form.destroy();
});
- QUnit.test('editable o2m with required field, pressing ESC discard current changes', function (assert) {
+ QUnit.test('editable o2m with required field, pressing ESC discard current changes', async function (assert) {
assert.expect(5);
this.data.turtle.fields.turtle_foo.required = true;
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -3149,22 +3142,22 @@ QUnit.module('fields', {}, function () {
},
});
- testUtils.form.clickEdit(form);
- testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
+ await testUtils.form.clickEdit(form);
+ await testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
assert.containsOnce(form, 'tr.o_data_row',
"there should be one data row");
- form.$('input[name="turtle_foo"]').trigger({ type: 'keydown', which: $.ui.keyCode.ESCAPE });
+ await testUtils.fields.triggerKeydown(form.$('input[name="turtle_foo"]'), 'escape');
assert.containsNone(form, 'tr.o_data_row',
"data row should have been discarded");
assert.verifySteps(['read', 'default_get']);
form.destroy();
});
- QUnit.test('pressing escape in editable o2m list in dialog', function (assert) {
+ QUnit.test('pressing escape in editable o2m list in dialog', async function (assert) {
assert.expect(3);
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -3192,14 +3185,13 @@ QUnit.module('fields', {}, function () {
},
});
- testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
- testUtils.dom.click($('.modal .o_field_x2many_list_row_add a'));
+ await testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
+ await testUtils.dom.click($('.modal .o_field_x2many_list_row_add a'));
assert.strictEqual($('.modal .o_data_row.o_selected_row').length, 1,
"there should be a row in edition in the dialog");
- // trigger keydown ESCAPE in the edited row
- $('.modal .o_data_cell input').trigger({ type: 'keydown', which: $.ui.keyCode.ESCAPE });
+ await testUtils.fields.triggerKeydown($('.modal .o_data_cell input'), 'escape');
assert.strictEqual($('.modal').length, 1,
"dialog should still be open");
@@ -3209,7 +3201,7 @@ QUnit.module('fields', {}, function () {
form.destroy();
});
- QUnit.test('editable o2m with onchange and required field: delete an invalid line', function (assert) {
+ QUnit.test('editable o2m with onchange and required field: delete an invalid line', async function (assert) {
assert.expect(5);
this.data.partner.onchanges = {
@@ -3218,7 +3210,7 @@ QUnit.module('fields', {}, function () {
this.data.partner.records[0].turtles = [1];
this.data.turtle.records[0].product_id = 37;
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -3239,16 +3231,16 @@ QUnit.module('fields', {}, function () {
},
});
- testUtils.dom.click(form.$('.o_data_cell:first'));
+ await testUtils.dom.click(form.$('.o_data_cell:first'));
form.$('.o_field_widget[name="product_id"] input').val('').trigger('keyup');
assert.verifySteps(['read', 'read'], 'no onchange should be done as line is invalid');
- testUtils.dom.click(form.$('.o_list_record_remove'));
- assert.verifySteps(['read', 'read', 'onchange'], 'onchange should have been done');
+ await testUtils.dom.click(form.$('.o_list_record_remove'));
+ assert.verifySteps(['onchange'], 'onchange should have been done');
form.destroy();
});
- QUnit.test('onchange in a one2many', function (assert) {
+ QUnit.test('onchange in a one2many', async function (assert) {
assert.expect(1);
this.data.partner.records.push({
@@ -3258,7 +3250,7 @@ QUnit.module('fields', {}, function () {
this.data.partner.records[1].p = [3];
this.data.partner.onchanges = { p: true };
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -3272,7 +3264,7 @@ QUnit.module('fields', {}, function () {
res_id: 2,
mockRPC: function (route, args) {
if (args.method === 'onchange') {
- return $.when({
+ return Promise.resolve({
value: {
p: [
[5], // delete all
@@ -3285,17 +3277,17 @@ 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);
+ await testUtils.form.clickEdit(form);
+ await testUtils.dom.click(form.$('.o_field_one2many tbody td').first());
+ await testUtils.fields.editInput(form.$('.o_field_one2many tbody td').first().find('input'), "new value");
+ await 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'");
form.destroy();
});
- QUnit.test('one2many, default_get and onchange (basic)', function (assert) {
+ QUnit.test('one2many, default_get and onchange (basic)', async function (assert) {
assert.expect(1);
this.data.partner.fields.p.default = [
@@ -3303,7 +3295,7 @@ QUnit.module('fields', {}, function () {
];
this.data.partner.onchanges = { p: true };
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -3316,7 +3308,7 @@ QUnit.module('fields', {}, function () {
'</form>',
mockRPC: function (route, args) {
if (args.method === 'onchange') {
- return $.when({
+ return Promise.resolve({
value: {
p: [
[5], // delete all
@@ -3334,14 +3326,14 @@ QUnit.module('fields', {}, function () {
form.destroy();
});
- QUnit.test('one2many and default_get (with date)', function (assert) {
+ QUnit.test('one2many and default_get (with date)', async function (assert) {
assert.expect(1);
this.data.partner.fields.p.default = [
[0, false, { date: '2017-10-08' }],
];
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -3360,14 +3352,14 @@ QUnit.module('fields', {}, function () {
form.destroy();
});
- QUnit.test('one2many and onchange (with integer)', function (assert) {
+ QUnit.test('one2many and onchange (with integer)', async function (assert) {
assert.expect(4);
this.data.turtle.onchanges = {
- turtle_int: function (obj) { }
+ turtle_int: function () { }
};
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -3384,10 +3376,10 @@ QUnit.module('fields', {}, function () {
return this._super.apply(this, arguments);
},
});
- testUtils.form.clickEdit(form);
+ await testUtils.form.clickEdit(form);
- testUtils.dom.click(form.$('td:contains(9)'));
- testUtils.fields.editInput(form.$('td input[name="turtle_int"]'), "3");
+ await testUtils.dom.click(form.$('td:contains(9)'));
+ await testUtils.fields.editInput(form.$('td input[name="turtle_int"]'), "3");
// the 'change' event is triggered on the input when we focus somewhere
// else, for example by clicking in the body. However, if we try to
@@ -3399,15 +3391,15 @@ QUnit.module('fields', {}, function () {
form.destroy();
});
- QUnit.test('one2many and onchange (with date)', function (assert) {
+ QUnit.test('one2many and onchange (with date)', async function (assert) {
assert.expect(7);
this.data.partner.onchanges = {
- date: function (obj) { }
+ date: function () { }
};
this.data.partner.records[0].p = [2];
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -3424,23 +3416,28 @@ QUnit.module('fields', {}, function () {
return this._super.apply(this, arguments);
},
});
- testUtils.form.clickEdit(form);
-
- testUtils.dom.click(form.$('td:contains(01/25/2017)'));
- testUtils.dom.click(form.$('.o_datepicker_input'));
- testUtils.dom.click($('.bootstrap-datetimepicker-widget .picker-switch').first());
- testUtils.dom.click($('.bootstrap-datetimepicker-widget .picker-switch:eq(1)'));
- testUtils.dom.click($('.bootstrap-datetimepicker-widget .year:contains(2017)'));
- testUtils.dom.click($('.bootstrap-datetimepicker-widget .month').eq(1));
- testUtils.dom.click($('.day:contains(22)'));
+ await testUtils.form.clickEdit(form);
- testUtils.form.clickSave(form);
+ await testUtils.dom.click(form.$('td:contains(01/25/2017)'));
+ await testUtils.dom.click(form.$('.o_datepicker_input'));
+ await testUtils.nextTick();
+ await testUtils.dom.click($('.bootstrap-datetimepicker-widget .picker-switch').first());
+ await testUtils.dom.click($('.bootstrap-datetimepicker-widget .picker-switch:eq(1)'));
+ await testUtils.dom.click($('.bootstrap-datetimepicker-widget .year:contains(2017)'));
+ await testUtils.dom.click($('.bootstrap-datetimepicker-widget .month').eq(1));
+ await testUtils.dom.click($('.day:contains(22)'));
+ // trigger the blur of input before the click on Save, to closely mock what actually
+ // happens when we really click on Save
+ // this is required to close the datepicker before removing the input from the DOM
+ // (because of the re-rendering in readonly), otherwise tempusdominus crashes
+ await testUtils.dom.triggerEvents(form.$('.o_datepicker_input'), 'blur');
+ await testUtils.form.clickSave(form);
assert.verifySteps(['read', 'read', 'onchange', 'write', 'read', 'read']);
form.destroy();
});
- QUnit.test('one2many and onchange (with command DELETE_ALL)', function (assert) {
+ QUnit.test('one2many and onchange (with command DELETE_ALL)', async function (assert) {
assert.expect(5);
this.data.partner.onchanges = {
@@ -3451,7 +3448,7 @@ QUnit.module('fields', {}, function () {
};
this.data.partner.records[0].p = [2];
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -3482,34 +3479,34 @@ QUnit.module('fields', {}, function () {
"o2m should contain one row");
// empty o2m by triggering the onchange
- testUtils.fields.editInput(form.$('.o_field_widget[name=foo]'), 'trigger onchange');
+ await testUtils.fields.editInput(form.$('.o_field_widget[name=foo]'), 'trigger onchange');
assert.containsNone(form, '.o_data_row',
"rows of the o2m should have been deleted");
// add two new subrecords
- testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
- testUtils.fields.editInput(form.$('.o_field_widget[name=display_name]'), 'x');
- testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
- testUtils.fields.editInput(form.$('.o_field_widget[name=display_name]'), 'y');
+ await testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
+ await testUtils.fields.editInput(form.$('.o_field_widget[name=display_name]'), 'x');
+ await testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
+ await testUtils.fields.editInput(form.$('.o_field_widget[name=display_name]'), 'y');
assert.containsN(form, '.o_data_row', 2,
"o2m should contain two rows");
// empty o2m by triggering the onchange
- testUtils.fields.editInput(form.$('.o_field_widget[name=foo]'), 'trigger onchange again');
+ await testUtils.fields.editInput(form.$('.o_field_widget[name=foo]'), 'trigger onchange again');
assert.containsNone(form, '.o_data_row',
"rows of the o2m should have been deleted");
- testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
- testUtils.fields.editInput(form.$('.o_field_widget[name=display_name]'), 'z');
+ await testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
+ await testUtils.fields.editInput(form.$('.o_field_widget[name=display_name]'), 'z');
- testUtils.form.clickSave(form);
+ await testUtils.form.clickSave(form);
form.destroy();
});
- QUnit.test('one2many and onchange only write modified field', function (assert) {
+ QUnit.test('one2many and onchange only write modified field', async function (assert) {
assert.expect(2);
this.data.partner.onchanges = {
@@ -3532,7 +3529,7 @@ QUnit.module('fields', {}, function () {
this.data.partner.records[0].turtles = [3];
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -3567,14 +3564,14 @@ QUnit.module('fields', {}, function () {
assert.containsOnce(form, '.o_data_row',
"o2m should contain one row");
- 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');
+ await testUtils.dom.click(form.$('.o_field_one2many .o_list_view tbody tr:first td:first'));
+ await testUtils.fields.editInput(form.$('.o_field_one2many .o_list_view tbody tr:first input:first'), 'blurp');
- testUtils.form.clickSave(form);
+ await testUtils.form.clickSave(form);
form.destroy();
});
- QUnit.test('one2many with CREATE onchanges correctly refreshed', function (assert) {
+ QUnit.test('one2many with CREATE onchanges correctly refreshed', async function (assert) {
assert.expect(5);
var delta = 0;
@@ -3626,7 +3623,7 @@ QUnit.module('fields', {}, function () {
},
};
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -3648,27 +3645,27 @@ QUnit.module('fields', {}, function () {
assert.containsNone(form, '.o_data_row',
"o2m shouldn't contain any row");
- testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
+ await testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
// trigger the first onchange
deactiveOnchange = false;
- testUtils.fields.editInput(form.$('input[name="turtle_int"]'), '10');
+ await testUtils.fields.editInput(form.$('input[name="turtle_int"]'), '10');
// put the list back in non edit mode
- testUtils.dom.click(form.$('input[name="foo"]'));
+ await testUtils.dom.click(form.$('input[name="foo"]'));
assert.strictEqual(form.$('.o_data_row').text(), "first10second-10",
"should correctly refresh the records");
// trigger the second onchange
- testUtils.dom.click(form.$('.o_field_x2many_list tbody tr:first td:first'));
- testUtils.fields.editInput(form.$('input[name="turtle_int"]'), '20');
+ await testUtils.dom.click(form.$('.o_field_x2many_list tbody tr:first td:first'));
+ await testUtils.fields.editInput(form.$('input[name="turtle_int"]'), '20');
- testUtils.dom.click(form.$('input[name="foo"]'));
+ await testUtils.dom.click(form.$('input[name="foo"]'));
assert.strictEqual(form.$('.o_data_row').text(), "first20second-20",
"should correctly refresh the records");
assert.containsN(form, '.o_field_widget', delta,
"all (non visible) field widgets should have been destroyed");
- testUtils.form.clickSave(form);
+ await testUtils.form.clickSave(form);
assert.strictEqual(form.$('.o_data_row').text(), "first20second-20",
"should correctly refresh the records after save");
@@ -3677,7 +3674,7 @@ QUnit.module('fields', {}, function () {
testUtils.mock.unpatch(AbstractField);
});
- QUnit.test('editable one2many with sub widgets are rendered in readonly', function (assert) {
+ QUnit.test('editable one2many with sub widgets are rendered in readonly', async function (assert) {
assert.expect(2);
var editableWidgets = 0;
@@ -3690,7 +3687,7 @@ QUnit.module('fields', {}, function () {
},
});
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -3710,7 +3707,7 @@ QUnit.module('fields', {}, function () {
assert.strictEqual(editableWidgets, 1,
"o2m is only widget in edit mode");
- testUtils.dom.click(form.$('tbody td.o_field_x2many_list_row_add a'));
+ await testUtils.dom.click(form.$('tbody td.o_field_x2many_list_row_add a'));
assert.strictEqual(editableWidgets, 3,
"3 widgets currently in edit mode");
@@ -3719,7 +3716,7 @@ QUnit.module('fields', {}, function () {
testUtils.mock.unpatch(AbstractField);
});
- QUnit.test('one2many editable list with onchange keeps the order', function (assert) {
+ QUnit.test('one2many editable list with onchange keeps the order', async function (assert) {
assert.expect(2);
this.data.partner.records[0].p = [1, 2, 4];
@@ -3727,7 +3724,7 @@ QUnit.module('fields', {}, function () {
p: function () { },
};
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -3747,9 +3744,9 @@ QUnit.module('fields', {}, function () {
assert.strictEqual(form.$('.o_data_cell').text(), 'first recordsecond recordaaa',
"records should be display in the correct order");
- testUtils.dom.click(form.$('.o_data_row:first .o_data_cell'));
- testUtils.fields.editInput(form.$('.o_selected_row .o_field_widget[name=display_name]'), 'new');
- testUtils.dom.click(form.$el);
+ await testUtils.dom.click(form.$('.o_data_row:first .o_data_cell'));
+ await testUtils.fields.editInput(form.$('.o_selected_row .o_field_widget[name=display_name]'), 'new');
+ await testUtils.dom.click(form.$el);
assert.strictEqual(form.$('.o_data_cell').text(), 'newsecond recordaaa',
"records should be display in the correct order");
@@ -3757,14 +3754,14 @@ QUnit.module('fields', {}, function () {
form.destroy();
});
- QUnit.test('one2many list (editable): readonly domain is evaluated', function (assert) {
+ QUnit.test('one2many list (editable): readonly domain is evaluated', async function (assert) {
assert.expect(2);
this.data.partner.records[0].p = [2, 4];
this.data.partner.records[1].product_id = false;
this.data.partner.records[2].product_id = 37;
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -3779,7 +3776,7 @@ QUnit.module('fields', {}, function () {
res_id: 1,
});
- testUtils.form.clickEdit(form);
+ await testUtils.form.clickEdit(form);
assert.hasClass(form.$('.o_list_view tbody tr:eq(0) td:first'),'o_readonly_modifier',
"first record should have display_name in readonly mode");
@@ -3789,12 +3786,12 @@ QUnit.module('fields', {}, function () {
form.destroy();
});
- QUnit.test('pager of one2many field in new record', function (assert) {
+ QUnit.test('pager of one2many field in new record', async function (assert) {
assert.expect(3);
this.data.partner.records[0].p = [];
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -3811,7 +3808,7 @@ QUnit.module('fields', {}, function () {
'o2m pager should be hidden');
// click to create a subrecord
- testUtils.dom.click(form.$('tbody td.o_field_x2many_list_row_add a'));
+ 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'),
@@ -3819,7 +3816,7 @@ QUnit.module('fields', {}, function () {
form.destroy();
});
- QUnit.test('one2many list with a many2one', function (assert) {
+ QUnit.test('one2many list with a many2one', async function (assert) {
assert.expect(5);
this.data.partner.records[0].p = [2];
@@ -3833,7 +3830,7 @@ QUnit.module('fields', {}, function () {
//
};
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -3863,14 +3860,14 @@ QUnit.module('fields', {}, function () {
assert.strictEqual(form.$('tbody td:contains(xpad)').length, 0,
"should not display 'xpad' anywhere");
- testUtils.form.clickEdit(form);
+ await testUtils.form.clickEdit(form);
- testUtils.dom.click(form.$('tbody td.o_field_x2many_list_row_add a'));
+ await testUtils.dom.click(form.$('tbody td.o_field_x2many_list_row_add a'));
- testUtils.fields.many2one.clickOpenDropdown('product_id');
+ await testUtils.fields.many2one.clickOpenDropdown('product_id');
testUtils.fields.many2one.clickItem('product_id', 'xpad');
- testUtils.dom.click($('.modal .modal-footer button:eq(0)'));
+ await testUtils.dom.click($('.modal .modal-footer button:eq(0)'));
assert.strictEqual(form.$('tbody td:contains(xpad)').length, 1,
"should display 'xpad' on a td");
@@ -3879,14 +3876,12 @@ QUnit.module('fields', {}, function () {
form.destroy();
});
- QUnit.test('one2many list with inline form view', function (assert) {
+ QUnit.test('one2many list with inline form view', async function (assert) {
assert.expect(5);
this.data.partner.records[0].p = [];
- var rpcCount = 0;
-
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -3907,7 +3902,6 @@ QUnit.module('fields', {}, function () {
'</form>',
res_id: 1,
mockRPC: function (route, args) {
- rpcCount++;
if (args.method === 'write') {
assert.deepEqual(args.args[1].p, [[0, args.args[1].p[0][1], {
foo: false, int_field: 123, product_id: 41,
@@ -3917,63 +3911,63 @@ QUnit.module('fields', {}, function () {
},
});
- testUtils.form.clickEdit(form);
+ await testUtils.form.clickEdit(form);
- testUtils.dom.click(form.$('tbody td.o_field_x2many_list_row_add a'));
+ await testUtils.dom.click(form.$('tbody td.o_field_x2many_list_row_add a'));
// write in the many2one field, value = 37 (xphone)
- testUtils.fields.many2one.clickOpenDropdown('product_id');
- testUtils.fields.many2one.clickHighlightedItem('product_id');
+ await testUtils.fields.many2one.clickOpenDropdown('product_id');
+ await testUtils.fields.many2one.clickHighlightedItem('product_id');
// write in the integer field
- testUtils.fields.editInput($('.modal .modal-body input.o_field_widget'), '123');
+ await testUtils.fields.editInput($('.modal .modal-body input.o_field_widget'), '123');
// save and close
- testUtils.dom.click($('.modal .modal-footer button:eq(0)'));
+ await testUtils.dom.click($('.modal .modal-footer button:eq(0)'));
assert.strictEqual(form.$('tbody td:contains(xphone)').length, 1,
"should display 'xphone' in a td");
// reopen the record in form view
- testUtils.dom.click(form.$('tbody td:contains(xphone)'));
+ await testUtils.dom.click(form.$('tbody td:contains(xphone)'));
assert.strictEqual($('.modal .modal-body input').val(), "xphone",
"should display 'xphone' in an input");
- testUtils.fields.editInput($('.modal .modal-body input.o_field_widget'), '456');
+ await testUtils.fields.editInput($('.modal .modal-body input.o_field_widget'), '456');
// discard
- testUtils.dom.click($('.modal .modal-footer span:contains(Discard)'));
+ await testUtils.dom.click($('.modal .modal-footer span:contains(Discard)'));
// reopen the record in form view
- testUtils.dom.click(form.$('tbody td:contains(xphone)'));
+ await testUtils.dom.click(form.$('tbody td:contains(xphone)'));
assert.strictEqual($('.modal .modal-body input.o_field_widget').val(), "123",
"should display 123 (previous change has been discarded)");
// write in the many2one field, value = 41 (xpad)
- testUtils.fields.many2one.clickOpenDropdown('product_id');
+ await testUtils.fields.many2one.clickOpenDropdown('product_id');
testUtils.fields.many2one.clickItem('product_id', 'xpad');
// save and close
- testUtils.dom.click($('.modal .modal-footer button:eq(0)'));
+ await testUtils.dom.click($('.modal .modal-footer button:eq(0)'));
assert.strictEqual(form.$('tbody td:contains(xpad)').length, 1,
"should display 'xpad' in a td");
// save the record
- testUtils.form.clickSave(form);
+ await testUtils.form.clickSave(form);
form.destroy();
});
- QUnit.test('one2many list with inline form view with context with parent key', function (assert) {
+ QUnit.test('one2many list with inline form view with context with parent key', async function (assert) {
assert.expect(2);
this.data.partner.records[0].p = [2];
this.data.partner.records[0].product_id = 41;
this.data.partner.records[1].product_id = 37;
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -4001,23 +3995,23 @@ QUnit.module('fields', {}, function () {
},
});
- testUtils.form.clickEdit(form);
+ await testUtils.form.clickEdit(form);
// open a modal
- testUtils.dom.click(form.$('tr.o_data_row:eq(0) td:contains(xphone)'));
+ await testUtils.dom.click(form.$('tr.o_data_row:eq(0) td:contains(xphone)'));
// write in the many2one field
- testUtils.dom.click($('.modal .o_field_many2one input'));
+ await testUtils.dom.click($('.modal .o_field_many2one input'));
form.destroy();
});
- QUnit.test('value of invisible x2many fields is correctly evaluated in context', function (assert) {
+ QUnit.test('value of invisible x2many fields is correctly evaluated in context', async function (assert) {
assert.expect(1);
this.data.partner.records[0].timmy = [12];
this.data.partner.records[0].p = [2, 3];
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -4040,19 +4034,19 @@ QUnit.module('fields', {}, function () {
},
});
- testUtils.form.clickEdit(form);
- testUtils.dom.click(form.$('.o_field_widget[name=product_id] input'));
+ await testUtils.form.clickEdit(form);
+ await testUtils.dom.click(form.$('.o_field_widget[name=product_id] input'));
form.destroy();
});
- QUnit.test('one2many list, editable, with many2one and with context with parent key', function (assert) {
+ QUnit.test('one2many list, editable, with many2one and with context with parent key', async function (assert) {
assert.expect(1);
this.data.partner.records[0].p = [2];
this.data.partner.records[1].product_id = 37;
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -4074,23 +4068,23 @@ QUnit.module('fields', {}, function () {
},
});
- testUtils.form.clickEdit(form);
+ await testUtils.form.clickEdit(form);
- testUtils.dom.click(form.$('tr.o_data_row:eq(0) td:contains(xphone)'));
+ await testUtils.dom.click(form.$('tr.o_data_row:eq(0) td:contains(xphone)'));
// trigger a name search
- testUtils.dom.click(form.$('table td input'));
+ await testUtils.dom.click(form.$('table td input'));
form.destroy();
});
- QUnit.test('one2many list, editable, with a date in the context', function (assert) {
+ QUnit.test('one2many list, editable, with a date in the context', async function (assert) {
assert.expect(1);
this.data.partner.records[0].p = [2];
this.data.partner.records[1].product_id = 37;
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -4114,18 +4108,18 @@ QUnit.module('fields', {}, function () {
},
});
- testUtils.form.clickEdit(form);
- testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
+ await testUtils.form.clickEdit(form);
+ await testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
form.destroy();
});
- QUnit.test('one2many field with context', function (assert) {
+ QUnit.test('one2many field with context', async function (assert) {
assert.expect(2);
var counter = 0;
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -4152,19 +4146,19 @@ QUnit.module('fields', {}, function () {
},
});
- testUtils.form.clickEdit(form);
- testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
- testUtils.fields.editInput(form.$('input[name="turtle_foo"]'), 'hammer');
- testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
+ await testUtils.form.clickEdit(form);
+ await testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
+ await testUtils.fields.editInput(form.$('input[name="turtle_foo"]'), 'hammer');
+ await testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
form.destroy();
});
- QUnit.test('one2many list edition, some basic functionality', function (assert) {
+ QUnit.test('one2many list edition, some basic functionality', async function (assert) {
assert.expect(3);
this.data.partner.fields.foo.default = false;
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -4177,30 +4171,30 @@ QUnit.module('fields', {}, function () {
'</form>',
res_id: 1,
});
- testUtils.form.clickEdit(form);
+ await testUtils.form.clickEdit(form);
- testUtils.dom.click(form.$('tbody td.o_field_x2many_list_row_add a'));
+ await testUtils.dom.click(form.$('tbody td.o_field_x2many_list_row_add a'));
assert.containsOnce(form, 'td input.o_field_widget',
"should have created a row in edit mode");
- testUtils.fields.editInput(form.$('td input.o_field_widget'), 'a');
+ await testUtils.fields.editInput(form.$('td input.o_field_widget'), 'a');
assert.containsOnce(form, 'td input.o_field_widget',
"should not have unselected the row after edition");
- testUtils.fields.editInput(form.$('td input.o_field_widget'), 'abc');
- testUtils.form.clickSave(form);
+ await testUtils.fields.editInput(form.$('td input.o_field_widget'), 'abc');
+ await testUtils.form.clickSave(form);
assert.strictEqual(form.$('td:contains(abc)').length, 1,
"should have a row with the correct value");
form.destroy();
});
- QUnit.test('one2many list, the context is properly evaluated and sent', function (assert) {
+ QUnit.test('one2many list, the context is properly evaluated and sent', async function (assert) {
assert.expect(2);
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -4223,15 +4217,15 @@ QUnit.module('fields', {}, function () {
},
});
- testUtils.form.clickEdit(form);
- testUtils.dom.click(form.$('tbody td.o_field_x2many_list_row_add a'));
+ await testUtils.form.clickEdit(form);
+ await testUtils.dom.click(form.$('tbody td.o_field_x2many_list_row_add a'));
form.destroy();
});
- QUnit.test('one2many with many2many widget: create', function (assert) {
+ QUnit.test('one2many with many2many widget: create', async function (assert) {
assert.expect(10);
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -4271,28 +4265,28 @@ QUnit.module('fields', {}, function () {
},
});
- testUtils.form.clickEdit(form);
- testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
+ await testUtils.form.clickEdit(form);
+ await testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
assert.strictEqual($('.modal .o_data_row').length, 2,
"sould have 2 records in the select view (the last one is not displayed because it is already selected)");
- testUtils.dom.click($('.modal .o_data_row:first .o_list_record_selector input'));
- testUtils.dom.click($('.modal .o_select_button'));
- testUtils.dom.click($('.o_form_button_save'));
- testUtils.form.clickEdit(form);
- testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
+ await testUtils.dom.click($('.modal .o_data_row:first .o_list_record_selector input'));
+ await testUtils.dom.click($('.modal .o_select_button'));
+ await testUtils.dom.click($('.o_form_button_save'));
+ await testUtils.form.clickEdit(form);
+ await testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
assert.strictEqual($('.modal .o_data_row').length, 1,
"sould have 1 record in the select view");
- testUtils.dom.click($('.modal-footer button:eq(1)'));
- testUtils.fields.editInput($('.modal input.o_field_widget[name="turtle_foo"]'), 'tototo');
- testUtils.fields.editInput($('.modal input.o_field_widget[name="turtle_int"]'), 50);
- testUtils.fields.many2one.clickOpenDropdown('product_id');
- testUtils.fields.many2one.clickHighlightedItem('product_id');
+ await testUtils.dom.click($('.modal-footer button:eq(1)'));
+ await testUtils.fields.editInput($('.modal input.o_field_widget[name="turtle_foo"]'), 'tototo');
+ await testUtils.fields.editInput($('.modal input.o_field_widget[name="turtle_int"]'), 50);
+ await testUtils.fields.many2one.clickOpenDropdown('product_id');
+ await testUtils.fields.many2one.clickHighlightedItem('product_id');
- testUtils.dom.click($('.modal-footer button:contains(&):first'));
+ await testUtils.dom.click($('.modal-footer button:contains(&):first'));
assert.strictEqual($('.modal').length, 0, "sould close the modals");
@@ -4301,15 +4295,15 @@ QUnit.module('fields', {}, function () {
assert.strictEqual(form.$('.o_data_row').text(), "blip1.59yop1.50tototo1.550xphone",
"should display the record values in one2many list");
- testUtils.dom.click($('.o_form_button_save'));
+ await testUtils.dom.click($('.o_form_button_save'));
form.destroy();
});
- QUnit.test('one2many with many2many widget: edition', function (assert) {
+ QUnit.test('one2many with many2many widget: edition', async function (assert) {
assert.expect(7);
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -4351,44 +4345,44 @@ QUnit.module('fields', {}, function () {
},
});
- testUtils.dom.click(form.$('.o_data_row:first'));
+ await testUtils.dom.click(form.$('.o_data_row:first'));
assert.strictEqual($('.modal .modal-title').first().text().trim(), 'Open: one2many turtle field',
"modal should use the python field string as title");
- testUtils.dom.click($('.modal .o_form_button_cancel'));
- testUtils.form.clickEdit(form);
+ await testUtils.dom.click($('.modal .o_form_button_cancel'));
+ await testUtils.form.clickEdit(form);
// edit the first one2many record
- testUtils.dom.click(form.$('.o_data_row:first'));
- testUtils.fields.many2one.clickOpenDropdown('product_id');
- testUtils.fields.many2one.clickHighlightedItem('product_id');
- testUtils.dom.click($('.modal-footer button:first'));
+ await testUtils.dom.click(form.$('.o_data_row:first'));
+ await testUtils.fields.many2one.clickOpenDropdown('product_id');
+ await testUtils.fields.many2one.clickHighlightedItem('product_id');
+ await testUtils.dom.click($('.modal-footer button:first'));
- testUtils.dom.click($('.o_form_button_save'));
+ await testUtils.dom.click($('.o_form_button_save'));
// add a one2many record
- testUtils.form.clickEdit(form);
- testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
- testUtils.dom.click($('.modal .o_data_row:first .o_list_record_selector input'));
- testUtils.dom.click($('.modal .o_select_button'));
+ await testUtils.form.clickEdit(form);
+ await testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
+ await testUtils.dom.click($('.modal .o_data_row:first .o_list_record_selector input'));
+ await testUtils.dom.click($('.modal .o_select_button'));
// edit the second one2many record
- testUtils.dom.click(form.$('.o_data_row:eq(1)'));
- testUtils.fields.many2one.clickOpenDropdown('product_id');
- testUtils.fields.many2one.clickHighlightedItem('product_id');
- testUtils.dom.click($('.modal-footer button:first'));
+ await testUtils.dom.click(form.$('.o_data_row:eq(1)'));
+ await testUtils.fields.many2one.clickOpenDropdown('product_id');
+ await testUtils.fields.many2one.clickHighlightedItem('product_id');
+ await testUtils.dom.click($('.modal-footer button:first'));
- testUtils.dom.click($('.o_form_button_save'));
+ await testUtils.dom.click($('.o_form_button_save'));
form.destroy();
});
- QUnit.test('new record, the context is properly evaluated and sent', function (assert) {
+ QUnit.test('new record, the context is properly evaluated and sent', async function (assert) {
assert.expect(2);
this.data.partner.fields.int_field.default = 17;
var n = 0;
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -4413,15 +4407,15 @@ QUnit.module('fields', {}, function () {
},
});
- testUtils.dom.click(form.$('tbody td.o_field_x2many_list_row_add a'));
+ await testUtils.dom.click(form.$('tbody td.o_field_x2many_list_row_add a'));
form.destroy();
});
- QUnit.test('parent data is properly sent on an onchange rpc', function (assert) {
+ QUnit.test('parent data is properly sent on an onchange rpc', async function (assert) {
assert.expect(1);
this.data.partner.onchanges = { bar: function () { } };
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -4444,16 +4438,16 @@ QUnit.module('fields', {}, function () {
},
});
- testUtils.form.clickEdit(form);
- testUtils.dom.click(form.$('tbody td.o_field_x2many_list_row_add a'));
+ await testUtils.form.clickEdit(form);
+ await testUtils.dom.click(form.$('tbody td.o_field_x2many_list_row_add a'));
form.destroy();
});
- QUnit.test('parent data is properly sent on an onchange rpc, new record', function (assert) {
+ QUnit.test('parent data is properly sent on an onchange rpc, new record', async function (assert) {
assert.expect(6);
this.data.turtle.onchanges = { turtle_bar: function () { } };
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -4475,12 +4469,12 @@ QUnit.module('fields', {}, function () {
return this._super.apply(this, arguments);
},
});
- testUtils.dom.click(form.$('tbody td.o_field_x2many_list_row_add a'));
+ await testUtils.dom.click(form.$('tbody td.o_field_x2many_list_row_add a'));
assert.verifySteps(['default_get', 'onchange', 'default_get', 'onchange']);
form.destroy();
});
- QUnit.test('id in one2many obtained in onchange is properly set', function (assert) {
+ QUnit.test('id in one2many obtained in onchange is properly set', async function (assert) {
assert.expect(1);
this.data.partner.onchanges.turtles = function (obj) {
@@ -4489,7 +4483,7 @@ QUnit.module('fields', {}, function () {
[1, 3, { turtle_foo: "kawa" }]
];
};
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -4508,10 +4502,10 @@ QUnit.module('fields', {}, function () {
form.destroy();
});
- QUnit.test('id field in one2many in a new record', function (assert) {
+ QUnit.test('id field in one2many in a new record', async function (assert) {
assert.expect(1);
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -4533,19 +4527,19 @@ QUnit.module('fields', {}, function () {
return this._super.apply(this, arguments);
},
});
- 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);
+ await testUtils.dom.click(form.$('td.o_field_x2many_list_row_add a'));
+ await testUtils.fields.editInput(form.$('td input[name="turtle_foo"]'), 'cat');
+ await testUtils.form.clickSave(form);
form.destroy();
});
- QUnit.test('sub form view with a required field', function (assert) {
+ QUnit.test('sub form view with a required field', async function (assert) {
assert.expect(2);
this.data.partner.fields.foo.required = true;
this.data.partner.fields.foo.default = null;
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -4562,9 +4556,9 @@ QUnit.module('fields', {}, function () {
res_id: 1,
});
- testUtils.form.clickEdit(form);
- testUtils.dom.click(form.$('tbody td.o_field_x2many_list_row_add a'));
- testUtils.dom.click($('.modal-footer button.btn-primary').first());
+ await testUtils.form.clickEdit(form);
+ await testUtils.dom.click(form.$('tbody td.o_field_x2many_list_row_add a'));
+ await testUtils.dom.click($('.modal-footer button.btn-primary').first());
assert.strictEqual($('.modal').length, 1, "should still have an open modal");
assert.strictEqual($('.modal tbody label.o_field_invalid').length, 1,
@@ -4572,12 +4566,12 @@ QUnit.module('fields', {}, function () {
form.destroy();
});
- QUnit.test('one2many list with action button', function (assert) {
+ QUnit.test('one2many list with action button', async function (assert) {
assert.expect(4);
this.data.partner.records[0].p = [2];
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -4605,17 +4599,17 @@ QUnit.module('fields', {}, function () {
},
});
- testUtils.dom.click(form.$('.o_list_button button'));
+ await testUtils.dom.click(form.$('.o_list_button button'));
form.destroy();
});
- QUnit.test('one2many kanban with action button', function (assert) {
+ QUnit.test('one2many kanban with action button', async function (assert) {
assert.expect(4);
this.data.partner.records[0].p = [2];
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -4649,12 +4643,12 @@ QUnit.module('fields', {}, function () {
},
});
- testUtils.dom.click(form.$('.oe_kanban_action_button'));
+ await testUtils.dom.click(form.$('.oe_kanban_action_button'));
form.destroy();
});
- QUnit.test('one2many kanban with edit type action and domain widget (widget using SpecialData)', function (assert) {
+ QUnit.test('one2many kanban with edit type action and domain widget (widget using SpecialData)', async function (assert) {
assert.expect(1);
this.data.turtle.fields.model_name = { string: "Domain Condition Model", type: "char" };
@@ -4664,7 +4658,7 @@ QUnit.module('fields', {}, function () {
record.condition = '[]';
});
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -4694,12 +4688,12 @@ QUnit.module('fields', {}, function () {
res_id: 1,
});
- testUtils.dom.click(form.$('.oe_kanban_action:eq(0)'));
+ await testUtils.dom.click(form.$('.oe_kanban_action:eq(0)'));
assert.strictEqual($('.o_domain_selector').length, 1, "should add domain selector widget");
form.destroy();
});
- QUnit.test('one2many list with onchange and domain widget (widget using SpecialData)', function (assert) {
+ QUnit.test('one2many list with onchange and domain widget (widget using SpecialData)', async function (assert) {
assert.expect(3);
this.data.turtle.fields.model_name = { string: "Domain Condition Model", type: "char" };
@@ -4729,7 +4723,7 @@ QUnit.module('fields', {}, function () {
},
};
var nbFetchSpecialDomain = 0;
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -4762,28 +4756,28 @@ QUnit.module('fields', {}, function () {
}
});
- testUtils.dom.click(form.$('.o_field_one2many .o_field_x2many_list_row_add a'));
+ await testUtils.dom.click(form.$('.o_field_one2many .o_field_x2many_list_row_add a'));
assert.strictEqual($('.modal').length, 1, "form view dialog should be opened");
- testUtils.fields.editInput($('.modal-body input[name="model_name"]'), 'partner');
- testUtils.dom.click($('.modal-footer button:first'));
+ await testUtils.fields.editInput($('.modal-body input[name="model_name"]'), 'partner');
+ await testUtils.dom.click($('.modal-footer button:first'));
assert.strictEqual(form.$('.o_field_one2many tbody tr:first').text(), "coucouhas changed[]",
"the onchange should create one new record and remove the existing");
- testUtils.dom.click(form.$('.o_field_one2many .o_list_view tbody tr:eq(0) td:first'));
+ await testUtils.dom.click(form.$('.o_field_one2many .o_list_view tbody tr:eq(0) td:first'));
- testUtils.form.clickSave(form);
+ await testUtils.form.clickSave(form);
assert.strictEqual(nbFetchSpecialDomain, 1,
"should only fetch special domain once");
form.destroy();
});
- QUnit.test('one2many without inline tree arch', function (assert) {
+ QUnit.test('one2many without inline tree arch', async function (assert) {
assert.expect(2);
this.data.partner.records[0].turtles = [2, 3];
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -4809,13 +4803,13 @@ QUnit.module('fields', {}, function () {
form.destroy();
});
- QUnit.test('many2one and many2many in one2many', function (assert) {
+ QUnit.test('many2one and many2many in one2many', async function (assert) {
assert.expect(11);
this.data.turtle.records[1].product_id = 37;
this.data.partner.records[0].turtles = [2, 3];
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -4862,46 +4856,46 @@ QUnit.module('fields', {}, function () {
assert.strictEqual(form.$('.o_data_row:first td:nth(2) .badge:first span').text(),
'second record', "m2m values should have been correctly fetched");
- testUtils.dom.click(form.$('.o_data_row:first'));
+ await testUtils.dom.click(form.$('.o_data_row:first'));
assert.strictEqual($('.modal .o_field_widget').text(), "xphone",
'should display the form view dialog with the many2one value');
- testUtils.dom.click($('.modal-footer button'));
+ await testUtils.dom.click($('.modal-footer button'));
- testUtils.form.clickEdit(form);
+ await testUtils.form.clickEdit(form);
// edit the m2m of first row
- testUtils.dom.click(form.$('.o_list_view tbody td:first()'));
+ await testUtils.dom.click(form.$('.o_list_view tbody td:first()'));
// remove a tag
- testUtils.dom.click(form.$('.o_field_many2manytags .badge:contains(aaa) .o_delete'));
+ await testUtils.dom.click(form.$('.o_field_many2manytags .badge:contains(aaa) .o_delete'));
assert.strictEqual(form.$('.o_selected_row .o_field_many2manytags .o_badge_text:contains(aaa)').length, 0,
"tag should have been correctly removed");
// add a tag
- testUtils.fields.many2one.clickOpenDropdown('partner_ids');
- testUtils.fields.many2one.clickHighlightedItem('partner_ids');
+ await testUtils.fields.many2one.clickOpenDropdown('partner_ids');
+ await testUtils.fields.many2one.clickHighlightedItem('partner_ids');
assert.strictEqual(form.$('.o_selected_row .o_field_many2manytags .o_badge_text:contains(first record)').length, 1,
"tag should have been correctly added");
// edit the m2o of first row
- testUtils.fields.many2one.clickOpenDropdown('product_id');
- testUtils.fields.many2one.clickItem('product_id', 'xpad');
+ await testUtils.fields.many2one.clickOpenDropdown('product_id');
+ await testUtils.fields.many2one.clickItem('product_id', 'xpad');
assert.strictEqual(form.$('.o_selected_row .o_field_many2one:first input').val(), 'xpad',
"m2o value should have been updated");
// save (should correctly generate the commands)
- testUtils.form.clickSave(form);
+ await testUtils.form.clickSave(form);
form.destroy();
});
- QUnit.test('many2manytag in one2many, onchange, some modifiers, and more than one page', function (assert) {
+ QUnit.test('many2manytag in one2many, onchange, some modifiers, and more than one page', async function (assert) {
assert.expect(9);
this.data.partner.records[0].turtles = [1, 2, 3];
this.data.partner.onchanges.turtles = function () { };
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -4922,8 +4916,8 @@ QUnit.module('fields', {}, function () {
});
assert.containsN(form, '.o_data_row', 2,
'there should be only 2 rows displayed');
- testUtils.dom.clickFirst(form.$('.o_list_record_remove'));
- testUtils.dom.clickFirst(form.$('.o_list_record_remove'));
+ await testUtils.dom.clickFirst(form.$('.o_list_record_remove'));
+ await testUtils.dom.clickFirst(form.$('.o_list_record_remove'));
assert.containsOnce(form, '.o_data_row',
'there should be just one remaining row');
@@ -4940,7 +4934,7 @@ QUnit.module('fields', {}, function () {
form.destroy();
});
- QUnit.test('onchange many2many in one2many list editable', function (assert) {
+ QUnit.test('onchange many2many in one2many list editable', async function (assert) {
assert.expect(14);
this.data.product.records.push({
@@ -4988,7 +4982,7 @@ QUnit.module('fields', {}, function () {
turtles: partnerOnchange,
};
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -5007,11 +5001,11 @@ QUnit.module('fields', {}, function () {
});
// add new line (first, xpad)
- testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
- testUtils.fields.editInput(form.$('input[name="display_name"]'), 'first');
- testUtils.dom.click(form.$('div[name="product_id"] input'));
+ await testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
+ await testUtils.fields.editInput(form.$('input[name="display_name"]'), 'first');
+ await testUtils.dom.click(form.$('div[name="product_id"] input'));
// the onchange won't be generated
- testUtils.dom.click($('li.ui-menu-item a:contains(xpad)').trigger('mouseenter'));
+ await testUtils.dom.click($('li.ui-menu-item a:contains(xpad)').trigger('mouseenter'));
assert.containsOnce(form, '.o_field_many2manytags.o_input',
'should display the line in editable mode');
@@ -5020,7 +5014,7 @@ QUnit.module('fields', {}, function () {
assert.strictEqual(form.$('.o_field_many2manytags.o_input .o_badge_text').text(), "first record",
'should display the tag from the onchange');
- testUtils.dom.click(form.$('input.o_field_integer[name="int_field"]'));
+ await testUtils.dom.click(form.$('input.o_field_integer[name="int_field"]'));
assert.strictEqual(form.$('.o_data_cell.o_required_modifier').text(), "xpad",
'should display the product xpad');
@@ -5028,7 +5022,7 @@ QUnit.module('fields', {}, function () {
'should display the tag in readonly');
// enable the many2many onchange and generate it
- testUtils.fields.editInput(form.$('input.o_field_integer[name="int_field"]'), '10');
+ await testUtils.fields.editInput(form.$('input.o_field_integer[name="int_field"]'), '10');
assert.strictEqual(form.$('.o_data_cell.o_required_modifier').text(), "xenomorphexphone",
'should display the product xphone and xenomorphe');
@@ -5036,21 +5030,21 @@ QUnit.module('fields', {}, function () {
'should display the name, one2many and many2many value');
// disable the many2many onchange
- testUtils.fields.editInput(form.$('input.o_field_integer[name="int_field"]'), '0');
+ await testUtils.fields.editInput(form.$('input.o_field_integer[name="int_field"]'), '0');
// remove and start over
- testUtils.dom.click(form.$('.o_list_record_remove:first button'));
- testUtils.dom.click(form.$('.o_list_record_remove:first button'));
+ await testUtils.dom.click(form.$('.o_list_record_remove:first button'));
+ await testUtils.dom.click(form.$('.o_list_record_remove:first button'));
// enable the many2many onchange
- testUtils.fields.editInput(form.$('input.o_field_integer[name="int_field"]'), '10');
+ await testUtils.fields.editInput(form.$('input.o_field_integer[name="int_field"]'), '10');
// add new line (first, xenomorphe)
- testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
- testUtils.fields.editInput(form.$('input[name="display_name"]'), 'first');
- testUtils.dom.click(form.$('div[name="product_id"] input'));
+ await testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
+ await testUtils.fields.editInput(form.$('input[name="display_name"]'), 'first');
+ await testUtils.dom.click(form.$('div[name="product_id"] input'));
// generate the onchange
- testUtils.dom.click($('li.ui-menu-item a:contains(xenomorphe)').trigger('mouseenter'));
+ await testUtils.dom.click($('li.ui-menu-item a:contains(xenomorphe)').trigger('mouseenter'));
assert.containsOnce(form, '.o_field_many2manytags.o_input',
'should display the line in editable mode');
@@ -5060,19 +5054,19 @@ QUnit.module('fields', {}, function () {
'should display the tag from the onchange');
// put list in readonly mode
- testUtils.dom.click(form.$('input.o_field_integer[name="int_field"]'));
+ await testUtils.dom.click(form.$('input.o_field_integer[name="int_field"]'));
assert.strictEqual(form.$('.o_data_cell.o_required_modifier').text(), "xenomorphexphone",
'should display the product xphone and xenomorphe');
assert.strictEqual(form.$('.o_field_many2manytags:not(.o_input) .o_badge_text').text(), "second recordfirst record",
'should display the tag in readonly (first record and second record)');
- testUtils.fields.editInput(form.$('input.o_field_integer[name="int_field"]'), '10');
+ await testUtils.fields.editInput(form.$('input.o_field_integer[name="int_field"]'), '10');
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);
+ await 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');
@@ -5080,14 +5074,14 @@ QUnit.module('fields', {}, function () {
form.destroy();
});
- QUnit.test('load view for x2many in one2many', function (assert) {
+ QUnit.test('load view for x2many in one2many', async function (assert) {
assert.expect(2);
this.data.turtle.records[1].product_id = 37;
this.data.partner.records[0].turtles = [2, 3];
this.data.partner.records[2].turtles = [1, 3];
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -5116,7 +5110,7 @@ QUnit.module('fields', {}, function () {
assert.containsN(form, '.o_data_row', 2,
'should display the 2 turtles');
- testUtils.dom.click(form.$('.o_data_row:first'));
+ await testUtils.dom.click(form.$('.o_data_row:first'));
assert.strictEqual($('.modal .o_field_widget[name="partner_ids"] .o_list_view').length, 1,
'should display many2many list view in the modal');
@@ -5124,12 +5118,12 @@ QUnit.module('fields', {}, function () {
form.destroy();
});
- QUnit.test('one2many (who contains a one2many) with tree view and without form view', function (assert) {
+ QUnit.test('one2many (who contains a one2many) with tree view and without form view', async function (assert) {
assert.expect(1);
// avoid error in _postprocess
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -5148,7 +5142,7 @@ QUnit.module('fields', {}, function () {
},
});
- testUtils.dom.click(form.$('.o_data_row:first'));
+ await testUtils.dom.click(form.$('.o_data_row:first'));
assert.strictEqual($('.modal .o_field_widget[name="turtle_foo"]').text(), 'blip',
'should open the modal and display the form field');
@@ -5156,7 +5150,7 @@ QUnit.module('fields', {}, function () {
form.destroy();
});
- QUnit.test('one2many with x2many in form view (but not in list view)', function (assert) {
+ QUnit.test('one2many with x2many in form view (but not in list view)', async function (assert) {
assert.expect(1);
// avoid error when saving the edited related record (because the
@@ -5165,7 +5159,7 @@ QUnit.module('fields', {}, function () {
this.data.turtle.fields.o2m = { string: "o2m", type: "one2many", relation: 'user' };
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -5197,26 +5191,26 @@ QUnit.module('fields', {}, function () {
},
});
- testUtils.dom.click(form.$('.o_data_row:first')); // edit first record
+ await testUtils.dom.click(form.$('.o_data_row:first')); // edit first record
- testUtils.fields.many2one.clickOpenDropdown('partner_ids');
- testUtils.fields.many2one.clickHighlightedItem('partner_ids');
+ await testUtils.fields.many2one.clickOpenDropdown('partner_ids');
+ await testUtils.fields.many2one.clickHighlightedItem('partner_ids');
// add a many2many tag and save
- testUtils.dom.click($('.modal .o_field_many2manytags input'));
- testUtils.fields.editInput($('.modal .o_field_many2manytags input'), 'test');
- testUtils.dom.click($('.modal .modal-footer .btn-primary')); // save
+ await testUtils.dom.click($('.modal .o_field_many2manytags input'));
+ await testUtils.fields.editInput($('.modal .o_field_many2manytags input'), 'test');
+ await testUtils.dom.click($('.modal .modal-footer .btn-primary')); // save
- testUtils.form.clickSave(form);
+ await testUtils.form.clickSave(form);
form.destroy();
});
- QUnit.test('many2many list in a one2many opened by a many2one', function (assert) {
+ QUnit.test('many2many list in a one2many opened by a many2one', async function (assert) {
assert.expect(1);
this.data.turtle.records[1].turtle_trululu = 2;
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -5243,7 +5237,7 @@ QUnit.module('fields', {}, function () {
},
mockRPC: function (route, args) {
if (route === '/web/dataset/call_kw/partner/get_formview_id') {
- return $.when(false);
+ return Promise.resolve(false);
}
if (args.method === 'write') {
assert.deepEqual(args.args[1].timmy, [[6, false, [12]]],
@@ -5254,27 +5248,27 @@ QUnit.module('fields', {}, function () {
});
// edit the first partner in the one2many partner form view
- testUtils.dom.click(form.$('.o_data_row:first td.o_data_cell'));
+ await testUtils.dom.click(form.$('.o_data_row:first td.o_data_cell'));
// open form view for many2one
- testUtils.dom.click(form.$('.o_external_button'));
+ await testUtils.dom.click(form.$('.o_external_button'));
// click on add, to add a new partner in the m2m
- testUtils.dom.click($('.modal .o_field_x2many_list_row_add a'));
+ await testUtils.dom.click($('.modal .o_field_x2many_list_row_add a'));
// select the partner_type 'gold' (this closes the 2nd modal)
- testUtils.dom.click($('.modal td:contains(gold)'));
+ await testUtils.dom.click($('.modal td:contains(gold)'));
// confirm the changes in the modal
- testUtils.dom.click($('.modal .modal-footer .btn-primary'));
+ await testUtils.dom.click($('.modal .modal-footer .btn-primary'));
- testUtils.form.clickSave(form);
+ await testUtils.form.clickSave(form);
form.destroy();
});
- QUnit.test('nested x2many default values', function (assert) {
+ QUnit.test('nested x2many default values', async function (assert) {
assert.expect(3);
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -5287,7 +5281,7 @@ QUnit.module('fields', {}, function () {
'</form>',
mockRPC: function (route, args) {
if (args.model === 'partner' && args.method === 'default_get') {
- return $.when({
+ return Promise.resolve({
turtles: [
[0, 0, { partner_ids: [[6, 0, [4]]] }],
[0, 0, { partner_ids: [[6, 0, [1]]] }],
@@ -5308,12 +5302,12 @@ QUnit.module('fields', {}, function () {
form.destroy();
});
- QUnit.test('one2many (who contains display_name) with tree view and without form view', function (assert) {
+ QUnit.test('one2many (who contains display_name) with tree view and without form view', async function (assert) {
assert.expect(1);
// avoid error in _fetchX2Manys
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -5332,7 +5326,7 @@ QUnit.module('fields', {}, function () {
},
});
- testUtils.dom.click(form.$('.o_data_row:first'));
+ await testUtils.dom.click(form.$('.o_data_row:first'));
assert.strictEqual($('.modal .o_field_widget[name="turtle_foo"]').text(), 'blip',
'should open the modal and display the form field');
@@ -5340,10 +5334,10 @@ QUnit.module('fields', {}, function () {
form.destroy();
});
- QUnit.test('one2many field with virtual ids', function (assert) {
+ QUnit.test('one2many field with virtual ids', async function (assert) {
assert.expect(11);
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -5387,13 +5381,13 @@ QUnit.module('fields', {}, function () {
"should not have kanban records yet");
// // switch to edit mode and create a new kanban record
- testUtils.form.clickEdit(form);
- testUtils.dom.click(form.$('.o_field_widget .o-kanban-button-new'));
+ await testUtils.form.clickEdit(form);
+ await testUtils.dom.click(form.$('.o_field_widget .o-kanban-button-new'));
// save & close the modal
assert.strictEqual($('.modal-content input.o_field_widget').val(), 'My little Foo Value',
"should already have the default value for field foo");
- testUtils.dom.click($('.modal-content .btn-primary').first());
+ await testUtils.dom.click($('.modal-content .btn-primary').first());
assert.containsOnce(form, '.o_field_widget .o_kanban_view',
"should have one inner kanban view for the one2many field");
@@ -5405,7 +5399,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);
+ await 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,
@@ -5418,10 +5412,10 @@ QUnit.module('fields', {}, function () {
form.destroy();
});
- QUnit.test('focusing fields in one2many list', function (assert) {
+ QUnit.test('focusing fields in one2many list', async function (assert) {
assert.expect(2);
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -5438,23 +5432,23 @@ QUnit.module('fields', {}, function () {
'</form>',
res_id: 1,
});
- testUtils.form.clickEdit(form);
+ await testUtils.form.clickEdit(form);
- testUtils.dom.click(form.$('.o_data_row:first td:first'));
+ await testUtils.dom.click(form.$('.o_data_row:first td:first'));
assert.strictEqual(form.$('input[name="turtle_foo"]')[0], document.activeElement,
"turtle foo field should have focus");
- form.$('input[name="turtle_foo"]').trigger({ type: 'keydown', which: $.ui.keyCode.TAB });
+ await testUtils.fields.triggerKeydown(form.$('input[name="turtle_foo"]'), 'tab');
assert.strictEqual(form.$('input[name="turtle_int"]')[0], document.activeElement,
"turtle int field should have focus");
form.destroy();
});
- QUnit.test('one2many list editable = top', function (assert) {
+ QUnit.test('one2many list editable = top', async function (assert) {
assert.expect(6);
this.data.turtle.fields.turtle_foo.default = "default foo turtle";
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -5479,12 +5473,12 @@ QUnit.module('fields', {}, function () {
return this._super.apply(this, arguments);
},
});
- testUtils.form.clickEdit(form);
+ await testUtils.form.clickEdit(form);
assert.containsOnce(form, '.o_data_row',
"should start with one data row");
- testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
+ await testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
assert.containsN(form, '.o_data_row', 2,
"should have 2 data rows");
@@ -5493,15 +5487,15 @@ QUnit.module('fields', {}, function () {
assert.hasClass(form.$('tr.o_data_row:first'),'o_selected_row',
"first row should be selected");
- testUtils.form.clickSave(form);
+ await testUtils.form.clickSave(form);
form.destroy();
});
- QUnit.test('one2many list editable = bottom', function (assert) {
+ QUnit.test('one2many list editable = bottom', async function (assert) {
assert.expect(6);
this.data.turtle.fields.turtle_foo.default = "default foo turtle";
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -5526,12 +5520,12 @@ QUnit.module('fields', {}, function () {
return this._super.apply(this, arguments);
},
});
- testUtils.form.clickEdit(form);
+ await testUtils.form.clickEdit(form);
assert.containsOnce(form, '.o_data_row',
"should start with one data row");
- testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
+ await testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
assert.containsN(form, '.o_data_row', 2,
"should have 2 data rows");
@@ -5540,14 +5534,14 @@ 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);
+ await testUtils.form.clickSave(form);
form.destroy();
});
- QUnit.test('x2many fields use their "mode" attribute', function (assert) {
+ QUnit.test('x2many fields use their "mode" attribute', async function (assert) {
assert.expect(1);
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -5578,8 +5572,8 @@ QUnit.module('fields', {}, function () {
form.destroy();
});
- QUnit.test('one2many list editable, no onchange when required field is not set', function (assert) {
- assert.expect(7);
+ QUnit.test('one2many list editable, no onchange when required field is not set', async function (assert) {
+ assert.expect(8);
this.data.turtle.fields.turtle_foo.required = true;
this.data.partner.onchanges = {
@@ -5590,7 +5584,7 @@ QUnit.module('fields', {}, function () {
this.data.partner.records[0].int_field = 0;
this.data.partner.records[0].turtles = [];
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -5609,28 +5603,29 @@ QUnit.module('fields', {}, function () {
},
res_id: 1,
});
- testUtils.form.clickEdit(form);
+ await testUtils.form.clickEdit(form);
assert.strictEqual(form.$('.o_field_widget[name="int_field"]').val(), "0",
"int_field should start with value 0");
- testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
+ await testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
assert.strictEqual(form.$('.o_field_widget[name="int_field"]').val(), "0",
"int_field should still be 0 (no onchange should have been done yet");
assert.verifySteps(['read', 'default_get'], "no onchange should have been applied");
- testUtils.fields.editInput(form.$('.o_field_widget[name="turtle_foo"]'), "some text");
+ await testUtils.fields.editInput(form.$('.o_field_widget[name="turtle_foo"]'), "some text");
+ assert.verifySteps(['onchange']);
assert.strictEqual(form.$('.o_field_widget[name="int_field"]').val(), "1",
"int_field should now be 1 (the onchange should have been done");
form.destroy();
});
- QUnit.test('one2many list editable: trigger onchange when row is valid', function (assert) {
+ QUnit.test('one2many list editable: trigger onchange when row is valid', async function (assert) {
// should omit require fields that aren't in the view as they (obviously)
// have no value, when checking the validity of required fields
// shouldn't consider numerical fields with value 0 as unset
- assert.expect(12);
+ assert.expect(13);
this.data.turtle.fields.turtle_foo.required = true;
this.data.turtle.fields.turtle_qux.required = true; // required field not in the view
@@ -5647,7 +5642,7 @@ QUnit.module('fields', {}, function () {
this.data.partner.records[0].int_field = 0;
this.data.partner.records[0].turtles = [];
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -5670,33 +5665,34 @@ QUnit.module('fields', {}, function () {
},
res_id: 1,
});
- testUtils.form.clickEdit(form);
+ await testUtils.form.clickEdit(form);
assert.strictEqual(form.$('.o_field_widget[name="int_field"]').val(), "0",
"int_field should start with value 0");
// add a new row (which is invalid at first)
- testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
+ await testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
assert.strictEqual(form.$('.o_field_widget[name="int_field"]').val(), "0",
"int_field should still be 0 (no onchange should have been done yet)");
assert.verifySteps(['load_views', 'read', 'default_get'], "no onchange should have been applied");
// fill turtle_foo field
- testUtils.fields.editInput(form.$('.o_field_widget[name="turtle_foo"]'), "some text");
+ await testUtils.fields.editInput(form.$('.o_field_widget[name="turtle_foo"]'), "some text");
assert.strictEqual(form.$('.o_field_widget[name="int_field"]').val(), "0",
"int_field should still be 0 (no onchange should have been done yet)");
- assert.verifySteps(['load_views', 'read', 'default_get'], "no onchange should have been applied");
+ assert.verifySteps([], "no onchange should have been applied");
// fill partner_ids field with a tag (all required fields will then be set)
- testUtils.fields.many2one.clickOpenDropdown('partner_ids');
- testUtils.fields.many2one.clickHighlightedItem('partner_ids');
+ await testUtils.fields.many2one.clickOpenDropdown('partner_ids');
+ await testUtils.fields.many2one.clickHighlightedItem('partner_ids');
assert.strictEqual(form.$('.o_field_widget[name="int_field"]').val(), "1",
"int_field should now be 1 (the onchange should have been done");
+ assert.verifySteps(['name_search', 'read', 'onchange']);
form.destroy();
});
- QUnit.test('one2many list editable: \'required\' modifiers is properly working', function (assert) {
+ QUnit.test('one2many list editable: \'required\' modifiers is properly working', async function (assert) {
assert.expect(3);
this.data.partner.onchanges = {
@@ -5707,7 +5703,7 @@ QUnit.module('fields', {}, function () {
this.data.partner.records[0].turtles = [];
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -5721,18 +5717,18 @@ QUnit.module('fields', {}, function () {
'</form>',
res_id: 1,
});
- testUtils.form.clickEdit(form);
+ await testUtils.form.clickEdit(form);
assert.strictEqual(form.$('.o_field_widget[name="int_field"]').val(), "10",
"int_field should start with value 10");
- testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
+ await testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
assert.strictEqual(form.$('.o_field_widget[name="int_field"]').val(), "10",
"int_field should still be 10 (no onchange, because line is not valid)");
// fill turtle_foo field
- testUtils.fields.editInput(form.$('.o_field_widget[name="turtle_foo"]'), "some text");
+ await testUtils.fields.editInput(form.$('.o_field_widget[name="turtle_foo"]'), "some text");
assert.strictEqual(form.$('.o_field_widget[name="int_field"]').val(), "1",
"int_field should be 1 (onchange triggered, because line is now valid)");
@@ -5740,7 +5736,7 @@ QUnit.module('fields', {}, function () {
form.destroy();
});
- QUnit.test('one2many list editable: \'required\' modifiers is properly working, part 2', function (assert) {
+ QUnit.test('one2many list editable: \'required\' modifiers is properly working, part 2', async function (assert) {
assert.expect(3);
this.data.partner.onchanges = {
@@ -5751,7 +5747,7 @@ QUnit.module('fields', {}, function () {
this.data.partner.records[0].turtles = [];
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -5766,18 +5762,18 @@ QUnit.module('fields', {}, function () {
'</form>',
res_id: 1,
});
- testUtils.form.clickEdit(form);
+ await testUtils.form.clickEdit(form);
assert.strictEqual(form.$('.o_field_widget[name="int_field"]').val(), "10",
"int_field should start with value 10");
- testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
+ await testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
assert.strictEqual(form.$('.o_field_widget[name="int_field"]').val(), "10",
"int_field should still be 10 (no onchange, because line is not valid)");
// fill turtle_int field
- testUtils.fields.editInput(form.$('.o_field_widget[name="turtle_int"]'), "1");
+ await testUtils.fields.editInput(form.$('.o_field_widget[name="turtle_int"]'), "1");
assert.strictEqual(form.$('.o_field_widget[name="int_field"]').val(), "1",
"int_field should be 1 (onchange triggered, because line is now valid)");
@@ -5785,7 +5781,7 @@ QUnit.module('fields', {}, function () {
form.destroy();
});
- QUnit.test('one2many list editable: add new line before onchange returns', function (assert) {
+ QUnit.test('one2many list editable: add new line before onchange returns', async function (assert) {
// If the user adds a new row (with a required field with onchange), selects
// a value for that field, then adds another row before the onchange returns,
// the editable list must wait for the onchange to return before trying to
@@ -5796,8 +5792,8 @@ QUnit.module('fields', {}, function () {
turtle_trululu: function () { },
};
- var def;
- var form = createView({
+ var prom;
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -5811,23 +5807,23 @@ QUnit.module('fields', {}, function () {
mockRPC: function (route, args) {
var result = this._super.apply(this, arguments);
if (args.method === 'onchange') {
- return $.when(def).then(_.constant(result));
+ return Promise.resolve(prom).then(_.constant(result));
}
return result;
},
});
// add a first line but hold the onchange back
- testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
+ await testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
+ prom = testUtils.makeTestPromise();
assert.containsOnce(form, '.o_data_row',
"should have created the first row immediately");
- def = $.Deferred();
- testUtils.fields.many2one.clickOpenDropdown('turtle_trululu');
- testUtils.fields.many2one.clickHighlightedItem('turtle_trululu');
+ await testUtils.fields.many2one.clickOpenDropdown('turtle_trululu');
+ await testUtils.fields.many2one.clickHighlightedItem('turtle_trululu');
// try to add a second line and check that it is correctly waiting
// for the onchange to return
- testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
+ await testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
assert.strictEqual($('.modal').length, 0, "no modal should be displayed");
assert.strictEqual($('.o_field_invalid').length, 0,
"no field should be marked as invalid");
@@ -5836,8 +5832,9 @@ QUnit.module('fields', {}, function () {
assert.hasClass(form.$('.o_data_row'),'o_selected_row',
"first row should still be in edition");
- // resolve the onchange def
- def.resolve();
+ // resolve the onchange promise
+ prom.resolve();
+ await testUtils.nextTick();
assert.containsN(form, '.o_data_row', 2,
"second row should now have been created");
assert.doesNotHaveClass(form.$('.o_data_row:first'), 'o_selected_row',
@@ -5846,15 +5843,15 @@ QUnit.module('fields', {}, function () {
form.destroy();
});
- QUnit.test('editable list: multiple clicks on Add an item do not create invalid rows', function (assert) {
+ QUnit.test('editable list: multiple clicks on Add an item do not create invalid rows', async function (assert) {
assert.expect(3);
this.data.turtle.onchanges = {
turtle_trululu: function () { },
};
- var def;
- var form = createView({
+ var prom;
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -5868,21 +5865,21 @@ QUnit.module('fields', {}, function () {
mockRPC: function (route, args) {
var result = this._super.apply(this, arguments);
if (args.method === 'onchange') {
- return $.when(def).then(_.constant(result));
+ return Promise.resolve(prom).then(_.constant(result));
}
return result;
},
});
-
+ prom = testUtils.makeTestPromise();
// click twice to add a new line
- def = $.Deferred();
- testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
- testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
+ await testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
+ await testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
assert.containsNone(form, '.o_data_row',
"no row should have been created yet (waiting for the onchange)");
- // resolve the onchange def
- def.resolve();
+ // resolve the onchange promise
+ prom.resolve();
+ await testUtils.nextTick();
assert.containsOnce(form, '.o_data_row',
"only one row should have been created");
assert.hasClass(form.$('.o_data_row:first'),'o_selected_row',
@@ -5891,7 +5888,7 @@ QUnit.module('fields', {}, function () {
form.destroy();
});
- QUnit.test('editable list: value reset by an onchange', function (assert) {
+ QUnit.test('editable list: value reset by an onchange', async function (assert) {
// this test reproduces a subtle behavior that may occur in a form view:
// the user adds a record in a one2many field, and directly clicks on a
// datetime field of the form view which has an onchange, which totally
@@ -5907,8 +5904,8 @@ QUnit.module('fields', {}, function () {
},
};
- var def;
- var form = createView({
+ var prom;
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -5923,22 +5920,23 @@ QUnit.module('fields', {}, function () {
mockRPC: function (route, args) {
var result = this._super.apply(this, arguments);
if (args.method === 'onchange') {
- return $.when(def).then(_.constant(result));
+ return Promise.resolve(prom).then(_.constant(result));
}
return result;
},
});
// trigger the two onchanges
- testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
- testUtils.fields.editInput(form.$('.o_data_row .o_field_widget'), 'a name');
- def = $.Deferred();
- testUtils.dom.click(form.$('.o_datepicker_input'));
+ await testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
+ await testUtils.fields.editInput(form.$('.o_data_row .o_field_widget'), 'a name');
+ prom = testUtils.makeTestPromise();
+ await testUtils.dom.click(form.$('.o_datepicker_input'));
var dateTimeVal = fieldUtils.format.datetime(moment(), { timezone: false });
- testUtils.fields.editSelect(form.$('.o_datepicker_input'), dateTimeVal);
+ await testUtils.fields.editSelect(form.$('.o_datepicker_input'), dateTimeVal);
- // resolve the onchange def
- def.resolve();
+ // resolve the onchange promise
+ prom.resolve();
+ await testUtils.nextTick();
assert.containsOnce(form, '.o_data_row',
"should have one record in the o2m");
@@ -5948,14 +5946,14 @@ QUnit.module('fields', {}, function () {
form.destroy();
});
- QUnit.test('editable list: onchange that returns a warning', function (assert) {
+ QUnit.test('editable list: onchange that returns a warning', async function (assert) {
assert.expect(5);
this.data.turtle.onchanges = {
display_name: function () { },
};
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -5970,7 +5968,7 @@ QUnit.module('fields', {}, function () {
mockRPC: function (route, args) {
if (args.method === 'onchange') {
assert.step(args.method);
- return $.when({
+ return Promise.resolve({
value: {},
warning: {
title: "Warning",
@@ -5991,22 +5989,22 @@ QUnit.module('fields', {}, function () {
});
// add a line (this should trigger an onchange and a warning)
- testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
+ await testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
// check if 'Add an item' still works (this should trigger an onchange
// and a warning again)
- testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
+ await testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
assert.verifySteps(['onchange', 'warning', 'onchange', 'warning']);
form.destroy();
});
- QUnit.test('editable list: contexts are correctly sent', function (assert) {
+ QUnit.test('editable list: contexts are correctly sent', async function (assert) {
assert.expect(5);
this.data.partner.records[0].timmy = [12];
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -6051,14 +6049,14 @@ QUnit.module('fields', {}, function () {
res_id: 1,
});
- testUtils.dom.click(form.$('.o_data_cell:first'));
- testUtils.fields.editInput(form.$('.o_field_widget[name=display_name]'), 'abc');
- testUtils.form.clickSave(form);
+ await testUtils.dom.click(form.$('.o_data_cell:first'));
+ await testUtils.fields.editInput(form.$('.o_field_widget[name=display_name]'), 'abc');
+ await testUtils.form.clickSave(form);
form.destroy();
});
- QUnit.test('resetting invisible one2manys', function (assert) {
+ QUnit.test('resetting invisible one2manys', async function (assert) {
assert.expect(3);
this.data.partner.records[0].turtles = [];
@@ -6066,7 +6064,7 @@ QUnit.module('fields', {}, function () {
obj.turtles = [[5], [4, 1]];
};
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -6084,20 +6082,20 @@ QUnit.module('fields', {}, function () {
},
});
- testUtils.fields.editInput(form.$('input[name="foo"]'), 'abcd');
+ await testUtils.fields.editInput(form.$('input[name="foo"]'), 'abcd');
assert.verifySteps(['read', 'onchange']);
form.destroy();
});
- QUnit.test('one2many: onchange that returns unknow field in list, but not in form', function (assert) {
+ QUnit.test('one2many: onchange that returns unknow field in list, but not in form', async function (assert) {
assert.expect(5);
this.data.partner.onchanges = {
name: function () { },
};
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -6115,7 +6113,7 @@ QUnit.module('fields', {}, function () {
'</form>',
mockRPC: function (route, args) {
if (args.method === 'onchange') {
- return $.when({
+ return Promise.resolve({
value: {
p: [[5], [0, 0, { display_name: 'new', timmy: [[5], [4, 12]] }]],
},
@@ -6130,7 +6128,7 @@ QUnit.module('fields', {}, function () {
assert.containsNone(form, '.o_field_widget[name="timmy"]',
"timmy should not be displayed in the list view");
- testUtils.dom.click(form.$('.o_data_row td:first'));
+ await testUtils.dom.click(form.$('.o_data_row td:first'));
assert.strictEqual($('.modal .o_field_many2manytags[name="timmy"]').length, 1,
"timmy should be displayed in the form view");
@@ -6142,16 +6140,16 @@ QUnit.module('fields', {}, function () {
form.destroy();
});
- QUnit.test('onchange and required fields with override in arch', function (assert) {
+ QUnit.test('onchange and required fields with override in arch', async function (assert) {
assert.expect(4);
this.data.partner.onchanges = {
- turtles: function (obj) { }
+ turtles: function () { }
};
this.data.turtle.fields.turtle_foo.required = true;
this.data.partner.records[0].turtles = [];
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -6169,16 +6167,16 @@ QUnit.module('fields', {}, function () {
return this._super.apply(this, arguments);
},
});
- testUtils.form.clickEdit(form);
+ await testUtils.form.clickEdit(form);
// triggers an onchange on partner, because the new record is valid
- testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
+ await testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
assert.verifySteps(['read', 'default_get', 'onchange']);
form.destroy();
});
- QUnit.test('onchange on a one2many containing a one2many', function (assert) {
+ QUnit.test('onchange on a one2many containing a one2many', async function (assert) {
// the purpose of this test is to ensure that the onchange specs are
// correctly and recursively computed
assert.expect(1);
@@ -6187,7 +6185,7 @@ QUnit.module('fields', {}, function () {
p: function () { }
};
var checkOnchange = false;
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -6211,16 +6209,16 @@ QUnit.module('fields', {}, function () {
},
});
- testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
- testUtils.dom.click($('.modal .o_field_x2many_list_row_add a'));
- testUtils.fields.editInput($('.modal .o_data_cell input'), 'new record');
+ await testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
+ await testUtils.dom.click($('.modal .o_field_x2many_list_row_add a'));
+ await testUtils.fields.editInput($('.modal .o_data_cell input'), 'new record');
checkOnchange = true;
- testUtils.dom.clickFirst($('.modal .modal-footer .btn-primary'));
+ await testUtils.dom.clickFirst($('.modal .modal-footer .btn-primary'));
form.destroy();
});
- QUnit.test('editing tabbed one2many (editable=bottom)', function (assert) {
+ QUnit.test('editing tabbed one2many (editable=bottom)', async function (assert) {
assert.expect(12);
this.data.partner.records[0].turtles = [];
@@ -6230,7 +6228,7 @@ QUnit.module('fields', {}, function () {
this.data.partner.records[0].turtles.push(id);
}
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -6255,14 +6253,14 @@ QUnit.module('fields', {}, function () {
});
- testUtils.form.clickEdit(form);
- testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
+ await testUtils.form.clickEdit(form);
+ await testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
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);
+ await testUtils.fields.editInput(form.$('.o_data_row input[name="turtle_foo"]'), 'rainbow dash');
+ await testUtils.form.clickSave(form);
assert.containsN(form, 'tr.o_data_row', 40);
@@ -6270,7 +6268,7 @@ QUnit.module('fields', {}, function () {
form.destroy();
});
- QUnit.test('editing tabbed one2many (editable=bottom), again...', function (assert) {
+ QUnit.test('editing tabbed one2many (editable=bottom), again...', async function (assert) {
assert.expect(1);
this.data.partner.records[0].turtles = [];
@@ -6280,7 +6278,7 @@ QUnit.module('fields', {}, function () {
this.data.partner.records[0].turtles.push(id);
}
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -6295,18 +6293,18 @@ QUnit.module('fields', {}, function () {
});
- testUtils.form.clickEdit(form);
- testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
- testUtils.fields.editInput(form.$('.o_data_row input[name="turtle_foo"]'), 'rainbow dash');
- testUtils.dom.click(form.$('.o_x2m_control_panel .o_pager_next'));
- testUtils.dom.click(form.$('.o_x2m_control_panel .o_pager_next'));
+ await testUtils.form.clickEdit(form);
+ await testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
+ await testUtils.fields.editInput(form.$('.o_data_row input[name="turtle_foo"]'), 'rainbow dash');
+ await testUtils.dom.click(form.$('.o_x2m_control_panel .o_pager_next'));
+ await testUtils.dom.click(form.$('.o_x2m_control_panel .o_pager_next'));
assert.containsN(form, 'tr.o_data_row', 3,
"should have 3 data rows on the current page");
form.destroy();
});
- QUnit.test('editing tabbed one2many (editable=top)', function (assert) {
+ QUnit.test('editing tabbed one2many (editable=top)', async function (assert) {
assert.expect(15);
this.data.partner.records[0].turtles = [];
@@ -6317,7 +6315,7 @@ QUnit.module('fields', {}, function () {
this.data.partner.records[0].turtles.push(id);
}
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -6342,12 +6340,12 @@ QUnit.module('fields', {}, function () {
});
- testUtils.form.clickEdit(form);
- testUtils.dom.click(form.$('.o_field_widget[name=turtles] .o_pager_next'));
+ await testUtils.form.clickEdit(form);
+ await testUtils.dom.click(form.$('.o_field_widget[name=turtles] .o_pager_next'));
assert.containsN(form, 'tr.o_data_row', 2);
- testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
+ await testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
assert.containsN(form, 'tr.o_data_row', 3);
@@ -6356,8 +6354,8 @@ QUnit.module('fields', {}, function () {
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);
+ await testUtils.fields.editInput(form.$('.o_data_row input[name="turtle_foo"]'), 'rainbow dash');
+ await testUtils.form.clickSave(form);
assert.containsN(form, 'tr.o_data_row', 40);
@@ -6365,8 +6363,7 @@ QUnit.module('fields', {}, function () {
form.destroy();
});
- QUnit.test('one2many field: change value before pending onchange returns', function (assert) {
- var done = assert.async();
+ QUnit.test('one2many field: change value before pending onchange returns', async function (assert) {
assert.expect(2);
var M2O_DELAY = relationalFields.FieldMany2One.prototype.AUTOCOMPLETE_DELAY;
@@ -6375,8 +6372,8 @@ QUnit.module('fields', {}, function () {
this.data.partner.onchanges = {
int_field: function () { }
};
- var def;
- var form = createView({
+ var prom;
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -6392,42 +6389,41 @@ QUnit.module('fields', {}, function () {
var result = this._super.apply(this, arguments);
if (args.method === 'onchange') {
// delay the onchange RPC
- return $.when(def).then(_.constant(result));
+ return Promise.resolve(prom).then(_.constant(result));
}
return result;
},
});
- testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
- def = $.Deferred();
- testUtils.fields.editInput(form.$('.o_field_widget[name=int_field]'), '44');
+ await testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
+ prom = testUtils.makeTestPromise();
+ await testUtils.fields.editInput(form.$('.o_field_widget[name=int_field]'), '44');
var $dropdown = form.$('.o_field_many2one input').autocomplete('widget');
// set trululu before onchange
- form.$('.o_field_many2one input').val('first').trigger('keydown').trigger('keyup');
+ await testUtils.fields.editAndTrigger(form.$('.o_field_many2one input'),
+ 'first', ['keydown', 'keyup']);
// complete the onchange
- def.resolve();
+ prom.resolve();
assert.strictEqual(form.$('.o_field_many2one input').val(), 'first',
'should have kept the new value');
- concurrency.delay(0).then(function () {
- // check name_search result
- assert.strictEqual($dropdown.find('li:not(.o_m2o_dropdown_option)').length, 1,
- 'autocomplete should contains 1 suggestion');
+ await testUtils.nextTick();
+ // check name_search result
+ assert.strictEqual($dropdown.find('li:not(.o_m2o_dropdown_option)').length, 1,
+ 'autocomplete should contains 1 suggestion');
- relationalFields.FieldMany2One.prototype.AUTOCOMPLETE_DELAY = M2O_DELAY;
- form.destroy();
- done();
- });
+ relationalFields.FieldMany2One.prototype.AUTOCOMPLETE_DELAY = M2O_DELAY;
+ form.destroy();
});
- QUnit.test('focus is correctly reset after an onchange in an x2many', function (assert) {
+ QUnit.test('focus is correctly reset after an onchange in an x2many', async function (assert) {
assert.expect(2);
this.data.partner.onchanges = {
int_field: function () { }
};
- var def;
- var form = createView({
+ var prom;
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -6445,37 +6441,38 @@ QUnit.module('fields', {}, function () {
var result = this._super.apply(this, arguments);
if (args.method === 'onchange') {
// delay the onchange RPC
- return $.when(def).then(_.constant(result));
+ return Promise.resolve(prom).then(_.constant(result));
}
return result;
},
});
- testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
- def = $.Deferred();
+ await testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
+ prom = testUtils.makeTestPromise();
testUtils.fields.editAndTrigger(form.$('.o_field_widget[name=int_field]'), '44',
['input', { type: 'keydown', which: $.ui.keyCode.TAB }]);
- def.resolve();
+ prom.resolve();
+ await testUtils.nextTick();
assert.strictEqual(document.activeElement, form.$('.o_field_widget[name=qux]')[0],
"qux field should have the focus");
- testUtils.fields.many2one.clickOpenDropdown('trululu');
- testUtils.fields.many2one.clickHighlightedItem('trululu');
+ await testUtils.fields.many2one.clickOpenDropdown('trululu');
+ await testUtils.fields.many2one.clickHighlightedItem('trululu');
assert.strictEqual(form.$('.o_field_many2one input').val(), 'first record',
"the one2many field should have the expected value");
form.destroy();
});
- QUnit.test('checkbox in an x2many that triggers an onchange', function (assert) {
+ QUnit.test('checkbox in an x2many that triggers an onchange', async function (assert) {
assert.expect(1);
this.data.partner.onchanges = {
bar: function () { }
};
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -6488,23 +6485,23 @@ QUnit.module('fields', {}, function () {
'</form>',
});
- testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
+ await testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
- testUtils.dom.click(form.$('.o_field_widget[name=bar] input'));
+ await testUtils.dom.click(form.$('.o_field_widget[name=bar] input'));
assert.notOk(form.$('.o_field_widget[name=bar] input').prop('checked'),
"the checkbox should be unticked");
form.destroy();
});
- QUnit.test('one2many with default value: edit line to make it invalid', function (assert) {
+ QUnit.test('one2many with default value: edit line to make it invalid', async function (assert) {
assert.expect(3);
this.data.partner.fields.p.default = [
[0, false, { foo: "coucou", int_field: 5 }],
];
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -6519,9 +6516,9 @@ QUnit.module('fields', {}, function () {
});
// edit the line and enter an invalid value for int_field
- testUtils.dom.click(form.$('.o_data_row .o_data_cell:nth(1)'));
- testUtils.fields.editInput(form.$('.o_field_widget[name=int_field]'), 'e');
- testUtils.dom.click(form.$el);
+ await testUtils.dom.click(form.$('.o_data_row .o_data_cell:nth(1)'));
+ await testUtils.fields.editInput(form.$('.o_field_widget[name=int_field]'), 'e');
+ await testUtils.dom.click(form.$el);
assert.containsOnce(form, '.o_data_row.o_selected_row',
"line should not have been removed and should still be in edition");
@@ -6533,7 +6530,7 @@ QUnit.module('fields', {}, function () {
form.destroy();
});
- QUnit.test('default value for nested one2manys (coming from onchange)', function (assert) {
+ QUnit.test('default value for nested one2manys (coming from onchange)', async function (assert) {
assert.expect(3);
this.data.partner.onchanges.p = function (obj) {
@@ -6543,7 +6540,7 @@ QUnit.module('fields', {}, function () {
];
};
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -6568,17 +6565,17 @@ 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);
+ await testUtils.form.clickSave(form);
form.destroy();
});
- QUnit.test('display correct value after validation error', function (assert) {
+ QUnit.test('display correct value after validation error', async function (assert) {
assert.expect(4);
this.data.partner.onchanges.turtles = function () { };
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -6597,8 +6594,8 @@ QUnit.module('fields', {}, function () {
// 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();
+ // model, the promise is just rejected.
+ return Promise.reject();
}
}
if (args.method === 'write') {
@@ -6615,31 +6612,31 @@ QUnit.module('fields', {}, function () {
"initial text should be correct");
// click and edit value to 'foo', which will trigger onchange
- testUtils.dom.click(form.$('.o_data_row .o_data_cell:nth(0)'));
- testUtils.fields.editInput(form.$('.o_field_widget[name=turtle_foo]'), 'foo');
- testUtils.dom.click(form.$el);
+ await testUtils.dom.click(form.$('.o_data_row .o_data_cell:nth(0)'));
+ await testUtils.fields.editInput(form.$('.o_field_widget[name=turtle_foo]'), 'foo');
+ await testUtils.dom.click(form.$el);
assert.strictEqual(form.$('.o_data_row .o_data_cell:nth(0)').text(), 'foo',
"field should have been changed to foo");
// click and edit value to 'pinky', which trigger a failed onchange
- testUtils.dom.click(form.$('.o_data_row .o_data_cell:nth(0)'));
- testUtils.fields.editInput(form.$('.o_field_widget[name=turtle_foo]'), 'pinky');
- testUtils.dom.click(form.$el);
+ await testUtils.dom.click(form.$('.o_data_row .o_data_cell:nth(0)'));
+ await testUtils.fields.editInput(form.$('.o_field_widget[name=turtle_foo]'), 'pinky');
+ await testUtils.dom.click(form.$el);
assert.strictEqual(form.$('.o_data_row .o_data_cell:nth(0)').text(), 'foo',
"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.
- testUtils.form.clickSave(form);
+ await testUtils.form.clickSave(form);
form.destroy();
});
- QUnit.test('propagate context to sub views', function (assert) {
+ QUnit.test('propagate context to sub views', async function (assert) {
assert.expect(5);
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -6659,14 +6656,14 @@ QUnit.module('fields', {}, function () {
},
viewOptions: { context: { flutter: 'shy' } },
});
- 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);
+ await testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
+ await testUtils.fields.editInput(form.$('input[name="turtle_foo"]'), 'pinky pie');
+ await testUtils.form.clickSave(form);
form.destroy();
});
- QUnit.test('onchange on nested one2manys', function (assert) {
+ QUnit.test('onchange on nested one2manys', async function (assert) {
assert.expect(6);
this.data.partner.onchanges.display_name = function (obj) {
@@ -6681,7 +6678,7 @@ QUnit.module('fields', {}, function () {
}
};
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -6715,30 +6712,30 @@ QUnit.module('fields', {}, function () {
},
});
- testUtils.fields.editInput(form.$('.o_field_widget[name=display_name]'), 'trigger onchange');
+ await testUtils.fields.editInput(form.$('.o_field_widget[name=display_name]'), 'trigger onchange');
assert.strictEqual(form.$('.o_data_cell').text(), 'test',
"should have added the new row to the one2many");
// open the new subrecord to check the value of the nested o2m, and to
// ensure that it will be saved
- testUtils.dom.click(form.$('.o_data_cell:first'));
+ await testUtils.dom.click(form.$('.o_data_cell:first'));
assert.strictEqual($('.modal .o_data_cell').text(), 'test nested',
"should have added the new row to the nested one2many");
- testUtils.dom.clickFirst($('.modal .modal-footer .btn-primary'));
+ await testUtils.dom.clickFirst($('.modal .modal-footer .btn-primary'));
- testUtils.form.clickSave(form);
+ await testUtils.form.clickSave(form);
form.destroy();
});
- QUnit.test('one2many with multiple pages and sequence field', function (assert) {
+ QUnit.test('one2many with multiple pages and sequence field', async function (assert) {
assert.expect(1);
this.data.partner.records[0].turtles = [3, 2, 1];
this.data.partner.onchanges.turtles = function () { };
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -6754,7 +6751,7 @@ QUnit.module('fields', {}, function () {
res_id: 1,
mockRPC: function (route, args) {
if (args.method === 'onchange') {
- return $.when({
+ return Promise.resolve({
value: {
turtles: [
[5],
@@ -6769,19 +6766,19 @@ QUnit.module('fields', {}, function () {
mode: 'edit',
},
});
- testUtils.dom.click(form.$('.o_list_record_remove:first button'));
+ await testUtils.dom.click(form.$('.o_list_record_remove:first button'));
assert.strictEqual(form.$('.o_data_row').text(), 'from onchange',
'onchange has been properly applied');
form.destroy();
});
- QUnit.test('one2many with multiple pages and sequence field, part2', function (assert) {
+ QUnit.test('one2many with multiple pages and sequence field, part2', async function (assert) {
assert.expect(1);
this.data.partner.records[0].turtles = [3, 2, 1];
this.data.partner.onchanges.turtles = function () { };
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -6797,7 +6794,7 @@ QUnit.module('fields', {}, function () {
res_id: 1,
mockRPC: function (route, args) {
if (args.method === 'onchange') {
- return $.when({
+ return Promise.resolve({
value: {
turtles: [
[5],
@@ -6813,20 +6810,20 @@ QUnit.module('fields', {}, function () {
mode: 'edit',
},
});
- testUtils.dom.click(form.$('.o_list_record_remove:first button'));
+ await testUtils.dom.click(form.$('.o_list_record_remove:first button'));
assert.strictEqual(form.$('.o_data_row').text(), 'from onchange id2from onchange id3',
'onchange has been properly applied');
form.destroy();
});
- QUnit.test('one2many with sequence field, override default_get, bottom when inline', function (assert) {
+ QUnit.test('one2many with sequence field, override default_get, bottom when inline', async function (assert) {
assert.expect(2);
this.data.partner.records[0].turtles = [3, 2, 1];
this.data.turtle.fields.turtle_int.default = 10;
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -6852,22 +6849,22 @@ QUnit.module('fields', {}, function () {
// check line is at the correct place
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);
+ await testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
+ await testUtils.fields.editInput(form.$('.o_input[name="turtle_foo"]'), inputText);
+ await testUtils.form.clickSave(form);
assert.strictEqual($('.o_data_cell').text(), "blipyopkawa" + inputText);
form.destroy();
});
- QUnit.test('one2many with sequence field, override default_get, top when inline', function (assert) {
+ QUnit.test('one2many with sequence field, override default_get, top when inline', async function (assert) {
assert.expect(2);
this.data.partner.records[0].turtles = [3, 2, 1];
this.data.turtle.fields.turtle_int.default = 10;
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -6893,22 +6890,22 @@ QUnit.module('fields', {}, function () {
// check line is at the correct place
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);
+ await testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
+ await testUtils.fields.editInput(form.$('.o_input[name="turtle_foo"]'), inputText);
+ await testUtils.form.clickSave(form);
assert.strictEqual($('.o_data_cell').text(), inputText + "blipyopkawa");
form.destroy();
});
- QUnit.test('one2many with sequence field, override default_get, bottom when popup', function (assert) {
+ QUnit.test('one2many with sequence field, override default_get, bottom when popup', async function (assert) {
assert.expect(3);
this.data.partner.records[0].turtles = [3, 2, 1];
this.data.turtle.fields.turtle_int.default = 10;
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -6939,25 +6936,25 @@ QUnit.module('fields', {}, function () {
// check line is at the correct place
var inputText = 'ninja';
- testUtils.dom.click($('.o_field_x2many_list_row_add a'));
- testUtils.fields.editInput($('.o_input[name="turtle_foo"]'), inputText);
- testUtils.dom.click($('.modal .modal-footer .btn-primary:first'));
+ await testUtils.dom.click($('.o_field_x2many_list_row_add a'));
+ await testUtils.fields.editInput($('.o_input[name="turtle_foo"]'), inputText);
+ await testUtils.dom.click($('.modal .modal-footer .btn-primary:first'));
assert.strictEqual($('.o_data_cell').text(), "blipyopkawa" + inputText);
- testUtils.dom.click($('.o_form_button_save'));
+ await testUtils.dom.click($('.o_form_button_save'));
assert.strictEqual($('.o_data_cell').text(), "blipyopkawa" + inputText);
form.destroy();
});
- QUnit.test('one2many with sequence field, override default_get, not last page', function (assert) {
+ QUnit.test('one2many with sequence field, override default_get, not last page', async function (assert) {
assert.expect(1);
this.data.partner.records[0].turtles = [3, 2, 1];
this.data.turtle.fields.turtle_int.default = 10;
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -6979,19 +6976,19 @@ QUnit.module('fields', {}, function () {
// click add a new line
// check turtle_int for new is the current max of the page
- testUtils.dom.click($('.o_field_x2many_list_row_add a'));
+ await testUtils.dom.click($('.o_field_x2many_list_row_add a'));
assert.strictEqual($('.modal .o_input[name="turtle_int"]').val(), '10');
form.destroy();
});
- QUnit.test('one2many with sequence field, override default_get, last page', function (assert) {
+ QUnit.test('one2many with sequence field, override default_get, last page', async function (assert) {
assert.expect(1);
this.data.partner.records[0].turtles = [3, 2, 1];
this.data.turtle.fields.turtle_int.default = 10;
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -7013,12 +7010,12 @@ QUnit.module('fields', {}, function () {
// click add a new line
// check turtle_int for new is the current max of the page +1
- testUtils.dom.click($('.o_field_x2many_list_row_add a'));
+ await testUtils.dom.click($('.o_field_x2many_list_row_add a'));
assert.strictEqual($('.modal .o_input[name="turtle_int"]').val(), '22');
form.destroy();
});
- QUnit.test('one2many with sequence field, fetch name_get from empty list, field text', function (assert) {
+ QUnit.test('one2many with sequence field, fetch name_get from empty list, field text', async function (assert) {
// There was a bug where a RPC would fail because no route was set.
// The scenario is:
// - create a new parent model, which has a one2many
@@ -7043,7 +7040,7 @@ QUnit.module('fields', {}, function () {
relation: 'product'
};
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -7067,11 +7064,11 @@ QUnit.module('fields', {}, function () {
var inputText1 = 'relax';
var inputText2 = 'max';
- testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
- testUtils.fields.editInput(form.$('.o_input[name="turtle_foo"]'), inputText1);
- testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
- testUtils.fields.editInput(form.$('.o_input[name="turtle_foo"]'), inputText2);
- testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
+ await testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
+ await testUtils.fields.editInput(form.$('.o_input[name="turtle_foo"]'), inputText1);
+ await testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
+ await testUtils.fields.editInput(form.$('.o_input[name="turtle_foo"]'), inputText2);
+ await testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
assert.strictEqual($('.o_data_cell:nth-child(2)').text(), inputText1 + inputText2);
@@ -7079,7 +7076,7 @@ QUnit.module('fields', {}, function () {
assert.equal($handles.length, 3, 'There should be 3 sequence handlers');
- testUtils.dom.dragAndDrop($handles.eq(1),
+ await testUtils.dom.dragAndDrop($handles.eq(1),
form.$('tbody tr').first(),
{ position: 'top' }
);
@@ -7089,7 +7086,7 @@ QUnit.module('fields', {}, function () {
form.destroy();
});
- QUnit.test('one2many with several pages, onchange and default order', function (assert) {
+ QUnit.test('one2many with several pages, onchange and default order', async function (assert) {
// This test reproduces a specific scenario where a one2many is displayed
// over several pages, and has a default order such that a record that
// would normally be on page 1 is actually on another page. Moreover,
@@ -7117,7 +7114,7 @@ QUnit.module('fields', {}, function () {
},
};
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: data,
@@ -7145,9 +7142,9 @@ QUnit.module('fields', {}, function () {
"should display two records out of three, in the correct order");
// edit turtle_int field of first row
- testUtils.dom.click(form.$('.o_data_cell:first'));
- testUtils.fields.editInput(form.$('.o_field_widget[name=turtle_int]'), 3);
- testUtils.dom.click(form.$el);
+ await testUtils.dom.click(form.$('.o_data_cell:first'));
+ await testUtils.fields.editInput(form.$('.o_field_widget[name=turtle_int]'), 3);
+ await testUtils.dom.click(form.$el);
assert.strictEqual(form.$('.o_data_cell.foo').text(), 'blipkawa',
"should still display the same two records");
@@ -7163,10 +7160,10 @@ QUnit.module('fields', {}, function () {
form.destroy();
});
- QUnit.test('new record, with one2many with more default values than limit', function (assert) {
+ QUnit.test('new record, with one2many with more default values than limit', async function (assert) {
assert.expect(2);
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -7184,14 +7181,14 @@ QUnit.module('fields', {}, function () {
});
assert.strictEqual(form.$('.o_data_row').text(), 'yopblip',
'data has been properly loaded');
- testUtils.form.clickSave(form);
+ await testUtils.form.clickSave(form);
assert.strictEqual(form.$('.o_data_row').text(), 'yopblip',
'data has been properly saved');
form.destroy();
});
- QUnit.test('add a new line after limit is reached should behave nicely', function (assert) {
+ QUnit.test('add a new line after limit is reached should behave nicely', async function (assert) {
assert.expect(2);
this.data.partner.records[0].turtles = [1, 2, 3];
@@ -7208,7 +7205,7 @@ QUnit.module('fields', {}, function () {
},
};
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -7225,16 +7222,16 @@ QUnit.module('fields', {}, function () {
},
});
- testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
+ await testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
assert.containsN(form, '.o_data_row', 4, 'should have 4 data rows');
- testUtils.fields.editInput(form.$('.o_input[name="turtle_foo"]'), 'a');
+ await testUtils.fields.editInput(form.$('.o_input[name="turtle_foo"]'), 'a');
assert.containsN(form, '.o_data_row', 4,
'should still have 4 data rows (the limit is increased to 4)');
form.destroy();
});
- QUnit.test('onchange in a one2many with non inline view on an existing record', function (assert) {
+ QUnit.test('onchange in a one2many with non inline view on an existing record', async function (assert) {
assert.expect(6);
this.data.partner.fields.sequence = { string: 'Sequence', type: 'integer' };
@@ -7245,7 +7242,7 @@ QUnit.module('fields', {}, function () {
this.data.partner_type.fields.partner_ids = { string: "Partner", type: "one2many", relation: 'partner' };
this.data.partner_type.records[0].partner_ids = [1, 2];
- var form = testUtils.createView({
+ var form = await createView({
View: FormView,
model: 'partner_type',
data: this.data,
@@ -7265,13 +7262,13 @@ QUnit.module('fields', {}, function () {
});
// swap 2 lines in the one2many
- testUtils.dom.dragAndDrop(form.$('.ui-sortable-handle:eq(1)'), form.$('tbody tr').first(),
+ await testUtils.dom.dragAndDrop(form.$('.ui-sortable-handle:eq(1)'), form.$('tbody tr').first(),
{ position: 'top' });
assert.verifySteps(['load_views', 'read', 'read', 'onchange', 'onchange']);
form.destroy();
});
- QUnit.test('onchange in a one2many with non inline view on a new record', function (assert) {
+ QUnit.test('onchange in a one2many with non inline view on a new record', async function (assert) {
assert.expect(8);
this.data.turtle.onchanges = {
@@ -7282,7 +7279,7 @@ QUnit.module('fields', {}, function () {
},
};
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -7300,8 +7297,8 @@ QUnit.module('fields', {}, function () {
});
// add a row and trigger the onchange
- testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
- testUtils.fields.editInput(form.$('.o_data_row .o_field_widget[name=display_name]'), 'a name');
+ await testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
+ await testUtils.fields.editInput(form.$('.o_data_row .o_field_widget[name=display_name]'), 'a name');
assert.strictEqual(form.$('.o_data_row .o_field_widget[name=turtle_int]').val(), "44",
"should have triggered the onchange");
@@ -7318,10 +7315,10 @@ QUnit.module('fields', {}, function () {
form.destroy();
});
- QUnit.test('add a line, edit it and "Save & New"', function (assert) {
+ QUnit.test('add a line, edit it and "Save & New"', async function (assert) {
assert.expect(5);
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -7337,27 +7334,27 @@ QUnit.module('fields', {}, function () {
"there should be no record in the relation");
// add a new record
- testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
- testUtils.fields.editInput($('.modal .o_field_widget'), 'new record');
- testUtils.dom.click($('.modal .modal-footer .btn-primary:first'));
+ await testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
+ await testUtils.fields.editInput($('.modal .o_field_widget'), 'new record');
+ await testUtils.dom.click($('.modal .modal-footer .btn-primary:first'));
assert.strictEqual(form.$('.o_data_row .o_data_cell').text(), 'new record',
"should display the new record");
// reopen freshly added record and edit it
- testUtils.dom.click(form.$('.o_data_row .o_data_cell'));
- testUtils.fields.editInput($('.modal .o_field_widget'), 'new record edited');
+ await testUtils.dom.click(form.$('.o_data_row .o_data_cell'));
+ await testUtils.fields.editInput($('.modal .o_field_widget'), 'new record edited');
// save it, and choose to directly create another record
- testUtils.dom.click($('.modal .modal-footer .btn-primary:nth(1)'));
+ await testUtils.dom.click($('.modal .modal-footer .btn-primary:nth(1)'));
assert.strictEqual($('.modal').length, 1,
"the model should still be open");
assert.strictEqual($('.modal .o_field_widget').text(), '',
"should have cleared the input");
- testUtils.fields.editInput($('.modal .o_field_widget'), 'another new record');
- testUtils.dom.click($('.modal .modal-footer .btn-primary:first'));
+ await testUtils.fields.editInput($('.modal .o_field_widget'), 'another new record');
+ await testUtils.dom.click($('.modal .modal-footer .btn-primary:first'));
assert.strictEqual(form.$('.o_data_row .o_data_cell').text(),
'new record editedanother new record', "should display the two records");
@@ -7365,10 +7362,10 @@ QUnit.module('fields', {}, function () {
form.destroy();
});
- QUnit.test('o2m add a line custom control create editable', function (assert) {
+ QUnit.test('o2m add a line custom control create editable', async function (assert) {
assert.expect(5);
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -7402,25 +7399,25 @@ QUnit.module('fields', {}, function () {
// click add food
// check it's empty
- testUtils.dom.click(form.$('.o_field_x2many_list_row_add a:eq(0)'));
+ await testUtils.dom.click(form.$('.o_field_x2many_list_row_add a:eq(0)'));
assert.strictEqual($('.o_data_cell').text(), "");
// click add pizza
// save the modal
// check it's pizza
- testUtils.dom.click(form.$('.o_field_x2many_list_row_add a:eq(1)'));
+ await 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);
+ await testUtils.dom.click(form.$('.o_field_x2many_list_row_add a:eq(2)'));
+ await testUtils.form.clickSave(form);
assert.strictEqual($('.o_data_cell').text(), "pizzapasta");
form.destroy();
});
- QUnit.test('o2m add a line custom control create non-editable', function (assert) {
+ QUnit.test('o2m add a line custom control create non-editable', async function (assert) {
assert.expect(6);
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -7454,31 +7451,31 @@ QUnit.module('fields', {}, function () {
// click add food
// check it's empty
- testUtils.dom.click(form.$('.o_field_x2many_list_row_add a:eq(0)'));
- testUtils.dom.click($('.modal .modal-footer .btn-primary:first'));
+ await testUtils.dom.click(form.$('.o_field_x2many_list_row_add a:eq(0)'));
+ await testUtils.dom.click($('.modal .modal-footer .btn-primary:first'));
assert.strictEqual($('.o_data_cell').text(), "");
// click add pizza
// save the modal
// check it's pizza
- testUtils.dom.click(form.$('.o_field_x2many_list_row_add a:eq(1)'));
- testUtils.dom.click($('.modal .modal-footer .btn-primary:first'));
+ await testUtils.dom.click(form.$('.o_field_x2many_list_row_add a:eq(1)'));
+ await testUtils.dom.click($('.modal .modal-footer .btn-primary:first'));
assert.strictEqual($('.o_data_cell').text(), "pizza");
// click add pasta
// save the whole record
// check it's pizzapasta
- testUtils.dom.click(form.$('.o_field_x2many_list_row_add a:eq(2)'));
- testUtils.dom.click($('.modal .modal-footer .btn-primary:first'));
+ await testUtils.dom.click(form.$('.o_field_x2many_list_row_add a:eq(2)'));
+ await testUtils.dom.click($('.modal .modal-footer .btn-primary:first'));
assert.strictEqual($('.o_data_cell').text(), "pizzapasta");
form.destroy();
});
- QUnit.test('o2m add a line custom control create align with handle', function (assert) {
+ QUnit.test('o2m add a line custom control create align with handle', async function (assert) {
assert.expect(3);
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -7501,7 +7498,7 @@ QUnit.module('fields', {}, function () {
form.destroy();
});
- QUnit.test('one2many form view with action button', function (assert) {
+ QUnit.test('one2many form view with action button', async function (assert) {
// once the action button is clicked, the record is reloaded (via the
// on_close handler, executed because the python method does not return
// any action, or an ir.action.act_window_close) ; this test ensures that
@@ -7512,7 +7509,7 @@ QUnit.module('fields', {}, function () {
var data = this.data;
data.partner.records[0].p = [2];
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: data,
@@ -7547,21 +7544,21 @@ QUnit.module('fields', {}, function () {
"initial display_name of o2m record should be correct");
// open one2many record in form view
- testUtils.dom.click(form.$('.o_data_cell:first'));
+ await testUtils.dom.click(form.$('.o_data_cell:first'));
assert.strictEqual($('.modal .o_form_view').length, 1,
"should have opened the form view in a dialog");
assert.strictEqual($('.modal .o_form_view .o_data_row').length, 0,
"there should be no record in the many2many");
// click on the action button
- testUtils.dom.click($('.modal .o_form_view button'));
+ await testUtils.dom.click($('.modal .o_form_view button'));
assert.strictEqual($('.modal .o_data_row').length, 1,
"fields in the o2m form view should have been read");
assert.strictEqual($('.modal .o_data_cell').text(), 'gold',
"many2many subrecord should have been fetched");
// save the dialog
- testUtils.dom.click($('.modal .modal-footer .btn-primary'));
+ await testUtils.dom.click($('.modal .modal-footer .btn-primary'));
assert.strictEqual(form.$('.o_data_cell').text(), 'new name',
"fields in the o2m list view should have been read as well");
@@ -7569,7 +7566,7 @@ QUnit.module('fields', {}, function () {
form.destroy();
});
- QUnit.test('onchange affecting inline unopened list view', function (assert) {
+ QUnit.test('onchange affecting inline unopened list view', async function (assert) {
// when we got onchange result for fields of record that were not
// already available because they were in a inline view not already
// opened, in a given configuration the change were applied ignoring
@@ -7605,7 +7602,7 @@ QUnit.module('fields', {}, function () {
},
};
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'user',
data: this.data,
@@ -7627,42 +7624,42 @@ QUnit.module('fields', {}, function () {
});
// add a turtle on second partner
- testUtils.form.clickEdit(form);
- testUtils.dom.click(form.$('.o_data_row:eq(1)'));
- testUtils.dom.click($('.modal .o_field_x2many_list_row_add a'));
+ await testUtils.form.clickEdit(form);
+ await testUtils.dom.click(form.$('.o_data_row:eq(1)'));
+ await testUtils.dom.click($('.modal .o_field_x2many_list_row_add a'));
$('.modal input[name="display_name"]').val('michelangelo').change();
- testUtils.dom.click($('.modal .btn-primary'));
+ await testUtils.dom.click($('.modal .btn-primary'));
// 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);
+ await testUtils.dom.click(form.$('.o_data_row:eq(0)'));
+ await testUtils.dom.click($('.modal .btn-primary'));
+ await testUtils.form.clickSave(form);
assert.strictEqual(numUserOnchange, 2,
'there should 2 and only 2 onchange from closing the partner modal');
- testUtils.dom.click(form.$('.o_data_row:eq(0)'));
+ await testUtils.dom.click(form.$('.o_data_row:eq(0)'));
assert.strictEqual($('.modal .o_data_row').length, 1,
'only 1 turtle for first partner');
assert.strictEqual($('.modal .o_data_row').text(), 'donatello',
'first partner turtle is donatello');
- testUtils.dom.click($('.modal .o_form_button_cancel'));
+ await testUtils.dom.click($('.modal .o_form_button_cancel'));
- testUtils.dom.click(form.$('.o_data_row:eq(1)'));
+ await testUtils.dom.click(form.$('.o_data_row:eq(1)'));
assert.strictEqual($('.modal .o_data_row').length, 1,
'only 1 turtle for second partner');
assert.strictEqual($('.modal .o_data_row').text(), 'michelangelo',
'second partner turtle is michelangelo');
- testUtils.dom.click($('.modal .o_form_button_cancel'));
+ await testUtils.dom.click($('.modal .o_form_button_cancel'));
form.destroy();
});
- QUnit.test('click on URL should not open the record', function (assert) {
+ QUnit.test('click on URL should not open the record', async function (assert) {
assert.expect(2);
this.data.partner.records[0].turtles = [1];
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -7678,20 +7675,20 @@ QUnit.module('fields', {}, function () {
res_id: 1,
});
- testUtils.dom.click(form.$('.o_email_cell a'));
+ await testUtils.dom.click(form.$('.o_email_cell a'));
assert.strictEqual($('.modal .o_form_view').length, 0,
'click should not open the modal');
- testUtils.dom.click(form.$('.o_url_cell a'));
+ await testUtils.dom.click(form.$('.o_url_cell a'));
assert.strictEqual($('.modal .o_form_view').length, 0,
'click should not open the modal');
form.destroy();
});
- QUnit.test('create and edit on m2o in o2m, and press ESCAPE', function (assert) {
+ QUnit.test('create and edit on m2o in o2m, and press ESCAPE', async function (assert) {
assert.expect(4);
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -7707,21 +7704,18 @@ QUnit.module('fields', {}, function () {
},
});
- testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
+ await testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
assert.containsOnce(form, '.o_selected_row',
"should have create a new row in edition");
- testUtils.fields.many2one.clickOpenDropdown('turtle_trululu');
- testUtils.fields.many2one.clickItem('turtle_trululu','Create and Edit...');
+ await testUtils.fields.many2one.clickOpenDropdown('turtle_trululu');
+ await testUtils.fields.many2one.clickItem('turtle_trululu','Create and Edit...');
assert.strictEqual($('.modal .o_form_view').length, 1,
"should have opened a form view in a dialog");
- $('.modal .o_form_view .o_field_widget[name=display_name]').trigger($.Event('keydown', {
- which: $.ui.keyCode.ESCAPE,
- keyCode: $.ui.keyCode.ESCAPE,
- }));
+ await testUtils.fields.triggerKeydown($('.modal .o_form_view .o_field_widget[name=display_name]'), 'escape');
assert.strictEqual($('.modal .o_form_view').length, 0,
"should have closed the dialog");
@@ -7731,13 +7725,13 @@ QUnit.module('fields', {}, function () {
form.destroy();
});
- QUnit.test('one2many add a line should not crash if orderedResIDs is not set', function (assert) {
+ QUnit.test('one2many add a line should not crash if orderedResIDs is not set', async function (assert) {
// There is no assertion, the code will just crash before the bugfix.
assert.expect(0);
this.data.partner.records[0].turtles = [];
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -7761,16 +7755,16 @@ QUnit.module('fields', {}, function () {
},
});
- testUtils.dom.click($('button[name="action_invoice_open"]'));
- testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
+ await testUtils.dom.click($('button[name="action_invoice_open"]'));
+ await testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
form.destroy();
});
- QUnit.test('one2many shortcut tab should not crash when there is no input widget', function (assert) {
+ QUnit.test('one2many shortcut tab should not crash when there is no input widget', async function (assert) {
assert.expect(2);
// create a one2many view which has no input (only 1 textarea in this case)
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -7788,12 +7782,9 @@ QUnit.module('fields', {}, function () {
});
// add a row, fill it, then trigger the tab shortcut
- testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
- testUtils.fields.editAndTrigger(
- form.$('.o_input[name="turtle_foo"]'),
- 'ninja',
- ['input', $.Event('keydown', {which: $.ui.keyCode.TAB, keyCode: $.ui.keyCode.TAB,})]
- );
+ await testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
+ await testUtils.fields.editInput(form.$('.o_input[name="turtle_foo"]'), 'ninja');
+ await testUtils.fields.triggerKeydown(form.$('.o_input[name="turtle_foo"]'), 'tab');
assert.strictEqual(form.$('.o_field_text').text(), 'blipninja',
'current line should be saved');
@@ -7803,15 +7794,15 @@ QUnit.module('fields', {}, function () {
form.destroy();
});
- QUnit.test('one2many with onchange, required field, shortcut enter', function (assert) {
+ QUnit.test('one2many with onchange, required field, shortcut enter', async function (assert) {
assert.expect(5);
this.data.turtle.onchanges = {
turtle_foo: function () { },
};
- var def;
- var form = createView({
+ var prom;
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -7825,7 +7816,7 @@ QUnit.module('fields', {}, function () {
mockRPC: function (route, args) {
var result = this._super.apply(this, arguments);
if (args.method === 'onchange') {
- return $.when(def).then(_.constant(result));
+ return Promise.resolve(prom).then(_.constant(result));
}
return result;
},
@@ -7837,20 +7828,15 @@ QUnit.module('fields', {}, function () {
var value = "hello";
// add a new line
- testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
+ await testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
// we want to add a delay to simulate an onchange
- def = $.Deferred();
+ prom = testUtils.makeTestPromise();
// write something in the field
var $input = form.$('input[name="turtle_foo"]');
- testUtils.fields.editInput($input, value);
-
- // trigger keydown ENTER
- $input.trigger($.Event('keydown', {
- keyCode: $.ui.keyCode.ENTER,
- which: $.ui.keyCode.ENTER,
- }));
+ await testUtils.fields.editInput($input, value);
+ await testUtils.fields.triggerKeydown($input, 'enter');
// check that nothing changed before the onchange finished
assert.strictEqual($input.val(), value, "input content shouldn't change");
@@ -7858,7 +7844,8 @@ QUnit.module('fields', {}, function () {
"should still contain only one row");
// unlock onchange
- def.resolve();
+ prom.resolve();
+ await testUtils.nextTick();
// check the current line is added with the correct content and a new line is editable
assert.strictEqual(form.$('td.o_data_cell').text(), value);
@@ -7869,13 +7856,13 @@ QUnit.module('fields', {}, function () {
form.destroy();
});
- QUnit.test('no deadlock when leaving a one2many line with uncommitted changes', function (assert) {
+ QUnit.test('no deadlock when leaving a one2many line with uncommitted changes', async function (assert) {
// Before unselecting a o2m line, field widgets are asked to commit their changes (new values
// that they wouldn't have sent to the model yet). This test is added alongside a bug fix
// ensuring that we don't end up in a deadlock when a widget actually has some changes to
// commit at that moment.
assert.expect(9);
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -7895,13 +7882,13 @@ QUnit.module('fields', {}, function () {
fieldDebounce: 5000,
});
- testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
+ await testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
- testUtils.fields.editInput(form.$('.o_field_widget[name=turtles] input'), 'some foo value');
+ await 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);
+ await testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
+ await testUtils.form.clickSave(form);
assert.containsOnce(form, '.o_form_readonly',
"form view should be in readonly");
@@ -7919,10 +7906,10 @@ QUnit.module('fields', {}, function () {
form.destroy();
});
- QUnit.test('one2many with extra field from server not in form', function (assert) {
+ QUnit.test('one2many with extra field from server not in form', async function (assert) {
assert.expect(6);
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -7948,20 +7935,20 @@ QUnit.module('fields', {}, function () {
}
});
- testUtils.form.clickEdit(form);
+ await testUtils.form.clickEdit(form);
var x2mList = form.$('.o_field_x2many_list[name=p]');
// Add a record in the list
- testUtils.dom.click(x2mList.find('.o_field_x2many_list_row_add a'));
+ await testUtils.dom.click(x2mList.find('.o_field_x2many_list_row_add a'));
var modal = $('.modal-lg');
var nameInput = modal.find('input.o_input[name=display_name]');
- testUtils.fields.editInput(nameInput, 'michelangelo');
+ await testUtils.fields.editInput(nameInput, 'michelangelo');
// Save the record in the modal (though it is still virtual)
- testUtils.dom.click(modal.find('.btn-primary').first());
+ await testUtils.dom.click(modal.find('.btn-primary').first());
assert.equal(x2mList.find('.o_data_row').length, 1,
'There should be 1 records in the x2m list');
@@ -7974,7 +7961,7 @@ QUnit.module('fields', {}, function () {
'The display name field should have the right value');
// Save the whole thing
- testUtils.form.clickSave(form);
+ await testUtils.form.clickSave(form);
x2mList = form.$('.o_field_x2many_list[name=p]');
@@ -7992,11 +7979,11 @@ QUnit.module('fields', {}, function () {
form.destroy();
});
- QUnit.test('one2many invisible depends on parent field', function (assert) {
+ QUnit.test('one2many invisible depends on parent field', async function (assert) {
assert.expect(4);
this.data.partner.records[0].p = [2];
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -8022,21 +8009,22 @@ QUnit.module('fields', {}, function () {
});
assert.containsN(form, 'th', 2,
"should be 2 columns in the one2many");
- testUtils.form.clickEdit(form);
- testUtils.dom.click(form.$('.o_field_many2one[name="product_id"] input'));
- testUtils.dom.click($('li.ui-menu-item a:contains(xpad)').trigger('mouseenter'));
+ await testUtils.form.clickEdit(form);
+ await testUtils.dom.click(form.$('.o_field_many2one[name="product_id"] input'));
+ await testUtils.dom.click($('li.ui-menu-item a:contains(xpad)').trigger('mouseenter'));
assert.containsOnce(form, 'th',
"should be 1 column when the product_id is set");
- form.$('.o_field_many2one[name="product_id"] input').val('').trigger('keyup');
+ await testUtils.fields.editAndTrigger(form.$('.o_field_many2one[name="product_id"] input'),
+ '', 'keyup');
assert.containsN(form, 'th', 2,
"should be 2 columns in the one2many when product_id is not set");
- testUtils.dom.click(form.$('.o_field_boolean[name="bar"] input'));
+ await testUtils.dom.click(form.$('.o_field_boolean[name="bar"] input'));
assert.containsOnce(form, 'th',
"should be 1 column after the value change");
form.destroy();
});
- QUnit.test('one2many column visiblity depends on onchange of parent field', function (assert) {
+ QUnit.test('one2many column visiblity depends on onchange of parent field', async function (assert) {
assert.expect(3);
this.data.partner.records[0].p = [2];
@@ -8049,7 +8037,7 @@ QUnit.module('fields', {}, function () {
}
};
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -8070,24 +8058,24 @@ QUnit.module('fields', {}, function () {
"should be only 1 column ('foo') in the one2many");
assert.containsOnce(form, '.o_list_view .o_data_row', "should contain one row");
- testUtils.form.clickEdit(form);
+ await testUtils.form.clickEdit(form);
// add a new o2m record
- testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
+ await testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
form.$('.o_field_one2many input:first').focus();
- testUtils.fields.editInput(form.$('.o_field_one2many input:first'), 'New line');
- testUtils.dom.click(form.$el);
+ await testUtils.fields.editInput(form.$('.o_field_one2many input:first'), 'New line');
+ await testUtils.dom.click(form.$el);
assert.containsN(form, 'th', 2, "should be 2 columns('foo' + 'int_field')");
form.destroy();
});
- QUnit.test('one2many column_invisible on view not inline', function (assert) {
+ QUnit.test('one2many column_invisible on view not inline', async function (assert) {
assert.expect(4);
this.data.partner.records[0].p = [2];
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -8114,24 +8102,25 @@ QUnit.module('fields', {}, function () {
});
assert.containsN(form, 'th', 2,
"should be 2 columns in the one2many");
- testUtils.form.clickEdit(form);
- testUtils.dom.click(form.$('.o_field_many2one[name="product_id"] input'));
- testUtils.dom.click($('li.ui-menu-item a:contains(xpad)').trigger('mouseenter'));
+ await testUtils.form.clickEdit(form);
+ await testUtils.dom.click(form.$('.o_field_many2one[name="product_id"] input'));
+ await testUtils.dom.click($('li.ui-menu-item a:contains(xpad)').trigger('mouseenter'));
assert.containsOnce(form, 'th',
"should be 1 column when the product_id is set");
- form.$('.o_field_many2one[name="product_id"] input').val('').trigger('keyup');
+ await testUtils.fields.editAndTrigger(form.$('.o_field_many2one[name="product_id"] input'),
+ '', 'keyup');
assert.containsN(form, 'th', 2,
"should be 2 columns in the one2many when product_id is not set");
- testUtils.dom.click(form.$('.o_field_boolean[name="bar"] input'));
+ await testUtils.dom.click(form.$('.o_field_boolean[name="bar"] input'));
assert.containsOnce(form, 'th',
"should be 1 column after the value change");
form.destroy();
});
- QUnit.test('field context is correctly passed to x2m subviews', function (assert) {
+ QUnit.test('field context is correctly passed to x2m subviews', async function (assert) {
assert.expect(2);
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
diff --git a/addons/web/static/tests/fields/relational_fields_mobile_tests.js b/addons/web/static/tests/fields/relational_fields_mobile_tests.js
index 1f2b2655e02..794a8a89545 100644
--- a/addons/web/static/tests/fields/relational_fields_mobile_tests.js
+++ b/addons/web/static/tests/fields/relational_fields_mobile_tests.js
@@ -52,11 +52,11 @@ QUnit.module('relational_fields', {
QUnit.module('FieldOne2Many');
- QUnit.test('one2many kanban: deletion in mobile', function (assert) {
+ QUnit.test('one2many kanban: deletion in mobile', async function (assert) {
assert.expect(9);
this.data.partner.records[0].p = [1, 2];
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -94,7 +94,7 @@ QUnit.module('relational_fields', {
assert.containsNone(form, '.o_field_one2many .o-kanban-button-new',
'"Create" button should not be visible in readonly');
- testUtils.form.clickEdit(form);
+ await testUtils.form.clickEdit(form);
assert.containsOnce(form, '.o_field_one2many .o-kanban-button-new',
'"Create" button should be visible in edit');
@@ -102,16 +102,16 @@ QUnit.module('relational_fields', {
"should have 2 records");
// open and delete record
- testUtils.dom.click(form.$('.oe_kanban_global_click').first());
+ await testUtils.dom.click(form.$('.oe_kanban_global_click').first());
assert.strictEqual($('.modal .modal-footer .o_btn_remove').length, 1,
'there should be a Remove button in the modal footer');
- testUtils.dom.click($('.modal .modal-footer .o_btn_remove'));
+ await testUtils.dom.click($('.modal .modal-footer .o_btn_remove'));
assert.strictEqual($('.o_modal').length, 0, "there shoul be no more modal");
assert.strictEqual(form.$('.o_kanban_record:not(.o_kanban_ghost)').length, 1,
'should contain 1 records');
// save and check that the correct command has been generated
- testUtils.form.clickSave(form);
+ await testUtils.form.clickSave(form);
form.destroy();
});
});
diff --git a/addons/web/static/tests/fields/relational_fields_tests.js b/addons/web/static/tests/fields/relational_fields_tests.js
index faf3df6f2e8..af64afbb9e4 100644
--- a/addons/web/static/tests/fields/relational_fields_tests.js
+++ b/addons/web/static/tests/fields/relational_fields_tests.js
@@ -1,7 +1,6 @@
odoo.define('web.relational_fields_tests', function (require) {
"use strict";
-var concurrency = require('web.concurrency');
var FormView = require('web.FormView');
var ListView = require('web.ListView');
var relationalFields = require('web.relational_fields');
@@ -147,10 +146,10 @@ QUnit.module('relational_fields', {
}]
},
};
- }
+ },
}, function () {
- QUnit.test('search more pager is reset when doing a new search', function (assert) {
+ QUnit.test('search more pager is reset when doing a new search', async function (assert) {
assert.expect(6);
for(var i = 10; i < 180; i++) {
this.data.partner.records.push({
@@ -159,17 +158,19 @@ QUnit.module('relational_fields', {
});
}
- function stringToEvent ($element, string) {
+ async function stringToEvent ($element, string) {
for (var i = 0; i < string.length; i++) {
var keyAscii = string.charCodeAt(i);
$element.val($element.val()+string[i]);
$element.trigger($.Event('keyup', {which: keyAscii, keyCode:keyAscii}));
+ await testUtils.nextTick();
}
$element.trigger($.Event('keyup', {which: $.ui.keyCode.ENTER, keyCode:$.ui.keyCode.ENTER}));
+ await testUtils.nextTick();
}
this.data.partner.fields.datetime.searchable = true;
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -187,17 +188,18 @@ QUnit.module('relational_fields', {
res_id: 1,
});
- form.$buttons.find('.o_form_button_edit').click();
- var $dropdown = form.$('.o_field_many2one input').autocomplete('widget');
- form.$('.o_field_many2one input').click();
- $dropdown.find('.o_m2o_dropdown_option:contains(Search)').mouseenter().click();
- $('.modal .o_pager_next').click();
+ await testUtils.form.clickEdit(form);
+
+
+ await testUtils.fields.many2one.clickOpenDropdown('trululu');
+ await testUtils.fields.many2one.clickItem('trululu','Search');
+ await testUtils.dom.click($('.modal .o_pager_next'));
assert.strictEqual($('.o_pager_limit').text(), "1173", "there should be 173 records");
assert.strictEqual($('.o_pager_value').text(), "181-160", "should display the second page");
assert.strictEqual($('tr.o_data_row').length, 80, "should display 80 record");
- stringToEvent($('.modal .o_searchview_input'), 'first');
+ await stringToEvent($('.modal .o_searchview_input'), 'first');
assert.strictEqual($('.o_pager_limit').text(), "11", "there should be 1 record");
assert.strictEqual($('.o_pager_value').text(), "11-1", "should display the first page");
@@ -205,7 +207,7 @@ QUnit.module('relational_fields', {
form.destroy();
});
- QUnit.test('do not call name_get if display_name already known', function (assert) {
+ QUnit.test('do not call name_get if display_name already known', async function (assert) {
// default_get only returns the id for many2one fields
// onchange returns an array with the id and the display_name
// thus, when an onchange is performed, there is no need to call
@@ -219,7 +221,7 @@ QUnit.module('relational_fields', {
},
};
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -241,7 +243,7 @@ QUnit.module('relational_fields', {
form.destroy();
});
- QUnit.test('x2many default_order multiple fields', function (assert) {
+ QUnit.test('x2many default_order multiple fields', async function (assert) {
assert.expect(7);
this.data.partner.records = [
@@ -256,7 +258,7 @@ QUnit.module('relational_fields', {
this.data.partner.records[0].p = [1, 7, 4, 5, 2, 6, 3];
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -284,7 +286,7 @@ QUnit.module('relational_fields', {
});
- QUnit.test('one2many from a model that has been sorted', function (assert) {
+ QUnit.test('one2many from a model that has been sorted', async function (assert) {
assert.expect(1);
/* On a standard list view, sort your records by a field
@@ -293,7 +295,7 @@ QUnit.module('relational_fields', {
*/
this.data.partner.records[0].turtles = [3, 2];
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -319,10 +321,10 @@ QUnit.module('relational_fields', {
form.destroy();
});
- QUnit.test('widget many2many_checkboxes in a subview', function (assert) {
+ QUnit.test('widget many2many_checkboxes in a subview', async function (assert) {
assert.expect(2);
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -347,19 +349,19 @@ QUnit.module('relational_fields', {
res_id: 1,
});
- form.$buttons.find('.o_form_button_edit').click();
- form.$('.o_data_cell').click();
+ await testUtils.form.clickEdit(form);
+ await testUtils.dom.click(form.$('.o_data_cell'));
// edit the partner_ids field by (un)checking boxes on the widget
var $firstCheckbox = $('.modal .custom-control-input').first();
- $firstCheckbox.click();
+ await testUtils.dom.click($firstCheckbox);
assert.ok($firstCheckbox.prop('checked'), "the checkbox should be ticked");
var $secondCheckbox = $('.modal .custom-control-input').eq(1);
- $secondCheckbox.click();
+ await testUtils.dom.click($secondCheckbox);
assert.notOk($secondCheckbox.prop('checked'), "the checkbox should be unticked");
form.destroy();
});
- QUnit.test('delete a record while adding another one in a multipage', function (assert) {
+ QUnit.test('delete a record while adding another one in a multipage', async function (assert) {
// in a many2one with at least 2 pages, add a new line. Delete the line above it.
// (the onchange makes it so that the virtualID is inserted in the middle of the currentResIDs.)
// it should load the next line to display it on the page.
@@ -370,7 +372,7 @@ QUnit.module('relational_fields', {
obj.turtles = [[5]].concat(obj.turtles);
};
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -389,12 +391,12 @@ QUnit.module('relational_fields', {
res_id: 1,
});
- form.$buttons.find('.o_form_button_edit').click();
+ await testUtils.form.clickEdit(form);
// add a line (virtual record)
- form.$('.o_field_x2many_list_row_add a').click();
- form.$('.o_input').val('pi').trigger('input');
+ await testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
+ await testUtils.fields.editInput(form.$('.o_input'), 'pi');
// delete the line above it
- form.$('.o_list_record_remove').first().click();
+ await testUtils.dom.click(form.$('.o_list_record_remove').first());
// the next line should be displayed below the newly added one
assert.strictEqual(form.$('.o_data_row').length, 2, "should have 2 records");
assert.strictEqual(form.$('.o_data_row .o_data_cell:first-child').text(), 'pikawa',
@@ -403,7 +405,7 @@ QUnit.module('relational_fields', {
form.destroy();
});
- QUnit.test('one2many, onchange, edition and multipage...', function (assert) {
+ QUnit.test('one2many, onchange, edition and multipage...', async function (assert) {
assert.expect(7);
this.data.partner.onchanges = {
@@ -414,7 +416,7 @@ QUnit.module('relational_fields', {
this.data.partner.records[0].turtles = [1,2,3];
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -434,8 +436,8 @@ QUnit.module('relational_fields', {
mode: 'edit',
},
});
- form.$('.o_field_x2many_list_row_add a').click();
- form.$('.o_field_x2many_list_row_add a').click();
+ await testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
+ await testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
assert.verifySteps([
'read partner',
@@ -448,7 +450,7 @@ QUnit.module('relational_fields', {
form.destroy();
});
- QUnit.test('onchange on unloaded record clearing posterious change', function (assert) {
+ QUnit.test('onchange on unloaded record clearing posterious change', async function (assert) {
// when we got onchange result for fields of record that were not
// already available because they were in a inline view not already
// opened, in a given configuration the change were applied ignoring
@@ -480,7 +482,7 @@ QUnit.module('relational_fields', {
},
};
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'user',
data: this.data,
@@ -503,47 +505,48 @@ QUnit.module('relational_fields', {
});
// open first partner and change turtle name
- form.$buttons.find('.o_form_button_edit').click();
- form.$('.o_data_row:eq(0)').click();
- $('.modal .o_data_cell:eq(0)').click();
- $('.modal input[name="display_name"]').val('Donatello').change();
- $('.modal .btn-primary').click();
-
- // open second partner and add a turtle
- form.$('.o_data_row:eq(1)').click();
- $('.modal .o_field_x2many_list_row_add a').click();
- $('.modal input[name="display_name"]').val('Michelangelo').change();
- $('.modal .btn-primary').click();
+ await testUtils.form.clickEdit(form);
+ await testUtils.dom.click(form.$('.o_data_row:eq(0)'));
+ await testUtils.dom.click($('.modal .o_data_cell:eq(0)'));
+ await testUtils.fields.editAndTrigger($('.modal input[name="display_name"]'),
+ 'Donatello', 'change');
+ await testUtils.dom.click($('.modal .btn-primary'));
+
+ await testUtils.dom.click(form.$('.o_data_row:eq(1)'));
+ await testUtils.dom.click($('.modal .o_field_x2many_list_row_add a'));
+ await testUtils.fields.editAndTrigger($('.modal input[name="display_name"]'),
+ 'Michelangelo', 'change');
+ await testUtils.dom.click($('.modal .btn-primary'));
assert.strictEqual(numUserOnchange, 2,
'there should 2 and only 2 onchange from closing the partner modal');
// check first record still has change
- form.$('.o_data_row:eq(0)').click();
+ await testUtils.dom.click(form.$('.o_data_row:eq(0)'));
assert.strictEqual($('.modal .o_data_row').length, 1,
'only 1 turtle for first partner');
assert.strictEqual($('.modal .o_data_row').text(), 'Donatello',
'first partner turtle is Donatello');
- $('.modal .o_form_button_cancel').click();
+ await testUtils.dom.click($('.modal .o_form_button_cancel'));
// check second record still has changes
- form.$('.o_data_row:eq(1)').click();
+ await testUtils.dom.click(form.$('.o_data_row:eq(1)'));
assert.strictEqual($('.modal .o_data_row').length, 1,
'only 1 turtle for second partner');
assert.strictEqual($('.modal .o_data_row').text(), 'Michelangelo',
'second partner turtle is Michelangelo');
- $('.modal .o_form_button_cancel').click();
+ await testUtils.dom.click($('.modal .o_form_button_cancel'));
form.destroy();
});
- QUnit.test('quickly switch between pages in one2many list', function (assert) {
+ QUnit.test('quickly switch between pages in one2many list', async function (assert) {
assert.expect(2);
this.data.partner.records[0].turtles = [1, 2, 3];
- var readDefs = [$.when(), $.Deferred(), $.Deferred()];
- var form = createView({
+ var readDefs = [Promise.resolve(), testUtils.makeTestPromise(), testUtils.makeTestPromise()];
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -558,34 +561,35 @@ QUnit.module('relational_fields', {
var result = this._super.apply(this, arguments);
if (args.method === 'read') {
var recordID = args.args[0][0];
- return $.when(readDefs[recordID - 1]).then(_.constant(result));
+ return Promise.resolve(readDefs[recordID - 1]).then(_.constant(result));
}
return result;
},
res_id: 1,
});
- form.$('.o_field_widget[name=turtles] .o_pager_next').click();
- form.$('.o_field_widget[name=turtles] .o_pager_next').click();
+ await testUtils.dom.click(form.$('.o_field_widget[name=turtles] .o_pager_next'));
+ await testUtils.dom.click(form.$('.o_field_widget[name=turtles] .o_pager_next'));
readDefs[1].resolve();
-
+ await testUtils.nextTick();
assert.strictEqual(form.$('.o_field_widget[name=turtles] .o_data_cell').text(), 'donatello');
readDefs[2].resolve();
+ await testUtils.nextTick();
assert.strictEqual(form.$('.o_field_widget[name=turtles] .o_data_cell').text(), 'raphael');
form.destroy();
});
- QUnit.test('many2many read, field context is properly sent', function (assert) {
+ QUnit.test('many2many read, field context is properly sent', async function (assert) {
assert.expect(4);
this.data.partner.fields.timmy.context = {hello: 'world'};
this.data.partner.records[0].timmy = [12];
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -603,18 +607,20 @@ QUnit.module('relational_fields', {
assert.verifySteps(['world']);
- form.$buttons.find('.o_form_button_edit').click();
+ await testUtils.form.clickEdit(form);
var $m2mInput = form.$('.o_field_many2manytags input');
$m2mInput.click();
+ await testUtils.nextTick();
$m2mInput.autocomplete('widget').find('li:first()').click();
- assert.verifySteps(['world', 'world']);
+ await testUtils.nextTick();
+ assert.verifySteps(['world']);
form.destroy();
});
QUnit.module('FieldStatus');
- QUnit.test('static statusbar widget on many2one field', function (assert) {
+ QUnit.test('static statusbar widget on many2one field', async function (assert) {
assert.expect(5);
this.data.partner.fields.trululu.domain = "[('bar', '=', True)]";
@@ -622,7 +628,7 @@ QUnit.module('relational_fields', {
var count = 0;
var nb_fields_fetched;
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -651,10 +657,10 @@ QUnit.module('relational_fields', {
form.destroy();
});
- QUnit.test('static statusbar widget on many2one field with domain', function (assert) {
+ QUnit.test('static statusbar widget on many2one field with domain', async function (assert) {
assert.expect(1);
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -675,10 +681,10 @@ QUnit.module('relational_fields', {
form.destroy();
});
- QUnit.test('clickable statusbar widget on many2one field', function (assert) {
+ QUnit.test('clickable statusbar widget on many2one field', async function (assert) {
assert.expect(5);
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -696,7 +702,7 @@ QUnit.module('relational_fields', {
assert.containsN(form, '.o_statusbar_status button.btn-secondary:not(.dropdown-toggle):not(:disabled)', 2);
var $clickable = form.$('.o_statusbar_status button.btn-secondary:not(.dropdown-toggle):not(:disabled)');
- testUtils.dom.click($clickable.last()); // (last is visually the first here (css))
+ await testUtils.dom.click($clickable.last()); // (last is visually the first here (css))
assert.hasClass(form.$('.o_statusbar_status button[data-value="1"]'), "btn-primary");
assert.hasClass(form.$('.o_statusbar_status button[data-value="1"]'), "disabled");
@@ -704,11 +710,11 @@ QUnit.module('relational_fields', {
form.destroy();
});
- QUnit.test('statusbar with no status', function (assert) {
+ QUnit.test('statusbar with no status', async function (assert) {
assert.expect(2);
this.data.product.records = [];
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -725,12 +731,12 @@ QUnit.module('relational_fields', {
form.destroy();
});
- QUnit.test('statusbar with domain but no value (create mode)', function (assert) {
+ QUnit.test('statusbar with domain but no value (create mode)', async function (assert) {
assert.expect(1);
this.data.partner.fields.trululu.domain = "[('bar', '=', True)]";
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -745,12 +751,12 @@ QUnit.module('relational_fields', {
form.destroy();
});
- QUnit.test('clickable statusbar should change m2o fetching domain in edit mode', function (assert) {
+ QUnit.test('clickable statusbar should change m2o fetching domain in edit mode', async function (assert) {
assert.expect(2);
this.data.partner.fields.trululu.domain = "[('bar', '=', True)]";
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -762,20 +768,20 @@ QUnit.module('relational_fields', {
config: {device: {isMobile: false}},
});
- testUtils.form.clickEdit(form);
+ await testUtils.form.clickEdit(form);
assert.containsN(form, '.o_statusbar_status button:not(.dropdown-toggle)', 3);
- testUtils.dom.click(form.$('.o_statusbar_status button:not(.dropdown-toggle)').last());
+ await testUtils.dom.click(form.$('.o_statusbar_status button:not(.dropdown-toggle)').last());
assert.containsN(form, '.o_statusbar_status button:not(.dropdown-toggle)', 2);
form.destroy();
});
- QUnit.test('statusbar fold_field option and statusbar_visible attribute', function (assert) {
+ QUnit.test('statusbar fold_field option and statusbar_visible attribute', async function (assert) {
assert.expect(2);
this.data.partner.records[0].bar = false;
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -788,7 +794,7 @@ QUnit.module('relational_fields', {
config: {device: {isMobile: false}},
});
- testUtils.form.clickEdit(form);
+ await testUtils.form.clickEdit(form);
assert.containsOnce(form, '.o_statusbar_status:first .dropdown-menu button.disabled');
assert.containsOnce(form, '.o_statusbar_status:last button.disabled');
@@ -796,14 +802,14 @@ QUnit.module('relational_fields', {
form.destroy();
});
- QUnit.test('statusbar with dynamic domain', function (assert) {
+ QUnit.test('statusbar with dynamic domain', async function (assert) {
assert.expect(5);
this.data.partner.fields.trululu.domain = "[('int_field', '>', qux)]";
this.data.partner.records[2].int_field = 0;
var rpcCount = 0;
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -823,14 +829,14 @@ QUnit.module('relational_fields', {
config: {device: {isMobile: false}},
});
- testUtils.form.clickEdit(form);
+ await testUtils.form.clickEdit(form);
assert.containsN(form, '.o_statusbar_status button.disabled', 3);
assert.strictEqual(rpcCount, 1, "should have done 1 search_read rpc");
- testUtils.fields.editInput(form.$('input[name=qux]'), 9.5);
+ await testUtils.fields.editInput(form.$('input[name=qux]'), 9.5);
assert.containsN(form, '.o_statusbar_status button.disabled', 2);
assert.strictEqual(rpcCount, 2, "should have done 1 more search_read rpc");
- testUtils.fields.editInput(form.$('input[name=qux]'), "hey");
+ await testUtils.fields.editInput(form.$('input[name=qux]'), "hey");
assert.strictEqual(rpcCount, 2, "should not have done 1 more search_read rpc");
form.destroy();
@@ -838,14 +844,14 @@ QUnit.module('relational_fields', {
QUnit.module('FieldSelection');
- QUnit.test('widget selection in a list view', function (assert) {
+ QUnit.test('widget selection in a list view', async function (assert) {
assert.expect(3);
this.data.partner.records.forEach(function (r) {
r.color = 'red';
});
- var list = createView({
+ var list = await createView({
View: ListView,
model: 'partner',
data: this.data,
@@ -856,7 +862,7 @@ QUnit.module('relational_fields', {
assert.strictEqual(list.$('td:contains(Red)').length, 3,
"should have 3 rows with correct value");
- testUtils.dom.click(list.$('td:contains(Red):first'));
+ await testUtils.dom.click(list.$('td:contains(Red):first'));
var $td = list.$('tbody tr.o_selected_row td:not(.o_list_record_selector)');
@@ -865,15 +871,15 @@ QUnit.module('relational_fields', {
list.destroy();
});
- QUnit.test('widget selection, edition and on many2one field', function (assert) {
- assert.expect(18);
+ QUnit.test('widget selection, edition and on many2one field', async function (assert) {
+ assert.expect(19);
this.data.partner.onchanges = {product_id: function () {}};
this.data.partner.records[0].product_id = 37;
this.data.partner.records[0].trululu = false;
var count = 0;
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -898,7 +904,7 @@ QUnit.module('relational_fields', {
assert.strictEqual(form.$('.o_field_widget[name=color]').text(), 'Red',
"should have rendered the selection field correctly");
- testUtils.form.clickEdit(form);
+ await testUtils.form.clickEdit(form);
assert.containsN(form.$('.o_form_view'), 'select', 3);
assert.containsOnce(form, 'select[name="product_id"] option:contains(xphone)',
@@ -909,7 +915,7 @@ QUnit.module('relational_fields', {
"should have correct product_id value");
assert.strictEqual(form.$('select[name="trululu"]').val(), "false",
"should not have any value in trululu field");
- testUtils.fields.editSelect(form.$('select[name="product_id"]'), 41);
+ await testUtils.fields.editSelect(form.$('select[name="product_id"]'), 41);
assert.strictEqual(form.$('select[name="product_id"]').val(), "41",
"should have a value of xphone");
@@ -919,12 +925,14 @@ QUnit.module('relational_fields', {
assert.verifySteps(['read', 'name_search', 'name_search', 'onchange']);
count = 0;
- form.reload();
+ await form.reload();
assert.strictEqual(count, 1, "should not reload product_id relation");
+ assert.verifySteps(['read']);
+
form.destroy();
});
- QUnit.test('unset selection field with 0 as key', function (assert) {
+ QUnit.test('unset selection field with 0 as key', async function (assert) {
// The server doesn't make a distinction between false value (the field
// is unset), and selection 0, as in that case the value it returns is
// false. So the client must convert false to value 0 if it exists.
@@ -935,7 +943,7 @@ QUnit.module('relational_fields', {
selection: [[0, "Value O"], [1, "Value 1"]],
};
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -953,7 +961,7 @@ QUnit.module('relational_fields', {
form.destroy();
});
- QUnit.test('unset selection field with string keys', function (assert) {
+ QUnit.test('unset selection field with string keys', async function (assert) {
// The server doesn't make a distinction between false value (the field
// is unset), and selection 0, as in that case the value it returns is
// false. So the client must convert false to value 0 if it exists. In
@@ -965,7 +973,7 @@ QUnit.module('relational_fields', {
selection: [['0', "Value O"], ['1', "Value 1"]],
};
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -983,10 +991,10 @@ QUnit.module('relational_fields', {
form.destroy();
});
- QUnit.test('unset selection on a many2one field', function (assert) {
+ QUnit.test('unset selection on a many2one field', async function (assert) {
assert.expect(1);
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -1006,18 +1014,18 @@ QUnit.module('relational_fields', {
},
});
- testUtils.fields.editSelect(form.$('.o_form_view select'), 'false');
- testUtils.form.clickSave(form);
+ await testUtils.fields.editSelect(form.$('.o_form_view select'), 'false');
+ await testUtils.form.clickSave(form);
form.destroy();
});
- QUnit.test('field selection with many2ones and special characters', function (assert) {
+ QUnit.test('field selection with many2ones and special characters', async function (assert) {
assert.expect(1);
// edit the partner with id=4
this.data.partner.records[2].display_name = '<span>hey</span>';
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -1032,7 +1040,7 @@ QUnit.module('relational_fields', {
form.destroy();
});
- QUnit.test('widget selection on a many2one: domain updated by an onchange', function (assert) {
+ QUnit.test('widget selection on a many2one: domain updated by an onchange', async function (assert) {
assert.expect(4);
this.data.partner.onchanges = {
@@ -1040,7 +1048,7 @@ QUnit.module('relational_fields', {
};
var domain = [];
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -1052,7 +1060,7 @@ QUnit.module('relational_fields', {
mockRPC: function (route, args) {
if (args.method === 'onchange') {
domain = [['id', 'in', [10]]];
- return $.when({
+ return Promise.resolve({
domain: {
trululu: domain,
}
@@ -1073,7 +1081,7 @@ QUnit.module('relational_fields', {
"should be 4 options in the selection");
// trigger an onchange that will update the domain
- testUtils.fields.editInput(form.$('.o_field_widget[name=int_field]'), 2);
+ await testUtils.fields.editInput(form.$('.o_field_widget[name=int_field]'), 2);
assert.containsOnce(form, '.o_field_widget[name=trululu] option',
"should be 1 option in the selection");
@@ -1081,7 +1089,7 @@ QUnit.module('relational_fields', {
form.destroy();
});
- QUnit.test('required selection widget should not have blank option', function (assert) {
+ QUnit.test('required selection widget should not have blank option', async function (assert) {
assert.expect(3);
this.data.partner.fields.feedback_value = {
@@ -1091,7 +1099,7 @@ QUnit.module('relational_fields', {
default: 'good',
string: 'Good'
};
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -1102,14 +1110,14 @@ QUnit.module('relational_fields', {
res_id: 1
});
- testUtils.form.clickEdit(form);
+ await testUtils.form.clickEdit(form);
assert.strictEqual(form.$('.o_field_widget[name=color]')[0].options.length, 3,
"non required selection field must have 3 options 1 blank option and 2 value options");
assert.strictEqual(form.$('.o_field_widget[name=feedback_value]')[0].options.length, 2,
"should have only 2 options without blank option");
// change value to update widget modifier values
- testUtils.fields.editSelect(form.$('.o_field_widget[name=feedback_value]'), '"bad"');
+ await testUtils.fields.editSelect(form.$('.o_field_widget[name=feedback_value]'), '"bad"');
assert.strictEqual(form.$('.o_field_widget[name=color]')[0].options.length, 2,
"should have only 2 options");
@@ -1118,11 +1126,11 @@ QUnit.module('relational_fields', {
QUnit.module('FieldMany2ManyTags');
- QUnit.test('fieldmany2many tags with and without color', function (assert) {
+ QUnit.test('fieldmany2many tags with and without color', async function (assert) {
assert.expect(5);
this.data.partner.fields.partner_ids = {string: "Partner", type: "many2many", relation: 'partner'};
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -1141,29 +1149,29 @@ QUnit.module('relational_fields', {
});
// add a tag on field partner_ids
- testUtils.fields.many2one.clickOpenDropdown('partner_ids');
- testUtils.fields.many2one.clickHighlightedItem('partner_ids');
+ await testUtils.fields.many2one.clickOpenDropdown('partner_ids');
+ await testUtils.fields.many2one.clickHighlightedItem('partner_ids');
// add a tag on field timmy
- testUtils.fields.many2one.clickOpenDropdown('timmy');
+ await testUtils.fields.many2one.clickOpenDropdown('timmy');
var $input = form.$('.o_field_many2manytags[name="timmy"] input');
assert.strictEqual($input.autocomplete('widget').find('li').length, 3,
- "autocomplete dropdown should have 3 entries (2 values + 'Search and Edit...')");
- testUtils.fields.many2one.clickHighlightedItem('timmy');
+ "autocomplete dropdown should have 3 entries (2 values + 'Search and Edit...')");
+ await testUtils.fields.many2one.clickHighlightedItem('timmy');
assert.containsOnce(form, '.o_field_many2manytags[name="timmy"] .badge',
"should contain 1 tag");
- assert.ok(form.$('.o_field_many2manytags[name="timmy"] .badge:contains("gold")').length,
+ assert.containsOnce(form, '.o_field_many2manytags[name="timmy"] .badge:contains("gold")',
"should contain newly added tag 'gold'");
form.destroy();
});
- QUnit.test('fieldmany2many tags with color: rendering and edition', function (assert) {
+ QUnit.test('fieldmany2many tags with color: rendering and edition', async function (assert) {
assert.expect(28);
this.data.partner.records[0].timmy = [12, 14];
this.data.partner_type.records.push({id: 13, display_name: "red", color: 8});
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -1194,7 +1202,7 @@ QUnit.module('relational_fields', {
assert.strictEqual(form.$('.badge:first()').data('color'), 2,
'should have correctly fetched the color');
- testUtils.form.clickEdit(form);
+ await testUtils.form.clickEdit(form);
assert.containsN(form, '.o_field_many2manytags .badge .dropdown-toggle', 2,
"should still contain 2 tags in edit mode");
@@ -1205,12 +1213,12 @@ QUnit.module('relational_fields', {
// add an other existing tag
var $input = form.$('.o_field_many2manytags input');
- testUtils.fields.many2one.clickOpenDropdown('timmy');
+ await testUtils.fields.many2one.clickOpenDropdown('timmy');
assert.strictEqual($input.autocomplete('widget').find('li').length, 1,
"autocomplete dropdown should have 1 entry");
assert.strictEqual($input.autocomplete('widget').find('li a:contains("red")').length, 1,
"autocomplete dropdown should contain 'red'");
- testUtils.fields.many2one.clickHighlightedItem('timmy');
+ await testUtils.fields.many2one.clickHighlightedItem('timmy');
assert.containsN(form, '.o_field_many2manytags .badge .dropdown-toggle', 3,
"should contain 3 tags");
assert.ok(form.$('.o_field_many2manytags .badge .dropdown-toggle:contains("red")').length,
@@ -1219,34 +1227,34 @@ QUnit.module('relational_fields', {
"should have fetched the color of added tag");
// remove tag with id 14
- testUtils.dom.click(form.$('.o_field_many2manytags .badge[data-id=14] .o_delete'));
+ await testUtils.dom.click(form.$('.o_field_many2manytags .badge[data-id=14] .o_delete'));
assert.containsN(form, '.o_field_many2manytags .badge .dropdown-toggle', 2,
"should contain 2 tags");
assert.ok(!form.$('.o_field_many2manytags .badge .dropdown-toggle:contains("silver")').length,
"should not contain tag 'silver' anymore");
// save the record (should do the write RPC with the correct commands)
- testUtils.form.clickSave(form);
+ await testUtils.form.clickSave(form);
// checkbox 'Hide in Kanban'
$input = form.$('.o_field_many2manytags .badge[data-id=13] .dropdown-toggle'); // selects 'red' tag
- testUtils.dom.click($input);
+ await testUtils.dom.click($input);
var $checkBox = form.$('.o_field_many2manytags .badge[data-id=13] .custom-checkbox input');
assert.strictEqual($checkBox.length, 1, "should have a checkbox in the colorpicker dropdown menu");
assert.notOk($checkBox.is(':checked'), "should have unticked checkbox in colorpicker dropdown menu");
- testUtils.fields.editAndTrigger($checkBox, null,['mouseenter','mousedown']);
+ await testUtils.fields.editAndTrigger($checkBox, null,['mouseenter','mousedown']);
$input = form.$('.o_field_many2manytags .badge[data-id=13] .dropdown-toggle'); // refresh
- testUtils.dom.click($input);
+ await testUtils.dom.click($input);
$checkBox = form.$('.o_field_many2manytags .badge[data-id=13] .custom-checkbox input'); // refresh
assert.equal($input.parent().data('color'), "0", "should become transparent when toggling on checkbox");
assert.ok($checkBox.is(':checked'), "should have a ticked checkbox in colorpicker dropdown menu after mousedown");
- testUtils.fields.editAndTrigger($checkBox, null,['mouseenter','mousedown']);
+ await testUtils.fields.editAndTrigger($checkBox, null,['mouseenter','mousedown']);
$input = form.$('.o_field_many2manytags .badge[data-id=13] .dropdown-toggle'); // refresh
- testUtils.dom.click($input);
+ await testUtils.dom.click($input);
$checkBox = form.$('.o_field_many2manytags .badge[data-id=13] .custom-checkbox input'); // refresh
assert.equal($input.parent().data('color'), "8", "should revert to old color when toggling off checkbox");
assert.notOk($checkBox.is(':checked'), "should have an unticked checkbox in colorpicker dropdown menu after 2nd click");
@@ -1257,14 +1265,14 @@ QUnit.module('relational_fields', {
form.destroy();
});
- QUnit.test('fieldmany2many tags view a domain', function (assert) {
+ QUnit.test('fieldmany2many tags view a domain', async function (assert) {
assert.expect(7);
this.data.partner.fields.timmy.domain = [['id', '<', 50]];
this.data.partner.records[0].timmy = [12];
this.data.partner_type.records.push({id: 99, display_name: "red", color: 8});
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -1276,7 +1284,7 @@ QUnit.module('relational_fields', {
if (args.method === 'name_search') {
assert.deepEqual(args.kwargs.args, [['id', '<', 50], ['id', 'not in', [12]]],
"domain sent to name_search should be correct");
- return $.when([[14, 'silver']]);
+ return Promise.resolve([[14, 'silver']]);
}
return this._super.apply(this, arguments);
}
@@ -1286,16 +1294,16 @@ QUnit.module('relational_fields', {
assert.ok(form.$('.badge:contains(gold)').length,
'should have fetched and rendered gold partner tag');
- testUtils.form.clickEdit(form);
+ await testUtils.form.clickEdit(form);
// add an other existing tag
var $input = form.$('.o_field_many2manytags input');
- testUtils.fields.many2one.clickOpenDropdown('timmy');
+ await testUtils.fields.many2one.clickOpenDropdown('timmy');
assert.strictEqual($input.autocomplete('widget').find('li').length, 1,
"autocomplete dropdown should have 1 entry");
assert.strictEqual($input.autocomplete('widget').find('li a:contains("silver")').length, 1,
"autocomplete dropdown should contain 'silver'");
- testUtils.fields.many2one.clickHighlightedItem('timmy');
+ await testUtils.fields.many2one.clickHighlightedItem('timmy');
assert.containsN(form, '.o_field_many2manytags .badge', 2,
"should contain 2 tags");
assert.ok(form.$('.o_field_many2manytags .badge:contains("silver")').length,
@@ -1304,10 +1312,10 @@ QUnit.module('relational_fields', {
form.destroy();
});
- QUnit.test('fieldmany2many tags in a new record', function (assert) {
+ QUnit.test('fieldmany2many tags in a new record', async function (assert) {
assert.expect(7);
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -1326,10 +1334,10 @@ QUnit.module('relational_fields', {
});
assert.hasClass(form.$('.o_form_view'),'o_form_editable', "form should be in edit mode");
- testUtils.fields.many2one.clickOpenDropdown('timmy');
+ await testUtils.fields.many2one.clickOpenDropdown('timmy');
assert.strictEqual(form.$('.o_field_many2manytags input').autocomplete('widget').find('li').length, 3,
"autocomplete dropdown should have 3 entries (2 values + 'Search and Edit...')");
- testUtils.fields.many2one.clickHighlightedItem('timmy');
+ await testUtils.fields.many2one.clickHighlightedItem('timmy');
assert.containsOnce(form, '.o_field_many2manytags .badge',
"should contain 1 tag");
@@ -1337,18 +1345,18 @@ QUnit.module('relational_fields', {
"should contain newly added tag 'gold'");
// save the record (should do the write RPC with the correct commands)
- testUtils.form.clickSave(form);
+ await testUtils.form.clickSave(form);
form.destroy();
});
- QUnit.test('fieldmany2many tags: update color', function (assert) {
+ QUnit.test('fieldmany2many tags: update color', async function (assert) {
assert.expect(5);
this.data.partner.records[0].timmy = [12, 14];
this.data.partner_type.records[0].color = 0;
var color;
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -1371,28 +1379,30 @@ QUnit.module('relational_fields', {
// Update the color in readonly
color = 1;
- testUtils.dom.click(form.$('.badge:first() .dropdown-toggle'));
- $('.o_colorpicker a[data-color="' + color + '"]').trigger('mousedown'); // choose color 1
+ await testUtils.dom.click(form.$('.badge:first() .dropdown-toggle'));
+ await testUtils.dom.triggerEvents($('.o_colorpicker a[data-color="' + color + '"]'), ['mousedown']);
+ await testUtils.nextTick();
assert.strictEqual(form.$('.badge:first()').data('color'), color,
'should have correctly updated the color (in readonly)');
// Update the color in edit
color = 6;
- testUtils.form.clickEdit(form);
- testUtils.dom.click(form.$('.badge:first() .dropdown-toggle'));
- $('.o_colorpicker a[data-color="' + color + '"]').trigger('mousedown'); // choose color 6
+ await testUtils.form.clickEdit(form);
+ await testUtils.dom.click(form.$('.badge:first() .dropdown-toggle'));
+ await testUtils.dom.triggerEvents($('.o_colorpicker a[data-color="' + color + '"]'), ['mousedown']); // choose color 6
+ await testUtils.nextTick();
assert.strictEqual(form.$('.badge:first()').data('color'), color,
'should have correctly updated the color (in edit)');
form.destroy();
});
- QUnit.test('fieldmany2many tags in editable list', function (assert) {
+ QUnit.test('fieldmany2many tags in editable list', async function (assert) {
assert.expect(7);
this.data.partner.records[0].timmy = [12];
- var list = createView({
+ var list = await createView({
View: ListView,
model: 'partner',
data: this.data,
@@ -1414,20 +1424,20 @@ QUnit.module('relational_fields', {
"m2m field should contain one tag");
// edit first row
- testUtils.dom.click(list.$('.o_data_row:first td:nth(2)'));
+ await testUtils.dom.click(list.$('.o_data_row:first td:nth(2)'));
var $m2o = list.$('.o_data_row:first .o_field_many2manytags .o_field_many2one');
assert.strictEqual($m2o.length, 1, "a many2one widget should have been instantiated");
// add a tag
- testUtils.fields.many2one.clickOpenDropdown('timmy');
- testUtils.fields.many2one.clickHighlightedItem('timmy');
+ await testUtils.fields.many2one.clickOpenDropdown('timmy');
+ await testUtils.fields.many2one.clickHighlightedItem('timmy');
assert.containsN(list, '.o_data_row:first .o_field_many2manytags .badge', 2,
"m2m field should contain 2 tags");
// leave edition
- testUtils.dom.click(list.$('.o_data_row:nth(1) td:nth(2)'));
+ await testUtils.dom.click(list.$('.o_data_row:nth(1) td:nth(2)'));
assert.containsN(list, '.o_data_row:first .o_field_many2manytags .badge', 2,
"m2m field should contain 2 tags");
@@ -1457,9 +1467,8 @@ QUnit.module('relational_fields', {
id: 10,
display_name: "Partner 9",
});
-
this.data.partner.fields.datetime.searchable = true;
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -1482,23 +1491,23 @@ QUnit.module('relational_fields', {
mode: 'edit',
},
});
- testUtils.fields.many2one.clickOpenDropdown('trululu');
+ await testUtils.fields.many2one.clickOpenDropdown('trululu');
await testUtils.fields.many2one.clickItem('trululu', 'Search');
+ await testUtils.dom.click($('.modal .o_search_options .fa-bars'));
+ await testUtils.dom.click($('.modal .o_search_options .o_group_by_menu a:contains(Bar)'));
- testUtils.dom.click($('.modal .o_search_options .fa-bars'));
- testUtils.dom.click($('.modal .o_search_options .o_group_by_menu a:contains(Bar)'));
+ await testUtils.dom.click($('.modal .o_group_header:first'));
- testUtils.dom.click($('.modal .o_group_header:first'));
assert.strictEqual($('.modal tbody:nth(1) .o_data_row').length, 7,
"should display 7 records in the first page");
- testUtils.dom.click($('.modal .o_group_header:first .o_pager_next'));
+ await testUtils.dom.click($('.modal .o_group_header:first .o_pager_next'));
assert.strictEqual($('.modal tbody:nth(1) .o_data_row').length, 1,
"should display 1 record in the second page");
form.destroy();
});
- QUnit.test('many2many_tags can load more than 40 records', function (assert) {
+ QUnit.test('many2many_tags can load more than 40 records', async function (assert) {
assert.expect(1);
this.data.partner.fields.partner_ids = {string: "Partner", type: "many2many", relation: 'partner'};
@@ -1507,7 +1516,7 @@ QUnit.module('relational_fields', {
this.data.partner.records.push({id: i, display_name: 'walter' + i});
this.data.partner.records[0].partner_ids.push(i);
}
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -1521,7 +1530,7 @@ QUnit.module('relational_fields', {
form.destroy();
});
- QUnit.test('field many2many_tags keeps focus when being edited', function (assert) {
+ QUnit.test('field many2many_tags keeps focus when being edited', async function (assert) {
assert.expect(7);
this.data.partner.records[0].timmy = [12];
@@ -1529,7 +1538,7 @@ QUnit.module('relational_fields', {
obj.timmy = [[5]]; // DELETE command
};
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -1540,22 +1549,22 @@ QUnit.module('relational_fields', {
res_id: 1,
});
- testUtils.form.clickEdit(form);
+ await testUtils.form.clickEdit(form);
assert.containsOnce(form, '.o_field_many2manytags .badge',
"should contain one tag");
// update foo, which will trigger an onchange and update timmy
// -> m2mtags input should not have taken the focus
form.$('input[name=foo]').focus();
- testUtils.fields.editInput(form.$('input[name=foo]'), 'trigger onchange');
+ await testUtils.fields.editInput(form.$('input[name=foo]'), 'trigger onchange');
assert.containsNone(form, '.o_field_many2manytags .badge',
"should contain no tags");
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
- testUtils.fields.many2one.clickOpenDropdown('timmy');
- testUtils.fields.many2one.clickHighlightedItem('timmy');
+ await testUtils.fields.many2one.clickOpenDropdown('timmy');
+ await testUtils.fields.many2one.clickHighlightedItem('timmy');
assert.containsOnce(form, '.o_field_many2manytags .badge',
@@ -1564,7 +1573,7 @@ QUnit.module('relational_fields', {
"m2m tags input should have kept the focus");
// remove a tag -> m2mtags input should still have the focus
- testUtils.dom.click(form.$('.o_field_many2manytags .o_delete'));
+ await testUtils.dom.click(form.$('.o_field_many2manytags .o_delete'));
assert.containsNone(form, '.o_field_many2manytags .badge',
"should contain no tags");
assert.strictEqual(form.$('.o_field_many2manytags input').get(0), document.activeElement,
@@ -1573,11 +1582,11 @@ QUnit.module('relational_fields', {
form.destroy();
});
- QUnit.test('widget many2many_tags in one2many with display_name', function (assert) {
+ QUnit.test('widget many2many_tags in one2many with display_name', async function (assert) {
assert.expect(4);
this.data.turtle.records[0].partner_ids = [2];
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -1605,26 +1614,26 @@ QUnit.module('relational_fields', {
"secondrecordaaa", "the tags should be correctly rendered");
// open the x2m form view
- form.$('.o_field_one2many[name="turtles"] .o_list_view td.o_data_cell:first').click();
+ await testUtils.dom.click(form.$('.o_field_one2many[name="turtles"] .o_list_view td.o_data_cell:first'));
assert.strictEqual($('.modal .o_form_view .o_field_many2many[name="partner_ids"] .o_list_view .o_data_cell').text(),
"blipMy little Foo Value", "the list view should be correctly rendered with foo");
- $('.modal button.o_form_button_cancel').click();
+ await testUtils.dom.click($('.modal button.o_form_button_cancel'));
assert.strictEqual(form.$('.o_field_one2many[name="turtles"] .o_list_view .o_field_many2manytags[name="partner_ids"]').text().replace(/\s/g, ''),
"secondrecordaaa", "the tags should still be correctly rendered");
- form.$buttons.find('.o_form_button_edit').click();
+ await testUtils.form.clickEdit(form);
assert.strictEqual(form.$('.o_field_one2many[name="turtles"] .o_list_view .o_field_many2manytags[name="partner_ids"]').text().replace(/\s/g, ''),
"secondrecordaaa", "the tags should still be correctly rendered");
form.destroy();
});
- QUnit.test('widget many2many_tags: tags title attribute', function (assert) {
+ QUnit.test('widget many2many_tags: tags title attribute', async function (assert) {
assert.expect(1);
this.data.turtle.records[0].partner_ids = [2];
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'turtle',
data: this.data,
@@ -1645,13 +1654,13 @@ QUnit.module('relational_fields', {
form.destroy();
});
- QUnit.test('widget many2many_tags: toggle colorpicker multiple times', function (assert) {
+ QUnit.test('widget many2many_tags: toggle colorpicker multiple times', async function (assert) {
assert.expect(11);
this.data.partner.records[0].timmy = [12];
this.data.partner_type.records[0].color = 0;
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -1672,13 +1681,13 @@ QUnit.module('relational_fields', {
"colorpicker should be closed");
// click on the badge to open colorpicker
- testUtils.dom.click(form.$('.o_field_many2manytags .badge .dropdown-toggle'));
+ await testUtils.dom.click(form.$('.o_field_many2manytags .badge .dropdown-toggle'));
assert.strictEqual($('.o_colorpicker:visible').length, 1,
"colorpicker should be open");
// click on the badge again to close colorpicker
- testUtils.dom.click(form.$('.o_field_many2manytags .badge .dropdown-toggle'));
+ await testUtils.dom.click(form.$('.o_field_many2manytags .badge .dropdown-toggle'));
assert.strictEqual($('.o_field_many2manytags .badge').data('color'), 0,
"tag should still have color 0");
@@ -1686,13 +1695,13 @@ QUnit.module('relational_fields', {
"colorpicker should be closed");
// click on the badge to open colorpicker
- testUtils.dom.click(form.$('.o_field_many2manytags .badge .dropdown-toggle'));
+ await testUtils.dom.click(form.$('.o_field_many2manytags .badge .dropdown-toggle'));
assert.strictEqual($('.o_colorpicker:visible').length, 1,
"colorpicker should be open");
// click on the colorpicker, but not on a color
- testUtils.dom.click(form.$('.o_colorpicker'));
+ await testUtils.dom.click(form.$('.o_colorpicker'));
assert.strictEqual($('.o_field_many2manytags .badge').data('color'), 0,
"tag should still have color 0");
@@ -1700,10 +1709,10 @@ QUnit.module('relational_fields', {
"colorpicker should be closed");
// click on the badge to open colorpicker
- testUtils.dom.click(form.$('.o_field_many2manytags .badge .dropdown-toggle'));
+ await testUtils.dom.click(form.$('.o_field_many2manytags .badge .dropdown-toggle'));
// click on a color in the colorpicker
- form.$('.o_colorpicker .o_tag_color_2').trigger('mousedown');
+ await testUtils.dom.triggerEvents(form.$('.o_colorpicker .o_tag_color_2'),['mousedown']);
assert.strictEqual($('.o_field_many2manytags .badge').data('color'), 2,
"tag should have color 2");
@@ -1715,10 +1724,10 @@ QUnit.module('relational_fields', {
QUnit.module('FieldRadio');
- QUnit.test('fieldradio widget on a many2one in a new record', function (assert) {
+ QUnit.test('fieldradio widget on a many2one in a new record', async function (assert) {
assert.expect(6);
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -1732,18 +1741,18 @@ QUnit.module('relational_fields', {
assert.ok(form.$('label.o_form_label:contains(xphone)').length, "one of them should be xphone");
assert.containsNone(form, 'input:checked', "none of the input should be checked");
- testUtils.dom.click(form.$("input.o_radio_input:first"));
+ await testUtils.dom.click(form.$("input.o_radio_input:first"));
assert.containsOnce(form, 'input:checked', "one of the input should be checked");
- testUtils.form.clickSave(form);
+ await testUtils.form.clickSave(form);
var newRecord = _.last(this.data.partner.records);
assert.strictEqual(newRecord.product_id, 37, "should have saved record with correct value");
form.destroy();
});
- QUnit.test('fieldradio change value by onchange', function (assert) {
+ QUnit.test('fieldradio change value by onchange', async function (assert) {
assert.expect(4);
this.data.partner.onchanges = {bar: function (obj) {
@@ -1751,7 +1760,7 @@ QUnit.module('relational_fields', {
obj.color = obj.bar ? 'red' : 'black';
}};
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -1762,20 +1771,20 @@ QUnit.module('relational_fields', {
'</form>',
});
- testUtils.dom.click(form.$("input[type='checkbox']"));
+ await testUtils.dom.click(form.$("input[type='checkbox']"));
assert.containsOnce(form, 'input.o_radio_input[data-value="37"]:checked', "one of the input should be checked");
assert.containsOnce(form, 'input.o_radio_input[data-value="black"]:checked', "the other of the input should be checked");
- testUtils.dom.click(form.$("input[type='checkbox']"));
+ await testUtils.dom.click(form.$("input[type='checkbox']"));
assert.containsOnce(form, 'input.o_radio_input[data-value="41"]:checked', "the other of the input should be checked");
assert.containsOnce(form, 'input.o_radio_input[data-value="red"]:checked', "one of the input should be checked");
form.destroy();
});
- QUnit.test('fieldradio widget on a selection in a new record', function (assert) {
+ QUnit.test('fieldradio widget on a selection in a new record', async function (assert) {
assert.expect(4);
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -1790,21 +1799,21 @@ QUnit.module('relational_fields', {
assert.ok(form.$('label.o_form_label:contains(Red)').length, "one of them should be Red");
// click on 2nd option
- testUtils.dom.click(form.$("input.o_radio_input").eq(1));
+ await testUtils.dom.click(form.$("input.o_radio_input").eq(1));
- testUtils.form.clickSave(form);
+ await testUtils.form.clickSave(form);
var newRecord = _.last(this.data.partner.records);
assert.strictEqual(newRecord.color, 'black', "should have saved record with correct value");
form.destroy();
});
- QUnit.test('fieldradio widget has o_horizontal or o_vertical class', function (assert) {
+ QUnit.test('fieldradio widget has o_horizontal or o_vertical class', async function (assert) {
assert.expect(2);
this.data.partner.fields.color2 = this.data.partner.fields.color;
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -1824,7 +1833,7 @@ QUnit.module('relational_fields', {
form.destroy();
});
- QUnit.test('fieldradio widget with numerical keys encoded as strings', function (assert) {
+ QUnit.test('fieldradio widget with numerical keys encoded as strings', async function (assert) {
assert.expect(5);
this.data.partner.fields.selection = {
@@ -1832,7 +1841,7 @@ QUnit.module('relational_fields', {
selection: [['0', "Red"], ['1', "Black"]],
};
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -1853,19 +1862,19 @@ QUnit.module('relational_fields', {
assert.strictEqual(form.$('.o_field_widget').text(), '',
"field should be unset");
- testUtils.form.clickEdit(form);
+ await testUtils.form.clickEdit(form);
assert.containsNone(form, '.o_radio_input:checked',
"no value should be checked");
- testUtils.dom.click(form.$("input.o_radio_input:nth(1)"));
+ await testUtils.dom.click(form.$("input.o_radio_input:nth(1)"));
- testUtils.form.clickSave(form);
+ await testUtils.form.clickSave(form);
assert.strictEqual(form.$('.o_field_widget').text(), 'Black',
"value should be 'Black'");
- testUtils.form.clickEdit(form);
+ await testUtils.form.clickEdit(form);
assert.containsOnce(form, '.o_radio_input[data-index=1]:checked',
"'Black' should be checked");
@@ -1873,7 +1882,7 @@ QUnit.module('relational_fields', {
form.destroy();
});
- QUnit.test('widget radio on a many2one: domain updated by an onchange', function (assert) {
+ QUnit.test('widget radio on a many2one: domain updated by an onchange', async function (assert) {
assert.expect(4);
this.data.partner.onchanges = {
@@ -1881,7 +1890,7 @@ QUnit.module('relational_fields', {
};
var domain = [];
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -1893,7 +1902,7 @@ QUnit.module('relational_fields', {
mockRPC: function (route, args) {
if (args.method === 'onchange') {
domain = [['id', 'in', [10]]];
- return $.when({
+ return Promise.resolve({
value: {
trululu: false,
},
@@ -1917,8 +1926,7 @@ QUnit.module('relational_fields', {
"should be 3 radio buttons");
// trigger an onchange that will update the domain
- testUtils.fields.editInput(form.$('.o_field_widget[name=int_field]'), 2);
-
+ await testUtils.fields.editInput(form.$('.o_field_widget[name=int_field]'), 2);
assert.containsNone(form, '.o_field_widget[name=trululu] .o_radio_item',
"should be no more radio button");
@@ -1928,10 +1936,10 @@ QUnit.module('relational_fields', {
QUnit.module('FieldSelectionBadge');
- QUnit.test('FieldSelectionBadge widget on a many2one in a new record', function (assert) {
+ QUnit.test('FieldSelectionBadge widget on a many2one in a new record', async function (assert) {
assert.expect(6);
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -1945,21 +1953,21 @@ QUnit.module('relational_fields', {
assert.ok(form.$('span.o_selection_badge:contains(xphone)').length, "one of them should be xphone");
assert.containsNone(form, 'span.active', "none of the input should be checked");
- testUtils.dom.click($("span.o_selection_badge:first"));
+ await testUtils.dom.click($("span.o_selection_badge:first"));
assert.containsOnce(form, 'span.active', "one of the input should be checked");
- testUtils.form.clickSave(form);
+ await testUtils.form.clickSave(form);
var newRecord = _.last(this.data.partner.records);
assert.strictEqual(newRecord.product_id, 37, "should have saved record with correct value");
form.destroy();
});
- QUnit.test('FieldSelectionBadge widget on a selection in a new record', function (assert) {
+ QUnit.test('FieldSelectionBadge widget on a selection in a new record', async function (assert) {
assert.expect(4);
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -1973,19 +1981,19 @@ QUnit.module('relational_fields', {
assert.ok(form.$('span.o_selection_badge:contains(Red)').length, "one of them should be Red");
// click on 2nd option
- testUtils.dom.click(form.$("span.o_selection_badge").eq(1));
+ await testUtils.dom.click(form.$("span.o_selection_badge").eq(1));
- testUtils.form.clickSave(form);
+ await testUtils.form.clickSave(form);
var newRecord = _.last(this.data.partner.records);
assert.strictEqual(newRecord.color, 'black', "should have saved record with correct value");
form.destroy();
});
- QUnit.test('FieldSelectionBadge widget on a selection in a readonly mode', function (assert) {
+ QUnit.test('FieldSelectionBadge widget on a selection in a readonly mode', async function (assert) {
assert.expect(1);
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -2000,11 +2008,11 @@ QUnit.module('relational_fields', {
QUnit.module('FieldMany2ManyCheckBoxes');
- QUnit.test('widget many2many_checkboxes', function (assert) {
+ QUnit.test('widget many2many_checkboxes', async function (assert) {
assert.expect(10);
this.data.partner.records[0].timmy = [12];
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -2025,23 +2033,23 @@ QUnit.module('relational_fields', {
assert.ok(form.$('div.o_field_widget div.custom-checkbox input').prop('disabled'),
"the checkboxes should be disabled");
- testUtils.form.clickEdit(form);
+ await testUtils.form.clickEdit(form);
assert.notOk(form.$('div.o_field_widget div.custom-checkbox input').prop('disabled'),
"the checkboxes should not be disabled");
// add a m2m value by clicking on input
- testUtils.dom.click(form.$('div.o_field_widget div.custom-checkbox input').eq(1));
- testUtils.form.clickSave(form);
+ await testUtils.dom.click(form.$('div.o_field_widget div.custom-checkbox input').eq(1));
+ await testUtils.form.clickSave(form);
assert.deepEqual(this.data.partner.records[0].timmy, [12, 14],
"should have added the second element to the many2many");
assert.containsN(form, 'input:checked', 2,
"both checkboxes should be checked");
// remove a m2m value by clinking on label
- testUtils.form.clickEdit(form);
- testUtils.dom.click(form.$('div.o_field_widget div.custom-checkbox > label').eq(0));
- testUtils.form.clickSave(form);
+ await testUtils.form.clickEdit(form);
+ await testUtils.dom.click(form.$('div.o_field_widget div.custom-checkbox > label').eq(0));
+ await testUtils.form.clickSave(form);
assert.deepEqual(this.data.partner.records[0].timmy, [14],
"should have removed the first element to the many2many");
assert.notOk(form.$('div.o_field_widget div.custom-checkbox input').eq(0).prop('checked'),
@@ -2052,11 +2060,11 @@ QUnit.module('relational_fields', {
form.destroy();
});
- QUnit.test('widget many2many_checkboxes: start non empty, then remove twice', function (assert) {
+ QUnit.test('widget many2many_checkboxes: start non empty, then remove twice', async function (assert) {
assert.expect(2);
this.data.partner.records[0].timmy = [12,14];
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -2067,9 +2075,9 @@ QUnit.module('relational_fields', {
viewOptions: {mode: 'edit'},
});
- testUtils.dom.click(form.$('div.o_field_widget div.custom-checkbox input').eq(0));
- testUtils.dom.click(form.$('div.o_field_widget div.custom-checkbox input').eq(1));
- testUtils.form.clickSave(form);
+ await testUtils.dom.click(form.$('div.o_field_widget div.custom-checkbox input').eq(0));
+ await testUtils.dom.click(form.$('div.o_field_widget div.custom-checkbox input').eq(1));
+ await testUtils.form.clickSave(form);
assert.notOk(form.$('div.o_field_widget div.custom-checkbox input').eq(0).prop('checked'),
"first checkbox should not be checked");
assert.notOk(form.$('div.o_field_widget div.custom-checkbox input').eq(1).prop('checked'),
@@ -2080,8 +2088,8 @@ QUnit.module('relational_fields', {
QUnit.module('FieldMany2ManyBinaryMultiFiles');
- QUnit.test('widget many2many_binary', function (assert) {
- assert.expect(14);
+ QUnit.test('widget many2many_binary', async function (assert) {
+ assert.expect(15);
this.data['ir.attachment'] = {
fields: {
name: {string:"Name", type: "char"},
@@ -2100,7 +2108,7 @@ QUnit.module('relational_fields', {
};
this.data.turtle.records[0].picture_ids = [17];
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'turtle',
data: this.data,
@@ -2130,7 +2138,7 @@ QUnit.module('relational_fields', {
"there should not be a Delete button (readonly)");
// to edit mode
- testUtils.form.clickEdit(form);
+ await testUtils.form.clickEdit(form);
assert.containsOnce(form, 'div.o_field_widget.oe_fileupload .o_attach',
"there should be an Add button");
assert.strictEqual(form.$('div.o_field_widget.oe_fileupload .o_attach').text().trim(), "Pictures",
@@ -2142,7 +2150,7 @@ QUnit.module('relational_fields', {
// no idea how to test this
// delete the attachment
- testUtils.dom.click(form.$('div.o_field_widget.oe_fileupload .oe_attachment .oe_delete'));
+ await testUtils.dom.click(form.$('div.o_field_widget.oe_fileupload .oe_attachment .oe_delete'));
assert.verifySteps([
@@ -2150,17 +2158,23 @@ QUnit.module('relational_fields', {
'/web/dataset/call_kw/ir.attachment/read',
]);
- testUtils.form.clickSave(form);
+ await testUtils.form.clickSave(form);
assert.strictEqual(form.$('div.o_field_widget.oe_fileupload .oe_attachments').children().length, 0,
"there should be no attachment");
+ assert.verifySteps([
+ '/web/dataset/call_kw/turtle/write',
+ '/web/dataset/call_kw/turtle/read',
+ ]);
+
form.destroy();
});
QUnit.test('name_create in form dialog', async function (assert) {
assert.expect(2);
- var form = createView({
+
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -2184,7 +2198,7 @@ QUnit.module('relational_fields', {
},
});
- testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
+ await testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
await testUtils.fields.many2one.searchAndClickItem('product_id',
{selector: '.modal', search: 'new record'});
@@ -2195,14 +2209,14 @@ QUnit.module('relational_fields', {
QUnit.module('FieldReference');
- QUnit.test('Reference field in modal readonly mode', function (assert) {
+ QUnit.test('Reference field in modal readonly mode', async function (assert) {
assert.expect(4);
this.data.partner.records[0].p = [2];
this.data.partner.records[1].trululu = 1;
this.data.partner.records[1].reference = 'product,41';
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -2225,7 +2239,7 @@ QUnit.module('relational_fields', {
assert.equal($cell_o2m.text(), 'second record',
'the list should have one record');
- testUtils.dom.click($cell_o2m);
+ await testUtils.dom.click($cell_o2m);
// In modal
var $modal = $('.modal-lg');
@@ -2235,19 +2249,19 @@ QUnit.module('relational_fields', {
assert.equal($modal.find('.o_form_uri.o_field_widget[name=reference]').text(), 'xpad',
'The field reference in the modal should have the right value');
- testUtils.dom.click($modal.find('.o_form_button_cancel'));
+ await testUtils.dom.click($modal.find('.o_form_button_cancel'));
form.destroy();
});
- QUnit.test('Reference field in modal write mode', function (assert) {
+ QUnit.test('Reference field in modal write mode', async function (assert) {
assert.expect(5);
this.data.partner.records[0].p = [2];
this.data.partner.records[1].trululu = 1;
this.data.partner.records[1].reference = 'product,41';
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -2263,7 +2277,7 @@ QUnit.module('relational_fields', {
});
// current form
- testUtils.form.clickEdit(form);
+ await testUtils.form.clickEdit(form);
var $fieldRef = form.$('.o_field_widget.o_field_many2one[name=reference]');
assert.equal($fieldRef.find('option:selected').text(), 'Product',
@@ -2271,7 +2285,7 @@ QUnit.module('relational_fields', {
assert.equal($fieldRef.find('.o_input.ui-autocomplete-input').val(), 'xphone',
'The reference field\'s record should be xphone');
- testUtils.dom.click(form.$('.o_data_cell'));
+ await testUtils.dom.click(form.$('.o_data_cell'));
// In modal
var $modal = $('.modal-lg');
@@ -2288,10 +2302,10 @@ QUnit.module('relational_fields', {
form.destroy();
});
- QUnit.test('reference in form view', function (assert) {
+ QUnit.test('reference in form view', async function (assert) {
assert.expect(15);
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -2309,7 +2323,7 @@ QUnit.module('relational_fields', {
mockRPC: function (route, args) {
if (args.method === 'get_formview_action') {
assert.deepEqual(args.args[0], [37], "should call get_formview_action with correct id");
- return $.when({
+ return Promise.resolve({
res_id: 17,
type: 'ir.actions.act_window',
target: 'current',
@@ -2318,7 +2332,7 @@ QUnit.module('relational_fields', {
}
if (args.method === 'get_formview_id') {
assert.deepEqual(args.args[0], [37], "should call get_formview_id with correct id");
- return $.when(false);
+ return Promise.resolve(false);
}
if (args.method === 'name_search') {
assert.strictEqual(args.model, 'partner_type',
@@ -2341,9 +2355,9 @@ QUnit.module('relational_fields', {
assert.strictEqual(form.$('a.o_form_uri:contains(xphone)').length, 1,
"should contain a link");
- testUtils.dom.click(form.$('a.o_form_uri'));
+ await testUtils.dom.click(form.$('a.o_form_uri'));
- testUtils.form.clickEdit(form);
+ await testUtils.form.clickEdit(form);
assert.containsN(form, '.o_field_widget', 2,
"should contain two field widgets (selection and many2one)");
@@ -2360,28 +2374,28 @@ QUnit.module('relational_fields', {
assert.deepEqual(options, ['', 'product', 'partner_type', 'partner'],
"the options should be correctly set");
- testUtils.dom.click(form.$('.o_external_button'));
+ await testUtils.dom.click(form.$('.o_external_button'));
assert.strictEqual($('.modal .modal-title').text().trim(), 'Open: custom label',
"dialog title should display the custom string label");
- testUtils.dom.click($('.modal .o_form_button_cancel'));
+ await testUtils.dom.click($('.modal .o_form_button_cancel'));
- testUtils.fields.editSelect(form.$('.o_field_widget select'), 'partner_type');
+ await testUtils.fields.editSelect(form.$('.o_field_widget select'), 'partner_type');
assert.strictEqual(form.$('.o_field_widget input').val(), "",
"many2one value should be reset after model change");
- testUtils.fields.many2one.clickOpenDropdown('reference');
- testUtils.fields.many2one.clickHighlightedItem('reference');
+ await testUtils.fields.many2one.clickOpenDropdown('reference');
+ await testUtils.fields.many2one.clickHighlightedItem('reference');
- testUtils.form.clickSave(form);
+ await testUtils.form.clickSave(form);
assert.strictEqual(form.$('a.o_form_uri:contains(gold)').length, 1,
"should contain a link with the new value");
form.destroy();
});
- QUnit.test('default_get and onchange with a reference field', function (assert) {
+ QUnit.test('default_get and onchange with a reference field', async function (assert) {
assert.expect(8);
this.data.partner.fields.reference.default = 'product,37';
@@ -2393,7 +2407,7 @@ QUnit.module('relational_fields', {
},
};
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -2423,9 +2437,9 @@ QUnit.module('relational_fields', {
"reference field value should be correctly set");
// trigger onchange
- testUtils.fields.editInput(form.$('.o_field_widget[name=int_field]'), 12);
+ await testUtils.fields.editInput(form.$('.o_field_widget[name=int_field]'), 12);
- assert.verifySteps(['product', 'partner_type'], "the second name_get should have been done");
+ assert.verifySteps(['partner_type'], "the second name_get should have been done");
assert.strictEqual(form.$('.o_field_widget[name="reference"] select').val(), "partner_type",
"reference field model should be correctly set");
assert.strictEqual(form.$('.o_field_widget[name="reference"] input').val(), "gold",
@@ -2433,14 +2447,14 @@ QUnit.module('relational_fields', {
form.destroy();
});
- QUnit.test('default_get a reference field in a x2m', function (assert) {
+ QUnit.test('default_get a reference field in a x2m', async function (assert) {
assert.expect(1);
this.data.partner.fields.turtles.default = [
[0, false, {turtle_ref: 'product,37'}]
];
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -2465,7 +2479,7 @@ QUnit.module('relational_fields', {
form.destroy();
});
- QUnit.test('widget reference on char field, reset by onchange', function (assert) {
+ QUnit.test('widget reference on char field, reset by onchange', async function (assert) {
assert.expect(4);
this.data.partner.records[0].foo = 'product,37';
@@ -2476,7 +2490,7 @@ QUnit.module('relational_fields', {
};
var nbNameGet = 0;
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -2506,7 +2520,7 @@ QUnit.module('relational_fields', {
"foo field should be correctly set");
// trigger onchange
- testUtils.fields.editInput(form.$('.o_field_widget[name=int_field]'), 41);
+ await testUtils.fields.editInput(form.$('.o_field_widget[name=int_field]'), 41);
assert.strictEqual(nbNameGet, 2,
"the second name_get should have been done");
@@ -2515,10 +2529,10 @@ QUnit.module('relational_fields', {
form.destroy();
});
- QUnit.test('reference and list navigation', function (assert) {
+ QUnit.test('reference and list navigation', async function (assert) {
assert.expect(2);
- var list = createView({
+ var list = await createView({
View: ListView,
model: 'partner',
data: this.data,
@@ -2526,25 +2540,25 @@ QUnit.module('relational_fields', {
});
// edit first row
- testUtils.dom.click(list.$('.o_data_row .o_data_cell').first());
+ await testUtils.dom.click(list.$('.o_data_row .o_data_cell').first());
assert.strictEqual(list.$('.o_data_row:eq(0) .o_field_widget[name="reference"] input')[0], document.activeElement,
'input of first data row should be selected');
// press TAB to go to next line
- list.$('.o_data_row:eq(0) input').trigger($.Event('keydown', {
+ await testUtils.dom.triggerEvents(list.$('.o_data_row:eq(0) input:eq(1)'),[$.Event('keydown', {
which: $.ui.keyCode.TAB,
keyCode: $.ui.keyCode.TAB,
- }));
+ })]);
assert.strictEqual(list.$('.o_data_row:eq(1) .o_field_widget[name="reference"] select')[0], document.activeElement,
'select of second data row should be selected');
list.destroy();
});
- QUnit.test('one2many with extra field from server not in form', function (assert) {
+ QUnit.test('one2many with extra field from server not in form', async function (assert) {
assert.expect(6);
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -2569,20 +2583,20 @@ QUnit.module('relational_fields', {
}
});
- testUtils.form.clickEdit(form);
+ await testUtils.form.clickEdit(form);
var x2mList = form.$('.o_field_x2many_list[name=p]');
// Add a record in the list
- testUtils.dom.click(x2mList.find('.o_field_x2many_list_row_add a'));
+ await testUtils.dom.click(x2mList.find('.o_field_x2many_list_row_add a'));
var modal = $('.modal-lg');
var nameInput = modal.find('input.o_input[name=display_name]');
- testUtils.fields.editInput(nameInput, 'michelangelo');
+ await testUtils.fields.editInput(nameInput, 'michelangelo');
// Save the record in the modal (though it is still virtual)
- testUtils.dom.click(modal.find('.btn-primary').first());
+ await testUtils.dom.click(modal.find('.btn-primary').first());
assert.equal(x2mList.find('.o_data_row').length, 1,
'There should be 1 records in the x2m list');
@@ -2595,7 +2609,7 @@ QUnit.module('relational_fields', {
'The display name field should have the right value');
// Save the whole thing
- testUtils.form.clickSave(form);
+ await testUtils.form.clickSave(form);
x2mList = form.$('.o_field_x2many_list[name=p]');
@@ -2613,11 +2627,11 @@ QUnit.module('relational_fields', {
form.destroy();
});
- QUnit.test('one2many invisible depends on parent field', function (assert) {
+ QUnit.test('one2many invisible depends on parent field', async function (assert) {
assert.expect(4);
this.data.partner.records[0].p = [2];
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -2643,21 +2657,22 @@ QUnit.module('relational_fields', {
});
assert.containsN(form, 'th', 2,
"should be 2 columns in the one2many");
- testUtils.form.clickEdit(form);
- testUtils.dom.click(form.$('.o_field_many2one[name="product_id"] input'));
- testUtils.dom.click($('li.ui-menu-item a:contains(xpad)').trigger('mouseenter'));
+ await testUtils.form.clickEdit(form);
+ await testUtils.fields.many2one.clickOpenDropdown("product_id");
+ await testUtils.fields.many2one.clickHighlightedItem("product_id");
assert.containsOnce(form, 'th',
"should be 1 column when the product_id is set");
- form.$('.o_field_many2one[name="product_id"] input').val('').trigger('keyup');
+ await testUtils.fields.editAndTrigger(form.$('.o_field_many2one[name="product_id"] input'),
+ '', 'keyup');
assert.containsN(form, 'th', 2,
"should be 2 columns in the one2many when product_id is not set");
- testUtils.dom.click(form.$('.o_field_boolean[name="bar"] input'));
+ await testUtils.dom.click(form.$('.o_field_boolean[name="bar"] input'));
assert.containsOnce(form, 'th',
"should be 1 column after the value change");
form.destroy();
});
- QUnit.test('one2many column visiblity depends on onchange of parent field', function (assert) {
+ QUnit.test('one2many column visiblity depends on onchange of parent field', async function (assert) {
assert.expect(3);
this.data.partner.records[0].p = [2];
@@ -2670,7 +2685,7 @@ QUnit.module('relational_fields', {
}
};
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -2691,24 +2706,24 @@ QUnit.module('relational_fields', {
"should be only 1 column ('foo') in the one2many");
assert.containsOnce(form, '.o_list_view .o_data_row', "should contain one row");
- testUtils.form.clickEdit(form);
+ await testUtils.form.clickEdit(form);
// add a new o2m record
- testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
+ await testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
form.$('.o_field_one2many input:first').focus();
- testUtils.fields.editInput(form.$('.o_field_one2many input:first'), 'New line');
- testUtils.dom.click(form.$el);
+ await testUtils.fields.editInput(form.$('.o_field_one2many input:first'), 'New line');
+ await testUtils.dom.click(form.$el);
assert.containsN(form, 'th', 2, "should be 2 columns('foo' + 'int_field')");
form.destroy();
});
- QUnit.test('one2many column_invisible on view not inline', function (assert) {
+ QUnit.test('one2many column_invisible on view not inline', async function (assert) {
assert.expect(4);
this.data.partner.records[0].p = [2];
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -2735,25 +2750,26 @@ QUnit.module('relational_fields', {
});
assert.containsN(form, 'th', 2,
"should be 2 columns in the one2many");
- testUtils.form.clickEdit(form);
- testUtils.dom.click(form.$('.o_field_many2one[name="product_id"] input'));
- testUtils.dom.click($('li.ui-menu-item a:contains(xpad)').trigger('mouseenter'));
+ await testUtils.form.clickEdit(form);
+ await testUtils.dom.click(form.$('.o_field_many2one[name="product_id"] input'));
+ await testUtils.fields.many2one.clickHighlightedItem("product_id");
assert.containsOnce(form, 'th',
"should be 1 column when the product_id is set");
- form.$('.o_field_many2one[name="product_id"] input').val('').trigger('keyup');
+ await testUtils.fields.editAndTrigger(form.$('.o_field_many2one[name="product_id"] input'),
+ '', 'keyup');
assert.containsN(form, 'th', 2,
"should be 2 columns in the one2many when product_id is not set");
- testUtils.dom.click(form.$('.o_field_boolean[name="bar"] input'));
+ await testUtils.dom.click(form.$('.o_field_boolean[name="bar"] input'));
assert.containsOnce(form, 'th',
"should be 1 column after the value change");
form.destroy();
});
QUnit.module('TabNavigation');
- QUnit.test('when Navigating to a many2one with tabs, it receives the focus and adds a new line', function (assert) {
+ QUnit.test('when Navigating to a many2one with tabs, it receives the focus and adds a new line', async function (assert) {
assert.expect(3);
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
viewOptions: {
@@ -2782,10 +2798,7 @@ QUnit.module('relational_fields', {
assert.strictEqual(form.$el.find('input[name="qux"]')[0],
document.activeElement,
"initially, the focus should be on the 'qux' field because it is the first input");
- form.$el.find('input[name="qux"]').trigger($.Event('keydown', {
- which: $.ui.keyCode.TAB,
- keyCode: $.ui.keyCode.TAB,
- }));
+ await testUtils.fields.triggerKeydown(form.$el.find('input[name="qux"]'), 'tab');
assert.strictEqual(assert.strictEqual(form.$el.find('input[name="turtle_foo"]')[0],
document.activeElement,
"after tab, the focus should be on the many2one on the first input of the newly added line"));
@@ -2793,10 +2806,10 @@ QUnit.module('relational_fields', {
form.destroy();
});
- QUnit.test('when Navigating to a many to one with tabs, it places the focus on the first visible field', function (assert) {
+ QUnit.test('when Navigating to a many to one with tabs, it places the focus on the first visible field', async function (assert) {
assert.expect(3);
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
viewOptions: {
@@ -2830,7 +2843,7 @@ QUnit.module('relational_fields', {
which: $.ui.keyCode.TAB,
keyCode: $.ui.keyCode.TAB,
}));
- testUtils.dom.click(document.activeElement);
+ await testUtils.dom.click(document.activeElement);
assert.strictEqual(assert.strictEqual(form.$el.find('input[name="turtle_foo"]')[0],
document.activeElement,
"after tab, the focus should be on the many2one"));
@@ -2839,12 +2852,12 @@ QUnit.module('relational_fields', {
});
QUnit.test('when Navigating to a many2one with tabs, not filling any field and hitting tab,' +
- ' we should not add a first line but navigate to the next control', function (assert) {
+ ' we should not add a first line but navigate to the next control', async function (assert) {
assert.expect(3);
this.data.partner.records[0].turtles = [];
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
viewOptions: {
@@ -2875,32 +2888,27 @@ QUnit.module('relational_fields', {
});
assert.strictEqual(form.$el.find('input[name="qux"]')[0],
- document.activeElement,
- "initially, the focus should be on the 'qux' field because it is the first input");
- form.$el.find('input[name="qux"]').trigger($.Event('keydown', {
- which: $.ui.keyCode.TAB,
- keyCode: $.ui.keyCode.TAB,
- }));
+ document.activeElement,
+ "initially, the focus should be on the 'qux' field because it is the first input");
+ await testUtils.fields.triggerKeydown(form.$el.find('input[name="qux"]'), 'tab');
// skips the first field of the one2many
- $(document.activeElement).trigger($.Event('keydown', {which: $.ui.keyCode.TAB}));
-
+ await testUtils.fields.triggerKeydown($(document.activeElement), 'tab');
// skips the second (and last) field of the one2many
- $(document.activeElement).trigger($.Event('keydown', {which: $.ui.keyCode.TAB}));
-
+ await testUtils.fields.triggerKeydown($(document.activeElement), 'tab');
assert.strictEqual(assert.strictEqual(form.$el.find('input[name="foo"]')[0],
- document.activeElement,
- "after tab, the focus should be on the many2one"));
+ document.activeElement,
+ "after tab, the focus should be on the many2one"));
form.destroy();
});
- QUnit.test('when Navigating to a many to one with tabs, editing in a popup, the popup should receive the focus then give it back', function (assert) {
+ QUnit.test('when Navigating to a many to one with tabs, editing in a popup, the popup should receive the focus then give it back', async function (assert) {
assert.expect(3);
this.data.partner.records[0].turtles = [];
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
viewOptions: {
@@ -2934,22 +2942,14 @@ QUnit.module('relational_fields', {
});
assert.strictEqual(form.$el.find('input[name="qux"]')[0],
- document.activeElement,
- "initially, the focus should be on the 'qux' field because it is the first input");
- form.$el.find('input[name="qux"]').trigger($.Event('keydown', {
- which: $.ui.keyCode.TAB,
- keyCode: $.ui.keyCode.TAB,
- }));
-
+ document.activeElement,
+ "initially, the focus should be on the 'qux' field because it is the first input");
+ await testUtils.fields.triggerKeydown(form.$el.find('input[name="qux"]'), 'tab');
assert.strictEqual($.find('input[name="turtle_foo"]')[0],
document.activeElement,
"when the one2many received the focus, the popup should open because it automatically adds a new line");
- $('input[name="turtle_foo"]').trigger($.Event('keydown', {
- which: $.ui.keyCode.ESCAPE,
- keyCode: $.ui.keyCode.ESCAPE,
- }));
-
+ await testUtils.fields.triggerKeydown($('input[name="turtle_foo"]'), 'escape');
assert.strictEqual(form.$el.find('.o_field_x2many_list_row_add a')[0],
document.activeElement,
"after escape, the focus should be back on the add new line link");
@@ -2957,13 +2957,12 @@ QUnit.module('relational_fields', {
form.destroy();
});
- QUnit.test('when creating a new many2one on a x2many then discarding it immediately with ESCAPE, it should not crash', function (assert) {
- var done = assert.async();
+ QUnit.test('when creating a new many2one on a x2many then discarding it immediately with ESCAPE, it should not crash', async function (assert) {
assert.expect(1);
this.data.partner.records[0].turtles = [];
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
viewOptions: {
@@ -2987,33 +2986,30 @@ QUnit.module('relational_fields', {
});
// add a new line
- testUtils.dom.click(form.$el.find('.o_field_x2many_list_row_add>a'));
+ await testUtils.dom.click(form.$el.find('.o_field_x2many_list_row_add>a'));
// open the field turtle_trululu (one2many)
var M2O_DELAY = relationalFields.FieldMany2One.prototype.AUTOCOMPLETE_DELAY;
relationalFields.FieldMany2One.prototype.AUTOCOMPLETE_DELAY = 0;
- testUtils.dom.click(form.$el.find('.o_input_dropdown>input'));
+ await testUtils.dom.click(form.$el.find('.o_input_dropdown>input'));
- concurrency.delay(0).then(function () {
- // click create and edit
- testUtils.dom.click($('.ui-autocomplete .ui-menu-item a:contains(Create and)').trigger('mouseenter'));
+ // click create and edit
+ await testUtils.dom.click($('.ui-autocomplete .ui-menu-item a:contains(Create and)').trigger('mouseenter'));
- // hit escape immediately
- var escapeKey = $.ui.keyCode.ESCAPE;
- $(document.activeElement).trigger(
- $.Event('keydown', {which: escapeKey, keyCode: escapeKey}));
+ // hit escape immediately
+ var escapeKey = $.ui.keyCode.ESCAPE;
+ $(document.activeElement).trigger(
+ $.Event('keydown', {which: escapeKey, keyCode: escapeKey}));
- assert.ok('did not crash');
- relationalFields.FieldMany2One.prototype.AUTOCOMPLETE_DELAY = M2O_DELAY;
- form.destroy();
- done();
- });
+ assert.ok('did not crash');
+ relationalFields.FieldMany2One.prototype.AUTOCOMPLETE_DELAY = M2O_DELAY;
+ form.destroy();
});
- QUnit.test('navigating through an editable list with custom controls [REQUIRE FOCUS]', function (assert) {
+ QUnit.test('navigating through an editable list with custom controls [REQUIRE FOCUS]', async function (assert) {
assert.expect(5);
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -3040,44 +3036,29 @@ QUnit.module('relational_fields', {
"first input should be focused by default");
// press tab to navigate to the list
- form.$('.o_field_widget[name="display_name"]').trigger($.Event('keydown', {
- which: $.ui.keyCode.TAB,
- keyCode: $.ui.keyCode.TAB,
- }));
-
+ await testUtils.fields.triggerKeydown(
+ form.$('.o_field_widget[name="display_name"]'), 'tab');
// press ESC to cancel 1st control click (create)
- form.$('.o_data_cell input').trigger($.Event('keydown', {
- which: $.ui.keyCode.ESCAPE,
- keyCode: $.ui.keyCode.ESCAPE,
- }));
-
+ await testUtils.fields.triggerKeydown(
+ form.$('.o_data_cell input'), 'escape');
assert.strictEqual(document.activeElement, form.$('.o_field_x2many_list_row_add a:first')[0],
"first editable list control should now have the focus");
// press right to focus the second control
- form.$('.o_field_x2many_list_row_add a:first').trigger($.Event('keydown', {
- which: $.ui.keyCode.RIGHT,
- keyCode: $.ui.keyCode.RIGHT,
- }));
-
+ await testUtils.fields.triggerKeydown(
+ form.$('.o_field_x2many_list_row_add a:first'), 'right');
assert.strictEqual(document.activeElement, form.$('.o_field_x2many_list_row_add a:nth(1)')[0],
"second editable list control should now have the focus");
// press left to come back to first control
- form.$('.o_field_x2many_list_row_add a:nth(1)').trigger($.Event('keydown', {
- which: $.ui.keyCode.LEFT,
- keyCode: $.ui.keyCode.LEFT,
- }));
-
+ await testUtils.fields.triggerKeydown(
+ form.$('.o_field_x2many_list_row_add a:nth(1)'), 'left');
assert.strictEqual(document.activeElement, form.$('.o_field_x2many_list_row_add a:first')[0],
"first editable list control should now have the focus");
// press tab to leave the list
- form.$('.o_field_x2many_list_row_add a:first').trigger($.Event('keydown', {
- which: $.ui.keyCode.TAB,
- keyCode: $.ui.keyCode.TAB,
- }));
-
+ await testUtils.fields.triggerKeydown(
+ form.$('.o_field_x2many_list_row_add a:first'), 'tab');
assert.strictEqual(document.activeElement, form.$('.o_field_widget[name="int_field"]')[0],
"last input should now be focused");
diff --git a/addons/web/static/tests/fields/special_fields.js b/addons/web/static/tests/fields/special_fields.js
index 6acc2be521b..2a674be19ba 100644
--- a/addons/web/static/tests/fields/special_fields.js
+++ b/addons/web/static/tests/fields/special_fields.js
@@ -141,7 +141,7 @@ QUnit.module('special_fields', {
QUnit.module('FieldTimezoneMismatch');
- QUnit.test('widget timezone_mismatch in a list view', function (assert) {
+ QUnit.test('widget timezone_mismatch in a list view', async function (assert) {
assert.expect(5);
this.data.partner.fields.tz_offset = {
@@ -158,7 +158,7 @@ QUnit.module('special_fields', {
}
};
- var list = createView({
+ var list = await createView({
View: ListView,
model: 'partner',
data: this.data,
@@ -170,21 +170,21 @@ QUnit.module('special_fields', {
assert.strictEqual(list.$('td:contains(Red)').length, 3,
"should have 3 rows with correct value");
- list.$('td:contains(Red):first').click();
+ await testUtils.dom.click(list.$('td:contains(Red):first'));
var $td = list.$('tbody tr.o_selected_row td:not(.o_list_record_selector)');
assert.strictEqual($td.find('select').length, 1, "td should have a child 'select'");
assert.strictEqual($td.contents().length, 1, "select tag should be only child of td");
- $td.find('select').val('"black"').trigger('change');
+ await testUtils.fields.editSelect($td.find('select'), '"black"');
assert.strictEqual($td.find('.o_tz_warning').length, 1, "Should display icon alert");
assert.ok($td.find('select option:selected').text().match(/Black\s+\([0-9]+\/[0-9]+\/[0-9]+ [0-9]+:[0-9]+:[0-9]+\)/), "Should display the datetime in the selected timezone");
list.destroy();
});
- QUnit.test('widget timezone_mismatch in a form view', function (assert) {
+ QUnit.test('widget timezone_mismatch in a form view', async function (assert) {
assert.expect(1);
this.data.partner.fields.tz_offset = {
@@ -198,7 +198,7 @@ QUnit.module('special_fields', {
this.data.partner.records[0].tz = false;
this.data.partner.records[0].tz_offset = '+4800';
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
res_id: 1,
@@ -208,12 +208,12 @@ QUnit.module('special_fields', {
'<field name="tz" widget="timezone_mismatch"/>' +
'</form>',
});
- testUtils.form.clickEdit(form);
+ await testUtils.form.clickEdit(form);
assert.containsOnce(form, 'select[name=tz]');
form.destroy();
});
- QUnit.test('widget timezone_mismatch in a form view edit mode with mismatch', function (assert) {
+ QUnit.test('widget timezone_mismatch in a form view edit mode with mismatch', async function (assert) {
assert.expect(3);
this.data.partner.fields.tz_offset = {
@@ -227,7 +227,7 @@ QUnit.module('special_fields', {
this.data.partner.records[0].tz = 'America/Los_Angeles';
this.data.partner.records[0].tz_offset = '+4800';
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
res_id: 1,
@@ -256,7 +256,7 @@ QUnit.module('special_fields', {
QUnit.module('FieldReportLayout');
- QUnit.test('report_layout widget in form view', function (assert) {
+ QUnit.test('report_layout widget in form view', async function (assert) {
assert.expect(3);
this.data['report.layout'] = {
@@ -275,11 +275,11 @@ QUnit.module('special_fields', {
view_id: 41,
image: "/web/static/tata.png",
pdf: "/web/static/tata.pdf",
- }]
+ }],
};
this.data.partner.records[1].product_id = false;
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -287,6 +287,9 @@ QUnit.module('special_fields', {
'<field name="product_id" widget="report_layout"/> '+
'</form>',
res_id: 2,
+ viewOptions: {
+ mode: 'edit',
+ },
});
assert.strictEqual(form.$('.img.img-fluid').length, 2,
@@ -295,7 +298,7 @@ QUnit.module('special_fields', {
"No image should be selected");
// select first image
- form.$(".img.img-fluid:first").click();
+ await testUtils.dom.click(form.$(".img.img-fluid:first"));
assert.ok(form.$(".img.img-fluid:first").hasClass('btn-info'),
"First image should be selected");
diff --git a/addons/web/static/tests/fields/upgrade_fields_tests.js b/addons/web/static/tests/fields/upgrade_fields_tests.js
index 65de67a7951..d908fd48b61 100644
--- a/addons/web/static/tests/fields/upgrade_fields_tests.js
+++ b/addons/web/static/tests/fields/upgrade_fields_tests.js
@@ -22,27 +22,27 @@ QUnit.module('upgrade_fields', {
QUnit.module('UpgradeBoolean');
- QUnit.test('widget upgrade_boolean in a form view', function (assert) {
+ QUnit.test('widget upgrade_boolean in a form view', async function (assert) {
assert.expect(1);
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
arch: '<form><field name="bar" widget="upgrade_boolean"/></form>',
});
- testUtils.dom.click(form.$('input:checkbox'));
+ await testUtils.dom.click(form.$('input:checkbox'));
assert.strictEqual($('.modal').length, 1,
"the 'Upgrade to Enterprise' dialog should be opened");
form.destroy();
});
- QUnit.test('widget upgrade_boolean in a form view', function (assert) {
+ QUnit.test('widget upgrade_boolean in a form view', async function (assert) {
assert.expect(3);
- var form = createView({
+ var form = await createView({
View: FormView,
model: 'partner',
data: this.data,