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 lastN test.
damenchoc8a7877fddd2
diff --git a/tests/helpers/Participant.ts b/tests/helpers/Participant.tsindex 52d17c903f..7630d9af61 100644--- a/tests/helpers/Participant.ts+++ b/tests/helpers/Participant.ts@@ -339,6 +339,30 @@ export class Participant {});}+ /**+ * Waits for send and receive data.+ *+ * @returns {Promise<void>}+ */+ async waitForSendData(+ timeout = 15_000, msg = `expected to send data in 15s for ${this.name}`): Promise<void> {+ const driver = this.driver;++ return driver.waitUntil(async () =>+ await driver.execute(() => {+ const stats = APP.conference.getStats();+ const bitrateMap = stats?.bitrate || {};+ const rtpStats = {+ uploadBitrate: bitrateMap.upload || 0+ };++ return rtpStats.uploadBitrate > 0;+ }), {+ timeout,+ timeoutMsg: msg+ });+ }+/*** Waits for remote streams.*@@ -351,7 +375,7 @@ export class Participant {return driver.waitUntil(async () =>await driver.execute(count => APP.conference.getNumberOfParticipantsWithTracks() >= count, number), {timeout: 15_000,- timeoutMsg: `expected remote streams in 15s for ${this.name}`+ timeoutMsg: `expected number of remote streams:${number} in 15s for ${this.name}`});}@@ -617,4 +641,30 @@ export class Participant {async isLeaveReasonDialogOpen() {return await this.driver.$(`div[data-testid="dialog.leaveReason"]`).isDisplayed();}++ /**+ * Waits for remote video state - receiving and displayed.+ * @param endpointId+ */+ async waitForRemoteVideo(endpointId: string) {+ await this.driver.waitUntil(async () =>+ await this.driver.execute(epId => JitsiMeetJS.app.testing.isRemoteVideoReceived(`${epId}`),+ endpointId) && await this.driver.$(+ `//span[@id="participant_${endpointId}" and contains(@class, "display-video")]`).isExisting(), {+ timeout: 15_000,+ timeoutMsg: `expected remote video for ${endpointId} to be received 15s by ${this.name}`+ });+ }++ /**+ * Waits for ninja icon to be displayed.+ * @param endpointId+ */+ async waitForNinjaIcon(endpointId: string) {+ await this.driver.$(`//span[@id='participant_${endpointId}']//span[@class='connection_ninja']`)+ .waitForDisplayed({+ timeout: 15_000,+ timeoutMsg: `expected ninja icon for ${endpointId} to be displayed in 15s by ${this.name}`+ });+ }}diff --git a/tests/specs/4way/desktopSharing.spec.ts b/tests/specs/4way/desktopSharing.spec.tsindex 0c693536d7..f1665445c9 100644--- a/tests/specs/4way/desktopSharing.spec.ts+++ b/tests/specs/4way/desktopSharing.spec.ts@@ -296,49 +296,20 @@ describe('Desktop sharing - ', () => {expect(await p4.driver.execute(() => JitsiMeetJS.app.testing.isLargeVideoReceived())).toBe(true);const p1EndpointId = await p1.getEndpointId();+ const p2EndpointId = await p2.getEndpointId();// p4 has lastN=2 and has selected p3. With p2 being dominant speaker p4 should eventually// see video for [p3, p2] and p1 as ninja.- await p4.driver.$(`//span[@id='participant_${p1EndpointId}']//span[@class='connection_ninja']`)- .waitForDisplayed({- timeout: 15_000- });-- const p2EndpointId = await p2.getEndpointId();-- await p4.driver.waitUntil(async () =>- await p4.driver.execute(epId => JitsiMeetJS.app.testing.isRemoteVideoReceived(`${epId}`),- p2EndpointId) && await p4.driver.$(- `//span[@id="participant_${p2EndpointId}" and contains(@class, "display-video")]`).isExisting(), {- timeout: 15_000,- timeoutMsg: 'expected remote video to be received 15s'- });-- await p4.driver.waitUntil(async () =>- await p4.driver.execute(epId => JitsiMeetJS.app.testing.isRemoteVideoReceived(`${epId}`),- p2EndpointId) && await p4.driver.$(- `//span[@id="participant_${p2EndpointId}" and contains(@class, "display-video")]`).isExisting(), {- timeout: 15_000,- timeoutMsg: 'expected remote video to be received 15s'- });+ await p4.waitForNinjaIcon(p1EndpointId);+ await p4.waitForRemoteVideo(p2EndpointId);// Let's switch and check, muting participant 2 and unmuting 1 will leave participant 1 as dominantawait p1.getToolbar().clickAudioUnmuteButton();await p2.getToolbar().clickAudioMuteButton();// Participant4 should eventually see video for [p3, p1] and p2 as a ninja.- await p4.driver.$(`//span[@id='participant_${p2EndpointId}']//span[@class='connection_ninja']`)- .waitForDisplayed({- timeout: 15_000- });-- await p4.driver.waitUntil(async () =>- await p4.driver.execute(epId => JitsiMeetJS.app.testing.isRemoteVideoReceived(`${epId}`),- p1EndpointId) && await p4.driver.$(- `//span[@id="participant_${p1EndpointId}" and contains(@class, "display-video")]`).isExisting(), {- timeout: 15_000,- timeoutMsg: 'expected remote video to be received 15s'- });+ await p4.waitForNinjaIcon(p2EndpointId);+ await p4.waitForRemoteVideo(p1EndpointId);});});diff --git a/tests/specs/4way/lastN.spec.ts b/tests/specs/4way/lastN.spec.tsnew file mode 100644index 0000000000..fcbe9649e0--- /dev/null+++ b/tests/specs/4way/lastN.spec.ts@@ -0,0 +1,73 @@+import { ensureFourParticipants, ensureThreeParticipants, ensureTwoParticipants } from '../../helpers/participants';++describe('lastN - ', () => {+ it('joining the meeting', async () => {+ await ensureTwoParticipants(ctx, {+ skipInMeetingChecks: true,+ configOverwrite: {+ startWithAudioMuted: true,+ startWithVideoMuted: true,+ channelLastN: 1+ }+ });++ await ensureThreeParticipants(ctx, {+ skipInMeetingChecks: true,+ configOverwrite: {+ channelLastN: 1+ }+ });+ });++ it('checks', async () => {+ const { p3 } = ctx;+ const p3Toolbar = p3.getToolbar();++ await p3.waitForSendData();++ await ctx.p1.waitForRemoteVideo(await p3.getEndpointId());++ // Mute audio on participant3.+ await p3Toolbar.clickAudioMuteButton();++ await ensureFourParticipants(ctx, {+ skipInMeetingChecks: true,+ configOverwrite: {+ channelLastN: 1+ }+ });++ const { p1, p2, p4 } = ctx;++ await p4.waitForSendReceiveData();++ // Mute audio on p4 and unmute p3.+ await p4.getToolbar().clickAudioMuteButton();+ await p3Toolbar.clickAudioUnmuteButton();++ const p4EndpointId = await p4.getEndpointId();+ const p3EndpointId = await p3.getEndpointId();++ // Check if p1 starts receiving video from p3 and p4 shows up as ninja.+ await p1.waitForNinjaIcon(p4EndpointId);+ await p1.waitForRemoteVideo(p3EndpointId);++ // At this point, mute video of p3 and others should be receiving p4's video.+ // Mute p1's video+ await p3Toolbar.clickVideoMuteButton();+ await p3.getParticipantsPane().assertVideoMuteIconIsDisplayed(p3);+ await p1.getParticipantsPane().assertVideoMuteIconIsDisplayed(p3);+ await p1.waitForRemoteVideo(p4EndpointId);++ // Unmute p3's video and others should switch to receiving p3's video.+ await p3Toolbar.clickVideoUnmuteButton();+ await p1.waitForRemoteVideo(p3EndpointId);+ await p1.waitForNinjaIcon(p4EndpointId);++ // Mute p3's audio and unmute p2's audio. Other endpoints should continue to receive video from p3+ // even though p2 is the dominant speaker.+ await p3Toolbar.clickAudioMuteButton();+ await p2.getToolbar().clickAudioUnmuteButton();+ await p1.waitForRemoteVideo(p3EndpointId);+ });+});