summaryrefslogtreecommitdiff
path: root/addons/website/static/src/js
diff options
context:
space:
mode:
authorRomain Derie <rde@odoo.com>2019-06-03 14:26:05 +0000
committerJeremy Kersten <jke@odoo.com>2019-06-05 05:56:33 +0000
commitfdbf11643fd04059bfbc2210427c428979fed73d (patch)
tree56801140d47920d0582068323dd874c2ead687d5 /addons/website/static/src/js
parentd7cd97a9be63ae0a8643400b56d6f9a03285fba6 (diff)
[IMP] *: move test and tour files to new folder hierarchy and asset
As we now have a new debug mode 'tests' which load a new asset bundle containing tour-test files, we moved those files to a new folder hierarchy. That will clean the .js files trees. Also, those files should be included in the new asset. Basically, the .js tour files (not test) should be inside /static/src/js/tours while .js tour test files (test=true) should be inside /static/tests/tours next to QUnit tests, inside a tours folder. + test_new_api: don't run the test in debug assets task-1934445 Comes with https://github.com/odoo/enterprise/pull/4281 Closes #33213
Diffstat (limited to 'addons/website/static/src/js')
-rw-r--r--addons/website/static/src/js/html_editor.test.js140
-rw-r--r--addons/website/static/src/js/tours/restricted_editor.js17
-rw-r--r--addons/website/static/src/js/tours/rte.js203
-rw-r--r--addons/website/static/src/js/tours/website_tour_reset_password.js172
4 files changed, 0 insertions, 532 deletions
diff --git a/addons/website/static/src/js/html_editor.test.js b/addons/website/static/src/js/html_editor.test.js
deleted file mode 100644
index a7eda78f6ef..00000000000
--- a/addons/website/static/src/js/html_editor.test.js
+++ /dev/null
@@ -1,140 +0,0 @@
-odoo.define('website.test.html_editor', function (require) {
-'use strict';
-
-var tour = require('web_tour.tour');
-
-tour.register('html_editor_multiple_templates', {
- test: true,
- url: '/aboutus',
-},
- [
- // 1. Edit the page through Edit Mode, it will COW the view
- {
- content: "enter edit mode",
- trigger: 'a[data-action=edit]',
- },
- {
- content: "drop a snippet",
- trigger: '#oe_snippets .oe_snippet:has(.s_cover) .oe_snippet_thumbnail',
- // id starting by 'oe_structure..' will actually create an inherited view
- run: "drag_and_drop #oe_structure_test_ui",
- },
- {
- content: "save the page",
- extra_trigger: '#oe_structure_test_ui.o_dirty',
- trigger: "#web_editor-top-edit button[data-action=save]",
- },
- // 2. Edit generic aboutus view
- {
- content: "open customize menu",
- extra_trigger: "body:not(.editor_enable)",
- trigger: '#customize-menu > a',
- },
- {
- content: "open html editor",
- trigger: '#html_editor',
- },
- {
- content: "add something in the aboutus view",
- trigger: 'div.ace_line .ace_xml:contains("aboutus")',
- run: function () {
- ace.edit('ace-view-editor').getSession().insert({row: 3, column: 1}, '<p>somenewcontent</p>\n');
- },
- },
- // 3. Edit oe_structure specific view
- {
- content: "select oe_structure specific view",
- trigger: 'div.ace_line .ace_xml:contains("somenewcontent")',
- run: function () {
- var viewId = $('#ace-view-list option:contains("oe_structure")').val();
- $('#ace-view-list').val(viewId).trigger('change');
- },
- },
- {
- content: "add something in the oe_structure specific view",
- extra_trigger: '#ace-view-id:contains("website.aboutus_oe_structure_test_ui")', // If no xml_id it should show key
- trigger: 'div.ace_line .ace_xml:contains("s_cover")',
- run: function () {
- ace.edit('ace-view-editor').getSession().insert({row: 2, column: 1}, '<p>anothernewcontent</p>\n');
- },
- },
- {
- content: "save the html editor",
- extra_trigger: 'div.ace_line .ace_xml:contains("anothernewcontent")',
- trigger: ".o_ace_view_editor button[data-action=save]",
- },
- {
- content: "check that the page has both modification",
- extra_trigger: '#wrapwrap:contains("anothernewcontent")',
- trigger: '#wrapwrap:contains("somenewcontent")',
- run: function () {}, // it's a check
- },
- ]
-);
-
-tour.register('test_html_editor_scss', {
- test: true,
- url: '/aboutus',
-},
- [
- // 1. Open Html Editor and select a scss file
- {
- content: "open customize menu",
- extra_trigger: '#wrap:visible', // ensure state for later
- trigger: '#customize-menu > a',
- },
- {
- content: "open html editor",
- trigger: '#html_editor',
- },
- {
- content: "open type switcher",
- trigger: '.o_ace_type_switcher button',
- },
- {
- content: "select scss files",
- trigger: '.o_ace_type_switcher_choice[data-type="scss"]',
- },
- {
- content: "select 'user_custom_rules'",
- trigger: 'body:has(#ace-scss-list option:contains("user_custom_rules"))',
- run: function () {
- var scssId = $('#ace-scss-list option:contains("user_custom_rules")').val();
- $('#ace-scss-list').val(scssId).trigger('change');
- },
- },
- // 2. Edit that file and ensure it was saved then reset it
- {
- content: "add some scss content in the file",
- trigger: 'div.ace_line .ace_comment:contains("footer {")',
- run: function () {
- ace.edit('ace-view-editor').getSession().insert({row: 2, column: 0}, '#wrap {display: none;}\n');
- },
- },
- {
- content: "save the html editor",
- extra_trigger: 'div.ace_line:contains("#wrap {display: none;}")',
- trigger: ".o_ace_view_editor button[data-action=save]",
- },
- {
- content: "check that the scss modification got applied",
- trigger: 'body:has(#wrap:hidden)',
- run: function () {}, // it's a check
- },
- {
- content: "reset view (after reload, html editor should have been reopened where it was)",
- trigger: '#ace-view-id button[data-action="reset"]',
- },
- {
- content: "confirm reset warning",
- trigger: '.modal-footer .btn-primary',
- },
- {
- content: "check that the scss file was reset correctly, wrap content should now be visible again",
- trigger: '#wrap:visible',
- run: function () {}, // it's a check
- },
- ]
-);
-
-});
diff --git a/addons/website/static/src/js/tours/restricted_editor.js b/addons/website/static/src/js/tours/restricted_editor.js
deleted file mode 100644
index 10f24291be8..00000000000
--- a/addons/website/static/src/js/tours/restricted_editor.js
+++ /dev/null
@@ -1,17 +0,0 @@
-odoo.define("website.tour.restricted_editor", function (require) {
-"use strict";
-
-var tour = require("web_tour.tour");
-
-tour.register("restricted_editor", {
- test: true,
- url: "/",
-}, [{
- trigger: 'a[data-action=edit]',
- content: "Click \"EDIT\" button of website as Restricted Editor",
- extra_trigger: ".homepage",
-}, {
- trigger: '#oe_snippets.o_loaded',
- content: "Check that the snippets loaded properly",
-}]);
-});
diff --git a/addons/website/static/src/js/tours/rte.js b/addons/website/static/src/js/tours/rte.js
deleted file mode 100644
index e29f40e45ed..00000000000
--- a/addons/website/static/src/js/tours/rte.js
+++ /dev/null
@@ -1,203 +0,0 @@
-odoo.define('website.tour.rte', function (require) {
-'use strict';
-
-var ajax = require('web.ajax');
-var session = require('web.session');
-var tour = require('web_tour.tour');
-var Wysiwyg = require('web_editor.wysiwyg.root');
-
-var domReady = new Promise(function (resolve) {
- $(resolve);
-});
-var ready = Promise.all([domReady, session.is_bound, ajax.loadXML()]);
-
-tour.register('rte_translator', {
- test: true,
- wait_for: ready,
- url: '/',
-}, [{
- content: "click on Add a language",
- trigger: '.js_language_selector a:has(i.fa)',
-}, {
- content: "select french",
- trigger: 'select[name="lang"]',
- run: 'text "fr_BE"',
-}, {
- content: "load french",
- trigger: '.modal-footer button:first',
- extra_trigger: '.modal select[name="lang"]:propValueContains(fr_BE)',
-}, {
- content : "click language dropdown",
- trigger : '.js_language_selector .dropdown-toggle',
- timeout: 60000,
-}, {
- content: "go to english version",
- trigger: '.js_language_selector a[data-lang="en_US"]',
- extra_trigger: 'html[lang*="fr"]',
-}, {
- content: "Open new page menu",
- trigger: '#new-content-menu > a',
- extra_trigger: 'a[data-action="edit"]',
-}, {
- content: "click on new page",
- trigger: 'a[data-action="new_page"]',
-}, {
- content: "insert page name",
- trigger: '#editor_new_page input[type="text"]',
- run: 'text rte_translator',
-}, {
- content: "create page",
- trigger: 'button.btn-continue',
- extra_trigger: 'input[type="text"]:propValue(rte_translator)',
-}, {
- content: "drop a snippet",
- trigger: "#snippet_structure .oe_snippet:eq(1) .oe_snippet_thumbnail",
- run: 'drag_and_drop #wrap',
-}, {
- content: "change content",
- trigger: '.oe_overlay_options .oe_options:visible',
- run: 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"/>\
- <p>&lt;b&gt;&lt;/b&gt; is an HTML&nbsp;tag &amp; is empty</p>');
- $("#wrap img").attr("title", "test translate image title");
- }
-}, {
- content: "save",
- trigger: 'button[data-action=save]',
- extra_trigger: '#wrap p:first b',
-}, {
- content : "click language dropdown",
- trigger : '.js_language_selector .dropdown-toggle',
- extra_trigger: 'body:not(.o_wait_reload):not(:has(.note-editor))',
-}, {
- content: "click on french version",
- trigger: '.js_language_selector a[data-lang="fr_BE"]',
- extra_trigger: 'html[lang*="en"]:not(:has(button[data-action=save]))',
-}, {
- content: "translate",
- trigger: 'html:not(:has(#wrap p span)) .o_menu_systray a[data-action="translate"]',
-}, {
- content: "close modal",
- trigger: '.modal-footer .btn-secondary',
-}, {
- content: "check if translation is activate",
- trigger: '[data-oe-translation-id]',
-}, {
- content: "translate text",
- trigger: '#wrap p font:first',
- run: function (action_helper) {
- action_helper.text('translated french text');
- Wysiwyg.setRange(this.$anchor.contents()[0], 22);
- this.$anchor.trigger($.Event( "keyup", {key: '_', keyCode: 95}));
- },
-}, {
- content: "translate text with special char",
- trigger: '#wrap input + p span:first',
- run: function (action_helper) {
- action_helper.click();
- this.$anchor.prepend('&lt;{translated}&gt;');
- Wysiwyg.setRange(this.$anchor.contents()[0], 0);
- this.$anchor.trigger($.Event( "keyup", {key: '_', keyCode: 95}));
- },
-}, {
- content: "click on input",
- trigger: '#wrap input:first',
- extra_trigger: '#wrap .o_dirty font:first:contains(translated french text)',
- run: 'click',
-}, {
- content: "translate placeholder",
- trigger: 'input:first',
- run: 'text test french placeholder',
-}, {
- content: "close modal",
- trigger: '.modal-footer .btn-primary',
- extra_trigger: '.modal input:propValue(test french placeholder)',
-}, {
- content: "save translation",
- trigger: 'button[data-action=save]',
-}, {
- content: "check: content is translated",
- trigger: '#wrap p font:first:contains(translated french text)',
- run: function () {}, // it's a check
-}, {
- content: "check: content with special char is translated",
- trigger: "#wrap input + p:contains(<{translated}><b></b> is an HTML\xa0tag & )",
- run: function () {}, // it's a check
-
-}, {
- content: "check: placeholder translation",
- trigger: 'input[placeholder="test french placeholder"]',
- run: function () {}, // it's a check
-
-}, {
- content : "click language dropdown",
- trigger : '.js_language_selector .dropdown-toggle',
-
-}, {
- content: "open language selector",
- trigger: '.js_language_selector button:first',
- extra_trigger: 'html[lang*="fr"]:not(:has(#wrap p span))',
-}, {
- content: "return to english version",
- trigger: '.js_language_selector a[data-lang="en_US"]',
-}, {
- content: "edit english version",
- trigger: 'a[data-action=edit]',
- extra_trigger: 'body:not(:has(#wrap p font:first:containsExact(paragraphs <b>describing</b>)))',
-}, {
- content: "select text",
- extra_trigger: 'button[data-action=save]',
- trigger: '#wrap p',
- run: function (action_helper) {
- action_helper.click();
- var el = this.$anchor[0];
- this.$anchor.trigger('mousedown');
- Wysiwyg.setRange(el.childNodes[2], 6, el.childNodes[2], 13);
- this.$anchor.trigger('mouseup');
- },
-}, {
- content: "underline",
- trigger: 'button.note-btn-underline',
-}, {
- content: "save new change",
- trigger: 'button[data-action=save]',
- extra_trigger: '#wrap.o_dirty p u',
-
- }, {
- content : "click language dropdown",
- trigger : '.js_language_selector .dropdown-toggle',
- extra_trigger: '#wrap p u',
-}, {
- content: "return in french",
- trigger : 'html[lang="en-US"] .js_language_selector .js_change_lang[data-lang="fr_BE"]',
-}, {
- content: "check bis: content is translated",
- trigger: '#wrap p font:first:contains(translated french text)',
- extra_trigger: 'body:not(:has(button[data-action=save]))',
-}, {
- content: "check bis: placeholder translation",
- trigger: 'input[placeholder="test french placeholder"]',
-}, {
- content: "Open customize menu",
- trigger: "#customize-menu > .dropdown-toggle",
-}, {
- content: "Open HTML editor",
- trigger: "[data-action='ace']",
-}, {
- content: "Check that the editor is not showing translated content (1)",
- trigger: '.ace_text-layer .ace_line:contains("an HTML")',
- run: function (actions) {
- var lineEscapedText = $(this.$anchor.text()).text();
- if (lineEscapedText !== "&lt;b&gt;&lt;/b&gt; is an HTML&nbsp;tag &amp; is empty") {
- console.error('The HTML editor should display the correct untranslated content');
- $('body').addClass('rte_translator_error');
- }
- },
-}, {
- content: "Check that the editor is not showing translated content (2)",
- trigger: 'body:not(.rte_translator_error)',
- run: function () {},
-}]);
-});
diff --git a/addons/website/static/src/js/tours/website_tour_reset_password.js b/addons/website/static/src/js/tours/website_tour_reset_password.js
deleted file mode 100644
index 3239dc28f80..00000000000
--- a/addons/website/static/src/js/tours/website_tour_reset_password.js
+++ /dev/null
@@ -1,172 +0,0 @@
-odoo.define('website.tour_reset_password', function (require) {
-'use strict';
-
-var localStorage = require('web.local_storage');
-var rpc = require('web.rpc');
-var tour = require('web_tour.tour');
-require('web.dom_ready');
-
-var currentDomain = window.location.protocol + '//' + window.location.hostname;
-var emailsUrl = '/web#action=mail.action_view_mail_mail&view_type=list';
-var usersUrl = '/web#action=base.action_res_users&view_type=list';
-var resetLinkKey = 'website.tour_reset_password.resetLink';
-
-tour.register('website_reset_password', {
- test: true,
- url: '/web',
-},
-[
- {
- content: "Change the domain of the websites and go to users page",
- trigger: '.oe_topbar_name:contains("Admin")',
- run: function () {
- // We could do it with the UI but this is not the goal of this test,
- // so we just make an RPC to be faster.
-
- // We change the domain of the website to test that the email that
- // will be sent uses the correct domain for its links.
- var def1 = rpc.query({
- 'model': 'website',
- 'method': 'write',
- 'args': [[1], {
- 'domain': "my-test-domain.com",
- }],
- });
- // We need to change the domain of all the websites otherwise the
- // website selector will return the website 2 since the domain we
- // set on website 1 doesn't actually match our test server.
- var def2 = rpc.query({
- 'model': 'website',
- 'method': 'write',
- 'args': [[2], {
- 'domain': "https://domain-not-used.fr",
- }],
- });
- // Set a website on "Admin" partner to test the URL of the website.
- var def3 = rpc.query({
- model: 'res.partner',
- method: 'name_search',
- kwargs: {'name': 'Mitchell Admin'},
- }).then(function (res) {
- return rpc.query({
- 'model': 'res.partner',
- 'method': 'write',
- 'args': [[res[0][0]], {
- 'website_id': 1,
- }],
- });
- });
-
- return Promise.all([def1, def2, def3]).then(function () {
- window.location.href = usersUrl;
- });
- },
- },
- {
- content: "click on Admin",
- trigger: '.o_data_cell:contains("Admin")',
- },
- {
- content: "click on reset password",
- trigger: '.btn[name="action_reset_password"]',
- },
- {
- content: "wait mail to be sent, and go see it",
- trigger: 'a[name="signup_url"][href^="http://my-test-domain.com"]',
- run: function () {
- window.location.href = emailsUrl;
- },
- },
- {
- content: "click on the first email",
- trigger: '.o_data_cell:contains("Password reset"):eq(0)',
- },
- {
- content: "check email has the button",
- trigger: 'div.oe_form_field_html[name="body_html"] a:contains("Change password")',
- run: function () {},
- },
- {
- content: "check the URL is correct too",
- trigger: 'div.oe_form_field_html[name="body_html"] a:contains("Change password")[href^="http://my-test-domain.com"]',
- run: function () {
- // reset the domain of the websites, go to users page
- return rpc.query({
- 'model': 'website',
- 'method': 'write',
- 'args': [[1, 2], {
- 'domain': "",
- }],
- }).then(function () {
- window.location.href = usersUrl;
- });
- },
- },
- {
- content: "click on Admin",
- trigger: '.o_data_cell:contains("Admin")',
- },
- {
- content: "click on reset password",
- trigger: '.btn[name="action_reset_password"]',
- },
- {
- content: "wait mail to be sent, and go see it",
- trigger: 'a[name="signup_url"][href^="' + currentDomain + '"]',
- run: function () {
- window.location.href = emailsUrl;
- },
- },
- {
- content: "click on the first email",
- trigger: '.o_data_cell:contains("Password reset"):eq(0)',
- },
- {
- content: "check the link has the current host, save the link, logout",
- trigger: 'div.oe_form_field_html[name="body_html"] a:contains("Change password")[href^="' + currentDomain + '"]',
- run: function () {
- var link = $('div.oe_form_field_html[name="body_html"] a:contains("Change password")').attr('href');
- localStorage.setItem(resetLinkKey, link);
- window.location.href = "/web/session/logout?redirect=/";
- },
- },
- {
- content: "go to the reset link",
- trigger: 'a[href="/web/login"]',
- run: function () {
- window.location.href = localStorage.getItem(resetLinkKey);
- },
- },
- {
- content: "fill new password and submit",
- trigger: '.oe_reset_password_form',
- run: function () {
- var $form = $('.oe_reset_password_form');
- $form.find('input[name="password"]').val('adminadmin');
- // password must be at least 8 if the module `auth_password_policy`
- // is installed which is the case on runbot
- $form.find('input[name="confirm_password"]').val('adminadmin');
- $form.find('button[type="submit"]').click();
- },
- },
- {
- content: "check logged in, and reset admin website",
- trigger: '.oe_topbar_name:contains("Admin")',
- run: function () {
- return rpc.query({
- model: 'res.partner',
- method: 'name_search',
- kwargs: {'name': 'Admin'},
- }).then(function (res) {
- return rpc.query({
- 'model': 'res.partner',
- 'method': 'write',
- 'args': [[res[0][0]], {
- 'website_id': false,
- }],
- });
- });
- },
- },
-]);
-});