23 lines
1.2 KiB
Python
23 lines
1.2 KiB
Python
|
|
"""V8.22 studio canvas wiring and editor-published separation."""
|
||
|
|
from pathlib import Path
|
||
|
|
from bs4 import BeautifulSoup
|
||
|
|
ROOT=Path(__file__).resolve().parents[1]
|
||
|
|
|
||
|
|
def test_canvas_resources_are_real_and_editor_only():
|
||
|
|
bridge=(ROOT/'app/static/studio-canvas-bridge.js').read_text(encoding='utf-8')
|
||
|
|
source=(ROOT/'app/main.py').read_text(encoding='utf-8')
|
||
|
|
editor=(ROOT/'app/static/editor.js').read_text(encoding='utf-8')
|
||
|
|
assert 'studio-canvas-bridge.js' in source
|
||
|
|
assert 'studio-canvas-bridge.js' not in (ROOT/'app/builder.py').read_text(encoding='utf-8')
|
||
|
|
for command in ('reorder','resize-columns','add-after','duplicate','delete','inline-text'):
|
||
|
|
assert command in editor and command in bridge
|
||
|
|
assert 'eval(' not in bridge and 'new Function(' not in bridge
|
||
|
|
assert 'event.source!==frame.contentWindow' in editor
|
||
|
|
|
||
|
|
def test_editor_canvas_hints_and_save_remain_accessible():
|
||
|
|
soup=BeautifulSoup((ROOT/'app/templates/editor.html').read_text(encoding='utf-8'),'html.parser')
|
||
|
|
assert soup.select_one('#sfInsertHint')['hidden'] == ''
|
||
|
|
assert soup.select_one('#sitePreview')['sandbox']==['allow-scripts']
|
||
|
|
assert soup.select_one('#saveDraftButton')
|
||
|
|
assert soup.select_one('#publishDesignButton')
|