Skip to content

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

test: Check for send/receive independently. (#16356)

bgrozevdac9b5e24496
diff --git a/tests/helpers/Participant.ts b/tests/helpers/Participant.ts
index a328cca216..07b712f766 100644
--- a/tests/helpers/Participant.ts
+++ b/tests/helpers/Participant.ts
@@ -37,13 +37,6 @@ export const P2 = 'p2';
export const P3 = 'p3';
export const P4 = 'p4';
-interface IWaitForSendReceiveDataOptions {
- checkReceive?: boolean;
- checkSend?: boolean;
- msg?: string;
- timeout?: number;
-}
-
/**
* Participant.
*/
@@ -425,37 +418,50 @@ export class Participant {
}
/**
- * Waits for send and receive data.
+ * Waits until the conference stats show positive upload and download bitrate (independently).
*
- * @param {Object} options
- * @param {boolean} options.checkSend - If true we will chec
* @returns {Promise<boolean>}
*/
- waitForSendReceiveData({
- checkSend = true,
- checkReceive = true,
- timeout = 15_000,
- msg
- } = {} as IWaitForSendReceiveDataOptions): Promise<boolean> {
- if (!checkSend && !checkReceive) {
- return Promise.resolve(true);
- }
+ async waitForSendReceiveData(timeout = 15_000, msg?: string): Promise<boolean> {
+ const values = await Promise.all([
+ await this.waitForSendMedia(timeout, msg ? `${msg} (send)` : undefined),
+ await this.waitForReceiveMedia(timeout, msg ? `${msg} (receive)` : undefined)
+ ]);
- const lMsg = msg ?? `expected to ${
- checkSend && checkReceive ? 'receive/send' : checkSend ? 'send' : 'receive'} data in 15s for ${this.name}`;
+ return values[0] && values[1];
+ }
- return this.driver.waitUntil(() => this.execute((pCheckSend: boolean, pCheckReceive: boolean) => {
- const stats = APP?.conference?.getStats();
- const bitrateMap = stats?.bitrate || {};
- const rtpStats = {
- uploadBitrate: bitrateMap.upload || 0,
- downloadBitrate: bitrateMap.download || 0
- };
+ /**
+ * Waits until the conference stats show positive upload bitrate.
+ * @param timeout max time to wait in ms
+ * @param timeoutMsg the message to log if the timeout is reached
+ */
+ async waitForSendMedia(
+ timeout = 15_000,
+ timeoutMsg = `expected to send media in ${timeout / 1000}s for ${this.name}`): Promise<boolean> {
+
+ return this.driver.waitUntil(() => this.execute(() => {
+ return APP?.conference?.getStats()?.bitrate?.upload > 0;
+ }), {
+ timeout,
+ timeoutMsg
+ });
+ }
+
+ /**
+ * Waits until the conference stats show positive upload bitrate.
+ * @param timeout max time to wait in ms
+ * @param timeoutMsg the message to log if the timeout is reached
+ */
+ async waitForReceiveMedia(
+ timeout = 15_000,
+ timeoutMsg = `expected to receive media in ${timeout / 1000}s for ${this.name}`): Promise<boolean> {
- return (rtpStats.uploadBitrate > 0 || !pCheckSend) && (rtpStats.downloadBitrate > 0 || !pCheckReceive);
- }, checkSend, checkReceive), {
+ return this.driver.waitUntil(() => this.execute(() => {
+ return APP?.conference?.getStats()?.bitrate?.download > 0;
+ }), {
timeout,
- timeoutMsg: lMsg
+ timeoutMsg
});
}
diff --git a/tests/specs/2way/mute.spect.ts b/tests/specs/2way/mute.spect.ts
index dfaab3a4e2..bc02265c55 100644
--- a/tests/specs/2way/mute.spect.ts
+++ b/tests/specs/2way/mute.spect.ts
@@ -116,7 +116,7 @@ async function muteP1BeforeP2JoinsAndScreenshare(p2p: boolean) {
await p2.waitForIceConnected();
}
- await p2.waitForSendReceiveData({ checkReceive: false });
+ await p2.waitForSendMedia();
// Check if p1 appears video muted on p2.
await p2.getParticipantsPane().assertVideoMuteIconIsDisplayed(p1);
diff --git a/tests/specs/3way/startMuted.spec.ts b/tests/specs/3way/startMuted.spec.ts
index 99e1ea0a64..2a42848076 100644
--- a/tests/specs/3way/startMuted.spec.ts
+++ b/tests/specs/3way/startMuted.spec.ts
@@ -53,7 +53,7 @@ describe('StartMuted', () => {
const p2EndpointId = await p2.getEndpointId();
await p2.waitForIceConnected();
- await p2.waitForSendReceiveData({ checkSend: false });
+ await p2.waitForReceiveMedia();
await p2.getFilmstrip().assertAudioMuteIconIsDisplayed(p2);
await p2.getParticipantsPane().assertVideoMuteIconIsDisplayed(p2);
@@ -88,7 +88,7 @@ describe('StartMuted', () => {
const { p3 } = ctx;
await p3.waitForIceConnected();
- await p3.waitForSendReceiveData({ checkSend: false });
+ await p3.waitForReceiveMedia();
await p3.getFilmstrip().assertAudioMuteIconIsDisplayed(p2, true);
await p3.getParticipantsPane().assertVideoMuteIconIsDisplayed(p2, true);
@@ -118,7 +118,7 @@ describe('StartMuted', () => {
const { p2 } = ctx;
await p2.waitForIceConnected();
- await p2.waitForSendReceiveData({ checkSend: false });
+ await p2.waitForReceiveMedia();
await joinThirdParticipant({
...options,
@@ -128,7 +128,7 @@ describe('StartMuted', () => {
const { p3 } = ctx;
await p3.waitForIceConnected();
- await p3.waitForSendReceiveData({ checkSend: false });
+ await p3.waitForReceiveMedia();
const { p1 } = ctx;
@@ -240,7 +240,7 @@ describe('StartMuted', () => {
const { p1, p2 } = ctx;
await p2.waitForIceConnected();
- await p2.waitForSendReceiveData({ checkReceive: false });
+ await p2.waitForSendMedia();
await p2.waitForAudioMuted(p1, true);
await p2.getParticipantsPane().assertVideoMuteIconIsDisplayed(p1);
diff --git a/tests/specs/4way/lastN.spec.ts b/tests/specs/4way/lastN.spec.ts
index e2f5cea735..5188068c13 100644
--- a/tests/specs/4way/lastN.spec.ts
+++ b/tests/specs/4way/lastN.spec.ts
@@ -23,7 +23,7 @@ describe('lastN', () => {
const { p3 } = ctx;
const p3Toolbar = p3.getToolbar();
- await p3.waitForSendReceiveData({ checkReceive: false });
+ await p3.waitForSendMedia();
await ctx.p1.waitForRemoteVideo(await p3.getEndpointId());
diff --git a/tests/specs/helpers/DialIn.ts b/tests/specs/helpers/DialIn.ts
index e7453c8861..00722c2ddd 100644
--- a/tests/specs/helpers/DialIn.ts
+++ b/tests/specs/helpers/DialIn.ts
@@ -24,10 +24,7 @@ export async function waitForAudioFromDialInParticipant(participant: Participant
await participant.waitForIceConnected();
await participant.waitForRemoteStreams(1);
- await participant.waitForSendReceiveData({
- timeout: 20_000,
- msg: 'dial-in.test.jigasi.participant.no.audio.after.join'
- });
+ 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.`);
}
diff --git a/tests/specs/iframe/visitors.spec.ts b/tests/specs/iframe/visitors.spec.ts
index ca69290cdc..b7b4271b02 100644
--- a/tests/specs/iframe/visitors.spec.ts
+++ b/tests/specs/iframe/visitors.spec.ts
@@ -47,10 +47,8 @@ describe('Visitors', () => {
const { p1, p2, webhooksProxy } = ctx;
- await p2.waitForSendReceiveData({
- checkSend: false,
- msg: 'Visitor is not receiving media'
- }).then(() => p2.waitForRemoteStreams(1));
+ await p2.waitForReceiveMedia(15_000, 'Visitor is not receiving media');
+ await p2.waitForRemoteStreams(1);
const p2Visitors = p2.getVisitors();
const p1Visitors = p1.getVisitors();
diff --git a/tests/specs/iframe/visitorsLive.spec.ts b/tests/specs/iframe/visitorsLive.spec.ts
index ce0d79b1e3..7e151861b8 100644
--- a/tests/specs/iframe/visitorsLive.spec.ts
+++ b/tests/specs/iframe/visitorsLive.spec.ts
@@ -67,11 +67,8 @@ describe('Visitors', () => {
await p1Visitors.goLive();
await p2.waitToJoinMUC();
-
- await p2.waitForSendReceiveData({
- checkSend: false,
- msg: 'Visitor is not receiving media'
- }).then(() => p2.waitForRemoteStreams(1));
+ await p2.waitForReceiveMedia(15000, 'Visitor is not receiving media');
+ await p2.waitForRemoteStreams(1);
await p2.driver.waitUntil(() => p2Visitors.hasVisitorsDialog(), {
timeout: 5000,