|
9 | 9 | addUserToRoomSlashCommand, |
10 | 10 | acceptRoomInvite, |
11 | 11 | rejectRoomInvite, |
| 12 | + getRoomMembers, |
| 13 | + getSubscriptions, |
12 | 14 | } from '../../../../../apps/meteor/tests/data/rooms.helper'; |
13 | 15 | import { type IRequestConfig, getRequestConfig, createUser, deleteUser } from '../../../../../apps/meteor/tests/data/users.helper'; |
14 | 16 | import { IS_EE } from '../../../../../apps/meteor/tests/e2e/config/constants'; |
@@ -1563,14 +1565,58 @@ import { SynapseClient } from '../helper/synapse-client'; |
1563 | 1565 | // RC view: Admin tries to accept rc1User1's invitation |
1564 | 1566 | const response = await acceptRoomInvite(federatedChannel._id, rc1AdminRequestConfig); |
1565 | 1567 | expect(response.success).toBe(false); |
1566 | | - expect(response.error).toBe('Failed to handle invite: No subscription found or user does not have permission to accept or reject this invite'); |
| 1568 | + expect(response.error).toBe( |
| 1569 | + 'Failed to handle invite: No subscription found or user does not have permission to accept or reject this invite', |
| 1570 | + ); |
1567 | 1571 | }); |
1568 | 1572 |
|
1569 | 1573 | it('It should not allow admin to reject invitation on behalf of another user', async () => { |
1570 | 1574 | // RC view: Admin tries to reject rc1User1's invitation |
1571 | 1575 | const response = await rejectRoomInvite(federatedChannel._id, rc1AdminRequestConfig); |
1572 | 1576 | expect(response.success).toBe(false); |
1573 | | - expect(response.error).toBe('Failed to handle invite: No subscription found or user does not have permission to accept or reject this invite'); |
| 1577 | + expect(response.error).toBe( |
| 1578 | + 'Failed to handle invite: No subscription found or user does not have permission to accept or reject this invite', |
| 1579 | + ); |
| 1580 | + }); |
| 1581 | + }); |
| 1582 | + }); |
| 1583 | + |
| 1584 | + describe('Inviting a RC user from Synapse', () => { |
| 1585 | + describe('Room that already contains previous events', () => { |
| 1586 | + let matrixRoomId: string; |
| 1587 | + let channelName: string; |
| 1588 | + let rid: string; |
| 1589 | + beforeAll(async () => { |
| 1590 | + channelName = `federated-channel-from-synapse-${Date.now()}`; |
| 1591 | + matrixRoomId = await hs1AdminApp.createRoom(channelName); |
| 1592 | + |
| 1593 | + await hs1AdminApp.matrixClient.sendTextMessage(matrixRoomId, 'Message from admin'); |
| 1594 | + await hs1AdminApp.matrixClient.invite(matrixRoomId, federationConfig.hs1.additionalUser1.matrixUserId); |
| 1595 | + await hs1User1App.matrixClient.joinRoom(matrixRoomId); |
| 1596 | + await hs1User1App.matrixClient.sendTextMessage(matrixRoomId, 'Message from user1'); |
| 1597 | + await hs1AdminApp.matrixClient.invite(matrixRoomId, federationConfig.rc1.adminMatrixUserId); |
| 1598 | + |
| 1599 | + const subscriptions = await getSubscriptions(rc1AdminRequestConfig); |
| 1600 | + |
| 1601 | + const pendingInvitation = subscriptions.update.find((subscription) => subscription.status === 'INVITED'); |
| 1602 | + |
| 1603 | + expect(pendingInvitation).not.toBeUndefined(); |
| 1604 | + |
| 1605 | + rid = pendingInvitation?.rid!; |
| 1606 | + |
| 1607 | + await acceptRoomInvite(rid, rc1AdminRequestConfig); |
| 1608 | + }, 15000); |
| 1609 | + |
| 1610 | + describe('It should reflect all the members and messagens on the rocket.chat side', () => { |
| 1611 | + it('It should show all the three users in the members list', async () => { |
| 1612 | + const members = await getRoomMembers(rid, rc1AdminRequestConfig); |
| 1613 | + expect(members.members.length).toBe(3); |
| 1614 | + expect(members.members.find((member: IUser) => member.username === federationConfig.rc1.adminUser)).not.toBeNull(); |
| 1615 | + expect( |
| 1616 | + members.members.find((member: IUser) => member.username === federationConfig.rc1.additionalUser1.username), |
| 1617 | + ).not.toBeNull(); |
| 1618 | + expect(members.members.find((member: IUser) => member.username === federationConfig.hs1.adminMatrixUserId)).not.toBeNull(); |
| 1619 | + }); |
1574 | 1620 | }); |
1575 | 1621 | }); |
1576 | 1622 | }); |
|
0 commit comments