diff options
| author | Alexandre Kühn <aku@odoo.com> | 2020-01-22 09:29:23 +0000 |
|---|---|---|
| committer | Alexandre Kühn <aku@odoo.com> | 2020-01-30 14:11:06 +0000 |
| commit | 7a691c8eb09bb1a554eefca972ba6d545919d0c7 (patch) | |
| tree | 6744f2ea500787cbaff284850397ac9fc2028b21 /addons/web/static/tests | |
| parent | 8b9f17ee9025906c1598c47321091bb96a4473b2 (diff) | |
[FIX] web: update search view menu on click IME suggestion menu
Before this commit, when typing something in the search view in
Japanese, and then clicking on a suggestion from the IME dropdown
menu, the search view menu did not update with selection.
Steps to reproduce:
- Enable Japanese IME in hiragana mode;
- Type "test" in search view;
- Soft-select another suggestion item, e.g. "テスト";
- Double-click on suggestion item "test";
=> The search view menu still detects "テスト".
As a result, clicking on any of these search view suggested filters
picks "テスト" instead of "test".
This commit fixes the issue by updating search menu when clicking
in a suggestion in the IME menu.
opw-2061590
closes odoo/odoo#44318
X-original-commit: 0bca4c0883f2b58842da6a8c1a4e26bf2444d5f3
Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
Diffstat (limited to 'addons/web/static/tests')
| -rw-r--r-- | addons/web/static/tests/views/search_view_tests.js | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/addons/web/static/tests/views/search_view_tests.js b/addons/web/static/tests/views/search_view_tests.js index fb5174a056f..5d680488981 100644 --- a/addons/web/static/tests/views/search_view_tests.js +++ b/addons/web/static/tests/views/search_view_tests.js @@ -1538,6 +1538,86 @@ QUnit.module('Search View', { actionManager.destroy(); }); + QUnit.test('update suggested filters in autocomplete menu with Japanese IME', async function (assert) { + assert.expect(4); + + this.actions.push({ + id: 13, + name: 'Partners Action 11', + res_model: 'partner', + type: 'ir.actions.act_window', + views: [[false, 'list']], + search_view_id: [13, 'search'], + }); + this.archs['partner,13,search'] = ` + <search> + <field name="foo"/> + <field name="bar"/> + </search>`; + + const actionManager = await createActionManager({ + actions: this.actions, + archs: this.archs, + data: this.data, + }); + actionManager.doAction(13); + await testUtils.nextTick(); + + // Simulate typing "Test" on search view. + const TEST = "TEST"; + $('.o_searchview_input').val(TEST); + for (const char of TEST) { + $('.o_searchview_input').trigger($.Event('keypress', { + which: char.charCodeAt(0), + keyCode: char.charCodeAt(0), + })); + } + $('.o_searchview_input').trigger($.Event('keyup')); + await testUtils.nextTick(); + assert.containsOnce( + $, + '.o_searchview_autocomplete', + "should display autocomplete dropdown menu on typing something in search view" + ); + assert.strictEqual( + $('.o_searchview_autocomplete li:first').text(), + "Search Foo for: TEST", + `1st filter suggestion should be based on typed word "TEST"` + ); + + // Simulate soft-selection of another suggestion from IME. + const テスト = "テスト"; + $('.o_searchview_input').val(テスト); + for (const char of テスト) { + $('.o_searchview_input').trigger($.Event('keypress', { + which: char.charCodeAt(0), + keyCode: char.charCodeAt(0), + })); + } + $('.o_searchview_input').trigger($.Event('keyup')); + await testUtils.nextTick(); + assert.strictEqual( + $('.o_searchview_autocomplete li:first').text(), + "Search Foo for: テスト", + `1st filter suggestion should be updated with soft-selection typed word "テスト"` + ); + + // Simulate selection on suggestion item "Test" from IME. + $('.o_searchview_input').val("TEST"); + const nativeInputEvent = new window.InputEvent('input', { inputType: 'insertCompositionText' }); + const jqueryInputEvent = $.Event('input', { bubbles: true }); + jqueryInputEvent.originalEvent = nativeInputEvent; + $('.o_searchview_input').trigger(jqueryInputEvent); + await testUtils.nextTick(); + assert.strictEqual( + $('.o_searchview_autocomplete li:first').text(), + "Search Foo for: TEST", + `1st filter suggestion should finally be updated with click selection on word "TEST" from IME` + ); + + actionManager.destroy(); + }); + QUnit.module('TimeRangeMenu'); QUnit.test('time range menu stays hidden', async function (assert) { |
