[FIX] website_mass_mailing, *: add test for newsletter popup
*: website This is the forward-port of a stable dependency fix, needed as it includes a test. The dependency was properly fixed with [1]. [1]: https://github.com/odoo/odoo/commit/d4984b81e6b244297e192f2be2768ed11da170aa closes odoo/odoo#65530 X-original-commit: 76e1495b0d5eab8fc03b6daf51dbc1c148c7de53 Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
This commit is contained in:
@@ -170,6 +170,7 @@ function clickOnSnippet(snippet, position = "bottom") {
|
||||
function clickOnSave(position = "bottom") {
|
||||
return {
|
||||
trigger: "button[data-action=save]",
|
||||
in_modal: false,
|
||||
content: _t("Good job! It's time to <b>Save</b> your work."),
|
||||
position: position,
|
||||
};
|
||||
|
||||
@@ -0,0 +1,81 @@
|
||||
odoo.define("website_mass_mailing.tour.newsletter_popup_edition", function (require) {
|
||||
"use strict";
|
||||
|
||||
const tour = require('web_tour.tour');
|
||||
const wTourUtils = require('website.tour_utils');
|
||||
|
||||
tour.register('newsletter_popup_edition', {
|
||||
test: true,
|
||||
url: '/?enable_editor=1',
|
||||
}, [
|
||||
wTourUtils.dragNDrop({
|
||||
id: 's_newsletter_subscribe_popup',
|
||||
name: 'Newsletter Popup',
|
||||
}),
|
||||
{
|
||||
content: "Confirm newsletter choice",
|
||||
trigger: '.modal-footer .btn-primary',
|
||||
},
|
||||
{
|
||||
content: "Check the modal is opened for edition",
|
||||
trigger: '.o_newsletter_popup .modal:visible',
|
||||
in_modal: false,
|
||||
run: () => null,
|
||||
},
|
||||
wTourUtils.clickOnSave(),
|
||||
{
|
||||
content: "Check the modal has been saved, closed",
|
||||
trigger: '.o_newsletter_popup',
|
||||
extra_trigger: 'body:not(.editor_enable)',
|
||||
run: function (actions) {
|
||||
const $modal = this.$anchor.find('.modal');
|
||||
if ($modal.is(':visible')) {
|
||||
console.error('Modal is still opened...');
|
||||
}
|
||||
},
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
odoo.define("website_mass_mailing.tour.newsletter_popup_use", function (require) {
|
||||
"use strict";
|
||||
|
||||
const tour = require('web_tour.tour');
|
||||
|
||||
tour.register('newsletter_popup_use', {
|
||||
test: true,
|
||||
url: '/',
|
||||
}, [
|
||||
{
|
||||
content: "Check the modal is not yet opened and force it opened",
|
||||
trigger: '.o_newsletter_popup',
|
||||
run: function (actions) {
|
||||
const $modal = this.$anchor.find('.modal');
|
||||
if ($modal.is(':visible')) {
|
||||
console.error('Modal is already opened...');
|
||||
}
|
||||
$(document).trigger('mouseleave');
|
||||
},
|
||||
},
|
||||
{
|
||||
content: "Check the modal is now opened and enter text in the subscribe input",
|
||||
trigger: '.o_newsletter_popup .modal input',
|
||||
in_modal: false,
|
||||
run: 'text hello@world.com',
|
||||
},
|
||||
{
|
||||
content: "Subscribe",
|
||||
trigger: '.modal-dialog .btn-primary',
|
||||
},
|
||||
{
|
||||
content: "Check the modal is now closed",
|
||||
trigger: '.o_newsletter_popup',
|
||||
run: function (actions) {
|
||||
const $modal = this.$anchor.find('.modal');
|
||||
if ($modal.is(':visible')) {
|
||||
console.error('Modal is still opened...');
|
||||
}
|
||||
},
|
||||
}
|
||||
]);
|
||||
});
|
||||
@@ -0,0 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
from . import test_snippets
|
||||
@@ -0,0 +1,16 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
import odoo
|
||||
import odoo.tests
|
||||
|
||||
|
||||
@odoo.tests.common.tagged('post_install', '-at_install')
|
||||
class TestSnippets(odoo.tests.HttpCase):
|
||||
|
||||
def test_01_newsletter_popup(self):
|
||||
self.start_tour("/?enable_editor=1", "newsletter_popup_edition", login='admin')
|
||||
self.start_tour("/", "newsletter_popup_use", login=None)
|
||||
mailing_list = self.env['mailing.list'].search([], limit=1)
|
||||
emails = mailing_list.contact_ids.mapped('email')
|
||||
self.assertIn("hello@world.com", emails)
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
<template id="assets_tests" inherit_id="website.assets_tests">
|
||||
<xpath expr="//script[last()]" position="after">
|
||||
<script type="text/javascript" src="/website_mass_mailing/static/tests/tours/newsletter_popup.js"/>
|
||||
</xpath>
|
||||
</template>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user