diff options
| author | Géry Debongnie <ged@odoo.com> | 2017-02-24 11:53:28 +0100 |
|---|---|---|
| committer | Aaron Bohy <aab@odoo.com> | 2017-04-11 19:44:38 +0200 |
| commit | 064d7f462122bd5193e094d8b03c132cb43d14a2 (patch) | |
| tree | c91d7b68d2deb5267f1436539ce727703a5af9a0 /addons/web/static/test/fields/basic_fields_tests.js | |
| parent | 7c41254d8f5474deb755fbd5ff9ce6f40576fa5e (diff) | |
[FIX] web: make focus tests works if window has not the focus
Until now, those tests failed if the window did not have the focus. We
solve the issue with 2 different fixes:
* instead of checking that the focus property is set, we can check the
activeElement instead, it seems to work.
* instead of calling the focus method, in some tests, we can trigger a
* 'focusin' event. I don't know why this works, but it does.
Note that this might make the tests work in phantomjs
Diffstat (limited to 'addons/web/static/test/fields/basic_fields_tests.js')
| -rw-r--r-- | addons/web/static/test/fields/basic_fields_tests.js | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/addons/web/static/test/fields/basic_fields_tests.js b/addons/web/static/test/fields/basic_fields_tests.js index 0d03b98e467..cdba48ceff3 100644 --- a/addons/web/static/test/fields/basic_fields_tests.js +++ b/addons/web/static/test/fields/basic_fields_tests.js @@ -333,8 +333,8 @@ QUnit.module('basic_fields', { list.$buttons.find('.o_list_button_add').click(); - assert.ok(list.$('textarea').first().is(':focus'), - "text area should have the focus (make sure the test window had the focus)"); + assert.strictEqual(list.$('textarea').first().get(0), document.activeElement, + "text area should have the focus"); }); @@ -538,8 +538,8 @@ QUnit.module('basic_fields', { assert.strictEqual(list.$('input.o_datepicker_input').length, 1, "the view should have a date input for editable mode"); - assert.ok(list.$('input.o_datepicker_input').is(':focus'), - "date input should have the focus (make sure the test window had the focus)"); + assert.strictEqual(list.$('input.o_datepicker_input').get(0), document.activeElement, + "date input should have the focus"); }); QUnit.module('FieldDomain'); @@ -581,7 +581,7 @@ QUnit.module('basic_fields', { // Focusing the field selector input should open the field selector // popover - $fieldSelector.find("> input").focus(); + $fieldSelector.find("> input").trigger('focusin'); var $fieldSelectorPopover = $fieldSelector.find(".o_field_selector_popover"); assert.ok($fieldSelectorPopover.is(":visible"), "field selector popover should be visible"); @@ -646,7 +646,7 @@ QUnit.module('basic_fields', { "there should be a field selector"); // Focusing its input should open the field selector popover - $fieldSelector.find("> input").focus(); + $fieldSelector.find("> input").trigger('focusin'); var $fieldSelectorPopover = $fieldSelector.find(".o_field_selector_popover"); assert.ok($fieldSelectorPopover.is(":visible"), "field selector popover should be visible"); @@ -671,7 +671,7 @@ QUnit.module('basic_fields', { // Refocusing the field selector input should open the popover again $fieldSelector = form.$(".o_field_selector"); - $fieldSelector.find("> input").focus(); + $fieldSelector.find("> input").trigger('focusin'); $fieldSelectorPopover = $fieldSelector.find(".o_field_selector_popover"); assert.ok($fieldSelectorPopover.is(":visible"), "field selector popover should be visible"); |
