summaryrefslogtreecommitdiff
path: root/addons/web/static/tests/fields/basic_fields_tests.js
diff options
context:
space:
mode:
authorDavid Monjoie <dmo@odoo.com>2017-06-23 15:36:09 +0200
committerDavid Monjoie <dmo@odoo.com>2017-06-23 16:16:36 +0200
commit378efa14449baeb19a8fb6a810b8db148971c0c1 (patch)
tree707fa72cc0371f11f319fd91f03841143a5a89d2 /addons/web/static/tests/fields/basic_fields_tests.js
parent7c0fed48a1479b08e3a2d526f8557d247466a547 (diff)
[FIX] web: update filename correctly in binary fields
The update_field event is not used anymore so it needs to trigger a field_changed instead.
Diffstat (limited to 'addons/web/static/tests/fields/basic_fields_tests.js')
-rw-r--r--addons/web/static/tests/fields/basic_fields_tests.js27
1 files changed, 23 insertions, 4 deletions
diff --git a/addons/web/static/tests/fields/basic_fields_tests.js b/addons/web/static/tests/fields/basic_fields_tests.js
index 467d567a53d..c492537c63f 100644
--- a/addons/web/static/tests/fields/basic_fields_tests.js
+++ b/addons/web/static/tests/fields/basic_fields_tests.js
@@ -1046,7 +1046,7 @@ QUnit.module('basic_fields', {
QUnit.module('FieldBinary');
QUnit.test('binary fields are correctly rendered', function (assert) {
- assert.expect(9);
+ assert.expect(16);
// save the session function
var oldGetFile = session.get_file;
@@ -1059,18 +1059,24 @@ QUnit.module('basic_fields', {
return $.when();
};
+ this.data.partner.records[0].foo = 'coucou.txt';
var form = createView({
View: FormView,
model: 'partner',
data: this.data,
arch: '<form string="Partners">' +
- '<field name="document"/>' +
+ '<field name="document" filename="foo"/>' +
+ '<field name="foo"/>' +
'</form>',
res_id: 1,
});
assert.strictEqual(form.$('a.o_field_widget[name="document"] > .fa-download').length, 1,
"the binary field should be rendered as a downloadable link in readonly");
+ assert.strictEqual(form.$('a.o_field_widget[name="document"]').text().trim(), 'coucou.txt',
+ "the binary field should display the name of the file in the link");
+ assert.strictEqual(form.$('.o_field_char').text(), 'coucou.txt',
+ "the filename field should have the file name as value");
form.$('a.o_field_widget[name="document"]').click();
@@ -1078,12 +1084,15 @@ QUnit.module('basic_fields', {
assert.strictEqual(form.$('a.o_field_widget[name="document"] > .fa-download').length, 0,
"the binary field should not be rendered as a downloadable link in edit");
- assert.strictEqual(form.$('div.o_field_binary_file[name="document"]').length, 1,
- "the binary field should be correctly rendered in edit");
+ assert.strictEqual(form.$('div.o_field_binary_file[name="document"] > input').val(), 'coucou.txt',
+ "the binary field should display the file name in the input edit mode");
assert.strictEqual(form.$('.o_field_binary_file > input').attr('readonly'), 'readonly',
"the input should be readonly");
assert.strictEqual(form.$('.o_field_binary_file > .o_clear_file_button').length, 1,
"there shoud be a button to clear the file");
+ assert.strictEqual(form.$('input.o_field_char').val(), 'coucou.txt',
+ "the filename field should have the file name as value");
+
form.$('.o_field_binary_file > .o_clear_file_button').click();
@@ -1091,6 +1100,16 @@ QUnit.module('basic_fields', {
"the input should be hidden");
assert.strictEqual(form.$('.o_field_binary_file > .o_select_file_button:not(.o_hidden)').length, 1,
"there shoud be a button to upload the file");
+ assert.strictEqual(form.$('input.o_field_char').val(), '',
+ "the filename field should be empty since we removed the file");
+
+ form.$buttons.find('.o_form_button_save').click();
+ assert.strictEqual(form.$('a.o_field_widget[name="document"] > .fa-download').length, 0,
+ "the binary field should not render as a downloadable link since we removed the file");
+ assert.strictEqual(form.$('a.o_field_widget[name="document"]').text().trim(), '',
+ "the binary field should not display a filename in the link since we removed the file");
+ assert.strictEqual(form.$('.o_field_char').text().trim(), '',
+ "the filename field should be empty since we removed the file");
form.destroy();