*: test_website, website_blog, website_crm, website_hr_recruitment, website_mass_mailing, website_sale, website_sale_wishlist, website_slides This commit creates a new util which clicks on edit and waits for the edit mode to be started. This way, we make sure that the edit mode is enabled before testing the next step of the test. This avoids race conditions during tests. This commit replaces all the uses of the old util with the new one, it also removes the steps that are waiting for the edit mode to start. Finally, from [this other commit], we can start a tour in edit mode. For these tests (which have `edition: true`), it is useless to check if the edit mode has started at the beginning of the test because this check is already done by default. This commit removes unnecessary / duplicated steps. [this other commit]: https://github.com/odoo/odoo/commit/99b50d18e220aedf14de806f4bf1b2d35c32de35#diff-c7720501ec33f5f92c907d8bb41de50edd832a4564317073e801a6915796a6bdR278 task-3203820 closes odoo/odoo#120481 X-original-commit: https://github.com/odoo/odoo/commit/9fd5d25f59578abc9c608578a7d2e2953880b582 Related: odoo/design-themes#656 Signed-off-by: Romain Derie (rde) <rde@odoo.com> Signed-off-by: Guillaume-gdi <gdi@odoo.com>
74 lines
3.3 KiB
Python
74 lines
3.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
|
|
from odoo.tests.common import HOST
|
|
from odoo.tools import config
|
|
|
|
|
|
@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('/@/', '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')
|
|
|
|
def test_07_image_gallery(self):
|
|
self.start_tour(self.env['website'].get_client_action_url('/'), 'snippet_image_gallery', login='admin')
|
|
|
|
def test_08_table_of_content(self):
|
|
self.start_tour(self.env['website'].get_client_action_url('/'), 'snippet_table_of_content', login='admin')
|
|
|
|
def test_09_snippet_image_gallery(self):
|
|
IrAttachment = self.env['ir.attachment']
|
|
base = "http://%s:%s" % (HOST, config['http_port'])
|
|
IrAttachment.create({
|
|
'public': True,
|
|
'name': 's_default_image.jpg',
|
|
'type': 'url',
|
|
'url': base + '/web/image/website.s_banner_default_image.jpg',
|
|
})
|
|
IrAttachment.create({
|
|
'public': True,
|
|
'name': 's_default_image2.jpg',
|
|
'type': 'url',
|
|
'url': base + '/web/image/website.s_banner_default_image.jpg',
|
|
})
|
|
self.start_tour("/", "snippet_image_gallery_remove", login='admin')
|