From 86882112774024292efa3e5e26af62cf88d3bff0 Mon Sep 17 00:00:00 2001 From: Carlos Santos <4a.santos@gmail.com> Date: Fri, 14 Nov 2025 13:44:02 +0100 Subject: [PATCH] ov-components: Improve audio detection in stream UI tests to handle timing issues with retries --- .../e2e/stream.test.ts | 25 +++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/openvidu-components-angular/e2e/stream.test.ts b/openvidu-components-angular/e2e/stream.test.ts index e8c9972a4..6f8cd83ec 100644 --- a/openvidu-components-angular/e2e/stream.test.ts +++ b/openvidu-components-angular/e2e/stream.test.ts @@ -681,9 +681,27 @@ describe('Stream UI controls and interaction features', () => { await browser.switchTo().window(tabs[0]); - await utils.waitForElement('.OV_stream.remote.speaking'); + // Wait with retries for audio detection to appear (handles timing issues) + const maxRetries = 5; + const retryInterval = 1000; + let audioDetected = false; + + for (let i = 0; i < maxRetries && !audioDetected; i++) { + await browser.sleep(retryInterval); + const remoteSpeakingCount = await utils.getNumberOfElements('.OV_stream.remote.speaking'); + if (remoteSpeakingCount >= 1) { + audioDetected = true; + console.log(`[Audio Detection] Detected after ${i + 1} attempt(s)`); + } else { + console.log(`[Audio Detection] Attempt ${i + 1}/${maxRetries}: No audio detected yet`); + } + } + // Ensure at least one remote speaker element is present (timing-sensitive) - expect(await utils.getNumberOfElements('.OV_stream.remote.speaking')).toBeGreaterThanOrEqual(1); + expect(audioDetected).toBeTrue(); + if (!audioDetected) { + console.error('Audio detection indicator did not appear within timeout'); + } // The local participant is muted; poll briefly to ensure the local stream is not // marked as speaking. This handles timing races where classes may be applied @@ -701,6 +719,9 @@ describe('Stream UI controls and interaction features', () => { await browser.sleep(interval); } expect(localNotSpeaking).toBeTrue(); + if (!localNotSpeaking) { + console.error('Local stream should not be marked as speaking when muted'); + } }); });