diff options
| author | Christophe Matthieu <chm@odoo.com> | 2015-06-23 16:00:50 +0200 |
|---|---|---|
| committer | Christophe Matthieu <chm@odoo.com> | 2015-07-10 17:00:15 +0200 |
| commit | 087fd6942b5fb61a9ae2b050fa0ee2228e1c8f73 (patch) | |
| tree | 988f95a249c416b00b43be77c421cfd3f9db478d | |
| parent | 92983cfede4d4f1b320a6aca67c0f4cdab341fdc (diff) | |
[IMP] web_editor: add test translator
| -rw-r--r-- | addons/web/static/src/js/tour.js | 1 | ||||
| -rw-r--r-- | addons/web_editor/static/src/js/tour.rte.js | 1 | ||||
| -rw-r--r-- | addons/website/static/src/js/website.tour.rte.js | 172 | ||||
| -rw-r--r-- | addons/website/tests/test_ui.py | 3 | ||||
| -rw-r--r-- | addons/website/views/website_templates.xml | 6 |
5 files changed, 181 insertions, 2 deletions
diff --git a/addons/web/static/src/js/tour.js b/addons/web/static/src/js/tour.js index b2eb0f73e38..dd74ca42e9e 100644 --- a/addons/web/static/src/js/tour.js +++ b/addons/web/static/src/js/tour.js @@ -417,7 +417,6 @@ var Tour = { }, logError: function (step, message, all) { var state = Tour.getState(); - console.log(state.tour.steps.slice()); message += '\ntour: ' + state.id + (step ? '\nstep: ' + step.id + ": '" + (step._title || step.title) + "'" : '' ) + (all ? '\nhref: ' + window.location.href : '' ) diff --git a/addons/web_editor/static/src/js/tour.rte.js b/addons/web_editor/static/src/js/tour.rte.js index c257176fd6f..755fee8a606 100644 --- a/addons/web_editor/static/src/js/tour.rte.js +++ b/addons/web_editor/static/src/js/tour.rte.js @@ -25,7 +25,6 @@ Tour.register({ { title: "Change html for this test", onload: function () { - var $el = $(this.element); var html = '\n'+ '<section>\n'+ ' <div class="container">\n'+ diff --git a/addons/website/static/src/js/website.tour.rte.js b/addons/website/static/src/js/website.tour.rte.js new file mode 100644 index 00000000000..865042fd932 --- /dev/null +++ b/addons/website/static/src/js/website.tour.rte.js @@ -0,0 +1,172 @@ +odoo.define('website.tour.rte', function (require) { +'use strict'; + +var Tour = require('web.Tour'); + +Tour.register({ + id: 'rte_translator', + name: "Test translator", + mode: 'test', + steps: [ + { + title: "click on Add a language", + element: '.js_language_selector a:has(i.fa)', + }, + { + title: "select french", + element: '.modal select[name="lang"]', + sampleText: '"fr_BE"', + }, + { + title: "load french", + waitFor: '.modal select[name="lang"]:propValueContains(fr_BE)', + element: '.modal button.oe_highlight', + }, + { + title: "go to english version", + element: '.js_language_selector a[data-lang="en_US"]', + onload: function () { + localStorage.removeItem('website_translator_nodialog'); + } + }, + { + title: "Open content menu", + element: '#content-menu-button', + }, + { + title: "click on new page", + element: '[data-action="new_page"]', + }, + { + title: "insert page name", + element: '#editor_new_page input[type="text"]', + sampleText: 'rte_translator', + }, + { + title: "create page", + waitFor: 'input[type="text"]:propValue(rte_translator)', + element: '.modal:has(#editor_new_page) button.btn-continue', + }, + { + title: "drop a snippet", + snippet: '#snippet_structure .oe_snippet:eq(1)', + }, + { + title: "change content", + waitFor: '.oe_overlay_options .oe_options:visible', + onload: function () { + $("#wrap p:first").replaceWith('<p>Write one or <font style="background-color: yellow;">two paragraphs <b>describing</b></font> your product or\ + <font style="color: rgb(255, 0, 0);">services</font>. To be successful your content needs to be\ + useful to your <a href="/999">readers</a>.</p> <input placeholder="test translate placeholder"/>'); + $("#wrap img").attr("title", "test translate image title"); + } + }, + { + title: "save", + waitFor: '#wrap p:first b', + element: 'button[data-action=save]', + }, + { + title: "click on french version", + waitNot: 'button[data-action=save]', + element: '.js_language_selector a[data-lang="fr_BE"]', + }, + { + title: "translate", + waitNot: '#wrap p span', + element: '#oe_editzone button[data-action="translate"]', + }, + { + title: "check if translation is activate", + waitFor: '[data-oe-translation-id]', + }, + { + title: "close modal", + element: '.modal button[data-action="activate"]', + }, + { + title: "translate text", + element: '#wrap p font:first', + sampleText: 'translated french text', + onload: function () { + $(this.element).closest('[data-oe-translation-id]').addClass('o_dirty').trigger('keyup'); + }, + }, + { + title: "click on input", + waitFor: '#wrap .o_dirty font:first:contains(translated french text)', + element: 'input:first', + }, + { + title: "translate placeholder", + element: '.modal.web_editor-dialog input:first', + sampleText: 'test french placeholder', + }, + { + title: "close modal", + waitFor: '.web_editor-dialog input:propValue(test french placeholder)', + element: '.web_editor-dialog button', + }, + { + title: "close modal", + waitNot: '.web_editor-dialog', + element: 'button[data-action=save]', + }, + { + title: "check: content is translated", + waitNot: 'button[data-action=save]', + waitFor: '#wrap p font:first:contains(translated french text)', + }, + { + title: "check: placeholder translation", + waitFor: 'input[placeholder="test french placeholder"]', + }, + { + title: "return to english version", + waitNot: '#wrap p span', + element: '.js_language_selector a[data-lang="en_US"]', + }, + { + title: "edit english version", + waitNot: '#wrap p font:first:containsExact(paragraphs <b>describing</b>)', + element: 'button[data-action=edit]', + }, + { + title: "select text", + waitFor: 'button[data-action=save]', + element: '#wrap p', + onload: function () { + var el = $(this.element)[0]; + var evt = document.createEvent("MouseEvents"); + $.summernote.core.range.create(el.childNodes[2], 6, el.childNodes[2], 13).select(); + evt.initMouseEvent('mouseup', true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, el); + el.dispatchEvent(evt); + }, + }, + { + title: "underline", + element: '.note-air-popover button[data-event="underline"]', + }, + { + title: "save new change", + waitFor: '#wrap p u', + element: 'button[data-action=save]', + }, + { + title: "return in french", + waitNot: 'button[data-action=save]', + element: 'html[lang="en-US"] .js_language_selector a[data-lang="fr_BE"]', + }, + { + title: "check bis: content is translated", + waitNot: 'button[data-action=save]', + waitFor: '#wrap p font:first:contains(translated french text)', + }, + { + title: "check bis: placeholder translation", + waitFor: 'input[placeholder="test french placeholder"]', + }, + ] +}); + +}); diff --git a/addons/website/tests/test_ui.py b/addons/website/tests/test_ui.py index c1e45e743bd..f2729f934b6 100644 --- a/addons/website/tests/test_ui.py +++ b/addons/website/tests/test_ui.py @@ -10,3 +10,6 @@ class TestUi(openerp.tests.HttpCase): def test_03_admin_tour_banner(self): self.phantom_js("/", "odoo.__DEBUG__.services['web.Tour'].run('banner', 'test')", "odoo.__DEBUG__.services['web.Tour'].tours.banner", login='admin') + + def test_03_admin_tour_rte_translator(self): + self.phantom_js("/", "odoo.__DEBUG__.services['web.Tour'].run('rte_translator', 'test')", "odoo.__DEBUG__.services['web.Tour'].tours.rte_translator", login='admin') diff --git a/addons/website/views/website_templates.xml b/addons/website/views/website_templates.xml index 98fda216872..e0f1e0899ec 100644 --- a/addons/website/views/website_templates.xml +++ b/addons/website/views/website_templates.xml @@ -4,6 +4,12 @@ <!-- Assets --> +<template id="assets_common" inherit_id="web.assets_common" name="Website assets"> + <xpath expr="." position="inside"> + <script groups="base.group_website_designer" type="text/javascript" src="/website/static/src/js/website.tour.rte.js"></script> + </xpath> +</template> + <template id="assets_frontend" name="Website assets"> <link id="bootstrap_css" rel="stylesheet" href='/website/static/src/less/import_bootstrap.less'/> |
