summaryrefslogtreecommitdiff
path: root/addons/web/static/tests/chrome
diff options
context:
space:
mode:
authorLucas Perais (lpe) <lpe@odoo.com>2018-06-29 15:46:26 +0200
committerLucas Perais (lpe) <lpe@odoo.com>2018-07-12 13:01:05 +0200
commitc9a2b9a00a5f73c20892d74575b1b4c4a3c4cd5c (patch)
tree7b44b763f6693514210763530211a026c4fcd053 /addons/web/static/tests/chrome
parent2b38f271d55cbec45bfe71e1905fbb9a3428093e (diff)
[FIX] web: keep searchview floating content on update
In a search view, write text in the input, then hit enter to select the facet. Before this commit, the search view was detached and then reattached when the control panel was refreshed. This led to loosing the focus momentarily and erasing any supplementary input one might have typed *during* the rpc call. After this commit, if the search view is the same as before, we don't detach it in the first place. Thus, the input is conserved in this situation. OPW 1861941 OPW 185614t closes #25546
Diffstat (limited to 'addons/web/static/tests/chrome')
-rw-r--r--addons/web/static/tests/chrome/action_manager_tests.js56
1 files changed, 56 insertions, 0 deletions
diff --git a/addons/web/static/tests/chrome/action_manager_tests.js b/addons/web/static/tests/chrome/action_manager_tests.js
index e057db97f7a..241a125dd3c 100644
--- a/addons/web/static/tests/chrome/action_manager_tests.js
+++ b/addons/web/static/tests/chrome/action_manager_tests.js
@@ -3119,6 +3119,62 @@ QUnit.module('ActionManager', {
actionManager.destroy();
});
+
+ QUnit.module('Search View Action');
+
+ QUnit.test('search view should keep focus during do_search', function (assert) {
+ assert.expect(5);
+
+ /* One should be able to type something in the search view, press on enter to
+ * make the facet and trigger the search, then do this process
+ * over and over again seamlessly.
+ * Verifying the input's value is a lot trickier than verifying the search_read
+ * because of how native events are handled in tests
+ */
+
+ var searchDeferred = $.Deferred();
+
+ var actionManager = createActionManager({
+ actions: this.actions,
+ archs: this.archs,
+ data: this.data,
+ mockRPC: function (route, args) {
+ if (route === '/web/dataset/search_read') {
+ assert.step('search_read ' + args.domain);
+ if ( _.isEqual(args.domain, [['foo', 'ilike', 'm']])) {
+ return searchDeferred.then(this._super.bind(this, route, args));
+ }
+ }
+ return this._super.apply(this, arguments);
+ }
+ });
+
+ actionManager.doAction(3);
+
+ var $searchInput = $('.o_searchview input');
+ $searchInput.trigger($.Event('keypress', {key: 'm', which: 109, keyCode: 109}));
+ $searchInput.trigger($.Event('keydown', {key: 'Enter', which: 13, keyCode: 13}));
+
+ assert.verifySteps(["search_read ",
+ "search_read foo,ilike,m"]);
+
+ // Triggering the do_search above will kill the current searchview Input
+ $searchInput = $('.o_searchview input');
+ $searchInput.trigger($.Event('keypress', {key: 'o', which: 111, keyCode: 111}));
+
+ // We have something in the input of the search view. Making the search_read
+ // return at this point will trigger the redraw of the view.
+ // However we want to hold on to what we just typed
+ searchDeferred.resolve();
+
+ $searchInput.trigger($.Event('keydown', {key: 'Enter', which: 13, keyCode: 13}));
+
+ assert.verifySteps(["search_read ",
+ "search_read foo,ilike,m",
+ "search_read |,foo,ilike,m,foo,ilike,o"]);
+
+ actionManager.destroy();
+ });
});
});