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): Adds general visitors test.

damencho4d7d1a84bb8e
diff --git a/react/features/participants-pane/components/web/VisitorsList.tsx b/react/features/participants-pane/components/web/VisitorsList.tsx
index 150d227c42..8316a6245c 100644
--- a/react/features/participants-pane/components/web/VisitorsList.tsx
+++ b/react/features/participants-pane/components/web/VisitorsList.tsx
@@ -94,7 +94,9 @@ export default function VisitorsList() {
return (
<>
<div className = { classes.headingContainer }>
- <div className = { cx(classes.heading, classes.headingW) }>
+ <div
+ className = { cx(classes.heading, classes.headingW) }
+ id = 'visitor-list-header' >
{ t('participantsPane.headings.visitors', { count: visitorsCount })}
{ requests.length > 0
&& t('participantsPane.headings.visitorRequests', { count: requests.length }) }
diff --git a/tests/helpers/Participant.ts b/tests/helpers/Participant.ts
index 8083daad93..09521d2e2d 100644
--- a/tests/helpers/Participant.ts
+++ b/tests/helpers/Participant.ts
@@ -21,6 +21,7 @@ import SecurityDialog from '../pageobjects/SecurityDialog';
import SettingsDialog from '../pageobjects/SettingsDialog';
import Toolbar from '../pageobjects/Toolbar';
import VideoQualityDialog from '../pageobjects/VideoQualityDialog';
+import Visitors from '../pageobjects/Visitors';
import { LOG_PREFIX, logInfo } from './browserLogger';
import { IContext, IJoinOptions } from './types';
@@ -569,6 +570,16 @@ export class Participant {
return new LobbyScreen(this);
}
+ /**
+ * Returns the Visitors page object.
+ *
+ * @returns {Visitors}
+ */
+ getVisitors(): Visitors {
+ return new Visitors(this);
+ }
+
+
/**
* Switches to the iframe API context
*/
diff --git a/tests/helpers/WebhookProxy.ts b/tests/helpers/WebhookProxy.ts
index 89e9697689..72e66941a7 100644
--- a/tests/helpers/WebhookProxy.ts
+++ b/tests/helpers/WebhookProxy.ts
@@ -12,6 +12,7 @@ export default class WebhookProxy {
private cache = new Map();
private listeners = new Map();
private consumers = new Map();
+ private _defaultMeetingSettings: object | undefined;
/**
* Initializes the webhook proxy.
@@ -65,7 +66,13 @@ export default class WebhookProxy {
if (!processed && msg.eventType === 'SETTINGS_PROVISIONING') {
// just in case to not be empty
- this.ws?.send(JSON.stringify({ someField: 'someValue' }));
+ let response: any = { someField: 'someValue' };
+
+ if (this._defaultMeetingSettings) {
+ response = this._defaultMeetingSettings;
+ }
+
+ this.ws?.send(JSON.stringify(response));
}
}
});
@@ -163,4 +170,25 @@ export default class WebhookProxy {
console.error(err);
}
}
+
+ /**
+ * Sets the settings provider.
+ * @param value
+ */
+ set defaultMeetingSettings(value: {
+ autoAudioRecording?: boolean;
+ autoTranscriptions?: boolean;
+ autoVideoRecording?: boolean;
+ lobbyEnabled?: boolean;
+ lobbyType?: 'WAIT_FOR_APPROVAL' | 'WAIT_FOR_MODERATOR';
+ maxOccupants?: number;
+ outboundPhoneNo?: string;
+ participantsSoftLimit?: number;
+ passcode?: string;
+ transcriberType?: 'GOOGLE' | 'ORACLE_CLOUD_AI_SPEECH' | 'EGHT_WHISPER';
+ visitorsEnabled?: boolean;
+ visitorsLive?: boolean;
+ }) {
+ this._defaultMeetingSettings = value;
+ }
}
diff --git a/tests/helpers/participants.ts b/tests/helpers/participants.ts
index 82dd7cd995..ae340af119 100644
--- a/tests/helpers/participants.ts
+++ b/tests/helpers/participants.ts
@@ -26,7 +26,7 @@ export async function ensureOneParticipant(ctx: IContext, options?: IJoinOptions
* @param {IJoinOptions} options - The options to use when joining the participant.
* @returns {Promise<void>}
*/
-export async function ensureThreeParticipants(ctx: IContext, options: IJoinOptions = {}): Promise<void> {
+export async function ensureThreeParticipants(ctx: IContext, options?: IJoinOptions): Promise<void> {
await joinTheModeratorAsP1(ctx, options);
// these need to be all, so we get the error when one fails
@@ -35,7 +35,7 @@ export async function ensureThreeParticipants(ctx: IContext, options: IJoinOptio
_joinParticipant(P3, ctx, options)
]);
- if (options.skipInMeetingChecks) {
+ if (options?.skipInMeetingChecks) {
return Promise.resolve();
}
@@ -69,7 +69,7 @@ export function joinFirstParticipant(ctx: IContext, options: IJoinOptions = {}):
* @param {IJoinOptions} options - The options to use when joining the participant.
* @returns {Promise<void>}
*/
-export function joinSecondParticipant(ctx: IContext, options: IJoinOptions = {}): Promise<void> {
+export function joinSecondParticipant(ctx: IContext, options?: IJoinOptions): Promise<void> {
return _joinParticipant(P2, ctx, options);
}
@@ -80,7 +80,7 @@ export function joinSecondParticipant(ctx: IContext, options: IJoinOptions = {})
* @param {IJoinOptions} options - The options to use when joining the participant.
* @returns {Promise<void>}
*/
-export function joinThirdParticipant(ctx: IContext, options: IJoinOptions = {}): Promise<void> {
+export function joinThirdParticipant(ctx: IContext, options?: IJoinOptions): Promise<void> {
return _joinParticipant(P3, ctx, options);
}
@@ -91,7 +91,7 @@ export function joinThirdParticipant(ctx: IContext, options: IJoinOptions = {}):
* @param {IJoinOptions} options - The options to use when joining the participant.
* @returns {Promise<void>}
*/
-export async function ensureFourParticipants(ctx: IContext, options: IJoinOptions = {}): Promise<void> {
+export async function ensureFourParticipants(ctx: IContext, options?: IJoinOptions): Promise<void> {
await joinTheModeratorAsP1(ctx, options);
// these need to be all, so we get the error when one fails
@@ -101,7 +101,7 @@ export async function ensureFourParticipants(ctx: IContext, options: IJoinOption
_joinParticipant(P4, ctx, options)
]);
- if (options.skipInMeetingChecks) {
+ if (options?.skipInMeetingChecks) {
return Promise.resolve();
}
@@ -137,12 +137,12 @@ async function joinTheModeratorAsP1(ctx: IContext, options?: IJoinOptions) {
* @param {Object} ctx - The context.
* @param {IJoinOptions} options - The options to join.
*/
-export async function ensureTwoParticipants(ctx: IContext, options: IJoinOptions = {}): Promise<void> {
+export async function ensureTwoParticipants(ctx: IContext, options?: IJoinOptions): Promise<void> {
await joinTheModeratorAsP1(ctx, options);
await _joinParticipant(P2, ctx, options);
- if (options.skipInMeetingChecks) {
+ if (options?.skipInMeetingChecks) {
return Promise.resolve();
}
@@ -165,7 +165,7 @@ export async function ensureTwoParticipants(ctx: IContext, options: IJoinOptions
async function _joinParticipant( // eslint-disable-line max-params
name: string,
ctx: IContext,
- options: IJoinOptions = {}) {
+ options?: IJoinOptions) {
// @ts-ignore
const p = ctx[name] as Participant;
@@ -201,11 +201,11 @@ async function _joinParticipant( // eslint-disable-line max-params
|| !ctx.jwtPrivateKeyPath)) {
jwtToken = process.env.JWT_ACCESS_TOKEN;
} else if (ctx.jwtPrivateKeyPath) {
- jwtToken = getToken(ctx, name);
+ jwtToken = getToken(ctx, name, options);
}
}
} else if (name === P2) {
- jwtToken = options.preferGenerateToken ? getToken(ctx, P2) : undefined;
+ jwtToken = options?.preferGenerateToken ? getToken(ctx, P2, options) : undefined;
}
const newParticipant = new Participant(name, jwtToken);
@@ -286,7 +286,7 @@ export async function muteVideoAndCheck(testee: Participant, observer: Participa
/**
* Get a JWT token for a moderator.
*/
-function getToken(ctx: IContext, displayName: string, moderator = true) {
+function getToken(ctx: IContext, displayName: string, options?: IJoinOptions) {
const keyid = process.env.JWT_KID;
const headers = {
algorithm: 'RS256',
@@ -326,9 +326,13 @@ function getToken(ctx: IContext, displayName: string, moderator = true) {
'room': '*'
};
- if (moderator) {
+ // if the moderator is set, or options are missing, we assume moderator
+ if (options?.moderator || !options) {
// @ts-ignore
payload.context.user.moderator = true;
+ } else if (options.visitor) {
+ // @ts-ignore
+ payload.context.user.role = 'visitor';
}
ctx.data[`${displayName}-jwt-payload`] = payload;
diff --git a/tests/helpers/types.ts b/tests/helpers/types.ts
index f46bb96138..4c455c31c4 100644
--- a/tests/helpers/types.ts
+++ b/tests/helpers/types.ts
@@ -32,6 +32,11 @@ export type IJoinOptions = {
*/
displayName?: string;
+ /**
+ * Whether to create a moderator token for joining.
+ */
+ moderator?: boolean;
+
/**
* When joining the first participant and jwt singing material is available and a provided token
* is available, prefer generating a new token for the first participant.
@@ -58,4 +63,9 @@ export type IJoinOptions = {
* based on the logic of the test.
*/
skipWaitToJoin?: boolean;
+
+ /**
+ * Whether to create a visitor token for joining.
+ */
+ visitor?: boolean;
};
diff --git a/tests/pageobjects/Visitors.ts b/tests/pageobjects/Visitors.ts
new file mode 100644
index 0000000000..ba5ba8959c
--- /dev/null
+++ b/tests/pageobjects/Visitors.ts
@@ -0,0 +1,34 @@
+import BasePageObject from './BasePageObject';
+
+/**
+ * Page object for the visitors elements in moderator and visitor page.
+ */
+export default class Visitors extends BasePageObject {
+ /**
+ * Returns the visitors dialog element if any.
+ */
+ hasVisitorsDialog() {
+ return this.participant.driver.$('aria/Joining meeting');
+ }
+
+ /**
+ * Returns the visitors count shown in the conference info (subject) area.
+ */
+ getVisitorsCount() {
+ return this.participant.driver.$('#visitorsCountLabel').getText();
+ }
+
+ /**
+ * Returns the visitors count shown in the Participants pane.
+ */
+ async getVisitorsHeaderFromParticipantsPane() {
+ const participantsPane = this.participant.getParticipantsPane();
+ const isOpen = await participantsPane.isOpen();
+
+ if (!isOpen) {
+ await participantsPane.open();
+ }
+
+ return this.participant.driver.$('#visitor-list-header').getText();
+ }
+}
diff --git a/tests/specs/2way/iFrameApiVisitors.spec.ts b/tests/specs/2way/iFrameApiVisitors.spec.ts
new file mode 100644
index 0000000000..59e88556bd
--- /dev/null
+++ b/tests/specs/2way/iFrameApiVisitors.spec.ts
@@ -0,0 +1,119 @@
+import { ensureOneParticipant, ensureTwoParticipants } from '../../helpers/participants';
+
+describe('Visitors', () => {
+ it('joining the meeting', async () => {
+ const { webhooksProxy } = ctx;
+
+ if (webhooksProxy) {
+ webhooksProxy.defaultMeetingSettings = {
+ visitorsEnabled: true
+ };
+ }
+
+ await ensureOneParticipant(ctx);
+
+ const { p1 } = ctx;
+
+ if (await p1.execute(() => config.disableIframeAPI)) {
+ // skip the test if iframeAPI is disabled or visitors are not supported
+ ctx.skipSuiteTests = true;
+
+ return;
+ }
+
+ await p1.driver.waitUntil(() => p1.execute(() => APP.conference._room.isVisitorsSupported()), {
+ timeout: 2000
+ }).then(async () => {
+ await p1.switchToAPI();
+ }).catch(() => {
+ ctx.skipSuiteTests = true;
+ });
+ });
+
+ it('visitor joins', async () => {
+ await ensureTwoParticipants(ctx, {
+ preferGenerateToken: true,
+ visitor: true,
+ skipInMeetingChecks: true
+ });
+
+ const { p1, p2, webhooksProxy } = ctx;
+
+ await p2.waitForSendReceiveData({
+ checkSend: false,
+ msg: 'Visitor is not receiving media'
+ }).then(() => p2.waitForRemoteStreams(1));
+
+ const p2Visitors = p2.getVisitors();
+ const p1Visitors = p1.getVisitors();
+
+ await p2.driver.waitUntil(() => p2Visitors.hasVisitorsDialog(), {
+ timeout: 5000,
+ timeoutMsg: 'Missing visitors dialog'
+ });
+
+ expect((await p1Visitors.getVisitorsCount()).trim()).toBe('1');
+ expect((await p1Visitors.getVisitorsHeaderFromParticipantsPane()).trim()).toBe('Viewers 1');
+
+ if (webhooksProxy) {
+ // PARTICIPANT_JOINED webhook
+ // @ts-ignore
+ const event: {
+ customerId: string;
+ data: {
+ avatar: string;
+ email: string;
+ group: string;
+ id: string;
+ name: string;
+ participantJid: string;
+ role: string;
+ };
+ eventType: string;
+ } = await webhooksProxy.waitForEvent('PARTICIPANT_JOINED');
+
+ const jwtPayload = ctx.data[`${p2.name}-jwt-payload`];
+
+ expect('PARTICIPANT_JOINED').toBe(event.eventType);
+ expect(event.data.avatar).toBe(jwtPayload.context.user.avatar);
+ expect(event.data.email).toBe(jwtPayload.context.user.email);
+ expect(event.data.id).toBe(jwtPayload.context.user.id);
+ expect(event.data.group).toBe(jwtPayload.context.group);
+ expect(event.data.name).toBe(p2.name);
+ expect(event.data.participantJid.indexOf('meet.jitsi') != -1).toBe(true);
+ expect(event.data.name).toBe(p2.name);
+ expect(event.data.role).toBe('visitor');
+ expect(event.customerId).toBe(process.env.IFRAME_TENANT?.replace('vpaas-magic-cookie-', ''));
+
+ await p2.switchToAPI();
+ await p2.getIframeAPI().executeCommand('hangup');
+
+ // PARTICIPANT_LEFT webhook
+ // @ts-ignore
+ const eventLeft: {
+ customerId: string;
+ data: {
+ avatar: string;
+ email: string;
+ group: string;
+ id: string;
+ name: string;
+ participantJid: string;
+ role: string;
+ };
+ eventType: string;
+ } = await webhooksProxy.waitForEvent('PARTICIPANT_LEFT');
+
+ expect('PARTICIPANT_LEFT').toBe(eventLeft.eventType);
+ expect(eventLeft.data.avatar).toBe(jwtPayload.context.user.avatar);
+ expect(eventLeft.data.email).toBe(jwtPayload.context.user.email);
+ expect(eventLeft.data.id).toBe(jwtPayload.context.user.id);
+ expect(eventLeft.data.group).toBe(jwtPayload.context.group);
+ expect(eventLeft.data.name).toBe(p2.name);
+ expect(eventLeft.data.participantJid.indexOf('meet.jitsi') != -1).toBe(true);
+ expect(eventLeft.data.name).toBe(p2.name);
+ expect(eventLeft.data.role).toBe('visitor');
+ expect(eventLeft.customerId).toBe(process.env.IFRAME_TENANT?.replace('vpaas-magic-cookie-', ''));
+ }
+ });
+});