From 000f59d2fd112faa449da8a97bf43a4d83575d17 Mon Sep 17 00:00:00 2001 From: Chrislearn Young Date: Mon, 27 Oct 2025 22:53:57 +0800 Subject: [PATCH 1/2] Use `SyncLeftFrom` to check charlie leave event synced to hs1 (#808) --- tests/restricted_rooms_test.go | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/tests/restricted_rooms_test.go b/tests/restricted_rooms_test.go index 2787ad74..1fd28588 100644 --- a/tests/restricted_rooms_test.go +++ b/tests/restricted_rooms_test.go @@ -326,17 +326,7 @@ func doTestRestrictedRoomsRemoteJoinLocalUser(t *testing.T, roomVersion string, charlie.MustLeaveRoom(t, room) // Ensure the events have synced to hs1. - alice.MustSyncUntil(t, client.SyncReq{}, client.SyncTimelineHas( - room, - func(ev gjson.Result) bool { - if ev.Get("type").Str != "m.room.member" || ev.Get("state_key").Str != charlie.UserID { - return false - } - must.Equal(t, ev.Get("content").Get("membership").Str, "leave", "Charlie failed to leave the room") - - return true - }, - )) + alice.MustSyncUntil(t, client.SyncReq{}, client.SyncLeftFrom(charlie.UserID, room)) // Have bob leave and rejoin. This should still work even though hs2 isn't in // the room anymore! From 350d7666cab14cb0051ef53da7a1b0b3216d7269 Mon Sep 17 00:00:00 2001 From: Andrew Morgan <1342360+anoadragon453@users.noreply.github.com> Date: Wed, 29 Oct 2025 13:01:01 +0100 Subject: [PATCH 2/2] Convert sytest "Can search public room list" (#812) --- tests/csapi/public_rooms_test.go | 75 ++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 tests/csapi/public_rooms_test.go diff --git a/tests/csapi/public_rooms_test.go b/tests/csapi/public_rooms_test.go new file mode 100644 index 00000000..5aa7b406 --- /dev/null +++ b/tests/csapi/public_rooms_test.go @@ -0,0 +1,75 @@ +package csapi_tests + +import ( + "net/http" + "testing" + "time" + + "github.com/tidwall/gjson" + + "github.com/matrix-org/complement" + "github.com/matrix-org/complement/client" + "github.com/matrix-org/complement/helpers" + "github.com/matrix-org/complement/match" + "github.com/matrix-org/complement/must" +) + +func TestPublicRooms(t *testing.T) { + deployment := complement.Deploy(t, 1) + defer deployment.Destroy(t) + + t.Run("parallel", func(t *testing.T) { + // sytest: Can search public room list + t.Run("Can search public room list", func(t *testing.T) { + t.Parallel() + authedClient := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) + + roomID := authedClient.MustCreateRoom(t, map[string]any{ + "visibility": "public", + "name": "Test Name", + "topic": "Test Topic Wombles", + }) + + authedClient.MustDo( + t, + "POST", + []string{"_matrix", "client", "v3", "publicRooms"}, + client.WithJSONBody(t, map[string]any{ + "filter": map[string]any{ + "generic_search_term": "wombles", + }, + }), + client.WithRetryUntil(15*time.Second, func(res *http.Response) bool { + body := must.ParseJSON(t, res.Body) + + must.MatchGJSON( + t, + body, + match.JSONKeyPresent("chunk"), + match.JSONKeyTypeEqual("chunk", gjson.JSON), + ) + + chunk := body.Get("chunk") + if !chunk.IsArray() { + t.Logf("chunk is not an array") + return false + } + + results := chunk.Array() + if len(results) != 1 { + t.Logf("expected a single search result, got %d", len(results)) + return false + } + + foundRoomID := results[0].Get("room_id").Str + if foundRoomID != roomID { + t.Logf("expected room_id %s in search results, got %s", roomID, foundRoomID) + return false + } + + return true + }), + ) + }) + }) +}