@@ -937,6 +937,10 @@ const waitForRoomEvent = async (
937937 } ) ;
938938 } ) ;
939939
940+ it ( 'should show the room name as the inviter name on Synapse before join' , async ( ) => {
941+ expect ( hs1Room1 . name ) . toBe ( rcUser1 . username ) ;
942+ } ) ;
943+
940944 it ( 'should display the fname containing the two invited users for the inviter' , async ( ) => {
941945 // Check the subscription for the inviter
942946 const sub = await getSubscriptionByRoomId ( rcRoom . _id , rcUserConfig1 . credentials , rcUserConfig1 . request ) ;
@@ -954,16 +958,23 @@ const waitForRoomEvent = async (
954958 expect ( sub ) . toHaveProperty ( 'fname' , rcUser1 . username ) ;
955959 } ) ;
956960
957- it . failing ( 'should keep the fname to the RC invited user when the Synapse invited user accepts the DM' , async ( ) => {
958- const waitForRoomEventPromise1 = waitForRoomEvent ( hs1Room1 , RoomStateEvent . Members , ( { event } ) => {
959- expect ( event ) . toHaveProperty ( 'content.membership' , 'join' ) ;
960- expect ( event ) . toHaveProperty ( 'state_key' , federationConfig . hs1 . adminMatrixUserId ) ;
961- } ) ;
962-
961+ it ( 'should accept the invitation on Synapse' , async ( ) => {
963962 await hs1AdminApp . matrixClient . joinRoom ( rcRoom . federation . mrid ) ;
964963
965- await waitForRoomEventPromise1 ;
964+ await retry (
965+ 'wait for the join to be processed' ,
966+ async ( ) => {
967+ expect ( hs1Room1 . getMyMembership ( ) ) . toBe ( 'join' ) ;
968+ } ,
969+ { delayMs : 100 } ,
970+ ) ;
971+ } ) ;
966972
973+ it ( 'should show the room name with all members on Synapse after join' , async ( ) => {
974+ expect ( hs1Room1 . name ) . toBe ( `${ rcUser1 . username } and ${ rcUser2 . username } ` ) ;
975+ } ) ;
976+
977+ it . failing ( 'should keep the fname to the RC invited user when the Synapse invited user accepts the DM' , async ( ) => {
967978 await retry (
968979 'this is an async operation, so we need to wait for the event to be processed' ,
969980 async ( ) => {
@@ -991,11 +1002,6 @@ const waitForRoomEvent = async (
9911002 { delayMs : 100 } ,
9921003 ) ;
9931004 } ) ;
994-
995- it ( 'should validate the room name for group DMs on Synapse' , async ( ) => {
996- // TODO this should probably change
997- expect ( hs1Room1 . name ) . toBe ( 'Group chat with 3 members' ) ;
998- } ) ;
9991005 } ) ;
10001006
10011007 describe ( 'Permission validations' , ( ) => {
@@ -1103,12 +1109,11 @@ const waitForRoomEvent = async (
11031109 } ) ;
11041110
11051111 // TODO maybe we should allow it
1106- // is this working now?
1107- it . failing ( 'should fail if a user from rc try to add another user to the group DM' , async ( ) => {
1112+ it ( 'should fail if a user from rc try to add another user to the group DM' , async ( ) => {
11081113 const response = await addUserToRoom ( {
11091114 usernames : [ rcUser3 . username ] ,
11101115 rid : rcRoom . _id ,
1111- config : rcUserConfig1 ,
1116+ config : rcUserConfig2 ,
11121117 } ) ;
11131118
11141119 expect ( response . body ) . toHaveProperty ( 'success' , true ) ;
@@ -1120,23 +1125,32 @@ const waitForRoomEvent = async (
11201125 expect ( messageData ) . toHaveProperty ( 'error.error' , 'error-not-allowed' ) ;
11211126 } ) ;
11221127
1123- // TODO we're creating DMs with powerlevel 50 for invites, so this is not working
1124- it . failing ( 'should add another user by another user than the initial inviter' , async ( ) => {
1128+ it ( 'should add another user by another user than the initial inviter' , async ( ) => {
11251129 await hs1AdminApp . matrixClient . joinRoom ( rcRoom . federation . mrid ) ;
11261130
1127- await retry ( 'waiting for join' , async ( ) => {
1128- const members = await hs1Room1 . getMembers ( ) ;
1129- expect ( members . length ) . toBe ( 3 ) ;
1130- } ) ;
1131+ await retry (
1132+ 'waiting for join' ,
1133+ async ( ) => {
1134+ expect ( hs1Room1 . getMyMembership ( ) ) . toBe ( 'join' ) ;
1135+
1136+ const members = await hs1Room1 . getMembers ( ) ;
1137+ expect ( members . length ) . toBe ( 3 ) ;
1138+ } ,
1139+ { delayMs : 100 } ,
1140+ ) ;
11311141
11321142 await hs1AdminApp . inviteUserToRoom ( hs1Room1 . roomId , userDmId3 ) ;
11331143
1134- await retry ( 'waiting for user4 to receive invitation' , async ( ) => {
1135- const members = await hs1Room1 . getMembers ( ) ;
1136- const user4Member = members . find ( ( m ) => m . userId === userDmId3 ) ;
1137- expect ( user4Member ) . toBeDefined ( ) ;
1138- expect ( user4Member ?. membership ) . toBe ( 'invite' ) ;
1139- } ) ;
1144+ await retry (
1145+ 'waiting for user4 to receive invitation' ,
1146+ async ( ) => {
1147+ const members = await hs1Room1 . getMembers ( ) ;
1148+ const user4Member = members . find ( ( m ) => m . userId === userDmId3 ) ;
1149+ expect ( user4Member ) . toBeDefined ( ) ;
1150+ expect ( user4Member ?. membership ) . toBe ( 'invite' ) ;
1151+ } ,
1152+ { delayMs : 100 } ,
1153+ ) ;
11401154 } ) ;
11411155 } ) ;
11421156
@@ -1662,7 +1676,7 @@ const waitForRoomEvent = async (
16621676 expect ( messageData ) . toHaveProperty ( 'error.error' , 'error-cant-invite-for-direct-room' ) ;
16631677 } ) ;
16641678
1665- it ( 'should create a 1:1 a federated DM between ' , async ( ) => {
1679+ it ( 'should create a 1:1 federated DM' , async ( ) => {
16661680 // Create 1:1 DM from RC user to another RC user
16671681 const response = await rcUser1 . config . request
16681682 . post ( api ( 'dm.create' ) )
@@ -1696,7 +1710,7 @@ const waitForRoomEvent = async (
16961710 expect ( sub ) . toHaveProperty ( 'fname' , federationConfig . hs1 . adminMatrixUserId ) ;
16971711 } ) ;
16981712
1699- it ( 'should show the invite to the third user' , async ( ) => {
1713+ it ( 'should send an invite to another Synapse user' , async ( ) => {
17001714 // invite from rocket.chat
17011715 const response = await addUserToRoom ( {
17021716 usernames : [ federationConfig . hs1 . additionalUser1 . matrixUserId ] ,
@@ -1744,19 +1758,33 @@ const waitForRoomEvent = async (
17441758 expect ( roomInfo . room ) . toHaveProperty ( 'usersCount' , 3 ) ;
17451759 } ) ;
17461760
1747- // TODO we're creating DMs with powerlevel 50 for invites, so this is not working
1748- it . failing ( 'should invite a fourth user from Rocket.Chat by a Synapse user' , async ( ) => {
1761+ it ( 'should invite a fourth Rocket.Chat user by the invited Synapse user' , async ( ) => {
17491762 await hs1User1 . inviteUserToRoom ( hs1Room1 . roomId , rcUser2 . matrixId ) ;
17501763
1751- await retry ( 'waiting for fourth user to receive invitation' , async ( ) => {
1752- const subscriptionInvite = await getSubscriptionByRoomId ( rcRoom . _id , rcUser2 . config . credentials , rcUser2 . config . request ) ;
1764+ await retry (
1765+ 'waiting for user4 to receive invitation' ,
1766+ async ( ) => {
1767+ const members = await hs1Room1 . getMembers ( ) ;
17531768
1754- expect ( subscriptionInvite ) . toHaveProperty ( 'status' , 'INVITED' ) ;
1755- expect ( subscriptionInvite ) . toHaveProperty (
1756- 'fname' ,
1757- `${ federationConfig . hs1 . adminMatrixUserId } , ${ federationConfig . hs1 . additionalUser1 . matrixUserId } , ${ rcUser1 . matrixId } ` ,
1758- ) ;
1759- } ) ;
1769+ const user4Member = members . find ( ( m ) => m . userId === rcUser2 . matrixId ) ;
1770+
1771+ expect ( user4Member ) . toBeDefined ( ) ;
1772+ expect ( user4Member ?. membership ) . toBe ( 'invite' ) ;
1773+ } ,
1774+ { delayMs : 100 } ,
1775+ ) ;
1776+
1777+ await retry (
1778+ 'waiting for fourth user to receive invitation' ,
1779+ async ( ) => {
1780+ const sub = await getSubscriptionByRoomId ( rcRoom . _id , rcUser2 . config . credentials , rcUser2 . config . request ) ;
1781+
1782+ expect ( sub ) . toHaveProperty ( 'status' , 'INVITED' ) ;
1783+ expect ( sub ) . toHaveProperty ( 'name' , federationConfig . hs1 . additionalUser1 . matrixUserId ) ;
1784+ expect ( sub ) . toHaveProperty ( 'fname' , federationConfig . hs1 . additionalUser1 . matrixUserId ) ;
1785+ } ,
1786+ { delayMs : 100 } ,
1787+ ) ;
17601788 } ) ;
17611789 } ) ;
17621790 } ) ;
0 commit comments