package callstest import ( "encoding/base64" "encoding/json" "strings" "testing" ) // relayVectorForTest is the base64 CARLOS_RELAY value for one region, // built from relay's own platform vector key and username suffix // (internal/calls/relay/relay_test.go) so a leak of either into a // rendered page would be unmistakable. func relayVectorForTest(t *testing.T) string { t.Helper() const vectorKey = "uMhwW4P/9O5dQUIs91t2CCHGhwJbeiM0xQMQ2G0CJLU=" regions := []map[string]any{{ "region": "eu-west-1", "urls": []string{"stun:relay.eu-west-1.oncarlos.com:3478"}, "key": vectorKey, "username_suffix": "abc:meet:0123456789abcdef:k1", }} b, err := json.Marshal(regions) if err != nil { t.Fatal(err) } return base64.StdEncoding.EncodeToString(b) } // TestRoomPageShowsFloorWithNoRelay: holding_test.go's // TestHoldingPageShowsTitleStandingAndFloor covers /join; room.html // renders the identical sentence and nothing proved it — there was no // room-page floor test before this one. func TestRoomPageShowsFloorWithNoRelay(t *testing.T) { x, sqid, _ := memberWithMeeting(t) c := x.browser(t) c.signIn("paul@example.com") body := c.get("/m/" + sqid).Body.String() if !strings.Contains(body, "Calls outside your network may not connect yet.") { t.Fatalf("room page lacks the floor sentence with no relay configured:\n%s", body) } // The same fact room.js reads, and the only thing that chooses // between §5.5's two failed-tile sentences. Empty here. if !strings.Contains(body, `data-relay=""`) { t.Fatalf("room page does not render an empty data-relay with no relay configured:\n%s", body) } } // TestSetRelayHidesTheFloorSentenceOnBothPages: the floor sentence, // present on both the holding and room pages with no relay, must // disappear from both once TestHandle.SetRelay configures one — the // "relay configured ⇒ sentence absent" direction that hardcoding Floor // to true would still have passed. func TestSetRelayHidesTheFloorSentenceOnBothPages(t *testing.T) { x, sqid, _ := memberWithMeeting(t) if err := x.ctl.SetRelay(relayVectorForTest(t)); err != nil { t.Fatal(err) } c := x.browser(t) c.signIn("paul@example.com") if body := c.get("/m/" + sqid + "/join").Body.String(); strings.Contains(body, "Calls outside your network may not connect yet.") { t.Fatalf("holding page still shows the floor sentence with a relay configured:\n%s", body) } body := c.get("/m/" + sqid).Body.String() if strings.Contains(body, "Calls outside your network may not connect yet.") { t.Fatalf("room page still shows the floor sentence with a relay configured:\n%s", body) } // §5.5's other half: room.js says "even through the relay" on a // failed tile only when the server states there is one. if !strings.Contains(body, `data-relay="1"`) { t.Fatalf("room page does not render data-relay=\"1\" with a relay configured:\n%s", body) } }