diff options
| author | Christophe Simonis <chs@odoo.com> | 2017-09-21 18:52:56 +0200 |
|---|---|---|
| committer | Christophe Simonis <chs@odoo.com> | 2017-09-21 18:52:56 +0200 |
| commit | 4b455098f8cefa5122479a5a84fa07c2330e7a66 (patch) | |
| tree | 43d625a9e37a5d9c07780f8116bf0247fb693fe0 /addons/web/static/tests/fields/basic_fields_tests.js | |
| parent | f53e65c356a5d43d2b5b50dc509ee70e0df30ba5 (diff) | |
| parent | 5c51a0ad4d6bfab6427949ffe61650196798846a (diff) | |
[MERGE] forward port branch saas-18 up to 5c51a0ad4d6
Diffstat (limited to 'addons/web/static/tests/fields/basic_fields_tests.js')
| -rw-r--r-- | addons/web/static/tests/fields/basic_fields_tests.js | 41 |
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(); + }); }); }); }); |
