Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.
TypeScript debiandeep-videojitsijitsi-meetscalable-video-conferencessfuvideovideo-communicationvideo-conferencingwebrtc
feat(tests): Adds invite test. (#15986)
Дамян Минковf9927e4cd76f
diff --git a/tests/env.example b/tests/env.exampleindex b138b1562f..c42b040387 100644--- a/tests/env.example+++ b/tests/env.example@@ -43,6 +43,12 @@# A rest URL to be used by dial-in tests to invite jigasi to the conference#DIAL_IN_REST_URL=+# A destination number to dialout, that auto answers and sends media+#DIAL_OUT_URL=++# A destination number to dialout, that auto answer and sends media audio and video+#SIP_JIBRI_DIAL_OUT_URL=+# Whether to use beta for the first participants#BROWSER_CHROME_BETA=false#BROWSER_FF_BETA=falsediff --git a/tests/helpers/participants.ts b/tests/helpers/participants.tsindex abe0fd6feb..913f2cd3d6 100644--- a/tests/helpers/participants.ts+++ b/tests/helpers/participants.ts@@ -318,7 +318,8 @@ function getToken(ctx: IContext, displayName: string, moderator = true) {'features': {'outbound-call': 'true','transcription': 'true',- 'recording': 'true'+ 'recording': 'true',+ 'sip-outbound-call': true},},'room': '*'diff --git a/tests/pageobjects/IframeAPI.ts b/tests/pageobjects/IframeAPI.tsindex e32af45d6c..5b7ebbf9ec 100644--- a/tests/pageobjects/IframeAPI.ts+++ b/tests/pageobjects/IframeAPI.ts@@ -89,4 +89,24 @@ export default class IframeAPI extends BasePageObject {dispose() {return this.participant.execute(() => window.jitsiAPI.dispose());}++ /**+ * Invite the given participant to the meeting via PSTN.+ */+ invitePhone(value: string) {+ return this.participant.execute(v => window.jitsiAPI.invite([ {+ type: 'phone',+ number: v+ } ]), value);+ }++ /**+ * Invite the given participant to the meeting via sip (sip jibri).+ */+ inviteSIP(value: string) {+ return this.participant.execute(v => window.jitsiAPI.invite([ {+ type: 'sip',+ address: v+ } ]), value);+ }}diff --git a/tests/specs/alone/dialInAudio.spec.ts b/tests/specs/alone/dialInAudio.spec.tsindex da5302e6b2..b7f4053a3f 100644--- a/tests/specs/alone/dialInAudio.spec.ts+++ b/tests/specs/alone/dialInAudio.spec.ts@@ -1,8 +1,7 @@-import https from 'node:https';import process from 'node:process';import { ensureOneParticipant } from '../../helpers/participants';-import { cleanup, isDialInEnabled, waitForAudioFromDialInParticipant } from '../helpers/DialIn';+import { cleanup, dialIn, isDialInEnabled, retrievePin, waitForAudioFromDialInParticipant } from '../helpers/DialIn';describe('Dial-In', () => {it('join participant', async () => {@@ -22,59 +21,25 @@ describe('Dial-In', () => {});it('retrieve pin', async () => {- let dialInPin;-try {- dialInPin = await ctx.p1.getInviteDialog().getPinNumber();+ await retrievePin(ctx.p1);} catch (e) {console.error('dial-in.test.no-pin');ctx.skipSuiteTests = true;throw e;}- await ctx.p1.getInviteDialog().clickCloseButton();-- if (dialInPin.length === 0) {+ if (ctx.data.dialInPin === 0) {console.error('dial-in.test.no-pin');ctx.skipSuiteTests = true;throw new Error('no pin');}- expect(dialInPin.length >= 8).toBe(true);-- ctx.data.dialInPin = dialInPin;+ expect(ctx.data.dialInPin.length >= 8).toBe(true);});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.data.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}`);+ await dialIn(ctx.p1);});it('wait for audio from dial-in participant', async () => {diff --git a/tests/specs/alone/iFrameApiInvite.spec.ts b/tests/specs/alone/iFrameApiInvite.spec.tsnew file mode 100644index 0000000000..981014f4da--- /dev/null+++ b/tests/specs/alone/iFrameApiInvite.spec.ts@@ -0,0 +1,205 @@+import { ensureOneParticipant } from '../../helpers/participants';+import {+ cleanup,+ dialIn,+ isDialInEnabled,+ retrievePin,+ waitForAudioFromDialInParticipant+} from '../helpers/DialIn';+import type { Participant } from '../../helpers/Participant';++describe('Invite iframeAPI', () => {+ it('join participant', async () => {+ await ensureOneParticipant(ctx);++ const { p1 } = ctx;++ // check for dial-in dial-out sip-jibri maybe+ if (await p1.execute(() => config.disableIframeAPI)) {+ // skip the test if iframeAPI is disabled+ ctx.skipSuiteTests = true;++ return;+ }++ ctx.data.dialOutDisabled = Boolean(!await p1.execute(() => config.dialOutAuthUrl));+ ctx.data.sipJibriDisabled = Boolean(!await p1.execute(() => config.inviteServiceUrl));++ // check dial-in is enabled+ if (!await isDialInEnabled(ctx.p1) || !process.env.DIAL_IN_REST_URL) {+ ctx.data.dialInDisabled = true;+ }+ });++ it('dial-in', async () => {+ if (ctx.data.dialInDisabled) {+ return;+ }++ const { p1 } = ctx;++ await retrievePin(p1);++ expect(ctx.data.dialInPin.length >= 8).toBe(true);++ await dialIn(p1);++ if (!await p1.isInMuc()) {+ // local participant did not join abort+ return;+ }++ await waitForAudioFromDialInParticipant(p1);++ await checkDialEvents(p1, 'in', 'DIAL_IN_STARTED', 'DIAL_IN_ENDED');+ });++ it('dial-out', async () => {+ if (ctx.data.dialOutDisabled || !process.env.DIAL_OUT_URL) {+ return;+ }++ const { p1 } = ctx;++ await p1.switchToAPI();++ await p1.getIframeAPI().invitePhone(process.env.DIAL_OUT_URL);++ await p1.switchInPage();++ await p1.waitForParticipants(1);++ await waitForAudioFromDialInParticipant(p1);++ await checkDialEvents(p1, 'out', 'DIAL_OUT_STARTED', 'DIAL_OUT_ENDED');+ });++ it('sip jibri', async () => {+ if (ctx.data.sipJibriDisabled || !process.env.SIP_JIBRI_DIAL_OUT_URL) {+ return;+ }++ const { p1 } = ctx;++ await p1.switchToAPI();++ await p1.getIframeAPI().inviteSIP(process.env.SIP_JIBRI_DIAL_OUT_URL);++ await p1.switchInPage();++ await p1.waitForParticipants(1);++ await waitForAudioFromDialInParticipant(p1);++ const { webhooksProxy } = ctx;++ if (webhooksProxy) {+ const customerId = process.env.IFRAME_TENANT?.replace('vpaas-magic-cookie-', '');+ const sipCallOutStartedEvent: {+ customerId: string;+ data: {+ participantFullJid: string;+ participantId: string;+ participantJid: string;+ sipAddress: string;+ };+ eventType: string;+ } = await webhooksProxy.waitForEvent('SIP_CALL_OUT_STARTED');++ expect('SIP_CALL_OUT_STARTED').toBe(sipCallOutStartedEvent.eventType);+ expect(sipCallOutStartedEvent.data.sipAddress).toBe(`sip:${process.env.SIP_JIBRI_DIAL_OUT_URL}`);+ expect(sipCallOutStartedEvent.customerId).toBe(customerId);++ const participantId = sipCallOutStartedEvent.data.participantId;+ const participantJid = sipCallOutStartedEvent.data.participantJid;+ const participantFullJid = sipCallOutStartedEvent.data.participantFullJid;++ await cleanup(p1);++ const sipCallOutEndedEvent: {+ customerId: string;+ data: {+ direction: string;+ participantFullJid: string;+ participantId: string;+ participantJid: string;+ };+ eventType: string;+ } = await webhooksProxy.waitForEvent('SIP_CALL_OUT_ENDED');++ expect('SIP_CALL_OUT_ENDED').toBe(sipCallOutEndedEvent.eventType);+ expect(sipCallOutEndedEvent.customerId).toBe(customerId);+ expect(sipCallOutEndedEvent.data.participantFullJid).toBe(participantFullJid);+ expect(sipCallOutEndedEvent.data.participantId).toBe(participantId);+ expect(sipCallOutEndedEvent.data.participantJid).toBe(participantJid);+ } else {+ await cleanup(p1);+ }+ });+});++/**+ * Checks the dial events for a participant and clean up at the end.+ * @param participant+ * @param startedEventName+ * @param endedEventName+ * @param direction+ */+async function checkDialEvents(participant: Participant, direction: string, startedEventName: string, endedEventName: string) {+ const { webhooksProxy } = ctx;++ if (webhooksProxy) {+ const customerId = process.env.IFRAME_TENANT?.replace('vpaas-magic-cookie-', '');+ const dialInStartedEvent: {+ customerId: string;+ data: {+ direction: string;+ participantFullJid: string;+ participantId: string;+ participantJid: string;+ };+ eventType: string;+ } = await webhooksProxy.waitForEvent(startedEventName);++ expect(startedEventName).toBe(dialInStartedEvent.eventType);+ expect(dialInStartedEvent.data.direction).toBe(direction);+ expect(dialInStartedEvent.customerId).toBe(customerId);++ const participantId = dialInStartedEvent.data.participantId;+ const participantJid = dialInStartedEvent.data.participantJid;+ const participantFullJid = dialInStartedEvent.data.participantFullJid;++ const usageEvent: {+ customerId: string;+ data: any;+ eventType: string;+ } = await webhooksProxy.waitForEvent('USAGE');++ expect('USAGE').toBe(usageEvent.eventType);+ expect(usageEvent.customerId).toBe(customerId);++ expect(usageEvent.data.some((el: any) =>+ el.participantId === participantId && el.callDirection === direction)).toBe(true);++ await cleanup(participant);++ const dialInEndedEvent: {+ customerId: string;+ data: {+ direction: string;+ participantFullJid: string;+ participantId: string;+ participantJid: string;+ };+ eventType: string;+ } = await webhooksProxy.waitForEvent(endedEventName);++ expect(endedEventName).toBe(dialInEndedEvent.eventType);+ expect(dialInEndedEvent.customerId).toBe(customerId);+ expect(dialInEndedEvent.data.participantFullJid).toBe(participantFullJid);+ expect(dialInEndedEvent.data.participantId).toBe(participantId);+ expect(dialInEndedEvent.data.participantJid).toBe(participantJid);+ } else {+ await cleanup(participant);+ }+}diff --git a/tests/specs/helpers/DialIn.ts b/tests/specs/helpers/DialIn.tsindex afbfc06d61..c9dc485b87 100644--- a/tests/specs/helpers/DialIn.ts+++ b/tests/specs/helpers/DialIn.ts@@ -1,4 +1,6 @@import type { Participant } from '../../helpers/Participant';+import process from 'node:process';+import https from 'node:https';/*** Helper functions for dial-in related operations.@@ -49,3 +51,51 @@ export async function isDialInEnabled(participant: Participant) {return await participant.execute(() => Boolean(config.dialInConfCodeUrl && config.dialInNumbersUrl && config.hosts?.muc));}++/**+ * Retrieves the dial-in pin number from the invite dialog of the participant.+ * @param participant+ */+export async function retrievePin(participant: Participant) {+ const dialInPin = await participant.getInviteDialog().getPinNumber();++ await participant.getInviteDialog().clickCloseButton();++ ctx.data.dialInPin = dialInPin;+}++/**+ * Sends a request to the REST API to dial in the participant using the provided pin.+ * @param participant+ */+export async function dialIn(participant: Participant) {+ if (!await participant.isInMuc()) {+ // local participant did not join abort+ return;+ }++ const restUrl = process.env.DIAL_IN_REST_URL?.replace('{0}', ctx.data.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}`);+}diff --git a/tests/wdio.firefox.conf.ts b/tests/wdio.firefox.conf.tsindex 8aeb770402..edcd1ab5ad 100644--- a/tests/wdio.firefox.conf.ts+++ b/tests/wdio.firefox.conf.ts@@ -22,6 +22,7 @@ if (process.env.HEADLESS === 'true') {const ffExcludes = ['specs/2way/iFrameApiParticipantsPresence.spec.ts', // FF does not support uploading files (uploadFile)'specs/2way/iFrameApiTranscriptions.spec.ts',+ 'specs/alone/iFrameApiInvite.spec.ts',// FF does not support setting a file as mic input, no dominant speaker events'specs/3way/activeSpeaker.spec.ts',