mirror of
https://github.com/odoo/design-themes.git
synced 2025-10-07 01:18:52 +07:00
35f4de9674
Ripple option is now an ir.asset, not an ir.ui.view anymore, see [1].
[1]: https://github.com/odoo/odoo/commit/9f56357cc1f4a7b8606ef4d5fd431fc396bdf1e8
closes odoo/design-themes#585
X-original-commit: 96e713a14f
Signed-off-by: Romain Derie (rde) <rde@odoo.com>
61 lines
2.5 KiB
Python
61 lines
2.5 KiB
Python
# -*- coding: utf-8 -*-
|
|
|
|
from odoo.addons.website.tools import MockRequest
|
|
from odoo.tests import standalone
|
|
|
|
|
|
@standalone('theme_upgrade', 'website_standalone')
|
|
def test_01_theme_upgrade_post_copy(env):
|
|
""" This test ensures the theme `_post_copy()` method is only called when a
|
|
theme is installed for the first time on a website and not when the theme is
|
|
updated on that website.
|
|
"""
|
|
# 1. Setup
|
|
website = env['website'].search([], limit=1)
|
|
Website = env['website'].with_context(website_id=website.id)
|
|
|
|
# Get rid of as many website as we can, any website will drastically slows
|
|
# down the test as when updating Theme Nano, it will update Theme Common
|
|
# which is applied on every site having a theme. It will then update all
|
|
# those websites.
|
|
Website.get_test_themes_websites().unlink()
|
|
for w in Website.search([('theme_id', '!=', False), ('id', '!=', website.id)]):
|
|
try:
|
|
w.unlink()
|
|
except Exception:
|
|
pass
|
|
|
|
ofs_specific_view = Website.viewref('website.option_footer_scrolltop')
|
|
fls_specific_view = Website.viewref('portal.footer_language_selector')
|
|
theme_nano_module = env.ref('base.module_theme_nano')
|
|
|
|
def _simulate_user_manual_change():
|
|
# Change some website options that will be changed by Theme Nano
|
|
ofs_specific_view.active = False
|
|
fls_specific_view.active = True
|
|
|
|
# 2. Simulate some website option change made by the user
|
|
_simulate_user_manual_change()
|
|
|
|
# 3. Simulate user choosing a new theme for his website
|
|
with MockRequest(env, website=website):
|
|
theme_nano_module.with_context(website_id=website.id).button_choose_theme()
|
|
|
|
assert Website.viewref('website.option_footer_scrolltop').active is True, \
|
|
"Theme Nano custo should be applied"
|
|
assert Website.viewref('portal.footer_language_selector').active is False, \
|
|
"Theme Nano custo should be applied (2)"
|
|
|
|
# 4. Simulate some website option change made by the user, again
|
|
_simulate_user_manual_change()
|
|
|
|
# 5. Upgrade Theme Nano
|
|
theme_nano_module.button_immediate_upgrade()
|
|
env.reset() # clear the set of environments
|
|
env = env() # get an environment that refers to the new registry
|
|
|
|
assert Website.viewref('website.option_footer_scrolltop').active is False, \
|
|
"Theme Nano custo should NOT be applied"
|
|
assert Website.viewref('portal.footer_language_selector').active is True, \
|
|
"Theme Nano custo should NOT be applied (2)"
|