ov-components: improve stream detection logic in stream UI tests to handle timing races and ensure accurate local participant status

pull/856/head
Carlos Santos 2025-11-14 12:15:52 +01:00
parent bea3b8e70a
commit 19a5c21162
1 changed files with 18 additions and 4 deletions

View File

@ -682,11 +682,25 @@ describe('Stream UI controls and interaction features', () => {
await browser.switchTo().window(tabs[0]);
await utils.waitForElement('.OV_stream.remote.speaking');
expect(await utils.getNumberOfElements('.OV_stream.remote.speaking')).toEqual(1);
// Ensure at least one remote speaker element is present (timing-sensitive)
expect(await utils.getNumberOfElements('.OV_stream.remote.speaking')).toBeGreaterThanOrEqual(1);
// Check only one element is marked as speaker due to the local participant is muted
await utils.waitForElement('.OV_stream.speaking');
expect(await utils.getNumberOfElements('.OV_stream.speaking')).toEqual(1);
// 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
// or removed slightly later.
const timeout = 2000;
const interval = 200;
const start = Date.now();
let localNotSpeaking = false;
while (Date.now() - start < timeout) {
const localCount = await utils.getNumberOfElements('.OV_stream.local.speaking');
if (localCount === 0) {
localNotSpeaking = true;
break;
}
await browser.sleep(interval);
}
expect(localNotSpeaking).toBeTrue();
});
});