Files
odoo_source/addons/web/static/test/views/view_dialogs_tests.js
T
Géry Debongnie dde1223a14 [REF] *: remove manualDestroy options for tests
With the new JS test framework, we had experimented with an autodestroy
feature, meaning that all views/widgets are automatically destroyed
after a while.  By default, it was 50ms, because we could not hook some
code to run after the end of the current test.

For various reasons, this was not a good idea: some side effects, such
as modifications of the session or of the DOM (with modals) could
interfere with other tests.  This commit disable the feature.

From now on, we will have to destroy each widgets created in a test.
2017-04-11 19:44:38 +02:00

63 lines
1.7 KiB
JavaScript

odoo.define('web.view_dialogs_tests', function (require) {
"use strict";
var testUtils = require('web.test_utils');
var dialogs = require('web.view_dialogs');
var Widget = require('web.Widget');
QUnit.module('Views', {
beforeEach: function () {
this.data = {
partner: {
fields: {
foo: {string: "Foo", type: 'char'},
},
records: [
{id: 1, foo: 'blip',},
],
},
};
},
}, function () {
QUnit.module('view_dialogs');
function createParent(params) {
var widget = new Widget();
testUtils.addMockEnvironment(widget, params);
return widget;
}
QUnit.test('formviewdialog buttons in footer are positioned properly', function (assert) {
assert.expect(2);
var parent = createParent({
data: this.data,
archs: {
'partner,false,form':
'<form string="Partner">' +
'<sheet>' +
'<group><field name="foo"/></group>' +
'<footer><button string="Custom Button" type="object" class="btn-primary"/></footer>' +
'</sheet>' +
'</form>',
},
});
var dialog = new dialogs.FormViewDialog(parent, {
res_model: 'partner',
res_id: 1,
}).open();
assert.notOk($('div.modal .modal-body button').length,
"should not have any button in body");
assert.strictEqual($('div.modal .modal-footer button').length, 1,
"should have only one button in footer");
dialog.destroy();
});
});
});