Skip to content

Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.

feat(tests): Checks on participant left for user id and customer.

damenchoecb57774ed98
diff --git a/tests/helpers/Participant.ts b/tests/helpers/Participant.ts
index 91afad0c08..4f669806eb 100644
--- a/tests/helpers/Participant.ts
+++ b/tests/helpers/Participant.ts
@@ -587,10 +587,10 @@ export class Participant {
/**
* Switches to the meeting page context.
*/
- async switchInPage() {
+ switchInPage() {
const mainFrame = this.driver.$('iframe');
- await this.driver.switchFrame(mainFrame);
+ return this.driver.switchFrame(mainFrame);
}
/**
diff --git a/tests/helpers/participants.ts b/tests/helpers/participants.ts
index 655f5ac44c..f47b1b9b5e 100644
--- a/tests/helpers/participants.ts
+++ b/tests/helpers/participants.ts
@@ -173,7 +173,7 @@ async function joinTheModeratorAsP1(ctx: IContext, options?: IJoinOptions) {
|| !ctx.jwtPrivateKeyPath)) {
token = process.env.JWT_ACCESS_TOKEN;
} else if (ctx.jwtPrivateKeyPath) {
- token = getModeratorToken(p1DisplayName);
+ token = getToken(ctx, p1DisplayName);
}
}
@@ -200,7 +200,7 @@ export async function ensureTwoParticipants(ctx: IContext, options: IJoinOptions
}, {
displayName: P2_DISPLAY_NAME,
...options
- });
+ }, options.preferGenerateToken ? getToken(ctx, P2_DISPLAY_NAME) : undefined);
if (options.skipInMeetingChecks) {
return Promise.resolve();
@@ -324,7 +324,7 @@ export async function muteVideoAndCheck(testee: Participant, observer: Participa
/**
* Get a JWT token for a moderator.
*/
-function getModeratorToken(displayName: string) {
+function getToken(ctx: IContext, displayName: string, moderator = true) {
const keyid = process.env.JWT_KID;
const headers = {
algorithm: 'RS256',
@@ -352,6 +352,7 @@ function getModeratorToken(displayName: string) {
'avatar': 'https://avatars0.githubusercontent.com/u/3671647',
'email': '[email protected]'
},
+ 'group': uuidv4(),
'features': {
'outbound-call': 'true',
'transcription': 'true',
@@ -361,8 +362,12 @@ function getModeratorToken(displayName: string) {
'room': '*'
};
- // @ts-ignore
- payload.context.user.moderator = true;
+ if (moderator) {
+ // @ts-ignore
+ payload.context.user.moderator = true;
+ }
+
+ ctx.data[`${displayName}-jwt-payload`] = payload;
// @ts-ignore
return jwt.sign(payload, key, headers);
diff --git a/tests/specs/2way/iFrameApiParticipantsPresence.spec.ts b/tests/specs/2way/iFrameApiParticipantsPresence.spec.ts
index 500fc74d87..8e9cc485f1 100644
--- a/tests/specs/2way/iFrameApiParticipantsPresence.spec.ts
+++ b/tests/specs/2way/iFrameApiParticipantsPresence.spec.ts
@@ -2,20 +2,24 @@ import { isEqual } from 'lodash-es';
import { P1_DISPLAY_NAME, P2_DISPLAY_NAME, Participant } from '../../helpers/Participant';
import { ensureTwoParticipants, parseJid } from '../../helpers/participants';
+import { IContext } from '../../helpers/types';
/**
* Tests PARTICIPANT_LEFT webhook.
*/
-async function checkParticipantLeftHook(p: Participant, reason: string) {
+async function checkParticipantLeftHook(ctx: IContext, p: Participant, reason: string) {
const { webhooksProxy } = ctx;
if (webhooksProxy) {
// PARTICIPANT_LEFT webhook
// @ts-ignore
const event: {
+ customerId: string;
data: {
conference: string;
disconnectReason: string;
+ group: string;
+ id: string;
isBreakout: boolean;
name: string;
participantId: string;
@@ -29,6 +33,12 @@ async function checkParticipantLeftHook(p: Participant, reason: string) {
expect(event.data.isBreakout).toBe(false);
expect(event.data.participantId).toBe(await p.getEndpointId());
expect(event.data.name).toBe(p.displayName);
+
+ const jwtPayload = ctx.data[`${p.displayName}-jwt-payload`];
+
+ expect(event.data.id).toBe(jwtPayload?.context?.user?.id);
+ expect(event.data.group).toBe(jwtPayload?.context?.group);
+ expect(event.customerId).toBe(process.env.IFRAME_TENANT?.replace('vpaas-magic-cookie-', ''));
}
}
@@ -192,19 +202,35 @@ describe('Participants presence', () => {
});
it('kick participant', async () => {
- const { p1, p2, roomName } = ctx;
+ // we want to join second participant with token, so we can check info in webhook
+ await ctx.p2.getIframeAPI().addEventListener('videoConferenceLeft');
+ await ctx.p2.switchToAPI();
+ await ctx.p2.getIframeAPI().executeCommand('hangup');
+ await ctx.p2.driver.waitUntil(() =>
+ ctx.p2.getIframeAPI().getEventResult('videoConferenceLeft'), {
+ timeout: 4000,
+ timeoutMsg: 'videoConferenceLeft not received'
+ });
+
+ await ensureTwoParticipants(ctx, { preferGenerateToken: true });
+
+ const { p1, p2, roomName, webhooksProxy } = ctx;
+
+ webhooksProxy?.clearCache();
+
const p1EpId = await p1.getEndpointId();
const p2EpId = await p2.getEndpointId();
- await p1.switchInPage();
- await p2.switchInPage();
-
const p1DisplayName = await p1.getLocalDisplayName();
const p2DisplayName = await p2.getLocalDisplayName();
await p1.switchToAPI();
await p2.switchToAPI();
+ const roomsInfo = (await p1.getIframeAPI().getRoomsInfo()).rooms[0];
+
+ ctx.data.conferenceJid = roomsInfo.jid.substring(0, roomsInfo.jid.indexOf('/'));
+
await p1.getIframeAPI().addEventListener('participantKickedOut');
await p2.getIframeAPI().addEventListener('participantKickedOut');
await p2.getIframeAPI().addEventListener('videoConferenceLeft');
@@ -220,7 +246,7 @@ describe('Participants presence', () => {
timeoutMsg: 'participantKickedOut event not received on participant2 side'
});
- await checkParticipantLeftHook(p2, 'kicked');
+ await checkParticipantLeftHook(ctx, p2, 'kicked');
expect(eventP1).toBeDefined();
expect(eventP2).toBeDefined();
@@ -357,7 +383,7 @@ describe('Participants presence', () => {
expect(eventConferenceLeftP2).toBeDefined();
expect(eventConferenceLeftP2.roomName).toBe(roomName);
- await checkParticipantLeftHook(p2, 'left');
+ await checkParticipantLeftHook(ctx, p2, 'left');
const eventReadyToCloseP2 = await p2.driver.waitUntil(() => p2.getIframeAPI().getEventResult('readyToClose'), {
timeout: 2000,
@@ -386,7 +412,7 @@ describe('Participants presence', () => {
expect(eventConferenceLeft).toBeDefined();
expect(eventConferenceLeft.roomName).toBe(roomName);
- await checkParticipantLeftHook(p1, 'left');
+ await checkParticipantLeftHook(ctx, p1, 'left');
if (webhooksProxy) {
// ROOM_DESTROYED webhook
// @ts-ignore