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: Clean-up transcription test. (#16991)

bgrozevdfd75ddc08b5
diff --git a/tests/helpers/Participant.ts b/tests/helpers/Participant.ts
index f420d5d78b..af2a856b6b 100644
--- a/tests/helpers/Participant.ts
+++ b/tests/helpers/Participant.ts
@@ -512,7 +512,7 @@ export class Participant {
}
/**
- * Waits until the number of participants is exactly the given number.
+ * Waits until the number of remote participants is exactly the given number.
*
* @param {number} number - The number of participant to wait for.
* @param {string} msg - A custom message to use.
@@ -520,7 +520,7 @@ export class Participant {
*/
waitForParticipants(number: number, msg?: string): Promise<boolean> {
return this.driver.waitUntil(
- () => this.execute(count => (APP?.conference?.listMembers()?.length ?? -1) === count, number),
+ () => this.execute(count => (window.APP?.conference?.listMembers()?.length ?? -1) === count, number),
{
timeout: 15_000,
timeoutMsg: msg || `not the expected participants ${number} in 15s for ${this.name}`
diff --git a/tests/specs/jaas/transcriptions.spec.ts b/tests/specs/jaas/transcriptions.spec.ts
index 235c1395c0..9455f220cd 100644
--- a/tests/specs/jaas/transcriptions.spec.ts
+++ b/tests/specs/jaas/transcriptions.spec.ts
@@ -19,6 +19,40 @@ for (const asyncTranscriptions of asyncTranscriptionValues) {
let p1: Participant, p2: Participant;
let webhooksProxy: WebhookProxy;
+ async function clearTranscriptionStatusChange() {
+ await p1.getIframeAPI().clearEventResults('transcribingStatusChanged');
+ await p2.getIframeAPI().clearEventResults('transcribingStatusChanged');
+ }
+
+ /**
+ * Wait until a transcribingStatusChanged iFrame event is received for both p1 and p2, with a specific value
+ * for the "on" field.
+ * Note that addEventListener for 'transcriptionChunkReceived' should have been called prior to this function.
+ */
+ async function waitForTranscriptionStatusChange(expectedOn: boolean) {
+ for (const p of [ p1, p2 ]) {
+ const event = await p.driver.waitUntil(
+ () => p.getIframeAPI().getEventResult('transcribingStatusChanged'),
+ {
+ timeout: 10000,
+ timeoutMsg: `transcribingStatusChanged event not received on ${p.name}`
+ });
+
+ if (event.on !== expectedOn) {
+ throw new Error(`Expected transcribing to be ${expectedOn} for ${p.name}, got ${event.on}`);
+ }
+ if (!expectedOn && !asyncTranscriptions) {
+ // The "stopped" event is sometimes fired before the jigasi participant leaves. If we re-start
+ // transcription before jigasi has left, jicofo will reject the request.
+ await p.switchToIFrame();
+ await p.waitForParticipants(
+ 1,
+ 'Unexpected number of participants. Jigasi failed to leave?');
+ await p.switchToMainFrame();
+ }
+ }
+ }
+
it('setup', async () => {
const room = ctx.roomName;
@@ -60,127 +94,60 @@ for (const asyncTranscriptions of asyncTranscriptionValues) {
expect(await p1.getIframeAPI().getEventResult('isModerator')).toBe(true);
expect(await p1.getIframeAPI().getEventResult('videoConferenceJoined')).toBeDefined();
- });
- it('toggle subtitles', async () => {
+ await p1.getIframeAPI().addEventListener('transcribingStatusChanged');
+ await p2.getIframeAPI().addEventListener('transcribingStatusChanged');
await p1.getIframeAPI().addEventListener('transcriptionChunkReceived');
await p2.getIframeAPI().addEventListener('transcriptionChunkReceived');
+
+ });
+
+ it('toggle subtitles', async () => {
+ await clearTranscriptionStatusChange();
await p1.getIframeAPI().executeCommand('toggleSubtitles');
+ await waitForTranscriptionStatusChange(true);
await checkReceivingChunks(p1, p2, webhooksProxy, asyncTranscriptions);
- await p1.getIframeAPI().clearEventResults('transcribingStatusChanged');
- await p1.getIframeAPI().addEventListener('transcribingStatusChanged');
- await p2.getIframeAPI().clearEventResults('transcribingStatusChanged');
- await p2.getIframeAPI().addEventListener('transcribingStatusChanged');
-
+ await clearTranscriptionStatusChange();
await p1.getIframeAPI().executeCommand('toggleSubtitles');
- await p1.driver.waitUntil(() => p1.getIframeAPI()
- .getEventResult('transcribingStatusChanged'), {
- timeout: 15000,
- timeoutMsg: 'transcribingStatusChanged event not received by p1'
- });
- // The p1 event can be triggered locally, resulting in the code below executing prematurely. Make sure
- // transcription is indeed stopped on the backend before proceeding.
- await p2.driver.waitUntil(() => p2.getIframeAPI()
- .getEventResult('transcribingStatusChanged'), {
- timeout: 15000,
- timeoutMsg: 'transcribingStatusChanged event not received by p1'
- });
+ await waitForTranscriptionStatusChange(false);
});
it('set subtitles on and off', async () => {
// we need to clear results or the last one will be used, from the previous time subtitles were on
+ await clearTranscriptionStatusChange();
await p1.getIframeAPI().clearEventResults('transcriptionChunkReceived');
await p2.getIframeAPI().clearEventResults('transcriptionChunkReceived');
webhooksProxy.clearCache();
await p1.getIframeAPI().executeCommand('setSubtitles', true, true);
+ await waitForTranscriptionStatusChange(true);
await checkReceivingChunks(p1, p2, webhooksProxy, asyncTranscriptions);
- await p1.getIframeAPI().clearEventResults('transcribingStatusChanged');
- await p1.getIframeAPI().addEventListener('transcribingStatusChanged');
- await p2.getIframeAPI().clearEventResults('transcribingStatusChanged');
- await p2.getIframeAPI().addEventListener('transcribingStatusChanged');
-
+ await clearTranscriptionStatusChange();
await p1.getIframeAPI().executeCommand('setSubtitles', false);
- await p1.driver.waitUntil(() => p1.getIframeAPI()
- .getEventResult('transcribingStatusChanged'), {
- timeout: 15000,
- timeoutMsg: 'transcribingStatusChanged event not received by p1'
- });
- // The p1 event can be triggered locally, resulting in the code below executing prematurely. Make sure
- // transcription is indeed stopped on the backend before proceeding.
- await p2.driver.waitUntil(() => p2.getIframeAPI()
- .getEventResult('transcribingStatusChanged'), {
- timeout: 15000,
- timeoutMsg: 'transcribingStatusChanged event not received by p1'
- });
+ await waitForTranscriptionStatusChange(false);
});
it('start/stop transcriptions via recording', async () => {
// we need to clear results or the last one will be used, from the previous time subtitles were on
- await p1.getIframeAPI().clearEventResults('transcribingStatusChanged');
await p1.getIframeAPI().clearEventResults('transcriptionChunkReceived');
await p2.getIframeAPI().clearEventResults('transcriptionChunkReceived');
-
- await p2.getIframeAPI().addEventListener('transcribingStatusChanged');
+ await clearTranscriptionStatusChange();
await p1.getIframeAPI().executeCommand('startRecording', { transcription: true });
- let allTranscriptionStatusChanged: Promise<any>[] = [];
-
- allTranscriptionStatusChanged.push(await p1.driver.waitUntil(() => p1.getIframeAPI()
- .getEventResult('transcribingStatusChanged'), {
- timeout: 10000,
- timeoutMsg: 'transcribingStatusChanged event not received on p1'
- }));
- allTranscriptionStatusChanged.push(await p2.driver.waitUntil(() => p2.getIframeAPI()
- .getEventResult('transcribingStatusChanged'), {
- timeout: 10000,
- timeoutMsg: 'transcribingStatusChanged event not received on p2'
- }));
-
- let result = await Promise.allSettled(allTranscriptionStatusChanged);
-
- expect(result.length).toBe(2);
-
- result.forEach(e => {
- // @ts-ignore
- expect(e.value.on).toBe(true);
- });
-
+ await waitForTranscriptionStatusChange(true);
await checkReceivingChunks(p1, p2, webhooksProxy, asyncTranscriptions);
- await p1.getIframeAPI().clearEventResults('transcribingStatusChanged');
- await p2.getIframeAPI().clearEventResults('transcribingStatusChanged');
-
+ await clearTranscriptionStatusChange();
await p1.getIframeAPI().executeCommand('stopRecording', 'file', true);
- allTranscriptionStatusChanged = [];
-
- allTranscriptionStatusChanged.push(await p1.driver.waitUntil(() => p1.getIframeAPI()
- .getEventResult('transcribingStatusChanged'), {
- timeout: 10000,
- timeoutMsg: 'transcribingStatusChanged event not received on p1'
- }));
- allTranscriptionStatusChanged.push(await p2.driver.waitUntil(() => p2.getIframeAPI()
- .getEventResult('transcribingStatusChanged'), {
- timeout: 10000,
- timeoutMsg: 'transcribingStatusChanged event not received on p2'
- }));
-
- result = await Promise.allSettled(allTranscriptionStatusChanged);
-
- expect(result.length).toBe(2);
-
- result.forEach(e => {
- // @ts-ignore
- expect(e.value.on).toBe(false);
- });
+ await waitForTranscriptionStatusChange(false);
await p1.getIframeAPI().executeCommand('hangup');
await p2.getIframeAPI().executeCommand('hangup');