test: Use timeout for expected codec changes. (#16539)

I suspect some intermittent test failures are caused by not waiting for
the codec change to complete. Might be exacerbated by
ensureThreeParticipants only waiting for 1 remote stream, which means
it the "ensureTwo(); ensureThree()" call may return before p2 sees p3.
This commit is contained in:
bgrozev
2025-10-14 09:20:30 -05:00
committed by GitHub
parent 683d6eb208
commit 657aefefc2

View File

@@ -1,4 +1,5 @@
import { VIDEO_CODEC } from '../../../react/features/video-quality/constants';
import { Participant } from '../../helpers/Participant';
import { setTestProperties } from '../../helpers/TestProperties';
import {
ensureOneParticipant,
@@ -39,8 +40,10 @@ describe('Codec selection', () => {
// Except on Firefox because it doesn't support VP9 encode.
const p1ExpectedCodec = p1.driver.isFirefox ? VP8 : VP9;
expect(await p1.execute(() => JitsiMeetJS.app.testing.getLocalCameraEncoding())).toBe(p1ExpectedCodec);
expect(await p2.execute(() => JitsiMeetJS.app.testing.getLocalCameraEncoding())).toBe(VP8);
await Promise.all([
waitForCodec(p1, p1ExpectedCodec),
waitForCodec(p2, VP8)
]);
});
it('asymmetric codecs with AV1', async () => {
@@ -62,16 +65,13 @@ describe('Codec selection', () => {
// Check if p1 is encoding in VP9, p2 in VP8 and p3 in AV1 as per their codec preferences.
// Except on Firefox because it doesn't support VP9 encode.
const p1ExpectedCodec = p1.driver.isFirefox ? VP8 : VP9;
const p3ExpectedCodec = (p1.driver.isFirefox && majorVersion < 136) ? VP9 : AV1;
expect(await p1.execute(() => JitsiMeetJS.app.testing.getLocalCameraEncoding())).toBe(p1ExpectedCodec);
expect(await p2.execute(() => JitsiMeetJS.app.testing.getLocalCameraEncoding())).toBe(VP8);
// If there is a Firefox ep in the call, all other eps will switch to VP9.
if (p1.driver.isFirefox && majorVersion < 136) {
expect(await p3.execute(() => JitsiMeetJS.app.testing.getLocalCameraEncoding())).toBe(VP9);
} else {
expect(await p3.execute(() => JitsiMeetJS.app.testing.getLocalCameraEncoding())).toBe(AV1);
}
await Promise.all([
waitForCodec(p1, p1ExpectedCodec),
waitForCodec(p2, VP8),
waitForCodec(p3, p3ExpectedCodec)
]);
});
it('codec switch over', async () => {
@@ -92,8 +92,10 @@ describe('Codec selection', () => {
}
// Check if p1 and p2 are encoding in VP9 which is the default codec.
expect(await p1.execute(() => JitsiMeetJS.app.testing.getLocalCameraEncoding())).toBe(VP9);
expect(await p2.execute(() => JitsiMeetJS.app.testing.getLocalCameraEncoding())).toBe(VP9);
await Promise.all([
waitForCodec(p1, VP9),
waitForCodec(p2, VP9)
]);
await ensureThreeParticipants({
configOverwrite: {
@@ -105,27 +107,28 @@ describe('Codec selection', () => {
});
const { p3 } = ctx;
// Check if all three participants are encoding in VP8 now.
expect(await p1.execute(() => JitsiMeetJS.app.testing.getLocalCameraEncoding())).toBe(VP8);
expect(await p2.execute(() => JitsiMeetJS.app.testing.getLocalCameraEncoding())).toBe(VP8);
expect(await p3.execute(() => JitsiMeetJS.app.testing.getLocalCameraEncoding())).toBe(VP8);
await Promise.all([
waitForCodec(p1, VP8),
waitForCodec(p2, VP8),
waitForCodec(p3, VP8)
]);
await p3.hangup();
// Check of p1 and p2 have switched to VP9.
await p1.driver.waitUntil(
() => p1.execute(c => JitsiMeetJS.app.testing.getLocalCameraEncoding() === c, VP9),
{
timeout: 10000,
timeoutMsg: 'p1 did not switch back to VP9'
}
);
await p2.driver.waitUntil(
() => p2.execute(c => JitsiMeetJS.app.testing.getLocalCameraEncoding() === c, VP9),
{
timeout: 10000,
timeoutMsg: 'p2 did not switch back to VP9'
}
);
await Promise.all([
waitForCodec(p1, VP9),
waitForCodec(p2, VP9)
]);
});
});
async function waitForCodec(p: Participant, codec: string) {
await p.driver.waitUntil(
() => p.execute(c => JitsiMeetJS.app.testing.getLocalCameraEncoding() === c, codec),
{
timeout: 10000,
timeoutMsg: `${p.name} failed to use VP8`
}
);
}