Files
odoo_source/addons/website/tests/test_snippets.py
T
99b50d18e2 [REF] test_website, *: adapt tours to new client action
*: website, website_blog, website_crm, website_event, website_forum,
   website_hr_recruitment, website_mass_mailing, website_sale,
   website_sale_loyalty, website_slides

This commit adds the current website displayed view xmlid outside of the
iframe, on its container, so that the tours registered with
registerThemeHomepageTour can continue to prepend their triggers with
the view xml id.

Introduce registerEditionTour: this function will allow tour maker to
more easily register a tour that needs to start in the iframe's backend
and go in edit mode.

See merge commit for more information.

task-2687506

Co-authored-by: Benjamin Vray <bvr@odoo.com>
Co-authored-by: Younn Olivier <yol@odoo.com>
2022-06-24 10:28:07 +02:00

49 lines
2.3 KiB
Python

# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from lxml import html
from werkzeug.urls import url_encode
from odoo.tests import HttpCase, tagged
from odoo.addons.website.tools import MockRequest
@tagged('post_install', '-at_install', 'website_snippets')
class TestSnippets(HttpCase):
def test_01_empty_parents_autoremove(self):
self.start_tour(self.env['website'].get_client_action_url('/'), 'snippet_empty_parent_autoremove', login='admin')
def test_02_default_shape_gets_palette_colors(self):
self.start_tour("/web", "default_shape_gets_palette_colors", login='admin')
def test_03_snippets_all_drag_and_drop(self):
with MockRequest(self.env, website=self.env['website'].browse(1)):
snippets_template = self.env['ir.ui.view'].render_public_asset('website.snippets')
html_template = html.fromstring(snippets_template)
data_snippet_els = html_template.xpath("//*[@class='o_panel' and not(contains(@class, 'd-none'))]//*[@data-snippet]")
blacklist = [
's_facebook_page', # avoid call to external services (facebook.com)
's_map', # avoid call to maps.google.com
]
snippets_names = ','.join(set(el.attrib['data-snippet'] for el in data_snippet_els if el.attrib['data-snippet'] not in blacklist))
snippets_names_encoded = url_encode({'snippets_names': snippets_names})
path = url_encode({
'path': '/?' + snippets_names_encoded
})
self.start_tour("/web#action=website.website_preview&%s" % path, "snippets_all_drag_and_drop", login='admin', timeout=300)
def test_04_countdown_preview(self):
self.start_tour(self.env['website'].get_client_action_url('/'), 'snippet_countdown', login='admin')
def test_05_social_media(self):
self.start_tour(self.env['website'].get_client_action_url('/'), 'snippet_social_media', login="admin")
self.assertEqual(
self.env['website'].browse(1).social_instagram,
'https://instagram.com/odoo.official/',
'Social media should have been updated'
)
def test_06_snippet_popup_add_remove(self):
self.start_tour(self.env['website'].get_client_action_url('/'), 'snippet_popup_add_remove', login='admin')