mock: キャンバスの viewBox を、ツールバーを除いた SVG の大きさに合わせる

ResizeObserver がツールバーを含むペインを見ていたため、viewBox の高さが SVG の実寸より
ツールバーの分だけ大きく、描画が縮んでいた。ツールバーが折り返すとずれが広がる。SVG 自身を見る。

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ShoEXYqi8PWTjB9E86Ltot
This commit is contained in:
2026-10-23 20:59:42 +09:00
co-authored by Claude Opus 5.5
parent b314309e8c
commit a4eabe3691
3 changed files with 11 additions and 4 deletions
+8
View File
@@ -658,3 +658,11 @@ test("バリアントグループを選んでキーを足すと、表示中の
expect(Math.abs(box.x - left!.x)).toBeLessThan(1);
expect(Math.abs(box.y - (left!.y + unit))).toBeLessThan(1);
});
test("キャンバスのviewBoxはツールバーを除いたSVGの大きさに合う", async ({ page }) => {
const canvas = page.locator("svg.canvas");
const box = (await canvas.boundingBox())!;
const [, , w, h] = (await canvas.getAttribute("viewBox"))!.split(" ").map(Number);
expect(Math.abs(w! - box.width)).toBeLessThan(1);
expect(Math.abs(h! - box.height)).toBeLessThan(1);
});