8884e100f9
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>
75 lines
2.9 KiB
Python
75 lines
2.9 KiB
Python
"""V8.12 workbench usability, security boundaries and backend compatibility."""
|
|
from app.version import VERSION
|
|
from test_factory import client
|
|
import subprocess
|
|
from pathlib import Path
|
|
|
|
|
|
def test_workbench_has_real_entry_and_assets(client):
|
|
html=client.get('/').text
|
|
assert '/ui/workspace.js' in html and 'sitePicker' in html
|
|
assert client.get('/ui/workspace.js').status_code==200
|
|
assert client.get('/ui/workspace.css').status_code==200
|
|
|
|
|
|
def test_authorized_site_restoration_and_browser_history(client):
|
|
js=client.get('/ui/workspace.js').text
|
|
assert 'siteforge:selected-site' in js
|
|
assert "state.sites.some(x=>x.id===id)" in js
|
|
assert "state.sites.some(x=>x.id===id)" in js
|
|
assert "window.addEventListener('popstate'" in js
|
|
assert "history[replace?'replaceState':'pushState']" in js
|
|
assert "const token=++state.selectionToken" in js
|
|
|
|
|
|
def test_build_screen_recovers_durable_worker_jobs(client):
|
|
js=client.get('/ui/workspace.js').text
|
|
assert '/api/enterprise/sites/' in js
|
|
assert 'function activeJobs()' in js
|
|
assert 'refreshBuilds()' in js
|
|
assert 'cancel-job' in js and 'async function cancelJob' in js
|
|
assert '交付前检查' in js and '/migration/readiness' in js
|
|
assert 'setInterval' in js and '!document.hidden' in js
|
|
|
|
|
|
def test_build_rejects_download_while_incomplete(client):
|
|
js=client.get('/ui/workspace.js').text
|
|
assert '尚未完成,暂不能下载' in js
|
|
assert 'status' in js and "['done','completed','success','complete']" in js
|
|
|
|
|
|
def test_safe_import_is_default_and_direct_import_is_explicit(client):
|
|
js=client.get('/ui/workspace.js').text
|
|
assert '推荐:先预演再导入' in js
|
|
assert '直接写入网站(不可批次回滚)' in js
|
|
assert '安全导入与批次回滚' in js
|
|
assert "if(!confirm('将文件内容直接写入" in js
|
|
|
|
|
|
def test_wizard_does_not_claim_design_automatically_finished(client):
|
|
js=client.get('/ui/workspace-guide.js').text
|
|
assert "id:'design'" in js and 'optional:true' in js
|
|
assert "done:false,optional:true" in js
|
|
|
|
|
|
def test_live_job_endpoint_can_list_user_site_jobs(client):
|
|
site=client.post('/api/sites',json={'name':'UI V8.12 smoke','theme':'corporate'})
|
|
assert site.status_code==201,site.text
|
|
sid=site.json()['id']
|
|
result=client.get(f'/api/enterprise/sites/{sid}/jobs')
|
|
assert result.status_code==200,result.text
|
|
assert isinstance(result.json(),list)
|
|
audit=client.get(f'/api/factory/sites/{sid}/migration/readiness')
|
|
assert audit.status_code==200,audit.text
|
|
assert 'gates' in audit.json()
|
|
|
|
|
|
def test_version_is_updated(client):
|
|
assert client.get('/api/health').json()['version']==VERSION
|
|
|
|
|
|
def test_js_standalone_syntax():
|
|
root=Path(__file__).resolve().parents[1]
|
|
proc=subprocess.run(['node','--check',str(root/'app/static/workspace.js')],capture_output=True,text=True)
|
|
assert proc.returncode==0,proc.stderr
|