Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.
TypeScript debiandeep-videojitsijitsi-meetscalable-video-conferencessfuvideovideo-communicationvideo-conferencingwebrtc
fix(filmstrip) Ensures dominant speaker is always visible in filmstrip (#16901)
Jaya Allamsettybde8dca8256b
diff --git a/react/features/base/participants/functions.ts b/react/features/base/participants/functions.tsindex 4ce216ed81..0d87053857 100644--- a/react/features/base/participants/functions.ts+++ b/react/features/base/participants/functions.ts@@ -60,66 +60,6 @@ const AVATAR_CHECKER_FUNCTIONS = [return null;}];-/* eslint-enable arrow-body-style */--/**- * Returns the list of active speakers that should be moved to the top of the sorted list of participants so that the- * dominant speaker is visible always on the vertical filmstrip in stage layout.- *- * @param {Function | Object} stateful - The (whole) redux state, or redux's {@code getState} function to be used to- * retrieve the state.- * @returns {Array<string>}- */-export function getActiveSpeakersToBeDisplayed(stateful: IStateful) {- const state = toState(stateful);- const {- dominantSpeaker,- fakeParticipants,- sortedRemoteVirtualScreenshareParticipants,- speakersList- } = state['features/base/participants'];- const { visibleRemoteParticipants } = state['features/filmstrip'];- let activeSpeakers = new Map(speakersList);-- // Do not re-sort the active speakers if dominant speaker is currently visible.- if (dominantSpeaker && visibleRemoteParticipants.has(dominantSpeaker)) {- return activeSpeakers;- }- let availableSlotsForActiveSpeakers = visibleRemoteParticipants.size;-- if (activeSpeakers.has(dominantSpeaker ?? '')) {- activeSpeakers.delete(dominantSpeaker ?? '');- }-- // Add dominant speaker to the beginning of the list (not including self) since the active speaker list is always- // alphabetically sorted.- if (dominantSpeaker && dominantSpeaker !== getLocalParticipant(state)?.id) {- const updatedSpeakers = Array.from(activeSpeakers);-- updatedSpeakers.splice(0, 0, [ dominantSpeaker, getParticipantById(state, dominantSpeaker)?.name ?? '' ]);- activeSpeakers = new Map(updatedSpeakers);- }-- // Remove screenshares from the count.- if (sortedRemoteVirtualScreenshareParticipants) {- availableSlotsForActiveSpeakers -= sortedRemoteVirtualScreenshareParticipants.size * 2;- for (const screenshare of Array.from(sortedRemoteVirtualScreenshareParticipants.keys())) {- const ownerId = getVirtualScreenshareParticipantOwnerId(screenshare as string);-- activeSpeakers.delete(ownerId);- }- }-- // Remove fake participants from the count.- if (fakeParticipants) {- availableSlotsForActiveSpeakers -= fakeParticipants.size;- }- const truncatedSpeakersList = Array.from(activeSpeakers).slice(0, availableSlotsForActiveSpeakers);-- truncatedSpeakersList.sort((a: any, b: any) => a[1].localeCompare(b[1]));-- return new Map(truncatedSpeakersList);-}/*** Resolves the first loadable avatar URL for a participant.diff --git a/react/features/base/participants/reducer.ts b/react/features/base/participants/reducer.tsindex f4c89f2f9b..773b2f9d60 100644--- a/react/features/base/participants/reducer.ts+++ b/react/features/base/participants/reducer.ts@@ -68,6 +68,7 @@ const PARTICIPANT_PROPS_TO_OMIT_WHEN_UPDATE = [];const DEFAULT_STATE = {+ activeSpeakers: new Set<string>(),dominantSpeaker: undefined,fakeParticipants: new Map(),local: undefined,@@ -82,10 +83,10 @@ const DEFAULT_STATE = {remoteVideoSources: new Set<string>(),sortedRemoteVirtualScreenshareParticipants: new Map(),sortedRemoteParticipants: new Map(),- speakersList: new Map()};export interface IParticipantsState {+ activeSpeakers: Set<string>;dominantSpeaker?: string;fakeParticipants: Map<string, IParticipant>;local?: ILocalParticipant;@@ -100,7 +101,6 @@ export interface IParticipantsState {remoteVideoSources: Set<string>;sortedRemoteParticipants: Map<string, string>;sortedRemoteVirtualScreenshareParticipants: Map<string, string>;- speakersList: Map<string, string>;}/**@@ -157,22 +157,7 @@ ReducerRegistry.register<IParticipantsState>('features/base/participants',const { participant } = action;const { id, previousSpeakers = [] } = participant;const { dominantSpeaker, local } = state;- const newSpeakers = [ id, ...previousSpeakers ];- const sortedSpeakersList: Array<Array<string>> = [];-- for (const speaker of newSpeakers) {- if (speaker !== local?.id) {- const remoteParticipant = state.remote.get(speaker);-- remoteParticipant- && sortedSpeakersList.push(- [ speaker, _getDisplayName(state, remoteParticipant?.name) ]- );- }- }-- // Keep the remote speaker list sorted alphabetically.- sortedSpeakersList.sort((a, b) => a[1].localeCompare(b[1]));+ const activeSpeakers = new Set(previousSpeakers.filter((speakerId: string) => speakerId !== local?.id));// Only one dominant speaker is allowed.if (dominantSpeaker) {@@ -183,7 +168,7 @@ ReducerRegistry.register<IParticipantsState>('features/base/participants',return {...state,dominantSpeaker: id, // @ts-ignore- speakersList: new Map(sortedSpeakersList)+ activeSpeakers};}@@ -438,7 +423,7 @@ ReducerRegistry.register<IParticipantsState>('features/base/participants',}// Remove the participant from the list of speakers.- state.speakersList.has(id) && state.speakersList.delete(id);+ state.activeSpeakers.delete(id);if (pinnedParticipant === id) {state.pinnedParticipant = undefined;diff --git a/react/features/filmstrip/functions.any.ts b/react/features/filmstrip/functions.any.tsindex 9bd4a6e1f4..1b086fa0eb 100644--- a/react/features/filmstrip/functions.any.ts+++ b/react/features/filmstrip/functions.any.ts@@ -1,8 +1,5 @@import { IReduxState, IStore } from '../app/types';-import {- getActiveSpeakersToBeDisplayed,- getVirtualScreenshareParticipantOwnerId-} from '../base/participants/functions';+import { getParticipantById, getVirtualScreenshareParticipantOwnerId } from '../base/participants/functions';import { setRemoteParticipants } from './actions';import { isFilmstripScrollVisible } from './functions';@@ -33,44 +30,66 @@ export function updateRemoteParticipants(store: IStore, force?: boolean, partici}const {+ activeSpeakers,+ dominantSpeaker,fakeParticipants,sortedRemoteParticipants} = state['features/base/participants'];+ const config = state['features/base/config'];+ const defaultRemoteDisplayName = config?.defaultRemoteDisplayName ?? 'Fellow Jitster';+ const dominant = dominantSpeaker ? getParticipantById(state, dominantSpeaker) : undefined;+ let dominantSpeakerSlot = 0;+ const previousSpeakers = new Set(activeSpeakers);const remoteParticipants = new Map(sortedRemoteParticipants);const screenShareParticipants = sortedRemoteVirtualScreenshareParticipants? [ ...sortedRemoteVirtualScreenshareParticipants.keys() ] : [];const sharedVideos = fakeParticipants ? Array.from(fakeParticipants.keys()) : [];- const speakers = getActiveSpeakersToBeDisplayed(state);+ const speakers = new Array<string>();+ const { visibleRemoteParticipants } = state['features/filmstrip'];- for (const screenshare of screenShareParticipants) {+ const participantsWithScreenShare = screenShareParticipants.reduce<string[]>((acc, screenshare) => {const ownerId = getVirtualScreenshareParticipantOwnerId(screenshare);+ acc.push(ownerId);+ acc.push(screenshare);remoteParticipants.delete(ownerId);remoteParticipants.delete(screenshare);- speakers.delete(ownerId);- }+ previousSpeakers.delete(ownerId);++ return acc;+ }, []);for (const sharedVideo of sharedVideos) {remoteParticipants.delete(sharedVideo);}- for (const speaker of speakers.keys()) {- remoteParticipants.delete(speaker);- }- // Always update the order of the thubmnails.- const participantsWithScreenShare = screenShareParticipants.reduce<string[]>((acc, screenshare) => {- const ownerId = getVirtualScreenshareParticipantOwnerId(screenshare);-- acc.push(ownerId);- acc.push(screenshare);+ if (dominant && !dominant.local && participantsWithScreenShare.indexOf(dominant.id) === -1) {+ dominantSpeakerSlot = 1;+ remoteParticipants.delete(dominant.id);+ speakers.push(dominant.id);+ }- return acc;- }, []);+ // Find the number of slots available for speakers.+ const slotsForSpeakers+ = visibleRemoteParticipants.size - (screenShareParticipants.length * 2) - sharedVideos.length - dominantSpeakerSlot;++ // Construct the list of speakers to be shown.+ if (slotsForSpeakers > 0) {+ Array.from(previousSpeakers).slice(0, slotsForSpeakers).forEach((speakerId: string) => {+ speakers.push(speakerId);+ remoteParticipants.delete(speakerId);+ });+ speakers.sort((a: string, b: string) => {+ return (getParticipantById(state, a)?.name ?? defaultRemoteDisplayName)+ .localeCompare(getParticipantById(state, b)?.name ?? defaultRemoteDisplayName);+ });+ }+ // Always update the order of the thumbnails.reorderedParticipants = [...participantsWithScreenShare,...sharedVideos,- ...Array.from(speakers.keys()),+ ...speakers,...Array.from(remoteParticipants.keys())];diff --git a/tests/helpers/Participant.ts b/tests/helpers/Participant.tsindex e2c24fe589..f420d5d78b 100644--- a/tests/helpers/Participant.ts+++ b/tests/helpers/Participant.ts@@ -35,6 +35,8 @@ export const P1 = 'p1';export const P2 = 'p2';export const P3 = 'p3';export const P4 = 'p4';+export const P5 = 'p5';+export const P6 = 'p6';/*** Participant.diff --git a/tests/helpers/participants.ts b/tests/helpers/participants.tsindex 8009948be1..ba733e02b5 100644--- a/tests/helpers/participants.ts+++ b/tests/helpers/participants.ts@@ -1,4 +1,4 @@-import { P1, P2, P3, P4, Participant } from './Participant';+import { P1, P2, P3, P4, P5, P6, Participant } from './Participant';import { config } from './TestsConfig';import { IJoinOptions, IParticipantOptions } from './types';@@ -122,6 +122,50 @@ export async function ensureFourParticipants(options?: IJoinOptions): Promise<vo]);}+/**+ * Ensure that there are six participants.+ *+ * @param {IJoinOptions} options - The options to use when joining the participant.+ * @returns {Promise<void>}+ */+export async function ensureSixParticipants(options?: IJoinOptions): Promise<void> {+ await ensureOneParticipant(options);++ // Join participants in batches+ await Promise.all([+ joinParticipant({ name: P2 }, options),+ joinParticipant({ name: P3 }, options),+ joinParticipant({ name: P4 }, options)+ ]);++ await Promise.all([+ joinParticipant({ name: P5 }, options),+ joinParticipant({ name: P6 }, options)+ ]);++ if (options?.skipInMeetingChecks) {+ return Promise.resolve();+ }++ await Promise.all([+ ctx.p1.waitForIceConnected(),+ ctx.p2.waitForIceConnected(),+ ctx.p3.waitForIceConnected(),+ ctx.p4.waitForIceConnected(),+ ctx.p5.waitForIceConnected(),+ ctx.p6.waitForIceConnected()+ ]);+ await Promise.all([+ ctx.p1.waitForSendReceiveData().then(() => ctx.p1.waitForRemoteStreams(1)),+ ctx.p2.waitForSendReceiveData().then(() => ctx.p2.waitForRemoteStreams(1)),+ ctx.p3.waitForSendReceiveData().then(() => ctx.p3.waitForRemoteStreams(1)),+ ctx.p4.waitForSendReceiveData().then(() => ctx.p4.waitForRemoteStreams(1)),+ ctx.p5.waitForSendReceiveData().then(() => ctx.p5.waitForRemoteStreams(1)),+ ctx.p6.waitForSendReceiveData().then(() => ctx.p6.waitForRemoteStreams(1))+ ]);+}++/*** Ensure that there are two participants.*@@ -244,10 +288,16 @@ export async function checkForScreensharingTile(sharer: Participant, observer: P}/**- * Hangs up all participants (p1, p2, p3 and p4)+ * Hangs up all participants (p1, p2, p3, p4, p5, and p6)* @returns {Promise<void>}*/export function hangupAllParticipants() {- return Promise.all([ ctx.p1?.hangup(), ctx.p2?.hangup(), ctx.p3?.hangup(), ctx.p4?.hangup() ]- .map(p => p ?? Promise.resolve()));+ return Promise.all([+ ctx.p1?.hangup(),+ ctx.p2?.hangup(),+ ctx.p3?.hangup(),+ ctx.p4?.hangup(),+ ctx.p5?.hangup(),+ ctx.p6?.hangup()+ ].map(p => p ?? Promise.resolve()));}diff --git a/tests/helpers/types.ts b/tests/helpers/types.tsindex 9463459e3f..159cf31595 100644--- a/tests/helpers/types.ts+++ b/tests/helpers/types.ts@@ -7,13 +7,16 @@ import { IToken, ITokenOptions } from './token';export type IContext = {/**- * The up-to-four browser instances provided by the framework. These can be initialized using+ * The up-to-six browser instances provided by the framework. These can be initialized using* ensureOneParticipant, ensureTwoParticipants, etc. from participants.ts.**/p1: Participant;p2: Participant;p3: Participant;p4: Participant;+ p5: Participant;+ p6: Participant;+/** A room name automatically generated by the framework for convenience. */roomName: string;/**@@ -39,7 +42,7 @@ export type IParticipantOptions = {/** Whether it should use the iFrame API. */iFrameApi?: boolean;/** Determines the browser instance to use. */- name: 'p1' | 'p2' | 'p3' | 'p4';+ name: 'p1' | 'p2' | 'p3' | 'p4' | 'p5' | 'p6';/** An optional token to use. */token?: IToken;};diff --git a/tests/specs/media/activeSpeaker.spec.ts b/tests/specs/media/activeSpeaker.spec.tsindex 8a59fe2cb2..7451cfb3e6 100644--- a/tests/specs/media/activeSpeaker.spec.ts+++ b/tests/specs/media/activeSpeaker.spec.ts@@ -1,16 +1,20 @@import type { Participant } from '../../helpers/Participant';import { setTestProperties } from '../../helpers/TestProperties';-import { ensureThreeParticipants } from '../../helpers/participants';+import {+ checkForScreensharingTile,+ ensureSixParticipants,+ ensureThreeParticipants,+ hangupAllParticipants+} from '../../helpers/participants';import { muteAudioAndCheck } from '../helpers/mute';setTestProperties(__filename, {- usesBrowsers: [ 'p1', 'p2', 'p3' ]+ usesBrowsers: [ 'p1', 'p2', 'p3', 'p4', 'p5', 'p6' ]});describe('Active speaker', () => {it('testActiveSpeaker', async () => {await ensureThreeParticipants();-const { p1, p2, p3 } = ctx;await muteAudioAndCheck(p1, p2);@@ -30,6 +34,306 @@ describe('Active speaker', () => {await assertOneDominantSpeaker(p1);await assertOneDominantSpeaker(p2);await assertOneDominantSpeaker(p3);++ await hangupAllParticipants();+ });++ /**+ * Test that the dominant speaker appears in the filmstrip in stage view+ * even when alphabetically last with limited visible slots.+ * This tests the fix for the bug where dominant speakers at the bottom of+ * the alphabetically sorted list would not appear when slots were limited.+ *+ * Note: This test verifies filmstrip ordering via Redux state+ * (visibleRemoteParticipants), not large video behavior.+ */+ it.skip('testDominantSpeakerInFilmstripWithLimitedSlots', async () => {+ await ensureSixParticipants({+ configOverwrite: {+ startWithAudioMuted: true+ }+ });+ const { p1, p2, p3, p4, p5, p6 } = ctx;++ // Resize p1's window to limit filmstrip slots to 2-3 tiles+ // This creates the condition where not all participants fit in the filmstrip+ await p1.driver.setWindowSize(1024, 600);+ await p1.driver.pause(1000); // Wait for layout to adjust++ // Set display names to create alphabetical ordering+ // Names chosen so p6 ("Zoe") is alphabetically last: Alice, Bob, Charlie, Eve, Frank, Zoe+ await setAlphabeticalDisplayNames(p1, p2, p3, p4, p5, p6);++ // Test with multiple speakers: Eve (p4), Frank (p5), and Zoe (p6)+ // This verifies the fix works for different alphabetical positions+ const speakersToTest = [+ { participant: p4, name: 'Eve' },+ { participant: p5, name: 'Frank' },+ { participant: p6, name: 'Zoe' }+ ];++ for (const { participant, name } of speakersToTest) {+ const participantId = await participant.getEndpointId();++ await p1.log(`Testing ${name} (${participantId}) as dominant speaker`);++ // Make this participant the dominant speaker by unmuting+ await participant.getToolbar().clickAudioUnmuteButton();++ // Wait for the dominant speaker to be detected+ await waitForDominantSpeaker(p1, participantId, name);++ // Verify that the participant appears in the visible remote participants+ const filmstripState = await getFilmstripState(p1);++ await p1.log(`Dominant speaker: ${filmstripState.dominantSpeaker}`);+ await p1.log(`Visible remote participants: ${JSON.stringify(filmstripState.visibleRemoteParticipants)}`);+ await p1.log(`${name} endpoint ID: ${participantId}`);+ await p1.log(`Total remote: ${filmstripState.remoteParticipants.length}, Visible: ${filmstripState.visibleRemoteParticipants.length}`);++ // Verify we actually have slot limitation (fewer visible than total)+ expect(filmstripState.visibleRemoteParticipants.length).toBeLessThan(filmstripState.remoteParticipants.length);++ // Assert that the dominant speaker is in the visible participants+ // This is the key test - even though they may be alphabetically late and slots are limited,+ // they should still be visible because the fix reserves a slot for dominant speaker+ expect(filmstripState.visibleRemoteParticipants).toContain(participantId);++ // Verify the dominant speaker thumbnail is visible in the filmstrip+ await p1.driver.$(`//span[@id='participant_${participantId}']`).waitForDisplayed({+ timeout: 5_000,+ timeoutMsg: `${name} dominant speaker thumbnail not visible in filmstrip`+ });++ // Mute this participant back before testing the next one+ await participant.getToolbar().clickAudioMuteButton();+ await p1.driver.pause(2000);+ }++ await hangupAllParticipants();+ });++ /**+ * Test dominant speaker in filmstrip with screensharing active.+ * Verifies that dominant speaker is still visible when screen shares+ * take up some of the visible slots.+ */+ it.skip('testDominantSpeakerWithScreensharing', async () => {+ await ensureSixParticipants({+ configOverwrite: {+ startWithAudioMuted: true+ }+ });+ const { p1, p2, p3, p4, p5, p6 } = ctx;++ // Resize p1's window to limit filmstrip slots+ await p1.driver.setWindowSize(1024, 600);+ await p1.driver.pause(1000); // Wait for layout to adjust++ // Set display names+ await setAlphabeticalDisplayNames(p1, p2, p3, p4, p5, p6);++ // Start screensharing from p2+ await p2.getToolbar().clickDesktopSharingButton();+ await checkForScreensharingTile(p2, p1);++ // Test with multiple speakers while screensharing is active+ const speakersToTest = [+ { participant: p4, name: 'Eve' },+ { participant: p5, name: 'Frank' },+ { participant: p6, name: 'Zoe' }+ ];++ for (const { participant, name } of speakersToTest) {+ const participantId = await participant.getEndpointId();++ await p1.log(`Testing ${name} (${participantId}) as dominant speaker with screensharing`);++ // Make this participant the dominant speaker by unmuting+ await participant.getToolbar().clickAudioUnmuteButton();++ // Wait for the dominant speaker to be detected+ await waitForDominantSpeaker(p1, participantId, name);++ // Verify dominant speaker is still visible in filmstrip despite screenshare+ const filmstripState = await getFilmstripState(p1);++ await p1.log(`Dominant speaker (with screenshare): ${filmstripState.dominantSpeaker}`);+ await p1.log(`Visible remote participants with screenshare: ${JSON.stringify(filmstripState.visibleRemoteParticipants)}`);+ await p1.log(`${name} endpoint ID: ${participantId}`);+ await p1.log(`Total remote: ${filmstripState.remoteParticipants.length}, Visible: ${filmstripState.visibleRemoteParticipants.length}`);++ // Verify we have slot limitation even with screensharing+ expect(filmstripState.visibleRemoteParticipants.length).toBeLessThan(filmstripState.remoteParticipants.length);++ // The dominant speaker should still be in the visible participants despite screenshare taking slots+ expect(filmstripState.visibleRemoteParticipants).toContain(participantId);++ // Verify thumbnail visibility+ await p1.driver.$(`//span[@id='participant_${participantId}']`).waitForDisplayed({+ timeout: 5_000,+ timeoutMsg: `${name} not visible with screensharing active`+ });++ // Mute this participant back before testing the next one+ await participant.getToolbar().clickAudioMuteButton();+ await p1.driver.pause(1000);+ }++ // Clean up - stop screensharing+ await p2.getToolbar().clickStopDesktopSharingButton();++ await hangupAllParticipants();+ });++ /**+ * Test that filmstrip maintains stable ordering when multiple speakers alternate.+ * Verifies that the alphabetical sorting prevents visual reordering when the same+ * set of speakers take turns speaking.+ */+ it.skip('testFilmstripStableOrderingWithMultipleSpeakers', async () => {+ await ensureSixParticipants({+ configOverwrite: {+ startWithAudioMuted: true+ }+ });+ const { p1, p2, p3, p4, p5, p6 } = ctx;++ // Resize p1's window to limit filmstrip slots+ await p1.driver.setWindowSize(1024, 600);+ await p1.driver.pause(1000); // Wait for layout to adjust++ // Set display names+ await setAlphabeticalDisplayNames(p1, p2, p3, p4, p5, p6);++ // First, have Eve, Frank, and Zoe all speak to get them into the active speakers list+ const speakersToTest = [+ { participant: p4, name: 'Eve' },+ { participant: p5, name: 'Frank' },+ { participant: p6, name: 'Zoe' }+ ];++ await p1.log('Initial round: getting all three speakers into active speakers list');++ for (const { participant, name } of speakersToTest) {+ const participantId = await participant.getEndpointId();++ await p1.log(`${name} (${participantId}) speaking for the first time`);+ await participant.getToolbar().clickAudioUnmuteButton();+ await waitForDominantSpeaker(p1, participantId, name);+ await participant.getToolbar().clickAudioMuteButton();+ await p1.driver.pause(1000);+ }++ // Now cycle through them again and verify they maintain alphabetical order (Eve, Frank, Zoe)+ await p1.log('Second round: verifying stable alphabetical ordering when speakers alternate');++ const states = [];++ for (const { participant, name } of speakersToTest) {+ const participantId = await participant.getEndpointId();++ await p1.log(`Testing ${name} (${participantId}) for stable ordering`);++ // Make this participant the dominant speaker+ await participant.getToolbar().clickAudioUnmuteButton();++ // Wait for the dominant speaker to be detected+ await waitForDominantSpeaker(p1, participantId, name);++ // Capture filmstrip state+ const filmstripState = await getFilmstripState(p1);++ states.push({ name, id: participantId, state: filmstripState });++ // Mute back+ await participant.getToolbar().clickAudioMuteButton();+ await p1.driver.pause(1000);+ }++ const [ eveState, frankState, zoeState ] = states;++ // Helper function to get participant names in the order they appear+ const getVisibleParticipantNames = async (visibleIds: string[]) => {+ return await p1.execute(ids => {+ const state = APP.store.getState();+ const participants = state['features/base/participants'];++ return ids.map(id => {+ const participant = participants.remote.get(id);++ return participant?.name || 'Unknown';+ });+ }, visibleIds);+ };++ // Get the names of visible participants for each state+ const eveVisibleNames = await getVisibleParticipantNames(eveState.state.visibleRemoteParticipants);+ const frankVisibleNames = await getVisibleParticipantNames(frankState.state.visibleRemoteParticipants);+ const zoeVisibleNames = await getVisibleParticipantNames(zoeState.state.visibleRemoteParticipants);++ await p1.log(`Visible participants when Eve is dominant: ${JSON.stringify(eveVisibleNames)}`);+ await p1.log(`Visible participants when Frank is dominant: ${JSON.stringify(frankVisibleNames)}`);+ await p1.log(`Visible participants when Zoe is dominant: ${JSON.stringify(zoeVisibleNames)}`);++ await p1.log(`Eve visible count: ${eveState.state.visibleRemoteParticipants.length}, total remote: ${eveState.state.remoteParticipants.length}`);+ await p1.log(`Frank visible count: ${frankState.state.visibleRemoteParticipants.length}, total remote: ${frankState.state.remoteParticipants.length}`);+ await p1.log(`Zoe visible count: ${zoeState.state.visibleRemoteParticipants.length}, total remote: ${zoeState.state.remoteParticipants.length}`);++ // Verify that each dominant speaker appears in visible participants+ expect(eveState.state.visibleRemoteParticipants).toContain(eveState.id);+ expect(frankState.state.visibleRemoteParticipants).toContain(frankState.id);+ expect(zoeState.state.visibleRemoteParticipants).toContain(zoeState.id);++ // Helper function to get the relative order of Eve, Frank, and Zoe+ const getSpeakersOrder = (names: string[]) => {+ return names.filter(n => [ 'Eve', 'Frank', 'Zoe' ].includes(n));+ };++ const eveOrder = getSpeakersOrder(eveVisibleNames);+ const frankOrder = getSpeakersOrder(frankVisibleNames);+ const zoeOrder = getSpeakersOrder(zoeVisibleNames);++ await p1.log(`Speakers order when Eve is dominant: ${JSON.stringify(eveOrder)}`);+ await p1.log(`Speakers order when Frank is dominant: ${JSON.stringify(frankOrder)}`);+ await p1.log(`Speakers order when Zoe is dominant: ${JSON.stringify(zoeOrder)}`);++ // Verify that the dominant speaker is always in the visible list (this tests the bug fix)+ expect(eveOrder).toContain('Eve');+ expect(frankOrder).toContain('Frank');+ expect(zoeOrder).toContain('Zoe');++ // Helper to check if array is alphabetically sorted+ const isAlphabeticallySorted = (names: string[]) => {+ for (let i = 0; i < names.length - 1; i++) {+ if (names[i].localeCompare(names[i + 1]) > 0) {+ return false;+ }+ }++ return true;+ };++ // Verify that whatever speakers ARE visible maintain alphabetical order+ // This is the key test - when the same speakers alternate, visible speakers stay in alphabetical order+ expect(isAlphabeticallySorted(eveOrder)).toBe(true);+ expect(isAlphabeticallySorted(frankOrder)).toBe(true);+ expect(isAlphabeticallySorted(zoeOrder)).toBe(true);++ // Additionally verify order consistency: if multiple speakers are visible in multiple states,+ // their relative order should be the same+ // For example, if Eve and Frank are both visible when Zoe speaks, they should be [Eve, Frank]+ if (eveOrder.includes('Frank') && frankOrder.includes('Eve')) {+ // Both Eve and Frank visible in both states+ const eveAndFrankInEveState = eveOrder.filter(n => [ 'Eve', 'Frank' ].includes(n));+ const eveAndFrankInFrankState = frankOrder.filter(n => [ 'Eve', 'Frank' ].includes(n));++ expect(eveAndFrankInEveState).toEqual(eveAndFrankInFrankState);+ }++ await p1.log('Filmstrip maintains alphabetical ordering of visible speakers when dominant speaker changes');++ await hangupAllParticipants();});});@@ -95,3 +399,81 @@ async function assertOneDominantSpeaker(participant: Participant) {expect(await participant.driver.$$('//span[not(contains(@class, "tile-view"))]//span[contains(@class,"dominant-speaker")]').length).toBe(1);}++/**+ * Wait for a participant to be detected as the dominant speaker.+ *+ * @param {Participant} observer - The participant observing the dominant speaker state.+ * @param {string} participantId - The endpoint ID of the expected dominant speaker.+ * @param {string} participantName - The name of the participant for logging.+ */+async function waitForDominantSpeaker(+ observer: Participant,+ participantId: string,+ participantName: string+): Promise<void> {+ await observer.driver.waitUntil(+ async () => {+ const state = await observer.execute(() => {+ const participants = APP.store.getState()['features/base/participants'];++ return participants.dominantSpeaker;+ });++ return state === participantId;+ },+ {+ timeout: 10000,+ timeoutMsg: `${participantName} (${participantId}) was not detected as dominant speaker within 10 seconds`+ }+ );++ // Wait a bit more for filmstrip state to update after dominant speaker changes+ await observer.driver.pause(1000);+}++/**+ * Get the current filmstrip state from Redux.+ *+ * @param {Participant} participant - The participant to query.+ * @returns {Promise<FilmstripState>} The filmstrip state.+ */+async function getFilmstripState(participant: Participant): Promise<{+ dominantSpeaker: string | null;+ remoteParticipants: string[];+ visibleRemoteParticipants: string[];+}> {+ return await participant.execute(() => {+ const state = APP.store.getState();+ const filmstrip = state['features/filmstrip'];+ const participants = state['features/base/participants'];++ return {+ dominantSpeaker: participants.dominantSpeaker,+ remoteParticipants: filmstrip.remoteParticipants,+ visibleRemoteParticipants: Array.from(filmstrip.visibleRemoteParticipants)+ };+ });+}++/**+ * Set display names for all 6 participants to create alphabetical ordering.+ */+async function setAlphabeticalDisplayNames(+ p1: Participant,+ p2: Participant,+ p3: Participant,+ p4: Participant,+ p5: Participant,+ p6: Participant+): Promise<void> {+ await p1.setLocalDisplayName('Alice');+ await p2.setLocalDisplayName('Bob');+ await p3.setLocalDisplayName('Charlie');+ await p4.setLocalDisplayName('Eve');+ await p5.setLocalDisplayName('Frank');+ await p6.setLocalDisplayName('Zoe');++ // Wait for display names to propagate+ await p1.driver.pause(2000);+}diff --git a/tests/wdio.conf.ts b/tests/wdio.conf.tsindex 8000ab3a82..62862b7631 100644--- a/tests/wdio.conf.ts+++ b/tests/wdio.conf.ts@@ -68,7 +68,7 @@ const specs = [*/function generateCapabilitiesFromSpecs(): Record<string, any> {const allSpecFiles: string[] = [];- const browsers = [ 'p1', 'p2', 'p3', 'p4' ];+ const browsers = [ 'p1', 'p2', 'p3', 'p4', 'p5', 'p6' ];for (const pattern of specs) {const matches = glob.sync(pattern, { cwd: path.join(__dirname) });@@ -87,7 +87,9 @@ function generateCapabilitiesFromSpecs(): Record<string, any> {p1: new Set(),p2: new Set(),p3: new Set(),- p4: new Set()+ p4: new Set(),+ p5: new Set(),+ p6: new Set()};for (const file of allSpecFiles) {