[IMP] web_editor: add test translator
This commit is contained in:
@@ -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 : '' )
|
||||
|
||||
@@ -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'+
|
||||
|
||||
@@ -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"]',
|
||||
},
|
||||
]
|
||||
});
|
||||
|
||||
});
|
||||
@@ -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')
|
||||
|
||||
@@ -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'/>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user