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): Recording and live-streaming tests.

damencho403b9043b6e5
diff --git a/tests/env.example b/tests/env.example
index a58d8f3f56..3d73c06ac3 100644
--- a/tests/env.example
+++ b/tests/env.example
@@ -55,3 +55,7 @@
# Whether to use beta for the first participants
#BROWSER_CHROME_BETA=false
#BROWSER_FF_BETA=false
+
+# A stream key abd broadcast ID that can be used by the tests to stream to YouTube
+#YTUBE_TEST_STREAM_KEY=
+#YTUBE_TEST_BROADCAST_ID=
diff --git a/tests/helpers/participants.ts b/tests/helpers/participants.ts
index 913f2cd3d6..82dd7cd995 100644
--- a/tests/helpers/participants.ts
+++ b/tests/helpers/participants.ts
@@ -319,7 +319,8 @@ function getToken(ctx: IContext, displayName: string, moderator = true) {
'outbound-call': 'true',
'transcription': 'true',
'recording': 'true',
- 'sip-outbound-call': true
+ 'sip-outbound-call': true,
+ 'livestreaming': true
},
},
'room': '*'
diff --git a/tests/pageobjects/IframeAPI.ts b/tests/pageobjects/IframeAPI.ts
index 5b7ebbf9ec..9a3e123f97 100644
--- a/tests/pageobjects/IframeAPI.ts
+++ b/tests/pageobjects/IframeAPI.ts
@@ -109,4 +109,27 @@ export default class IframeAPI extends BasePageObject {
address: v
} ]), value);
}
+
+ /**
+ * Starts a file recording or streaming session.
+ * @param options
+ */
+ startRecording(options: any) {
+ return this.participant.execute(o => window.jitsiAPI.startRecording(o), options);
+ }
+
+ /**
+ * Stop a file recording or streaming session.
+ * @param mode
+ */
+ stopRecording(mode: string) {
+ return this.participant.execute(m => window.jitsiAPI.stopRecording(m), mode);
+ }
+
+ /**
+ * Returns the live-streaming url.
+ */
+ async getLivestreamUrl() {
+ return this.participant.execute(() => window.jitsiAPI.getLivestreamUrl());
+ }
}
diff --git a/tests/specs/alone/iFrameApiRecording.spec.ts b/tests/specs/alone/iFrameApiRecording.spec.ts
new file mode 100644
index 0000000000..f5e0823bf1
--- /dev/null
+++ b/tests/specs/alone/iFrameApiRecording.spec.ts
@@ -0,0 +1,193 @@
+import { ensureOneParticipant } from '../../helpers/participants';
+
+describe('Recording', () => {
+ 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.recordingDisabled = Boolean(!await p1.execute(() => config.recordingService?.enabled));
+ ctx.data.liveStreamingDisabled = Boolean(!await p1.execute(() => config.liveStreaming?.enabled))
+ || !process.env.YTUBE_TEST_STREAM_KEY;
+ });
+
+ it('start/stop function', async () => {
+ if (ctx.data.recordingDisabled) {
+ return;
+ }
+
+ await testRecordingStarted(true);
+ await testRecordingStopped(true);
+ });
+
+ it('start/stop command', async () => {
+ if (ctx.data.recordingDisabled) {
+ return;
+ }
+
+ await testRecordingStarted(false);
+ await testRecordingStopped(false);
+ });
+
+ it('start/stop Livestreaming command', async () => {
+ if (ctx.data.liveStreamingDisabled) {
+ return;
+ }
+
+ const { p1, webhooksProxy } = ctx;
+
+ await p1.switchToAPI();
+ await p1.getIframeAPI().addEventListener('recordingStatusChanged');
+
+ await p1.getIframeAPI().executeCommand('startRecording', {
+ youtubeBroadcastID: process.env.YTUBE_TEST_BROADCAST_ID,
+ mode: 'stream',
+ youtubeStreamKey: process.env.YTUBE_TEST_STREAM_KEY
+ });
+
+ if (webhooksProxy) {
+ const customerId = process.env.IFRAME_TENANT?.replace('vpaas-magic-cookie-', '');
+ const liveStreamEvent: {
+ customerId: string;
+ eventType: string;
+ } = await webhooksProxy.waitForEvent('LIVE_STREAM_STARTED', 15000);
+
+ expect('LIVE_STREAM_STARTED').toBe(liveStreamEvent.eventType);
+ expect(liveStreamEvent.customerId).toBe(customerId);
+ }
+
+ const statusEvent = (await p1.getIframeAPI().getEventResult('recordingStatusChanged'));
+
+ expect(statusEvent.mode).toBe('stream');
+ expect(statusEvent.on).toBe(true);
+
+ if (process.env.YTUBE_TEST_BROADCAST_ID) {
+ const liveStreamUrl = await p1.getIframeAPI().getLivestreamUrl();
+
+ expect(liveStreamUrl.livestreamUrl).toBeDefined();
+ }
+
+ await p1.getIframeAPI().executeCommand('stopRecording', 'stream');
+
+ if (webhooksProxy) {
+ const customerId = process.env.IFRAME_TENANT?.replace('vpaas-magic-cookie-', '');
+ const liveStreamEvent: {
+ customerId: string;
+ eventType: string;
+ } = await webhooksProxy.waitForEvent('LIVE_STREAM_ENDED');
+
+ expect('LIVE_STREAM_ENDED').toBe(liveStreamEvent.eventType);
+ expect(liveStreamEvent.customerId).toBe(customerId);
+ }
+
+ const stoppedStatusEvent = (await p1.getIframeAPI().getEventResult('recordingStatusChanged'));
+
+ expect(stoppedStatusEvent.mode).toBe('stream');
+ expect(stoppedStatusEvent.on).toBe(false);
+ });
+});
+
+/**
+ * Checks if the recording is started.
+ * @param command
+ */
+async function testRecordingStarted(command: boolean) {
+ const { p1, webhooksProxy } = ctx;
+
+ await p1.switchToAPI();
+ await p1.getIframeAPI().addEventListener('recordingStatusChanged');
+ await p1.getIframeAPI().addEventListener('recordingLinkAvailable');
+
+ if (command) {
+ await p1.getIframeAPI().executeCommand('startRecording', {
+ mode: 'file'
+ });
+ } else {
+ await p1.getIframeAPI().startRecording({
+ mode: 'file'
+ });
+ }
+
+ if (webhooksProxy) {
+ const customerId = process.env.IFRAME_TENANT?.replace('vpaas-magic-cookie-', '');
+ const recordingEvent: {
+ customerId: string;
+ eventType: string;
+ } = await webhooksProxy.waitForEvent('RECORDING_STARTED', 15000);
+
+ expect('RECORDING_STARTED').toBe(recordingEvent.eventType);
+ expect(recordingEvent.customerId).toBe(customerId);
+
+ webhooksProxy?.clearCache();
+ }
+
+ const statusEvent = (await p1.getIframeAPI().getEventResult('recordingStatusChanged'));
+
+ expect(statusEvent.mode).toBe('file');
+ expect(statusEvent.on).toBe(true);
+
+ const linkEvent = (await p1.getIframeAPI().getEventResult('recordingLinkAvailable'));
+
+ expect(linkEvent.link.startsWith('https://')).toBe(true);
+ expect(linkEvent.link.includes(process.env.IFRAME_TENANT)).toBe(true);
+ expect(linkEvent.ttl > 0).toBe(true);
+}
+
+/**
+ * Checks if the recording is stopped.
+ * @param command
+ */
+async function testRecordingStopped(command: boolean) {
+ const { p1, webhooksProxy } = ctx;
+
+ await p1.switchToAPI();
+ if (command) {
+ await p1.getIframeAPI().executeCommand('stopRecording', 'file');
+ } else {
+ await p1.getIframeAPI().stopRecording('file');
+ }
+
+ if (webhooksProxy) {
+ const customerId = process.env.IFRAME_TENANT?.replace('vpaas-magic-cookie-', '');
+ const liveStreamEvent: {
+ customerId: string;
+ eventType: string;
+ } = await webhooksProxy.waitForEvent('RECORDING_ENDED');
+
+ expect('RECORDING_ENDED').toBe(liveStreamEvent.eventType);
+ expect(liveStreamEvent.customerId).toBe(customerId);
+
+ const recordingUploadedEvent: {
+ customerId: string;
+ data: {
+ initiatorId: string;
+ participants: Array<string>;
+ };
+ eventType: string;
+ } = await webhooksProxy.waitForEvent('RECORDING_UPLOADED', 20000);
+
+ const jwtPayload = ctx.data[`${p1.name}-jwt-payload`];
+
+ expect(recordingUploadedEvent.data.initiatorId).toBe(jwtPayload?.context?.user?.id);
+ expect(recordingUploadedEvent.data.participants.some(
+ // @ts-ignore
+ e => e.id === jwtPayload?.context?.user?.id)).toBe(true);
+
+ webhooksProxy?.clearCache();
+ }
+
+ const statusEvent = (await p1.getIframeAPI().getEventResult('recordingStatusChanged'));
+
+ expect(statusEvent.mode).toBe('file');
+ expect(statusEvent.on).toBe(false);
+
+ await p1.getIframeAPI().clearEventResults('recordingStatusChanged');
+}
diff --git a/tests/wdio.firefox.conf.ts b/tests/wdio.firefox.conf.ts
index edcd1ab5ad..830ddd17e3 100644
--- a/tests/wdio.firefox.conf.ts
+++ b/tests/wdio.firefox.conf.ts
@@ -23,6 +23,7 @@ const ffExcludes = [
'specs/2way/iFrameApiParticipantsPresence.spec.ts', // FF does not support uploading files (uploadFile)
'specs/2way/iFrameApiTranscriptions.spec.ts',
'specs/alone/iFrameApiInvite.spec.ts',
+ 'specs/alone/iFrameApiRecording.spec.ts',
// FF does not support setting a file as mic input, no dominant speaker events
'specs/3way/activeSpeaker.spec.ts',