Files
cms-SiteForge/tests/test_v831_automotive_ref.py
T
浅念 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

80 lines
4.0 KiB
Python

"""Automotive v1.4.0 information architecture inspired by Magic Bridge Auto.
No real external content or vehicle claim is imported by the theme.
"""
import json
from pathlib import Path
from bs4 import BeautifulSoup
from app import theme_store
from test_factory_v2 import factory, site
ROOT=Path(__file__).resolve().parents[1]
def test_automotive_new_and_old_versions_remain_available(factory):
assert theme_store.latest('automotive')=='1.4.1'
for version in ('1.4.0','1.3.0','1.2.0','1.1.0','1.0.0'):
p=theme_store.resolve('automotive',version)
assert theme_store.compatibility('automotive',version)['valid']
assert ('auto31-home' in (p/'pages/home.html').read_text()) == (version == '1.4.0')
assert "'pages/' ~ kind" in (p/'pro.html').read_text()
assert theme_store.latest('industrial')=='1.3.0'
assert 'auto31-home' in (theme_store.resolve('automotive','1.4.0')/'pages/home.html').read_text()
def test_reference_inspired_full_page_structure(factory):
checks={'home':('.auto31-home','.auto31-search','.auto31-feature-tile'),
'listing':('.auto31-catalog','.pro-filter-panel','.pro-filter-scope'),
'brand':('.auto31-brand','#auto31-brand-models','.auto31-brand-story'),
'product':('.auto31-detail','.auto31-detail-main','.auto31-spec-panel'),
'about':('.pro-v30-about',), 'contact':('.pro-v30-contact',)}
for kind,selectors in checks.items():
res=factory.get('/api/factory/themes/automotive/preview',params={'page_type':kind})
assert res.status_code==200,(kind,res.text[:350])
soup=BeautifulSoup(res.text,'html.parser')
assert len(soup.select('h1'))==1
assert all(soup.select_one(css) for css in selectors),(kind,selectors)
assert soup.select_one('[data-pro-menu]')
def test_automotive_search_and_mega_use_real_catalogue_data(factory):
sid=site(factory)
assert factory.post(f'/api/factory/sites/{sid}/bootstrap').status_code==200
product=factory.post(f'/api/sites/{sid}/entries',json={
'type':'product','title':'Fictional A1','route':'/products/fictional-a1/',
'summary':'Demonstration model, not real inventory',
'meta':{'fields':{'brand':'DemoMotors','category':'SUV','energy':'EV'}}})
assert product.status_code==201,product.text
assert factory.put(f'/api/factory/sites/{sid}/theme',json={'theme':'automotive','version':'1.4.0'}).status_code==200
build=factory.post(f'/api/sites/{sid}/builds',json={})
assert build.status_code==200,build.text
version=build.json()['version']
def view(route):
r=factory.get(f'/preview/{sid}/{version}{route}')
assert r.status_code==200,(route,r.text[:250])
return r.text
home=view('/')
assert 'DemoMotors' in home and 'Fictional A1' in home
assert 'auto31.js' in home and 'auto31-search' in home
catalogue=view('/products/')
assert 'Fictional A1' in catalogue
assert 'data-pro-filter-search' in catalogue
assert 'DemoMotors' in view('/brands/demomotors/')
detail=view('/products/fictional-a1/')
assert 'Vehicle' in detail or '车辆参数' in detail
assert '<meta name="robots"' in detail
assert factory.get(f'/preview/{sid}/{version}/assets/auto31.js').status_code==200
report=factory.get(f'/api/sites/{sid}/builds/{version}/report').json()
assert not report['errors']
def test_v830_archived_template_is_not_v831_home(factory):
sid=site(factory)
assert factory.post(f'/api/factory/sites/{sid}/bootstrap').status_code==200
for version in ('1.3.0','1.4.0','1.4.1'):
assert factory.put(f'/api/factory/sites/{sid}/theme',json={'theme':'automotive','version':version}).status_code==200
build=factory.post(f'/api/sites/{sid}/builds',json={})
assert build.status_code==200,build.text
p=factory.get(f'/preview/{sid}/{build.json()["version"]}/')
assert p.status_code==200
assert ('auto31-home' in p.text)==(version in ('1.4.0','1.4.1'))
assert ('auto31-hero-grid' in p.text)==(version in ('1.4.0','1.4.1'))