diff options
| author | Alexandre Kühn <aku@odoo.com> | 2018-08-31 11:37:12 +0200 |
|---|---|---|
| committer | Alexandre Kühn <aku@odoo.com> | 2018-08-31 12:21:51 +0200 |
| commit | cb91165b9f6ad6dc70233deafaaf9ffd1c39752d (patch) | |
| tree | effb1d03a27d05118a2ad7ff1b263fd61b3b22d3 /addons/web/static/tests/tools/debug_manager_tests.js | |
| parent | 2b51fefa5e44b2bec17d7ff3c58379e2387d7c54 (diff) | |
[REF] web: move debug_manager_tests in tools
Revision on https://github.com/odoo/odoo/commit/984554f4cacf3aa7c9750c2972539ab26c4eb3a7
So that folders in 'tests' is on par with folders in 'src/js'.
Diffstat (limited to 'addons/web/static/tests/tools/debug_manager_tests.js')
| -rw-r--r-- | addons/web/static/tests/tools/debug_manager_tests.js | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/addons/web/static/tests/tools/debug_manager_tests.js b/addons/web/static/tests/tools/debug_manager_tests.js new file mode 100644 index 00000000000..c63fd02e48d --- /dev/null +++ b/addons/web/static/tests/tools/debug_manager_tests.js @@ -0,0 +1,71 @@ +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; +}; + +QUnit.module('DebugManager', {}, function () { + + QUnit.test("edit view menu item", function (assert) { + assert.expect(3); + + var debugManager = createDebugManager(); + + debugManager.appendTo($('#qunit-fixture')); + + // Simulate update debug manager from web client + var action = { + views: [{ + fieldsView: { + view_id: 1, + }, + type: "list", + }], + }; + var view = { + viewType: "list", + }; + debugManager.update('action', action, view); + + var $editView = debugManager.$('a[data-action=edit][data-model="ir.ui.view"]'); + assert.strictEqual($editView.length, 1, "should have edit view menu item"); + assert.strictEqual($editView.text().trim(), "Edit View: List", + "should have correct menu item text for editing view"); + assert.strictEqual($editView.data('id'), 1, "should have correct view_id"); + + debugManager.destroy(); + }); +}); +}); |
