Files
design-themes/test_themes/tests/test_crawl.py
T
qsm-odoo 0ed42f903c [FIX] test_themes: add a test which goes over all theme tours
This is a backport of [1] which at the same time finally enables the
test to be able to test all theme tours. Notice that the tours should
be improved so that each step properly checks that the previous step
actually had an effect (as those tours are normally made to display to
the user and were not designed for testing). However, this is already
really useful as only checking if *entering* edit mode in each theme
does not crash is already covering most issues that can be created when
designing a theme at the moment.

[1]: https://github.com/odoo/design-themes/commit/52fef46388ec880af78c5a5f3e6152c4510548f4

closes odoo/design-themes#532

Related: odoo/odoo#80936
Signed-off-by: Romain Derie (rde) <rde@odoo.com>
2021-12-08 13:05:57 +00:00

44 lines
2.0 KiB
Python

# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo.tests import HttpCase, tagged
@tagged('post_install', '-at_install')
class Crawler(HttpCase):
def test_01_crawl_every_themes(self):
""" Crawl every website (and so every themes) to ensure all themes can
be rendered and do not crash.
"""
Website = self.env['website']
websites_themes = Website.get_test_themes_websites()
assert len(websites_themes) == len(self.env.ref('base.module_test_themes').dependencies_id)
def test_crawling():
for website in websites_themes.filtered(lambda w: w.theme_id.name != 'theme_default'):
r = self.url_open('/?fw=%s&debug=assets' % website.id)
self.assertEqual(r.status_code, 200, "Ensure rendering went fine as public user")
self.assertTrue('/%s/static/src' % website.theme_id.name in r.text, "Ensure rendering went fine as public user")
# 1. Test as public user
test_crawling()
# 2. Test as admin
self.authenticate('admin', 'admin')
test_crawling()
# Note: this test is also really useful to build the default pages
# automatically by adding cr.commit() at the end of the tour
def test_02_homepage_tour_every_theme(self):
# TODO All the theme tours that are runned during this test should be
# improved so that each step properly checks that the previous step
# actually had an effect (as those tours are normally made to display to
# the user and were not designed for testing). However, this is already
# really useful as only checking if *entering* edit mode in each theme
# does not crash is already covering most issues that can be created
# when designing a theme at the moment.
Website = self.env['website']
websites_themes = Website.get_test_themes_websites()
for website in websites_themes:
self.start_tour(f"/?fw={website.id}", 'homepage', login='admin')