diff options
| author | Sébastien Theys <seb@odoo.com> | 2019-06-04 15:11:08 +0200 |
|---|---|---|
| committer | Sébastien Theys <seb@odoo.com> | 2019-06-04 22:14:13 +0200 |
| commit | 76cf2ae82a45b9ffcf63b524944a42b7f5192b0c (patch) | |
| tree | 89540178c9e62def90377eb50ea8f7e1c089aff6 /addons/web_editor/static/tests | |
| parent | 191c556d6b50b35178ea5bb91fb998bcffb86367 (diff) | |
[IMP] web_editor, *: improve media dialog attachment upload
* = web_unsplash, website
Remove iframe upload and replace it with a proper RPC. The route is now only
accepting one file at a time, which makes it easier to maintain, and allows to
process the first file as soon as it is ready, instead of having to wait on
everything.
Also fix a bug where a document could not be uploaded because it would try to
parse it as an image.
Remove filter after search result from the JS and add the corresponding
conditions in the domain to avoid processing and returning unnecessary records.
If multiple attachments exist with the same URL, now display them all to avoid
confusion.
Compute all the necessary values in the python model instead of in the JS.
Allow SVG in the widget (the server already accepted them before).
Disable multiple image upload when not in multiImages mode.
task-1930726
PR: #31208
Diffstat (limited to 'addons/web_editor/static/tests')
| -rw-r--r-- | addons/web_editor/static/tests/test_utils.js | 13 | ||||
| -rw-r--r-- | addons/web_editor/static/tests/wysiwyg_tests.js | 37 |
2 files changed, 26 insertions, 24 deletions
diff --git a/addons/web_editor/static/tests/test_utils.js b/addons/web_editor/static/tests/test_utils.js index 27ba86b52ff..7d2a4b37bbb 100644 --- a/addons/web_editor/static/tests/test_utils.js +++ b/addons/web_editor/static/tests/test_utils.js @@ -347,14 +347,21 @@ function wysiwygData(data) { string: "res_model", type: 'char', }, + public: { + string: "public", + type: 'boolean', + }, access_token: { string: "access_token", type: 'char', }, + image_src: { + string: "image_src", + type: 'char', + }, }, records: [{ id: 1, - public: true, name: 'image', datas_fname: 'image.png', mimetype: 'image/png', @@ -363,7 +370,9 @@ function wysiwygData(data) { type: 'url', res_id: 0, res_model: false, - access_token: false + public: true, + access_token: false, + image_src: '/web_editor/static/src/img/transparent.png', }], generate_access_token: function () { return; diff --git a/addons/web_editor/static/tests/wysiwyg_tests.js b/addons/web_editor/static/tests/wysiwyg_tests.js index be62dbb4192..e03fb3888fb 100644 --- a/addons/web_editor/static/tests/wysiwyg_tests.js +++ b/addons/web_editor/static/tests/wysiwyg_tests.js @@ -3378,28 +3378,6 @@ var altDialogSaved; var cropDialogOpened; QUnit.module('Media', { beforeEach: function () { - $('body').on('submit.WysiwygTests', function (ev) { - ev.preventDefault(); - var $from = $(ev.target); - var iframe = $from.find('iframe[name="' + $from.attr('target') + '"]')[0]; - if (iframe) { - iframe.contentWindow.attachments = [{ - id: 1, - public: true, - name: 'image', - datas_fname: 'image.png', - mimetype: 'image/png', - checksum: false, - url: '/web_editor/static/src/img/transparent.png', - type: 'url', - res_id: 0, - res_model: false, - access_token: false - }]; - $(iframe).trigger('load'); - } - }); - this.data = { debug: false, wysiwygOptions: { @@ -3415,6 +3393,21 @@ QUnit.module('Media', { if (route.indexOf('/web_editor/static/src/img/') === 0) { return Promise.resolve(); } + if (route === '/web_editor/attachment/add_url') { + return Promise.resolve({ + id: 1, + public: true, + name: 'image', + mimetype: 'image/png', + checksum: false, + url: '/web_editor/static/src/img/transparent.png', + image_src: '/web_editor/static/src/img/transparent.png', + type: 'url', + res_id: 0, + res_model: false, + access_token: false, + }); + } return this._super(route, args); }, }; |
