diff options
| author | stephanchrst <stephanchrst@gmail.com> | 2022-05-10 21:51:50 +0700 |
|---|---|---|
| committer | stephanchrst <stephanchrst@gmail.com> | 2022-05-10 21:51:50 +0700 |
| commit | 3751379f1e9a4c215fb6eb898b4ccc67659b9ace (patch) | |
| tree | a44932296ef4a9b71d5f010906253d8c53727726 /addons/base_automation/static/tests | |
| parent | 0a15094050bfde69a06d6eff798e9a8ddf2b8c21 (diff) | |
initial commit 2
Diffstat (limited to 'addons/base_automation/static/tests')
| -rw-r--r-- | addons/base_automation/static/tests/base_automation_error_dialog.js | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/addons/base_automation/static/tests/base_automation_error_dialog.js b/addons/base_automation/static/tests/base_automation_error_dialog.js new file mode 100644 index 00000000..af2e9ff6 --- /dev/null +++ b/addons/base_automation/static/tests/base_automation_error_dialog.js @@ -0,0 +1,72 @@ +odoo.define('base_automation.BaseAutomatioErrorDialogTests', function (require) { +'use strict'; + + const CrashManager = require('web.CrashManager').CrashManager; + const session = require('web.session'); + + QUnit.module('base_automation', {}, function () { + + QUnit.module('Error Dialog'); + + QUnit.test('Error due to an automated action', async function (assert) { + assert.expect(4); + + let baseAutomationName = 'Test base automation error dialog'; + let error = { + type: 'Odoo Client Error', + message: 'Message', + data: { + debug: 'Traceback', + context: { + exception_class: 'base_automation', + base_automation: { + id: 1, + name: baseAutomationName, + }, + }, + }, + }; + // Force the user session to be admin, to display the disable and edit action buttons, + // then reset back to the origin value after the test. + let isAdmin = session.is_admin; + session.is_admin = true; + + let crashManager = new CrashManager(); + let dialog = crashManager.show_error(error); + + await dialog._opened; + + assert.containsOnce(document.body, '.modal .o_clipboard_button'); + assert.containsOnce(document.body, '.modal .o_disable_action_button'); + assert.containsOnce(document.body, '.modal .o_edit_action_button'); + assert.ok(dialog.$el.text().indexOf(baseAutomationName) !== -1); + + session.is_admin = isAdmin; + crashManager.destroy(); + }); + + QUnit.test('Error not due to an automated action', async function (assert) { + assert.expect(3); + + let error = { + type: 'Odoo Client Error', + message: 'Message', + data: { + debug: 'Traceback', + }, + }; + let crashManager = new CrashManager(); + let dialog = crashManager.show_error(error); + + await dialog._opened; + + assert.containsOnce(document.body, '.modal .o_clipboard_button'); + assert.containsNone(document.body, '.modal .o_disable_action_button'); + assert.containsNone(document.body, '.modal .o_edit_action_button'); + + crashManager.destroy(); + }); + + }); + +}); |
