diff --git a/clientapi/routing/joinroom_test.go b/clientapi/routing/joinroom_test.go index 4f13b78eb..dd5ce691c 100644 --- a/clientapi/routing/joinroom_test.go +++ b/clientapi/routing/joinroom_test.go @@ -53,7 +53,7 @@ func TestJoinRoomByIDOrAlias(t *testing.T) { bobDev := &uapi.Device{UserID: bob.ID} charlieDev := &uapi.Device{UserID: charlie.ID, AccountType: uapi.AccountTypeGuest} - // create the room + // create a room with disabled guest access and invite Bob resp := createRoom(ctx, createRoomRequest{ Name: "testing", IsDirect: true, @@ -69,6 +69,21 @@ func TestJoinRoomByIDOrAlias(t *testing.T) { t.Fatalf("response is not a createRoomResponse: %+v", resp) } + // create a room with guest access enabled and invite Charlie + resp = createRoom(ctx, createRoomRequest{ + Name: "testing", + IsDirect: true, + Topic: "testing", + Visibility: "public", + Preset: presetPublicChat, + Invite: []string{charlie.ID}, + GuestCanJoin: true, + }, aliceDev, &base.Cfg.ClientAPI, userAPI, rsAPI, asAPI, time.Now()) + crRespWithGuestAccess, ok := resp.JSON.(createRoomResponse) + if !ok { + t.Fatalf("response is not a createRoomResponse: %+v", resp) + } + // Dummy request body := &bytes.Buffer{} req, err := http.NewRequest(http.MethodPost, "/?server_name=test", body) @@ -124,6 +139,11 @@ func TestJoinRoomByIDOrAlias(t *testing.T) { device: aliceDev, roomID: "#doesnotexist:test", }, + { + name: "room with guest_access event", + device: charlieDev, + roomID: crRespWithGuestAccess.RoomID, + }, } for _, tc := range testCases {