"""Deterministic P4 regression checks. Drafts must never leak into builds."""
import json
import pytest
from tests.test_factory import client,create
from app import blueprints,db,v8_templates
def _home(c,sid):
return next(x for x in c.get(f'/api/sites/{sid}/entries').json() if x['route']=='/')
def test_six_new_schema_blocks_and_safe_rendering():
specs=blueprints.BLOCK_PROPERTY_SCHEMA
kinds=('carousel','video','tabs','pricing','map','form_link')
assert all(k in specs for k in kinds)
blocks=[blueprints.new_block(x) for x in kinds]
assert len(blueprints.validate_blocks(blocks))==6
video=blueprints.new_block('video',{'url':'https://www.youtube.com/watch?v=dQw4w9WgXcQ'})
html=blueprints.render_blocks([video],{}, {}, [])
assert 'youtube-nocookie.com/embed/dQw4w9WgXcQ' in html
assert 'iframe' in html
blocked=blueprints.new_block('video',{'url':'https://www.evil.example/video/123'})
assert 'iframe' not in blueprints.render_blocks([blocked],{}, {}, [])
item=blueprints.new_block('pricing',{'items':[{'name':'', 'price':'$5','features':['
'], 'href':'javascript:alert(1)'}]})
text=blueprints.render_blocks([item],{}, {}, [])
assert '