summaryrefslogtreecommitdiff
path: root/addons/web/static/tests
diff options
context:
space:
mode:
authorAaron Bohy <aab@odoo.com>2021-02-17 09:27:48 +0000
committerJorge Pinna Puissant <jpp@odoo.com>2021-02-17 12:06:00 +0000
commit98f9cb4f692a15494cd8ef298673fe1c949c423c (patch)
tree26120f0c69b5c6b376133232e24cf1f823c76a65 /addons/web/static/tests
parente695cb7c7d6eb989fd0540412d137410363a483f (diff)
[FIX] web: correctly close confirm dialog
Let's assume the following scenario: - have an action in target new (e.g. a form view) - in the dialog, have an action/object button with confirm attribute - when clicking on that button, a confirm dialog opens - if validated, the following action returned by the server is again an action in target new Before this commit, the confirm dialog remained in the DOM. This issue occurred because it's parent wasn't correctly set (wrong use of `this`), so when the first dialog was destroyed, the confirm dialog wasn't automatically destroyed in turn. OPW~2440712 closes odoo/odoo#66345 X-original-commit: 2016fe31af970976775c9df160a31abfbec742ba Signed-off-by: Jorge Pinna Puissant (jpp) <jpp@odoo.com>
Diffstat (limited to 'addons/web/static/tests')
-rw-r--r--addons/web/static/tests/chrome/action_manager_tests.js52
1 files changed, 52 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 f8dc72c4a93..9ade9a544ec 100644
--- a/addons/web/static/tests/chrome/action_manager_tests.js
+++ b/addons/web/static/tests/chrome/action_manager_tests.js
@@ -4031,6 +4031,58 @@ QUnit.module('ActionManager', {
assert.strictEqual($(".modal").length, 1, "It should display a modal");
await testUtils.dom.click(`button[name="some_method"]`);
assert.strictEqual($(".modal").length, 0, "It should have closed the modal");
+
+ actionManager.destroy();
+ });
+
+ QUnit.test('can execute act_window actions in target="new"', async function (assert) {
+ assert.expect(5);
+
+ this.actions.push({
+ id: 999,
+ name: 'A window action',
+ res_model: 'partner',
+ target: 'new',
+ type: 'ir.actions.act_window',
+ views: [[999, 'form']],
+ });
+ this.archs['partner,999,form'] = `
+ <form>
+ <button name="method" string="Call method" type="object" confirm="Are you sure?"/>
+ </form>`;
+ this.archs['partner,1000,form'] = `<form>Another action</form>`;
+
+ const actionManager = await createActionManager({
+ actions: this.actions,
+ archs: this.archs,
+ data: this.data,
+ mockRPC: function (route, args) {
+ if (args.method === 'method') {
+ return Promise.resolve({
+ id: 1000,
+ name: 'Another window action',
+ res_model: 'partner',
+ target: 'new',
+ type: 'ir.actions.act_window',
+ views: [[1000, 'form']],
+ });
+ }
+ return this._super.apply(this, arguments);
+ },
+ });
+ await actionManager.doAction(999);
+
+ assert.containsOnce(document.body, '.modal button[name=method]');
+
+ await testUtils.dom.click($('.modal button[name=method]'));
+
+ assert.containsN(document.body, '.modal', 2);
+ assert.strictEqual($('.modal:last .modal-body').text(), 'Are you sure?');
+
+ await testUtils.dom.click($('.modal:last .modal-footer .btn-primary'));
+ assert.containsOnce(document.body, '.modal');
+ assert.strictEqual($('.modal:last .modal-body').text().trim(), 'Another action');
+
actionManager.destroy();
});