Files
cms-SiteForge/tests/test_v8311_performance_icons.py
浅念 8884e100f9 upgrade: adopt V8.31.1 (theme 1.3/1.4 redesigns, editor deep-canvas, guided launch, component library)
Overlay 190 upstream items (V8.22→8.31) preserving trade-pro theme,
registry tests, and design docs. Re-applied full patch set on identical
anchors (discovery/env_for/blocks.css/type-mapping/locale-override/
theme_color/frontend entries/test_theme_pro_v3 mods) plus compose pins.

Verified: theme suites 35/35; dual-baseline full run 415 passed vs
pristine 386+29 ours, FAILED-set diff EMPTY (same 10 Windows env fails).
Live: container 8.31.1-dev.1 healthy, hesupipe 192 entries intact,
trade-pro build 203 pages 0 errors.

Co-Authored-By: Claude Code <noreply@anthropic.com>
2026-10-26 09:43:17 +08:00

65 lines
3.3 KiB
Python

"""Real static build + legacy pin smoke for performance and semantic icons."""
from pathlib import Path
from bs4 import BeautifulSoup
from app import db, theme_store
from test_factory_v2 import factory,site
def test_latest_theme_icons_and_preview_resources(factory):
assert theme_store.latest('automotive')=='1.4.1'
for kind in ('home','product','brand','listing','contact'):
result=factory.get('/api/factory/themes/automotive/preview',params={'page_type':kind})
assert result.status_code==200,result.text[:400]
doc=BeautifulSoup(result.text,'html.parser')
assert len(doc.select('link[rel=stylesheet]'))==1
assert len(doc.select('script[src]'))==1
assert 'preview.bundle.css' in doc.select_one('link[rel=stylesheet]')['href']
assert 'preview.bundle.js' in doc.select_one('script[src]')['src']
uses=doc.select('svg.auto-icon use[href]')
assert uses
assert all('preview.icons.svg' in v['href'] for v in uses)
for name in ('bundle.css','bundle.js','icons.svg'):
r=factory.get('/api/factory/themes/automotive/preview.'+name)
assert r.status_code==200,(name,r.text[:80])
assert len(r.content)>250
def test_compiled_assets_in_new_version_and_legacy_original(factory):
sid=site(factory)
assert factory.post(f'/api/factory/sites/{sid}/bootstrap').status_code==200
for version in ('1.4.0','1.4.1'):
assert factory.put(f'/api/factory/sites/{sid}/theme',json={'theme':'automotive','version':version}).status_code==200
r=factory.post(f'/api/sites/{sid}/builds',json={})
assert r.status_code==200,r.text[:400]
bid=r.json()['version']
def open_path(path):
reply=factory.get(f'/preview/{sid}/{bid}/'+path)
assert reply.status_code==200,(version,path,reply.text[:160])
return reply
home=BeautifulSoup(open_path('').text,'html.parser')
if version=='1.4.1':
css=home.select('link[rel=stylesheet]')
js=home.select('script[src]')
assert len(css)==1 and css[0]['href']=='assets/auto-compiled.css'
assert len(js)==1 and js[0]['src']=='assets/auto-compiled.js'
icons=open_path('assets/auto-icons.svg').text
assert '<symbol id="search"' in icons and '<symbol id="chat"' in icons
assert '.auto31-search' in open_path('assets/auto-compiled.css').text
script=open_path('assets/auto-compiled.js').text
assert 'data-pro-menu' in script and 'search-index.json' in script
assert all(icon['href'].startswith('assets/auto-icons.svg#') for icon in home.select('use[href]'))
assert 'auto-compiled' in open_path('contact/').text
assert open_path('products/').status_code==200
else:
assert len(home.select('link[rel=stylesheet]'))>=6
assert len(home.select('script[src]'))>=3
assert 'auto-compiled.css' not in str(home)
def test_old_theme_source_is_snapshotted():
old=theme_store.resolve('automotive','1.4.0')
new=theme_store.resolve('automotive','1.4.1')
assert (old/'pro.html').read_text()!= (new/'pro.html').read_text()
assert 'auto-icons.svg' not in (old/'pro.html').read_text()
assert theme_store.compatibility('automotive','1.4.0')['valid']