summaryrefslogtreecommitdiff
path: root/addons/web/static/tests/fields/upgrade_fields_tests.js
diff options
context:
space:
mode:
authorstephanchrst <stephanchrst@gmail.com>2022-05-10 21:51:50 +0700
committerstephanchrst <stephanchrst@gmail.com>2022-05-10 21:51:50 +0700
commit3751379f1e9a4c215fb6eb898b4ccc67659b9ace (patch)
treea44932296ef4a9b71d5f010906253d8c53727726 /addons/web/static/tests/fields/upgrade_fields_tests.js
parent0a15094050bfde69a06d6eff798e9a8ddf2b8c21 (diff)
initial commit 2
Diffstat (limited to 'addons/web/static/tests/fields/upgrade_fields_tests.js')
-rw-r--r--addons/web/static/tests/fields/upgrade_fields_tests.js66
1 files changed, 66 insertions, 0 deletions
diff --git a/addons/web/static/tests/fields/upgrade_fields_tests.js b/addons/web/static/tests/fields/upgrade_fields_tests.js
new file mode 100644
index 00000000..d908fd48
--- /dev/null
+++ b/addons/web/static/tests/fields/upgrade_fields_tests.js
@@ -0,0 +1,66 @@
+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', async function (assert) {
+ assert.expect(1);
+
+ var form = await createView({
+ View: FormView,
+ model: 'partner',
+ data: this.data,
+ arch: '<form><field name="bar" widget="upgrade_boolean"/></form>',
+ });
+
+ await testUtils.dom.click(form.$('input:checkbox'));
+ assert.strictEqual($('.modal').length, 1,
+ "the 'Upgrade to Enterprise' dialog should be opened");
+
+ form.destroy();
+ });
+
+ QUnit.test('widget upgrade_boolean in a form view', async function (assert) {
+ assert.expect(3);
+
+ var form = await 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.containsNone(form, '.o_field .badge',
+ "the upgrade badge shouldn't be inside the field section");
+ assert.containsOnce(form, '.o_label .badge',
+ "the upgrade badge 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();
+ });
+
+});
+});
+});