@@ -1647,18 +1647,62 @@ import { SynapseClient } from '../helper/synapse-client';
16471647 rid = pendingInvitation ?. rid ! ;
16481648 } , 15000 ) ;
16491649
1650- it ( 'It should allow RC user to reject the invite' , async ( ) => {
1650+ it ( 'should allow RC user to reject the invite and remove the subscription ' , async ( ) => {
16511651 const rejectResponse = await rejectRoomInvite ( rid , rc1AdminRequestConfig ) ;
16521652 expect ( rejectResponse . success ) . toBe ( true ) ;
1653- } ) ;
16541653
1655- it ( 'It should remove the subscription after rejection' , async ( ) => {
16561654 const subscriptions = await getSubscriptions ( rc1AdminRequestConfig ) ;
1657-
16581655 const invitedSub = subscriptions . update . find ( ( sub ) => sub . fname ?. includes ( channelName ) ) ;
1659-
16601656 expect ( invitedSub ) . toBeFalsy ( ) ;
16611657 } ) ;
16621658 } ) ;
1659+
1660+ describe ( 'Revoked invitation flow from Synapse' , ( ) => {
1661+ describe ( 'Synapse revokes an invitation before the RC user responds' , ( ) => {
1662+ let matrixRoomId : string ;
1663+ let channelName : string ;
1664+ let rid : string ;
1665+
1666+ beforeAll ( async ( ) => {
1667+ channelName = `federated-channel-revoked-${ Date . now ( ) } ` ;
1668+ matrixRoomId = await hs1AdminApp . createRoom ( channelName ) ;
1669+
1670+ // hs1 invites RC user
1671+ await hs1AdminApp . matrixClient . invite ( matrixRoomId , federationConfig . rc1 . adminMatrixUserId ) ;
1672+ const subscriptions = await getSubscriptions ( rc1AdminRequestConfig ) ;
1673+
1674+ const pendingInvitation = subscriptions . update . find (
1675+ ( subscription ) => subscription . status === 'INVITED' && subscription . fname ?. includes ( channelName ) ,
1676+ ) ;
1677+
1678+ expect ( pendingInvitation ) . not . toBeUndefined ( ) ;
1679+
1680+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
1681+ rid = pendingInvitation ?. rid ! ;
1682+
1683+ // hs1 revokes the invitation by kicking the invited user
1684+ await hs1AdminApp . matrixClient . kick ( matrixRoomId , federationConfig . rc1 . adminMatrixUserId , 'Invitation revoked' ) ;
1685+ } , 15000 ) ;
1686+
1687+ it ( 'should fail when RC user tries to accept the revoked invitation' , async ( ) => {
1688+ const acceptResponse = await acceptRoomInvite ( rid , rc1AdminRequestConfig ) ;
1689+ expect ( acceptResponse . success ) . toBe ( false ) ;
1690+ } ) ;
1691+
1692+ it ( 'should allow RC user to reject the revoked invitation and remove the subscription' , async ( ) => {
1693+ const rejectResponse = await rejectRoomInvite ( rid , rc1AdminRequestConfig ) ;
1694+ expect ( rejectResponse . success ) . toBe ( true ) ;
1695+
1696+ const subscriptions = await getSubscriptions ( rc1AdminRequestConfig ) ;
1697+ const invitedSub = subscriptions . update . find ( ( sub ) => sub . fname ?. includes ( channelName ) ) ;
1698+ expect ( invitedSub ) . toBeFalsy ( ) ;
1699+ } ) ;
1700+
1701+ it ( 'should have the RC user with leave membership on Synapse side after revoked invitation' , async ( ) => {
1702+ const member = await hs1AdminApp . findRoomMember ( channelName , federationConfig . rc1 . adminMatrixUserId ) ;
1703+ expect ( member ?. membership ) . toBe ( 'leave' ) ;
1704+ } ) ;
1705+ } ) ;
1706+ } ) ;
16631707 } ) ;
16641708} ) ;
0 commit comments