From c2b4790be426f039ec47b0888b5e58c7970c3dae Mon Sep 17 00:00:00 2001 From: Vincent Schippefilt Date: Tue, 25 Sep 2018 20:48:22 +0200 Subject: [FIX] web: fix date picker fields do not capture the focus event when invisible Before this fix, in form view, when a datepicker was not visible (because they were on another page or literally invisible), when the user pressed TAB and the datepicker was positionned after the current field in the form, it was capturing the focus during the activate phase of the navigation_move. This is not correct for invisible elements. After this fix, only focusable datepickers get the focus during the activation phase of the navigation_move. co-author: aab-odoo (aab@odoo.com) --- .../web/static/tests/fields/basic_fields_tests.js | 43 +++++++++++++++++----- 1 file changed, 34 insertions(+), 9 deletions(-) (limited to 'addons/web/static/tests/fields/basic_fields_tests.js') diff --git a/addons/web/static/tests/fields/basic_fields_tests.js b/addons/web/static/tests/fields/basic_fields_tests.js index 6e2188d2998..5b59e4f8c5d 100644 --- a/addons/web/static/tests/fields/basic_fields_tests.js +++ b/addons/web/static/tests/fields/basic_fields_tests.js @@ -718,7 +718,7 @@ QUnit.module('basic_fields', { '' + '', res_id: 4, - translateParameters: { + translateParameters: { thousands_sep: ",", grouping: [3, 0], }, @@ -752,7 +752,7 @@ QUnit.module('basic_fields', { '' + '', res_id: 4, - translateParameters: { + translateParameters: { thousands_sep: ",", grouping: [3, 0], }, @@ -761,7 +761,7 @@ QUnit.module('basic_fields', { form.$buttons.find('.o_form_button_edit').click(); assert.strictEqual(form.$('.o_field_widget').attr('type'), 'text', 'Float field with option type must have a text type (default type).'); - + form.$('input').val('123456.7890').trigger('input'); form.$buttons.find('.o_form_button_save').click(); form.$buttons.find('.o_form_button_edit').click(); @@ -2772,7 +2772,32 @@ QUnit.module('basic_fields', { form.destroy(); }); - QUnit.test('datetime field in form view 2', function (assert) { + + QUnit.test('datetime field not visible in form view should not capture the focus on keyboard navigation', function (assert) { + assert.expect(1); + + var form = createView({ + View: FormView, + model: 'partner', + data: this.data, + arch:'
' + + '', + res_id: 1, + viewOptions: { + mode: 'edit', + }, + }); + + form.$el.find('textarea[name=txt]').trigger($.Event('keydown', { + which: $.ui.keyCode.TAB, + keyCode: $.ui.keyCode.TAB, + })); + assert.strictEqual(document.activeElement, form.$buttons.find('.o_form_button_save')[0], + "the save button should be selected, because the datepicker did not capture the focus"); + form.destroy(); + }); + + QUnit.test('datetime field with datetime formatted without second', function (assert) { assert.expect(2); this.data.partner.fields.datetime.default = "2017-08-02 12:00:05"; @@ -3514,7 +3539,7 @@ QUnit.module('basic_fields', { '' + '', res_id: 4, - translateParameters: { + translateParameters: { thousands_sep: ",", grouping: [3, 0], }, @@ -3525,7 +3550,7 @@ QUnit.module('basic_fields', { 'Integer field with option type must have a type attribute.'); assert.strictEqual(form.$('.o_field_widget').attr('type'), 'number', 'Integer field with option type must have a type attribute equals to "number".'); - + form.$('input').val('1234567890').trigger('input'); form.$buttons.find('.o_form_button_save').click(); form.$buttons.find('.o_form_button_edit').click(); @@ -3534,7 +3559,7 @@ QUnit.module('basic_fields', { form.$buttons.find('.o_form_button_save').click(); 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(); }); @@ -3549,7 +3574,7 @@ QUnit.module('basic_fields', { '' + '', res_id: 4, - translateParameters: { + translateParameters: { thousands_sep: ",", grouping: [3, 0], }, @@ -3558,7 +3583,7 @@ QUnit.module('basic_fields', { form.$buttons.find('.o_form_button_edit').click(); assert.strictEqual(form.$('.o_field_widget').attr('type'), 'text', 'Integer field without option type must have a text type (default type).'); - + form.$('input').val('1234567890').trigger('input'); form.$buttons.find('.o_form_button_save').click(); form.$buttons.find('.o_form_button_edit').click(); -- cgit v1.2.3 From a47f6093f80cefa51c5a1bc1301db01007f97761 Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Tue, 2 Oct 2018 20:32:40 +0200 Subject: [ADD] auth_password_policy{_signup}: password strength widgets * generic strenght meter widget which can be included in various places * password field, taking over the isPassword special cases strewn throughout the codebase, this should probably become an actual thing in core /cc @ged-odoo, the meter is opt-in as most uses of `field[@password=True]` are passwords & secrets for third-party services or external servers for which a meter would not make sense * separate override of the ChangePassword wizard which isn't a regular view for some reason * direct implementation for signup pages (create user & reset password) Skip/comment/remove existing testing of @password fields: the policy replacement/augmentation needs to make an RPC call and does not support readonly use (because it doesn't seem to be used anywhere so that made sense?); and there currently is no way to augment or override/replace existing tests, so the tests will either fail when auth_password_policy is installed (current situation) or fail when auth_password_policy is not installed (if updated to be compatible with APP). --- addons/web/static/tests/fields/basic_fields_tests.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'addons/web/static/tests/fields/basic_fields_tests.js') diff --git a/addons/web/static/tests/fields/basic_fields_tests.js b/addons/web/static/tests/fields/basic_fields_tests.js index 5b59e4f8c5d..c1d51b3a1c5 100644 --- a/addons/web/static/tests/fields/basic_fields_tests.js +++ b/addons/web/static/tests/fields/basic_fields_tests.js @@ -1246,7 +1246,10 @@ QUnit.module('basic_fields', { form.destroy(); }); - QUnit.test('input field: change password value', function (assert) { + QUnit.skip('input field: change password value', function (assert) { + // password policy needs an RPC call to initialize & + // presents somewhat differently (custom widget), need way + // to augment/override tests assert.expect(4); var form = createView({ @@ -1259,7 +1262,7 @@ QUnit.module('basic_fields', { res_id: 1, }); - assert.notOk(form.$('.o_field_char').text() === "yop", + assert.notEqual(form.$('.o_field_char').text(), "yop", "password field value should not be visible in read mode"); assert.strictEqual(form.$('.o_field_char').text(), "***", "password field value should be hidden with '*' in read mode"); @@ -1274,7 +1277,7 @@ QUnit.module('basic_fields', { form.destroy(); }); - QUnit.test('input field: empty password', function (assert) { + QUnit.skip('input field: empty password', function (assert) { assert.expect(3); this.data.partner.records[0].foo = false; -- cgit v1.2.3