mirror of https://github.com/OpenVidu/openvidu.git
ov-components: improve stream detection logic in stream UI tests to handle timing races and ensure accurate local participant status
parent
bea3b8e70a
commit
19a5c21162
|
|
@ -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();
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue