From 0b783b1ddcc330ce3b8f0e71ba55f29f70a7c1ac Mon Sep 17 00:00:00 2001 From: yetone Date: Sun, 1 Nov 2026 16:06:33 +0800 Subject: [PATCH] browsermcp: TestVisionBridgePassesLines takes the messages in any order The bridge passes each stdio message from its own goroutine, so initialize, the notification and the call reach the fake gateway in any order; the test read the call's image at index 2 and went red on mote when the call landed first (images ["" ".../shots/a.png" ""]). It now checks every path and that the one image named is the call's, made absolute. Run (mote-run), with a 50ms hold injected before every message but the call: the old test red 3 of 3, the new one green 3 of 3; without it, go test ./internal/browsermcp ok. --- internal/browsermcp/browsermcp_test.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/internal/browsermcp/browsermcp_test.go b/internal/browsermcp/browsermcp_test.go index 1f9e6b36d..2f90d3e45 100644 --- a/internal/browsermcp/browsermcp_test.go +++ b/internal/browsermcp/browsermcp_test.go @@ -8,6 +8,7 @@ import ( "net/http/httptest" "os" "path/filepath" + "slices" "strings" "sync" "testing" @@ -165,7 +166,10 @@ func TestVisionBridgePassesLines(t *testing.T) { if lines := strings.Split(strings.TrimSpace(out.String()), "\n"); len(lines) != 2 || !strings.Contains(out.String(), `"id":2`) { t.Fatalf("out: %q", out.String()) } - if len(paths) != 3 || paths[0] != gateway.VisionMCPPath || paths[2] != gateway.VisionMCPPath || images[2] != filepath.Join(wd, "shots", "a.png") { + // the bridge passes messages side by side, so they reach the gateway + // in any order: the one image named is the call's + named := slices.DeleteFunc(slices.Clone(images), func(v string) bool { return v == "" }) + if len(paths) != 3 || slices.ContainsFunc(paths, func(p string) bool { return p != gateway.VisionMCPPath }) || len(named) != 1 || named[0] != filepath.Join(wd, "shots", "a.png") { t.Fatalf("paths %q, images %q", paths, images) }