SVG preview fitting size problem solved

This commit is contained in:
2026-06-09 20:58:37 +08:00
parent fa0ebe899c
commit 7195dea7cd
2 changed files with 76 additions and 26 deletions
+13 -13
View File
@@ -33,16 +33,6 @@ assert(
'Build Layout should use the backend svg_url response'
);
assert(
<<<<<<< HEAD
canvasHtml.includes('result.svg_ready && result.svg_url') &&
canvasHtml.includes('buildLayoutRequestRef') &&
canvasHtml.includes('buildLayoutBusyRef') &&
canvasHtml.includes("cache: 'no-store'"),
'Build Layout should wait for a ready, versioned SVG response and prevent stale duplicate preview updates'
);
assert(
=======
>>>>>>> jingwen_main
canvasHtml.includes('result.preview_error') &&
canvasHtml.includes('Preview skipped: '),
'Build Layout should log when the backend saves YAML but skips SVG preview because the router stack is unavailable'
@@ -60,8 +50,18 @@ assert(
'layout SVG preview should expose an editable scale value'
);
assert(
canvasHtml.includes('objectFit: \'contain\''),
'100% layout preview scale should fit the full SVG within the screen'
canvasHtml.includes('objectFit: \'contain\'') &&
canvasHtml.includes('previewCanvasRef') &&
canvasHtml.includes('ResizeObserver') &&
canvasHtml.includes('svgSize') &&
canvasHtml.includes('naturalWidth') &&
canvasHtml.includes('naturalHeight') &&
canvasHtml.includes('const fitScalePercent = clampLayoutScale(Math.floor') &&
canvasHtml.includes('layoutScale ?? fitScalePercent') &&
canvasHtml.includes('const stageWidth = baseWidth * normalizedScale / 100') &&
!canvasHtml.includes('useState(100)') &&
!canvasHtml.includes('baseWidth * fitScale * normalizedScale / 100'),
'layout preview should default to the actual fitted SVG scale percent instead of redefining 100% as fit'
);
assert(
canvasHtml.includes('className="build-gds-btn"'),
@@ -354,7 +354,7 @@ assert(
canvasHtml.includes('layoutBounds') &&
canvasHtml.includes('stageWidth') &&
canvasHtml.includes('stageHeight'),
'layout preview should mouse-wheel zoom and size 100% from calculated box_size layout bounds'
'layout preview should mouse-wheel zoom from the actual calculated SVG scale'
);
assert(
canvasHtml.includes('reactFlowInstance.fitBounds') &&