Files
odoo_source/addons/web/static/tests/fields/upgrade_fields_tests.js
T
Martin Geubelle cb540c48eb [FIX] web: correctly display the enterprise label
The `upgrade_boolean` widget should display an `Enterprise` label next to it.

There is however an issue when a `label` is specified for this field. In this case,
the `Enterprise` label should be placed next to the field label (and not the field
itself).

The easiest solution would have been to instantiate the field widget with its label,
but this can't work because the field widget is instantiated before its label.

We thus re-render the widget after its label creation.
2017-09-15 16:36:40 +02:00

67 lines
1.9 KiB
JavaScript
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
odoo.define('web.upgrade_fields_tests', function (require) {
"use strict";
var FormView = require('web.FormView');
var testUtils = require('web.test_utils');
var createView = testUtils.createView;
QUnit.module('fields', {}, function () {
QUnit.module('upgrade_fields', {
beforeEach: function () {
this.data = {
partner: {
fields: {
bar: {string: "Bar", type: "boolean"},
},
}
};
},
}, function () {
QUnit.module('UpgradeBoolean');
QUnit.test('widget upgrade_boolean in a form view', function (assert) {
assert.expect(1);
var form = createView({
View: FormView,
model: 'partner',
data: this.data,
arch: '<form><field name="bar" widget="upgrade_boolean"/></form>',
});
form.$('input:checkbox').click();
assert.strictEqual($('.modal').length, 1,
"the 'Upgrade to Enterprise' dialog should be opened");
form.destroy();
});
QUnit.test('widget upgrade_boolean in a form view', function (assert) {
assert.expect(3);
var form = createView({
View: FormView,
model: 'partner',
data: this.data,
arch: '<form>' +
'<div class="o_field"><field name="bar" widget="upgrade_boolean"/></div>' +
'<div class="o_label"><label for="bar"/><div>Coucou</div></div>' +
'</form>',
});
assert.strictEqual(form.$('.o_field .label').length, 0,
"the upgrade label shouldn't be inside the field section");
assert.strictEqual(form.$('.o_label .label').length, 1,
"the upgrade label should be inside the label section");
assert.strictEqual(form.$('.o_label').text(), "Bar EnterpriseCoucou",
"the upgrade label should be inside the label section");
form.destroy();
});
});
});
});