"""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.1' assert theme_store.resolve('industrial','1.3.0') != theme_store.resolve('industrial') 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 '