From 81b668c3e3e0766594d8a784f674bbbda047567f Mon Sep 17 00:00:00 2001
From: Nicolas Lempereur
Date: Thu, 1 Dec 2016 14:34:27 +0100
Subject: [PATCH] [IMP] web_editor: tour testing inline editor saving (up to
s11)
With 98ed53ce when a form view is saved when a html field is in code
view mode, the change is not lost.
This new backend tour check that when saving in or not in code view, the
content is saved effectively.
The test not in code view would ensure issues like #14381 #14351 #14394
are detected on runbot.
closes #14475
opw-693052
note: the old test system is used so this test is only for up to saas-11
---
addons/web_editor/static/src/js/tour.rte.js | 45 ++++++++++++++++++++
addons/web_editor/tests/__init__.py | 1 +
addons/web_editor/tests/test_backend_view.py | 15 +++++++
3 files changed, 61 insertions(+)
create mode 100644 addons/web_editor/tests/test_backend_view.py
diff --git a/addons/web_editor/static/src/js/tour.rte.js b/addons/web_editor/static/src/js/tour.rte.js
index 8c3c494a73f..96a85114976 100644
--- a/addons/web_editor/static/src/js/tour.rte.js
+++ b/addons/web_editor/static/src/js/tour.rte.js
@@ -392,6 +392,51 @@ Tour.register({
});
+Tour.register({
+ id: 'rte_backend_inline',
+ name: "Test RTE in backend view",
+ mode: 'test',
+ steps: [
+ {
+ title: "Beginning test",
+ },
+ {
+ title: "Click on edit button",
+ element: '.o_form_button_edit, .oe_form_button_edit',
+ },
+ {
+ title: "Add text to inline html field and save",
+ element: '.o_form_button_save, .oe_form_button_save',
+ onload: function(){
+ $('.oe_form_field_html_text .note-editable > p').append('world');
+ },
+ },
+ {
+ title: "Verify saved data after edition then click on edit button",
+ waitFor: '.oe_form_field_html_text p > i:last-child:contains(world)',
+ element: '.o_form_button_edit, .oe_form_button_edit',
+ },
+ {
+ title: "Switch to code view mode",
+ element: 'button[data-event="codeview"]',
+ },
+ {
+ title: "Modify code view content and save",
+ element: '.o_form_button_save, .oe_form_button_save',
+ onload: function(){
+ $('.oe_form_field_html_text textarea.note-codable').val(function(_, val){
+ return val.replace('
', '!');
+ });
+ },
+ },
+ {
+ title: "Verify saved data after code view edition",
+ waitFor: '.oe_form_field_html_text p > u:last-child:contains(!)',
+ },
+ ]
+});
+
+
});
});
diff --git a/addons/web_editor/tests/__init__.py b/addons/web_editor/tests/__init__.py
index ee3fba301a9..7c583996806 100644
--- a/addons/web_editor/tests/__init__.py
+++ b/addons/web_editor/tests/__init__.py
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
import test_ui
import test_converter
+import test_backend_view
diff --git a/addons/web_editor/tests/test_backend_view.py b/addons/web_editor/tests/test_backend_view.py
new file mode 100644
index 00000000000..cceb2af3adf
--- /dev/null
+++ b/addons/web_editor/tests/test_backend_view.py
@@ -0,0 +1,15 @@
+from openerp.api import Environment
+import openerp.tests
+
+@openerp.tests.common.at_install(False)
+@openerp.tests.common.post_install(True)
+class TestBackendView(openerp.tests.HttpCase):
+
+ def test_01_rte_backend_inline(self):
+ """ Test saving inline editor in or out of code view mode. """
+ with self.registry.cursor() as test_cursor:
+ env = Environment(test_cursor, self.uid, {})
+ test_record = env['web_editor.converter.test'].create({'html': 'hello
'})
+ form_url = "/web?debug#id={}&view_type=form&model=web_editor.converter.test".format(test_record.id)
+
+ self.phantom_js(form_url, "odoo.__DEBUG__.services['web.Tour'].run('rte_backend_inline', 'test')", "odoo.__DEBUG__.services['web.Tour'].tours.rte", login="admin")