Browse Source

[IMP] website_mass_mailing_name: Make tour faster

Under some integration environment, the public part of the tour fails to load, I don't know exactly why (or better, I don't know why it was working before, because it was deleting the phantomjs session entirely).

In any case, with this fix, it works there and is faster to test.
pull/342/merge
Jairo Llopis 6 years ago
committed by Jairo Llopis
parent
commit
b77e4c4c9c
  1. 4
      website_mass_mailing_name/__manifest__.py
  2. 4
      website_mass_mailing_name/demo/assets.xml
  3. 45
      website_mass_mailing_name/static/src/js/editor_and_public_tour.js
  4. 50
      website_mass_mailing_name/static/src/js/editor_tour.js
  5. 20
      website_mass_mailing_name/tests/test_ui.py

4
website_mass_mailing_name/__manifest__.py

@ -4,9 +4,9 @@
{ {
"name": "Mass Mailing Subscription Snippet With Name", "name": "Mass Mailing Subscription Snippet With Name",
"summary": "Ask for name when subscribing, and create and/or link partner", "summary": "Ask for name when subscribing, and create and/or link partner",
"version": "10.0.1.0.0",
"version": "10.0.1.0.1",
"category": "Website", "category": "Website",
"website": "https://tecnativa.com/",
"website": "https://github.com/OCA/social",
"author": "Tecnativa, Odoo Community Association (OCA)", "author": "Tecnativa, Odoo Community Association (OCA)",
"license": "LGPL-3", "license": "LGPL-3",
"application": False, "application": False,

4
website_mass_mailing_name/demo/assets.xml

@ -8,9 +8,7 @@
inherit_id="website.assets_frontend"> inherit_id="website.assets_frontend">
<xpath expr="."> <xpath expr=".">
<script type="text/javascript" <script type="text/javascript"
src="/website_mass_mailing_name/static/src/js/editor_tour.js"/>
<script type="text/javascript"
src="/website_mass_mailing_name/static/src/js/public_tour.js"/>
src="/website_mass_mailing_name/static/src/js/editor_and_public_tour.js"/>
</xpath> </xpath>
</template> </template>

45
website_mass_mailing_name/static/src/js/public_tour.js → website_mass_mailing_name/static/src/js/editor_and_public_tour.js

@ -1,19 +1,60 @@
/* Copyright 2016-2017 Jairo Llopis <jairo.llopis@tecnativa.com> /* Copyright 2016-2017 Jairo Llopis <jairo.llopis@tecnativa.com>
* License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). */ * License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). */
odoo.define("website_mass_mailing_name.public_tour", function (require) {
odoo.define("website_mass_mailing_name.editor_and_public_tour", function (require) {
"use strict"; "use strict";
var base = require("web_editor.base"); var base = require("web_editor.base");
var tour = require("web_tour.tour"); var tour = require("web_tour.tour");
tour.register( tour.register(
"mass_mailing_name_public",
"mass_mailing_name_editor_and_public",
{ {
test: true, test: true,
wait_for: base.ready(), wait_for: base.ready(),
}, },
[ [
// Admin edits home page and adds subscription snippet
{
content: "Edit the homepage",
trigger: ".o_menu_systray a[data-action=edit]",
},
{
content: "Drag and drop a text snippet",
trigger: ".oe_snippet[name='Text Block'] .oe_snippet_thumbnail",
run: "drag_and_drop #wrap",
},
{
content: "Drag and drop a newsletter snippet",
trigger: ".oe_snippet[name='Newsletter'] .oe_snippet_thumbnail",
run: "drag_and_drop #wrap .s_text_block",
},
{
content: "Let the default mailing list",
trigger: ".modal-dialog button:contains('Continue')",
},
{
content: "Save changes",
extra_trigger: "body:not(:has(.modal:visible))",
trigger: "#web_editor-top-edit button[data-action=save]",
},
{
content: "Subscribe Administrator",
extra_trigger: "body:not(:has(#web_editor-top-edit))",
trigger: ".js_subscribe_btn",
},
// Log out
{
content: "Open user menu",
extra_trigger: ".js_subscribe .alert-success",
trigger: "#top_menu span:contains('Administrator')",
},
{
content: "Logout",
trigger: "#o_logout a",
},
// Now use the widget as a random public user
{ {
content: "Try to subscribe without data", content: "Try to subscribe without data",
extra_trigger: "a:contains('Sign in')",
trigger: ".js_subscribe_btn", trigger: ".js_subscribe_btn",
}, },
{ {

50
website_mass_mailing_name/static/src/js/editor_tour.js

@ -1,50 +0,0 @@
/* Copyright 2016-2017 Jairo Llopis <jairo.llopis@tecnativa.com>
* License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). */
odoo.define("website_mass_mailing_name.editor_tour", function (require) {
"use strict";
var base = require("web_editor.base");
var tour = require("web_tour.tour");
tour.register(
"mass_mailing_name_editor",
{
test: true,
wait_for: base.ready(),
},
[
{
content: "Edit the homepage",
trigger: ".o_menu_systray a[data-action=edit]",
},
{
content: "Drag and drop a text snippet",
trigger: ".oe_snippet[name='Text Block'] .oe_snippet_thumbnail",
run: "drag_and_drop #wrap",
},
{
content: "Drag and drop a newsletter snippet",
trigger: ".oe_snippet[name='Newsletter'] .oe_snippet_thumbnail",
run: "drag_and_drop #wrap .s_text_block",
},
{
content: "Let the default mailing list",
trigger: ".modal-dialog button:contains('Continue')",
},
{
content: "Save changes",
extra_trigger: "body:not(:has(.modal:visible))",
trigger: "#web_editor-top-edit button[data-action=save]",
},
{
content: "Subscribe Administrator",
extra_trigger: "body:not(:has(#web_editor-top-edit))",
trigger: ".js_subscribe_btn",
},
{
content: "Open user menu",
extra_trigger: ".js_subscribe .alert-success",
trigger: "#top_menu span:contains('Administrator')",
},
]
);
});

20
website_mass_mailing_name/tests/test_ui.py

@ -2,24 +2,14 @@
# Copyright 2016-2017 Jairo Llopis <jairo.llopis@tecnativa.com> # Copyright 2016-2017 Jairo Llopis <jairo.llopis@tecnativa.com>
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). # License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).
from odoo.http import root
from odoo.tests.common import HttpCase from odoo.tests.common import HttpCase
class UICase(HttpCase): class UICase(HttpCase):
def test_ui(self): def test_ui(self):
"""Test snippet behavior.""" """Test snippet behavior."""
tour = "odoo.__DEBUG__.services['web_tour.tour'].%s"
# Admin edits home page and adds subscription snippet
self.phantom_js(
"/",
tour % "run('mass_mailing_name_editor')",
tour % "tours.mass_mailing_name_editor.ready",
login="admin")
# Forced log out
root.session_store.delete(self.session)
# Public user uses subscription snippet
self.phantom_js(
"/",
tour % "run('mass_mailing_name_public')",
tour % "tours.mass_mailing_name_public.ready")
base = "odoo.__DEBUG__.services['web_tour.tour'].%s"
run = base % "run('%s')"
ready = base % "tours.%s.ready"
tour = "mass_mailing_name_editor_and_public"
self.phantom_js("/", run % tour, ready % tour, login="admin")
Loading…
Cancel
Save