Wizard DXF e riepilogo: overlay SVG, Salva immagine, NaN per quota non misurata
Refs #118 #119 #121 Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
"""Controllo del template del wizard DXF: Salva in due barre zoom e overlay SVG (#119, #121).
|
||||
|
||||
Legge task_editor.html come testo (come test_vision_panel_fit.py), senza renderlo.
|
||||
"""
|
||||
from pathlib import Path
|
||||
|
||||
TEMPLATE = Path(__file__).resolve().parent.parent / "templates" / "maker" / "task_editor.html"
|
||||
|
||||
|
||||
def _src() -> str:
|
||||
return TEMPLATE.read_text(encoding="utf-8")
|
||||
|
||||
|
||||
def _bar_of(src: str, marker: str) -> str:
|
||||
"""Testo della barra zoom che contiene il marker (dal div della barra al primo </div>)."""
|
||||
i = src.index(marker)
|
||||
start = src.rfind('absolute top-2 right-2', 0, i)
|
||||
return src[start:src.index("</div>", i)]
|
||||
|
||||
|
||||
def test_prova_overlay_is_svg_not_canvas():
|
||||
# #121: l'overlay della Prova e' un <svg> con preserveAspectRatio none, non piu' un canvas
|
||||
src = _src()
|
||||
i = src.index('x-ref="overlay"')
|
||||
tag = src[src.rfind("<", 0, i):src.index(">", i) + 1]
|
||||
assert tag.startswith("<svg")
|
||||
assert 'preserveAspectRatio="none"' in tag
|
||||
assert "pointer-events-none" in tag
|
||||
assert "<canvas" not in src[i - 200:i + 200]
|
||||
|
||||
|
||||
def test_save_button_in_image_and_prova_bars_only():
|
||||
# #119: Salva nella barra dell'immagine e in quella della Prova, non in quella del DXF
|
||||
src = _src()
|
||||
img_bar = _bar_of(src, "vFit('img')")
|
||||
prova_bar = _bar_of(src, 'zoomBy(1 / 1.25)')
|
||||
dxf_bar = _bar_of(src, "vFit('dxf')")
|
||||
assert "tmfSaveImage(imagePreviewUrl, 'immagine')" in img_bar
|
||||
assert "tmfSaveImage(imageSrc, 'prova')" in prova_bar
|
||||
assert "tmfSaveImage" not in dxf_bar
|
||||
assert src.count("tmfSaveImage(") == 2
|
||||
# il pulsante sta dopo Adatta e prima della percentuale
|
||||
assert img_bar.index("vFit('img')") < img_bar.index("tmfSaveImage") < img_bar.index("vPct('img')")
|
||||
assert prova_bar.index("fit()") < prova_bar.index("tmfSaveImage") < prova_bar.index("zoomPct")
|
||||
|
||||
|
||||
def test_scripts_loaded_before_wizard():
|
||||
# #119 #121: vision_overlay.js e save_image.js prima di dxf_recipe_wizard.js
|
||||
src = _src()
|
||||
wiz = src.index("js/dxf_recipe_wizard.js")
|
||||
assert src.index("js/vision_overlay.js") < wiz
|
||||
assert src.index("js/save_image.js") < wiz
|
||||
Reference in New Issue
Block a user