summaryrefslogtreecommitdiff
path: root/addons/web/static/tests/tools/debug_manager_tests.js
diff options
context:
space:
mode:
authorThanhDodeurOdoo <tso@odoo.com>2018-09-06 10:45:32 +0200
committerThanhDodeurOdoo <tso@odoo.com>2018-09-13 11:50:26 +0200
commitd12b88315536150931b01e219c79b248b1fa9c40 (patch)
tree677461f120e5e63e71d58c41368f46d0e8164840 /addons/web/static/tests/tools/debug_manager_tests.js
parent7f97c9fc056a0949c61c8444ee20f4c95bb3e9a9 (diff)
[IMP] mail, web: attachments & messages in debug actions.
- added two new actions to the form view debug action list, both opens list (+ form) views of messages and attachments respectively for which the domain is restricted to the current record. task: 1860031
Diffstat (limited to 'addons/web/static/tests/tools/debug_manager_tests.js')
-rw-r--r--addons/web/static/tests/tools/debug_manager_tests.js82
1 files changed, 49 insertions, 33 deletions
diff --git a/addons/web/static/tests/tools/debug_manager_tests.js b/addons/web/static/tests/tools/debug_manager_tests.js
index 424ebe1517f..8e41481734f 100644
--- a/addons/web/static/tests/tools/debug_manager_tests.js
+++ b/addons/web/static/tests/tools/debug_manager_tests.js
@@ -1,44 +1,13 @@
odoo.define('web.debugManagerTests', function (require) {
"use strict";
-var DebugManager = require('web.DebugManager');
var testUtils = require('web.test_utils');
-/**
- * Create and return an instance of DebugManager with all rpcs going through a
- * mock method, assuming that the user has access rights, and is an admin.
- *
- * @param {Object} [params={}]
- */
-var createDebugManager = function (params) {
- params = params || {};
- _.extend(params, {
- mockRPC: function (route, args) {
- if (args.method === 'check_access_rights') {
- return $.when(true);
- }
- if (args.method === 'xmlid_to_res_id') {
- return $.when(true);
- }
- return this._super.apply(this, arguments);
- },
- session: {
- user_has_group: function (group) {
- if (group === 'base.group_no_one') {
- return $.when(true);
- }
- return this._super.apply(this, arguments);
- },
- },
- });
- var debugManager = new DebugManager();
- testUtils.addMockEnvironment(debugManager, params);
- return debugManager;
-};
+var createDebugManager = testUtils.createDebugManager;
QUnit.module('DebugManager', {}, function () {
- QUnit.test("edit view menu item", function (assert) {
+ QUnit.test("list: edit view menu item", function (assert) {
assert.expect(3);
var debugManager = createDebugManager();
@@ -68,5 +37,52 @@ QUnit.module('DebugManager', {}, function () {
debugManager.destroy();
});
+
+ QUnit.test("form: Manage Attachments option", function (assert) {
+ assert.expect(3);
+
+ var debugManager = createDebugManager({
+ intercepts: {
+ do_action: function (event) {
+ assert.deepEqual(event.data.action, {
+ domain: [["res_model", "=", "test.model"],["res_id", "=", 5]],
+ name: "Manage Attachments",
+ res_model: "ir.attachment",
+ type: "ir.actions.act_window",
+ views: [[false, "list"],[false, "form"]],
+ });
+ },
+ },
+ });
+
+ debugManager.appendTo($('#qunit-fixture'));
+
+ // Simulate update debug manager from web client
+ var action = {
+ views: [{
+ displayName: "Form",
+ fieldsView: {
+ view_id: 2,
+ },
+ type: "form",
+ }],
+ res_model: "test.model",
+ };
+ var view = {
+ viewType: "form",
+ getSelectedIds: function () {
+ return [5];
+ },
+ };
+ debugManager.update('action', action, view);
+
+ var $attachmentMenu = debugManager.$('a[data-action=get_attachments]');
+ assert.strictEqual($attachmentMenu.length, 1, "should have Manage Attachments menu item");
+ assert.strictEqual($attachmentMenu.text().trim(), "Manage Attachments",
+ "should have correct menu item text");
+ $attachmentMenu.click();
+
+ debugManager.destroy();
+ });
});
});