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 dial-in test. (#15470)

Дамян Минковada61509717a
diff --git a/package.json b/package.json
index 060ee1d3fd..a62a9e8bf2 100644
--- a/package.json
+++ b/package.json
@@ -221,9 +221,11 @@
"tsc-test:native": "tsc --project tsconfig.native.json --listFilesOnly | grep -v node_modules | grep web",
"start": "make dev",
"test": "DOTENV_CONFIG_PATH=tests/.env wdio run tests/wdio.conf.ts",
+ "test-single": "DOTENV_CONFIG_PATH=tests/.env wdio run tests/wdio.conf.ts --spec",
"test-ff": "DOTENV_CONFIG_PATH=tests/.env wdio run tests/wdio.firefox.conf.ts",
"test-dev": "DOTENV_CONFIG_PATH=tests/.env wdio run tests/wdio.dev.conf.ts",
- "test-grid": "DOTENV_CONFIG_PATH=tests/.env wdio run tests/wdio.grid.conf.ts"
+ "test-grid": "DOTENV_CONFIG_PATH=tests/.env wdio run tests/wdio.grid.conf.ts",
+ "test-grid-single": "DOTENV_CONFIG_PATH=tests/.env wdio run tests/wdio.grid.conf.ts --spec"
},
"resolutions": {
"@types/react": "17.0.14",
diff --git a/tests/helpers/Participant.ts b/tests/helpers/Participant.ts
index d719759ec3..ed0f2d0561 100644
--- a/tests/helpers/Participant.ts
+++ b/tests/helpers/Participant.ts
@@ -9,6 +9,7 @@ import BreakoutRooms from '../pageobjects/BreakoutRooms';
import ChatPanel from '../pageobjects/ChatPanel';
import Filmstrip from '../pageobjects/Filmstrip';
import IframeAPI from '../pageobjects/IframeAPI';
+import InviteDialog from '../pageobjects/InviteDialog';
import Notifications from '../pageobjects/Notifications';
import ParticipantsPane from '../pageobjects/ParticipantsPane';
import SettingsDialog from '../pageobjects/SettingsDialog';
@@ -308,7 +309,7 @@ export class Participant {
*
* @returns {Promise<void>}
*/
- async waitForSendReceiveData(): Promise<void> {
+ async waitForSendReceiveData(timeout = 15_000, msg = 'expected to receive/send data in 15s'): Promise<void> {
const driver = this.driver;
return driver.waitUntil(async () =>
@@ -322,15 +323,15 @@ export class Participant {
return rtpStats.uploadBitrate > 0 && rtpStats.downloadBitrate > 0;
}), {
- timeout: 15_000,
- timeoutMsg: 'expected to receive/send data in 15s'
+ timeout,
+ timeoutMsg: msg
});
}
/**
* Waits for remote streams.
*
- * @param {number} number - The number of remote streams o wait for.
+ * @param {number} number - The number of remote streams to wait for.
* @returns {Promise<void>}
*/
waitForRemoteStreams(number: number): Promise<void> {
@@ -343,6 +344,23 @@ export class Participant {
});
}
+ /**
+ * Waits for number of participants.
+ *
+ * @param {number} number - The number of participant to wait for.
+ * @param {string} msg - A custom message to use.
+ * @returns {Promise<void>}
+ */
+ waitForParticipants(number: number, msg?: string): Promise<void> {
+ const driver = this.driver;
+
+ return driver.waitUntil(async () =>
+ await driver.execute(count => APP.conference.listMembers().length === count, number), {
+ timeout: 15_000,
+ timeoutMsg: msg || `not the expected participants ${number} in 15s`
+ });
+ }
+
/**
* Returns the chat panel for this participant.
*/
@@ -377,6 +395,15 @@ export class Participant {
return new Filmstrip(this);
}
+ /**
+ * Returns the invite dialog for this participant.
+ *
+ * @returns {InviteDialog}
+ */
+ getInviteDialog(): InviteDialog {
+ return new InviteDialog(this);
+ }
+
/**
* Returns the notifications.
*/
diff --git a/tests/helpers/types.ts b/tests/helpers/types.ts
index 39af0c9d63..c1d314e4fa 100644
--- a/tests/helpers/types.ts
+++ b/tests/helpers/types.ts
@@ -5,6 +5,7 @@ import WebhookProxy from './WebhookProxy';
export type IContext = {
conferenceJid: string;
+ dialInPin: string;
iframeAPI: boolean;
jwtKid: string;
jwtPrivateKeyPath: string;
@@ -14,6 +15,7 @@ export type IContext = {
p4: Participant;
roomName: string;
skipSuiteTests: boolean;
+ times: any;
webhooksProxy: WebhookProxy;
};
diff --git a/tests/pageobjects/Filmstrip.ts b/tests/pageobjects/Filmstrip.ts
index 10a7eb92b0..7a529a1494 100644
--- a/tests/pageobjects/Filmstrip.ts
+++ b/tests/pageobjects/Filmstrip.ts
@@ -99,6 +99,7 @@ export default class Filmstrip extends BasePageObject {
const popoverElement = this.participant.driver.$(
`//div[contains(@class, 'popover')]//div[contains(@class, '${linkClassname}')]`);
+ await popoverElement.waitForExist();
await popoverElement.waitForDisplayed();
await popoverElement.click();
@@ -127,6 +128,14 @@ export default class Filmstrip extends BasePageObject {
await this.clickOnRemoteMenuLink(await participant.getEndpointId(), 'mutevideolink', true);
}
+ /**
+ * Kicks a participant.
+ * @param participantId
+ */
+ async kickParticipant(participantId: string) {
+ await this.clickOnRemoteMenuLink(participantId, 'kicklink', true);
+ }
+
/**
* Clicks on the hide self view button from local video.
*/
diff --git a/tests/pageobjects/InviteDialog.ts b/tests/pageobjects/InviteDialog.ts
new file mode 100644
index 0000000000..0ed9fe5869
--- /dev/null
+++ b/tests/pageobjects/InviteDialog.ts
@@ -0,0 +1,44 @@
+import BaseDialog from './BaseDialog';
+
+const CONFERENCE_ID = 'conference-id';
+const DIALOG_CONTAINER = 'invite-more-dialog';
+
+/**
+ * Represents the invite dialog in a particular participant.
+ */
+export default class InviteDialog extends BaseDialog {
+ /**
+ * Checks if the dialog is open.
+ */
+ async isOpen() {
+ return this.participant.driver.$(`.${DIALOG_CONTAINER}`).isExisting();
+ }
+
+ /**
+ * Open the invite dialog, if the info dialog is closed.
+ */
+ async open() {
+ if (await this.isOpen()) {
+ return;
+ }
+
+ await this.participant.getParticipantsPane().clickInvite();
+ }
+
+ /**
+ * Returns the PIN for the conference.
+ */
+ async getPinNumber() {
+ await this.open();
+
+ const elem = this.participant.driver.$(`.${CONFERENCE_ID}`);
+
+ await elem.waitForExist({ timeout: 5000 });
+
+ const fullText = await elem.getText();
+
+ this.participant.log(`Extracted text in invite dialog: ${fullText}`);
+
+ return fullText.split(':')[1].trim().replace(/[# ]/g, '');
+ }
+}
diff --git a/tests/pageobjects/ParticipantsPane.ts b/tests/pageobjects/ParticipantsPane.ts
index 38515fbe78..9649aad7e0 100644
--- a/tests/pageobjects/ParticipantsPane.ts
+++ b/tests/pageobjects/ParticipantsPane.ts
@@ -8,6 +8,8 @@ import BasePageObject from './BasePageObject';
*/
const PARTICIPANTS_PANE = 'participants_pane';
+const INVITE = 'Invite someone';
+
/**
* Represents the participants pane from the UI.
*/
@@ -168,4 +170,18 @@ export default class ParticipantsPane extends BasePageObject {
await meetingParticipantMoreOptions.moveTo();
await meetingParticipantMoreOptions.click();
}
+
+ /**
+ * Clicks the invite button.
+ */
+ async clickInvite() {
+ if (!await this.isOpen()) {
+ await this.open();
+ }
+
+ const inviteButton = this.participant.driver.$(`aria/${INVITE}`);
+
+ await inviteButton.waitForDisplayed();
+ await inviteButton.click();
+ }
}
diff --git a/tests/specs/2way/fakeDialInAudio.spec.ts b/tests/specs/2way/fakeDialInAudio.spec.ts
new file mode 100644
index 0000000000..28865a767f
--- /dev/null
+++ b/tests/specs/2way/fakeDialInAudio.spec.ts
@@ -0,0 +1,53 @@
+import process from 'node:process';
+
+import { ensureOneParticipant, ensureTwoParticipants } from '../../helpers/participants';
+import { cleanup, waitForAudioFromDialInParticipant } from '../helpers/DialIn';
+
+describe('Fake Dial-In - ', () => {
+ it('join participant', async () => {
+ // we execute fake dial in only if the real dial in is not enabled
+
+ // check rest url is not configured
+ if (process.env.DIAL_IN_REST_URL) {
+ ctx.skipSuiteTests = true;
+
+ return;
+ }
+
+ await ensureOneParticipant(ctx);
+
+ // check dial-in is enabled, so skip
+ if (await ctx.p1.driver.execute(() => Boolean(
+ config.dialInConfCodeUrl && config.dialInNumbersUrl && config.hosts && config.hosts.muc))) {
+ ctx.skipSuiteTests = true;
+ }
+ });
+
+ it('open invite dialog', async () => {
+ await ctx.p1.getInviteDialog().open();
+
+ await ctx.p1.getInviteDialog().clickCloseButton();
+ });
+
+ it('invite second participant', async () => {
+ if (!await ctx.p1.isInMuc()) {
+ // local participant did not join abort
+ return;
+ }
+
+ await ensureTwoParticipants(ctx);
+ });
+
+ it('wait for audio from second participant', async () => {
+ const { p1 } = ctx;
+
+ if (!await p1.isInMuc()) {
+ // local participant did not join abort
+ return;
+ }
+
+ await waitForAudioFromDialInParticipant(p1);
+
+ await cleanup(p1);
+ });
+});
diff --git a/tests/specs/alone/dialInAudio.spec.ts b/tests/specs/alone/dialInAudio.spec.ts
new file mode 100644
index 0000000000..0c9e255314
--- /dev/null
+++ b/tests/specs/alone/dialInAudio.spec.ts
@@ -0,0 +1,83 @@
+import https from 'node:https';
+import process from 'node:process';
+
+import { ensureOneParticipant } from '../../helpers/participants';
+import { cleanup, waitForAudioFromDialInParticipant } from '../helpers/DialIn';
+
+describe('Dial-In - ', () => {
+ it('join participant', async () => {
+ // check rest url is configured
+ if (!process.env.DIAL_IN_REST_URL) {
+ ctx.skipSuiteTests = true;
+
+ return;
+ }
+
+ await ensureOneParticipant(ctx);
+
+ // check dial-in is enabled
+ if (!await ctx.p1.driver.execute(() => Boolean(
+ config.dialInConfCodeUrl && config.dialInNumbersUrl && config.hosts && config.hosts.muc))) {
+ ctx.skipSuiteTests = true;
+ }
+ });
+
+ it('retrieve pin', async () => {
+ const dialInPin = await ctx.p1.getInviteDialog().getPinNumber();
+
+ await ctx.p1.getInviteDialog().clickCloseButton();
+
+ if (dialInPin.length === 0) {
+ console.error('dial-in.test.no-pin');
+ }
+
+ expect(dialInPin.length >= 9).toBe(true);
+
+ ctx.dialInPin = dialInPin;
+ });
+
+ it('invite dial-in participant', async () => {
+ if (!await ctx.p1.isInMuc()) {
+ // local participant did not join abort
+ return;
+ }
+
+ const restUrl = process.env.DIAL_IN_REST_URL?.replace('{0}', ctx.dialInPin);
+
+ // we have already checked in the first test that DIAL_IN_REST_URL exist so restUrl cannot be ''
+ const responseData: string = await new Promise((resolve, reject) => {
+ https.get(restUrl || '', res => {
+ let data = '';
+
+ res.on('data', chunk => {
+ data += chunk;
+ });
+
+ res.on('end', () => {
+ ctx.times.restAPIExecutionTS = performance.now();
+
+ resolve(data);
+ });
+ }).on('error', err => {
+ console.error('dial-in.test.restAPI.request.fail');
+ console.error(err);
+ reject(err);
+ });
+ });
+
+ console.log(`dial-in.test.call_session_history_id:${JSON.parse(responseData).call_session_history_id}`);
+ });
+
+ it('wait for audio from dial-in participant', async () => {
+ const { p1 } = ctx;
+
+ if (!await p1.isInMuc()) {
+ // local participant did not join abort
+ return;
+ }
+
+ await waitForAudioFromDialInParticipant(p1);
+
+ await cleanup(p1);
+ });
+});
diff --git a/tests/specs/helpers/DialIn.ts b/tests/specs/helpers/DialIn.ts
new file mode 100644
index 0000000000..2131544b83
--- /dev/null
+++ b/tests/specs/helpers/DialIn.ts
@@ -0,0 +1,39 @@
+import type { Participant } from '../../helpers/Participant';
+
+/**
+ * Helper functions for dial-in related operations.
+ * To be able to create a fake dial-in test that will run most of the logic for the real dial-in test.
+ */
+
+/**
+ * Waits for the audio from the dial-in participant.
+ * @param participant
+ */
+export async function waitForAudioFromDialInParticipant(participant: Participant) {
+ // waits 15 seconds for the participant to join
+ await participant.waitForParticipants(1, `dial-in.test.jigasi.participant.no.join.for:${
+ ctx.times.restAPIExecutionTS + 15_000} ms.`);
+
+ const joinedTS = performance.now();
+
+ console.log(`dial-in.test.jigasi.participant.join.after:${joinedTS - ctx.times.restAPIExecutionTS}`);
+
+ await participant.waitForIceConnected();
+ await participant.waitForRemoteStreams(1);
+
+ await participant.waitForSendReceiveData(20_000, 'dial-in.test.jigasi.participant.no.audio.after.join');
+ console.log(`dial-in.test.jigasi.participant.received.audio.after.join:${performance.now() - joinedTS} ms.`);
+}
+
+/**
+ * Cleans up the dial-in participant by kicking it if the local participant is a moderator.
+ * @param participant
+ */
+export async function cleanup(participant: Participant) {
+ // cleanup
+ if (await participant.isModerator()) {
+ const jigasiEndpointId = await participant.driver.execute(() => APP.conference.listMembers()[0].getId());
+
+ await participant.getFilmstrip().kickParticipant(jigasiEndpointId);
+ }
+}
diff --git a/tests/wdio.conf.ts b/tests/wdio.conf.ts
index e0df0746a8..f2cf75822d 100644
--- a/tests/wdio.conf.ts
+++ b/tests/wdio.conf.ts
@@ -191,7 +191,9 @@ export const config: WebdriverIO.MultiremoteConfig = {
const globalAny: any = global;
const roomName = `jitsimeettorture-${crypto.randomUUID()}`;
- globalAny.ctx = {} as IContext;
+ globalAny.ctx = {
+ times: {}
+ } as IContext;
globalAny.ctx.roomName = roomName;
globalAny.ctx.jwtPrivateKeyPath = process.env.JWT_PRIVATE_KEY_PATH;
globalAny.ctx.jwtKid = process.env.JWT_KID;