summaryrefslogtreecommitdiff
path: root/addons/web/static/tests/fields
diff options
context:
space:
mode:
authorChristophe Simonis <chs@odoo.com>2019-05-13 15:26:12 +0200
committerChristophe Simonis <chs@odoo.com>2019-05-13 15:26:12 +0200
commit8dd5a85267b522ba569ab9ed44901f95fffbeb4f (patch)
treeddb62d1e83e1b810b96c05f6819ca66f8d6b4955 /addons/web/static/tests/fields
parent15716642e1975b4f2f29916011a4be29804cda88 (diff)
parent60e71302a38b36214efec1213882f573e3ea453c (diff)
[MERGE] forward port branch saas-12.3 up to 60e71302a38
Diffstat (limited to 'addons/web/static/tests/fields')
-rw-r--r--addons/web/static/tests/fields/basic_fields_tests.js28
-rw-r--r--addons/web/static/tests/fields/relational_fields/field_one2many_tests.js64
2 files changed, 77 insertions, 15 deletions
diff --git a/addons/web/static/tests/fields/basic_fields_tests.js b/addons/web/static/tests/fields/basic_fields_tests.js
index b7e487d5c12..02bf293e001 100644
--- a/addons/web/static/tests/fields/basic_fields_tests.js
+++ b/addons/web/static/tests/fields/basic_fields_tests.js
@@ -2887,10 +2887,7 @@ QUnit.module('basic_fields', {
View: FormView,
model: 'partner',
data: this.data,
- arch:'<form string="Partners">' +
- '<field name="display_name" /> ' + // Do not focus on the date field right away
- '<field name="date" />' +
- '</form>',
+ arch: '<form><field name="date"/></form>',
res_id: 1,
viewOptions: {
mode: 'edit',
@@ -2906,7 +2903,8 @@ QUnit.module('basic_fields', {
done();
}
});
- form.$('.o_input[name="date"]').mouseenter().trigger('focus');
+
+ testUtils.dom.openDatepicker(form.$('.o_datepicker'));
form.destroy();
});
@@ -2955,13 +2953,13 @@ QUnit.module('basic_fields', {
QUnit.module('FieldDatetime');
QUnit.test('datetime field in form view', async function (assert) {
- assert.expect(6);
+ assert.expect(7);
var form = await createView({
View: FormView,
model: 'partner',
data: this.data,
- arch:'<form string="Partners"><field name="datetime"/></form>',
+ arch: '<form string="Partners"><field name="datetime"/></form>',
res_id: 1,
translateParameters: { // Avoid issues due to localization formats
date_format: '%m/%d/%Y',
@@ -2982,8 +2980,14 @@ QUnit.module('basic_fields', {
await testUtils.form.clickEdit(form);
assert.strictEqual(form.$('.o_datepicker_input').val(), expectedDateString,
'the datetime should be correct in edit mode');
+
+ // datepicker should not open on focus
+ assert.containsNone($('body'), '.bootstrap-datetimepicker-widget');
+
+ testUtils.dom.openDatepicker(form.$('.o_datepicker'));
+ assert.containsOnce($('body'), '.bootstrap-datetimepicker-widget');
+
// select 22 February at 8:23:33
- assert.ok($('.bootstrap-datetimepicker-widget').length, 'datepicker should be open');
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)'));
@@ -3065,7 +3069,7 @@ QUnit.module('basic_fields', {
});
QUnit.test('datetime field in editable list view', async function (assert) {
- assert.expect(8);
+ assert.expect(9);
var list = await createView({
View: ListView,
@@ -3101,8 +3105,11 @@ QUnit.module('basic_fields', {
assert.strictEqual(list.$('input.o_datepicker_input').val(), expectedDateString,
'the date should be correct in edit mode');
+ assert.containsNone($('body'), '.bootstrap-datetimepicker-widget');
+ testUtils.dom.openDatepicker(list.$('.o_datepicker'));
+ assert.containsOnce($('body'), '.bootstrap-datetimepicker-widget');
+
// select 22 February at 8:23:33
- assert.ok($('.bootstrap-datetimepicker-widget').length, 'datepicker should be open');
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)'));
@@ -3278,6 +3285,7 @@ QUnit.module('basic_fields', {
});
await testUtils.form.clickCreate(form);
+ testUtils.dom.openDatepicker(form.$('.o_datepicker'));
$.each($('.day:last-child(),.day:nth-child(2)'), function (index, value) {
assert.hasClass(value, 'disabled', 'first and last days must be disabled');
});
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 52900bed5f9..a0c1b682f17 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
@@ -3428,11 +3428,6 @@ QUnit.module('fields', {}, function () {
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']);
@@ -8343,6 +8338,65 @@ QUnit.module('fields', {}, function () {
form.destroy();
});
+
+ QUnit.test('one2many editable list: edit and click on add a line', async function (assert) {
+ assert.expect(9);
+
+ this.data.turtle.onchanges = {
+ turtle_int: function () {},
+ };
+
+ var form = await createView({
+ View: FormView,
+ model: 'partner',
+ data: this.data,
+ arch: '<form>' +
+ '<field name="turtles">' +
+ '<tree editable="bottom"><field name="turtle_int"/></tree>' +
+ '</field>' +
+ '</form>',
+ res_id: 1,
+ mockRPC: function (route, args) {
+ if (args.method === 'onchange') {
+ assert.step('onchange');
+ }
+ return this._super.apply(this, arguments);
+ },
+ // in this test, we want to to accurately mock what really happens, that is, input
+ // fields only trigger their changes on 'change' event, not on 'input'
+ fieldDebounce: 100000,
+ viewOptions: {
+ mode: 'edit',
+ },
+ });
+
+ assert.containsOnce(form, '.o_data_row');
+
+ // edit first row
+ await testUtils.dom.click(form.$('.o_data_row:first .o_data_cell:first'));
+ assert.hasClass(form.$('.o_data_row:first'), 'o_selected_row');
+ await testUtils.fields.editInput(form.$('.o_selected_row input[name=turtle_int]'), '44');
+
+ assert.verifySteps([]);
+ // simulate a long click on 'Add a line' (mousedown [delay] mouseup and click events)
+ var $addLine = form.$('.o_field_x2many_list_row_add a');
+ testUtils.dom.triggerEvents($addLine, 'mousedown');
+ // mousedown is supposed to trigger the change event on the edited input, but it doesn't
+ // in the test environment, for an unknown reason, so we trigger it manually to reproduce
+ // what really happens
+ testUtils.dom.triggerEvents(form.$('.o_selected_row input[name=turtle_int]'), 'change');
+ await testUtils.nextTick();
+
+ // release the click
+ await testUtils.dom.triggerEvents($addLine, ['mouseup', 'click']);
+ assert.verifySteps(['onchange', 'onchange']);
+
+ assert.containsN(form, '.o_data_row', 2);
+ assert.strictEqual(form.$('.o_data_row:first').text(), '44');
+ assert.hasClass(form.$('.o_data_row:nth(1)'), 'o_selected_row');
+
+ form.destroy();
+ });
});
});
});