summaryrefslogtreecommitdiff
path: root/addons/web/static/tests/fields/basic_fields_tests.js
diff options
context:
space:
mode:
authorDeep Patel <dep@odoo.com>2017-09-12 18:40:29 +0530
committerAaron Bohy <aab@odoo.com>2017-09-20 10:56:57 +0200
commit9b9fcfe628f330bf31bfb841476d496e7892153f (patch)
tree4318a8c3bed39f67362f15ef835311c3f969c655 /addons/web/static/tests/fields/basic_fields_tests.js
parent48b8be29fa1e8c10f2ce652a768d3dcb581a53a2 (diff)
[FIX] web,base: document template widget in settings
Go to General Settings, click on 'Change Document Template', and in the opened dialog, click on a template. Before this rev., it automatically closed the dialog, which was not really convenient. This rev. introduces a new field widget (image_selection) for this use case, and ensures that the dialog doesn't close when a template is selected. Test written by @mba-odoo
Diffstat (limited to 'addons/web/static/tests/fields/basic_fields_tests.js')
-rw-r--r--addons/web/static/tests/fields/basic_fields_tests.js41
1 files changed, 41 insertions, 0 deletions
diff --git a/addons/web/static/tests/fields/basic_fields_tests.js b/addons/web/static/tests/fields/basic_fields_tests.js
index 9d0d0807199..91029cf9cfc 100644
--- a/addons/web/static/tests/fields/basic_fields_tests.js
+++ b/addons/web/static/tests/fields/basic_fields_tests.js
@@ -38,6 +38,8 @@ QUnit.module('basic_fields', {
selection: {string: "Selection", type: "selection", searchable:true,
selection: [['normal', 'Normal'],['blocked', 'Blocked'],['done', 'Done']]},
document: {string: "Binary", type: "binary"},
+ image_selection: {string: "Image Selection", type: "selection", searchable:true,
+ selection: [['background', 'Background'],['boxed', 'Boxed'],['clean', 'Clean'],['standard', 'Standard']]},
},
records: [{
id: 1,
@@ -3995,6 +3997,45 @@ QUnit.module('basic_fields', {
form.destroy();
});
+
+ QUnit.module('FieldImageSelection');
+
+ QUnit.test('image selection widget in form view', function (assert) {
+ assert.expect(3);
+
+ var nodeOptions = {
+ background: {
+ image_link: '/base/static/img/preview_background.png',
+ preview_link: '/base/static/pdf/preview_background.pdf',
+ },
+ boxed: {
+ image_link: '/base/static/img/preview_boxed.png',
+ preview_link: '/base/static/pdf/preview_boxed.pdf',
+ },
+ };
+ var form = createView({
+ View: FormView,
+ model: 'partner',
+ data: this.data,
+ arch: '<form>' +
+ '<field name="image_selection" widget="image_selection"' +
+ ' options=\'' + JSON.stringify(nodeOptions) + '\'/> '+
+ '</form>',
+ res_id: 2,
+ });
+
+ assert.strictEqual(form.$('.img.img-responsive').length, 2,
+ "Two images should be rendered");
+ assert.strictEqual(form.$('.img.btn-info').length, 0,
+ "No image should be selected");
+
+ // select first image
+ form.$(".img.img-responsive:first").click();
+ assert.ok(form.$(".img.img-responsive:first").hasClass('btn-info'),
+ "First image should be selected");
+
+ form.destroy();
+ });
});
});
});