Skip to content

Commit 3cf66ff

Browse files
fix: make the CI gates pass with the central router
Two gates broke on the routing change and both were the change surfacing, not a defect: - server embed test: the router derives its own path (routes are not persisted), so an edge given legacy `data.points` but no pinned anchors is auto-routed and its label lands on the new path. Assert the property the test names — the label sits ON the rendered polyline, not at the straight-midpoint fallback — instead of a coordinate baked from the old route. - library main-entry size budget: the orthogonal routing engine adds ~27 kB brotli to the always-loaded core (it runs on first paint, so it cannot be lazy split without flashing unrouted edges). Raise the limit from 87 to 118 kB — the new 114.28 kB baseline plus headroom for brotli variance, still tight enough to catch a real regression. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent ff3ba4f commit 3cf66ff

2 files changed

Lines changed: 42 additions & 7 deletions

File tree

library/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@
7676
{
7777
"name": "main entry (published JS, deps externalized)",
7878
"path": "dist/index.js",
79-
"limit": "87 kB",
79+
"limit": "118 kB",
8080
"disablePlugins": [
8181
"@size-limit/webpack",
8282
"@size-limit/time"

standalone/server/src/__tests__/embed.int.test.ts

Lines changed: 41 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -554,11 +554,46 @@ describe("end-to-end through the real conversion worker", () => {
554554
/<text x="([\d.]+)" y="([\d.]+)"[^>]*>edgelabel<\/text>/
555555
)
556556
expect(m).not.toBeNull()
557-
const [lx, ly] = [Number(m![1]), Number(m![2])]
558-
// The on-path midpoint is on the vertical segment at ~(469, 352); the label
559-
// must sit within a small offset of it (the source→target midpoint ~(438,
560-
// 334) is ~37px away, off the line).
561-
const dist = Math.hypot(lx - 469, ly - 352)
562-
expect(dist).toBeLessThan(25)
557+
const label = { x: Number(m![1]), y: Number(m![2]) }
558+
559+
// The router derives its own path (routes are not persisted), so we assert the
560+
// property, not a fixed coordinate: the label must sit ON the rendered edge — i.e.
561+
// close to its polyline — rather than at the straight source→target midpoint, which
562+
// for this L-shaped route is off the line entirely. That is exactly the fallback the
563+
// svgPathGeometry shim exists to avoid.
564+
const edgePathTag = asText(res).match(
565+
/<path[^>]*class="react-flow__edge-path"[^>]*>/
566+
)
567+
expect(edgePathTag).not.toBeNull()
568+
const pathD = edgePathTag![0].match(/\sd="([^"]+)"/)
569+
expect(pathD).not.toBeNull()
570+
const verts = [...pathD![1].matchAll(/-?[\d.]+/g)]
571+
.map(Number)
572+
.reduce<{ x: number; y: number }[]>((acc, n, i) => {
573+
if (i % 2 === 0) acc.push({ x: n, y: 0 })
574+
else acc[acc.length - 1].y = n
575+
return acc
576+
}, [])
577+
type Pt = { x: number; y: number }
578+
const distToSeg = (p: Pt, a: Pt, b: Pt) => {
579+
const dx = b.x - a.x
580+
const dy = b.y - a.y
581+
const len2 = dx * dx + dy * dy
582+
const t =
583+
len2 === 0
584+
? 0
585+
: Math.max(
586+
0,
587+
Math.min(1, ((p.x - a.x) * dx + (p.y - a.y) * dy) / len2)
588+
)
589+
return Math.hypot(p.x - (a.x + t * dx), p.y - (a.y + t * dy))
590+
}
591+
const distToPath = Math.min(
592+
...verts.slice(0, -1).map((v, i) => distToSeg(label, v, verts[i + 1]))
593+
)
594+
// A label sits beside the line with a small text offset; the straight-midpoint
595+
// fallback for this route is ~100px off the polyline, so this cleanly separates
596+
// "on the edge" from "at a fallback point".
597+
expect(distToPath).toBeLessThan(25)
563598
}, 20_000)
564599
})

0 commit comments

Comments
 (0)