[FIX] tests

This commit is contained in:
KKamaa
2022-03-27 17:47:54 +03:00
parent 139d6ea1e2
commit 872ae6cb09
4 changed files with 99 additions and 0 deletions

View File

@@ -34,3 +34,6 @@ class ResConfigSettings(models.TransientModel):
support_branding_color = fields.Char(string="Branding color")
support_email = fields.Char(string="Support email")
support_release = fields.Char(string="Support release")
def test_support_branding_error(self):
return 9 / 0

View File

@@ -0,0 +1,68 @@
odoo.define('support_branding.crash_manager_tests', function (require) {
"use strict";
const CrashManager = require('web.CrashManager').CrashManager;
const testUtils = require('web.test_utils');
const createActionManager = testUtils.createActionManager;
QUnit.module('support_branding', {}, function() {
QUnit.test("Error Dialog is created", async function (assert) {
// No of assertion expected.
assert.expect(5);
// Create action manager to trigger error dialog
var actionManager = await createActionManager({
services: {
crash_manager: CrashManager,
}
});
// Check if action with crash manager service was created.
assert.notOk(_.isEmpty(actionManager), "Action manager with " +
"crash manager service should be created and not empty");
// Test custom error
let error = {
type: 'Support Branding Odoo Client Error',
message: 'Message',
data: {
debug: 'Traceback',
},
};
// NB: This will use the saved res.config settings of support
// branding containing the support mail. It is fetched in crash
// manager init function as saved in res.config settings.
// attached is a default data xml with sample data.
actionManager.call('crash_manager', 'show_error', error);
await testUtils.nextTick();
var $mail_dialog = 'form.support-branding-submit-form';
// Confirm if we have a form and its required elements.
assert.containsOnce($, $mail_dialog, "Error dialog should be " +
"opened and showing mail section on footer");
assert.containsOnce($, '.support-desc', 'We should have a ' +
'textarea to add our issues');
assert.containsOnce($, 'button.support-btn', 'We should have a ' +
'send mail button to send support mail');
// Add a test text mail.
$(".support-desc").val("Send this as a test mail to " +
"configured support mail");
// Try to send mail, by default a popup will be triggered
// defaulting to form call of 'mailto'.
await testUtils.dom.click($('button.support-btn'),
{allowInvisible: true});
// Close error dialog
await testUtils.dom.click($('button.close'),
{allowInvisible: true});
// Confirm dialog was closed
assert.containsNone($, $mail_dialog,
"Error Dialog should be closed");
actionManager.destroy();
});
});
});

View File

@@ -25,4 +25,16 @@
/>
</xpath>
</template>
<template
id="support_branding_qunit_suite_tests"
name="Support Branding tests"
inherit_id="web.qunit_suite_tests"
>
<xpath expr="//script[last()]" position="after">
<script
type="text/javascript"
src="/support_branding/static/src/tests/support_branding_tests.js"
/>
</xpath>
</template>
</odoo>

View File

@@ -83,7 +83,23 @@
<field name="support_release" />
</div>
</div>
<br /> <br />
<div class="text-muted">
The below button generates a
division by zero python error which
allows a user to test the modules
functionality.
</div>
<br />
<button
name="test_support_branding_error"
string="Test Support Branding"
class="oe_highlight"
type="object"
data-toggle="tooltip"
title="Creates an error (i.e ZeroDivisionError) to test support branding"
/>
<br /> <br />
</div>
</div>
</div>