Files
odoo_source/addons/website/tests/test_snippets.py
T
Guillaume (gdi)andRomain Derie 8f7c6997e8 [IMP] website: propose a new social media snippet
This commit introduces a new social_media snippet that allows social
networks to be displayed. This snippet shares the same options as the
share snippet, but also provides a list to edit the URLs of the social
networks in the company data (social_facebook, ...). This list also
allows to manage links to custom social networks (which are not stored
in the DB).

Headers and footers now use this new social_media snippet instead of the
share snippet and in the settings, the urls to the DB social networks
are editable/visible only in developer mode.

task-2687447

closes odoo/odoo#80217

Signed-off-by: Romain Derie (rde) <rde@odoo.com>
Co-authored-by: Guillaume (gdi) <gdi@odoo.com>
Co-authored-by: Romain Derie <rde@odoo.com>
2022-01-16 23:36:46 +00:00

41 lines
1.9 KiB
Python

# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from lxml import html
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("/?enable_editor=1", "snippet_empty_parent_autoremove", login='admin')
def test_02_default_shape_gets_palette_colors(self):
self.start_tour("/?enable_editor=1", "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))
self.start_tour("/?enable_editor=1&snippets_names=%s" % snippets_names, "snippets_all_drag_and_drop", login='admin', timeout=300)
def test_04_countdown_preview(self):
self.start_tour("/?enable_editor=1", "snippet_countdown", login='admin')
def test_05_social_media(self):
self.start_tour("/?enable_editor=1", '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'
)