summaryrefslogtreecommitdiff
path: root/addons/web/static/tests/views/abstract_controller_tests.js
diff options
context:
space:
mode:
authoreco-odoo <eco@odoo.com>2018-05-11 11:25:53 +0200
committerGéry Debongnie <ged@odoo.com>2018-05-14 09:44:16 +0200
commitb19b9e756c973b82dddb75f22d0af9893e3438e4 (patch)
treec65c84232fb55bf297c09b2adfac775b679af74a /addons/web/static/tests/views/abstract_controller_tests.js
parentc1f04bef83aa74edd0cd2c8cf8aa4ff0a6de6aa4 (diff)
[FIX] web: click on <a> with type="action" triggers the correct action
Without this fix, clicks on <a> with a sub html tag do not work.
Diffstat (limited to 'addons/web/static/tests/views/abstract_controller_tests.js')
-rw-r--r--addons/web/static/tests/views/abstract_controller_tests.js74
1 files changed, 74 insertions, 0 deletions
diff --git a/addons/web/static/tests/views/abstract_controller_tests.js b/addons/web/static/tests/views/abstract_controller_tests.js
new file mode 100644
index 00000000000..c9b7daa45dc
--- /dev/null
+++ b/addons/web/static/tests/views/abstract_controller_tests.js
@@ -0,0 +1,74 @@
+odoo.define("base.abstract_controller_tests", function(require) {
+ "use strict";
+
+ var testUtils = require("web.test_utils");
+ var createView = testUtils.createView;
+ var BasicView = require("web.BasicView");
+ var BasicRenderer = require("web.BasicRenderer");
+
+ function getHtmlRenderer(html) {
+ return BasicRenderer.extend({
+ start: function() {
+ this.$el.html(html);
+ return this._super.apply(this, arguments);
+ }
+ });
+ }
+ function getHtmlView(html, viewType) {
+ viewType = viewType || "test";
+ return BasicView.extend({
+ viewType: viewType,
+ config: _.extend({}, BasicView.prototype.config, {
+ Renderer: getHtmlRenderer(html)
+ })
+ });
+ }
+
+ QUnit.module(
+ "Views",
+ {
+ beforeEach: function() {
+ this.data = {
+ test_model: {
+ fields: {},
+ records: []
+ }
+ };
+ }
+ },
+ function() {
+
+ QUnit.module('AbstractController');
+
+ QUnit.test(
+ 'click on a a[type="action"] child triggers the correct action',
+ function(assert) {
+ assert.expect(3);
+
+ var html =
+ "<div>" +
+ '<a name="a1" type="action" class="simple">simple</a>' +
+ '<a name="a2" type="action" class="with-child">' +
+ "<span>child</input>" +
+ "</a>" +
+ "</div>";
+
+ var view = createView({
+ View: getHtmlView(html, "test"),
+ data: this.data,
+ model: "test_model",
+ arch: "<test/>",
+ intercepts: {
+ do_action: function(event) {
+ assert.step(event.data.action);
+ }
+ }
+ });
+ view.$(".simple").click();
+ view.$(".with-child span").click();
+ assert.verifySteps(["a1", "a2"]);
+ }
+ );
+ }
+ );
+});