60 lines
2.8 KiB
Python
60 lines
2.8 KiB
Python
|
|
"""V8.29 theme versioning and editor usability: protected integration checks."""
|
||
|
|
import json
|
||
|
|
from pathlib import Path
|
||
|
|
from bs4 import BeautifulSoup
|
||
|
|
from test_factory_v2 import factory, site
|
||
|
|
from app import theme_store
|
||
|
|
|
||
|
|
THEMES=('automotive','industrial','corporate','minimal')
|
||
|
|
ROOT=Path(__file__).resolve().parents[1]
|
||
|
|
|
||
|
|
|
||
|
|
def test_all_themes_preserve_v110_and_publish_v120(factory):
|
||
|
|
for theme in THEMES:
|
||
|
|
assert theme_store.latest(theme)==('1.4.1' if theme=='automotive' else '1.3.0')
|
||
|
|
assert theme_store.resolve(theme,'1.1.0').is_dir()
|
||
|
|
assert theme_store.compatibility(theme,'1.1.0')['valid']
|
||
|
|
assert theme_store.compatibility(theme,'1.2.0')['valid']
|
||
|
|
assert json.loads((theme_store.resolve(theme,'1.1.0')/'manifest.json').read_text())['version']=='1.1.0'
|
||
|
|
|
||
|
|
|
||
|
|
def test_theme_versions_remain_buildable(factory):
|
||
|
|
sid=site(factory)
|
||
|
|
for theme in THEMES:
|
||
|
|
for version in ('1.1.0','1.2.0','1.3.0'):
|
||
|
|
res=factory.put(f'/api/factory/sites/{sid}/theme',json={'theme':theme,'version':version})
|
||
|
|
assert res.status_code==200, (theme,version,res.text)
|
||
|
|
res=factory.post(f'/api/sites/{sid}/builds',json={})
|
||
|
|
assert res.status_code==200,(theme,version,res.text)
|
||
|
|
bid=res.json()['version']
|
||
|
|
main=factory.get(f'/preview/{sid}/{bid}/')
|
||
|
|
assert main.status_code==200
|
||
|
|
assert f'pro-{theme}' in main.text
|
||
|
|
css=factory.get(f'/preview/{sid}/{bid}/assets/pro.css')
|
||
|
|
assert css.status_code==200
|
||
|
|
assert ('V8.29 presentation refinement' in css.text)==(version in ('1.2.0','1.3.0'))
|
||
|
|
|
||
|
|
|
||
|
|
def test_theme_preview_6_page_types(factory):
|
||
|
|
for theme in THEMES:
|
||
|
|
for kind in ('home','listing','product','article','about','contact'):
|
||
|
|
res=factory.get(f'/api/factory/themes/{theme}/preview',params={'page_type':kind})
|
||
|
|
assert res.status_code==200,(theme,kind)
|
||
|
|
assert BeautifulSoup(res.text,'html.parser').find('header',class_='pro-header')
|
||
|
|
assert 'V8.30 REAL PAGE COMPOSITION' in factory.get(f'/api/factory/themes/{theme}/preview.pro.css').text
|
||
|
|
|
||
|
|
|
||
|
|
def test_editor_controls_and_safe_preview_dialog(factory):
|
||
|
|
sid=site(factory)
|
||
|
|
# Real authenticated page route; selectors target actual shipped template.
|
||
|
|
res=factory.get(f'/studio/{sid}')
|
||
|
|
if res.status_code==404:
|
||
|
|
import re
|
||
|
|
editor=(ROOT/'app/templates/editor.html').read_text()
|
||
|
|
else:editor=res.text
|
||
|
|
for ident in ('studioThemePreviewButton','themePreviewModal','themePreviewTheme','themePreviewPage','themePreviewFrame','paletteSearch','quickUndo','quickRedo'):
|
||
|
|
assert f'id="{ident}"' in editor
|
||
|
|
assert 'sandbox="allow-scripts"' in editor
|
||
|
|
assert 'allow-same-origin' not in editor
|
||
|
|
assert 'studio-experience-v829.js' in editor
|