Files
jitsi-meet/react/features/base/testing/functions.ts

123 lines
4.2 KiB
TypeScript
Raw Normal View History

import { IReduxState, IStore } from '../../app/types';
import { isTrackStreamingStatusActive } from '../../connection-indicator/functions';
import { handleToggleVideoMuted } from '../../toolbox/actions.any';
import { muteLocal } from '../../video-menu/actions.any';
import { MEDIA_TYPE, VIDEO_TYPE } from '../media/constants';
import { getParticipantById, isScreenShareParticipant } from '../participants/functions';
import {
getLocalVideoTrack,
getTrackByMediaTypeAndParticipant,
getVideoTrackByParticipant
} from '../tracks/functions';
/**
* Indicates whether the test mode is enabled. When it's enabled
* {@link TestHint} and other components from the testing package will be
* rendered in various places across the app to help with automatic testing.
*
* @param {IReduxState} state - The redux store state.
* @returns {boolean}
*/
export function isTestModeEnabled(state: IReduxState): boolean {
const testingConfig = state['features/base/config'].testing;
return Boolean(testingConfig?.testMode);
}
/**
* Returns the video type of the remote participant's video.
*
* @param {IStore} store - The redux store.
* @param {string} id - The participant ID for the remote video.
* @returns {VIDEO_TYPE}
*/
export function getRemoteVideoType({ getState }: IStore, id: string) {
const state = getState();
const participant = getParticipantById(state, id);
if (isScreenShareParticipant(participant)) {
return VIDEO_TYPE.DESKTOP;
}
return getTrackByMediaTypeAndParticipant(state['features/base/tracks'], MEDIA_TYPE.VIDEO, id)?.videoType;
}
/**
* Returns whether the last media event received for large video indicates that the video is playing, if not muted.
*
* @param {IStore} store - The redux store.
* @returns {boolean}
*/
export function isLargeVideoReceived({ getState }: IStore): boolean {
const state = getState();
const largeVideoParticipantId = state['features/large-video'].participantId ?? '';
const largeVideoParticipant = getParticipantById(state, largeVideoParticipantId ?? '');
const videoTrack = getVideoTrackByParticipant(state, largeVideoParticipant);
return Boolean(videoTrack && !videoTrack.muted && isTrackStreamingStatusActive(videoTrack));
}
/**
Reorganize tests by feature, minor test updates (#16518) * test: Move lockRoom under moderation/. * ref: Cleanup lockRoom test. * test: Move lockRoomDigitsOnly to ui/. * test: Add a setPasswordAvailable expectation. * ref: Move the lobby test to moderation/. * test: Move tests to media/. * test: Add a useTenant expectation. * test: Move mute to media/. * test: Move audioOnly to media/. * test: Move startMuted to media/. * test: Move codecSelection to media/. * ref: Simplify, log the "actual" codec value. * test: Move stopVideo to media/. * test: Move videoLayout to ui/. * test: Move chatPanel to ui/. * test: Move switchVideo to media/pinning.spec.ts. * test: Move audioVideoModeration to media/. * test: Move displayName to ui/. * test: Move preJoin to ui/. * test: Move endConference to ui/. * test: Move selfView to ui/. * test: Move oneOnOne to ui/. * test: Move tileView to ui/. * test: Move singlePort and udp to misc/connectivity.spec.ts. * test: Move avatars to misc/. * test: Move polls to misc/. * test: Move breakoutRooms to misc/. * test: Move followMe to misc/. * test: Move invite to dial/dialInUi.spec.ts. * test: Move dialInAudio to dial/dialIn.spec.ts. * test: Only log expectations in the main wdio process. * test: Move fakeDialInAudio to dial/. * test: Move subject to misc/. * test: Check for subject set remotely. * test: Remove references to "2way", "3way". * test: Consolidate all dial-in tests in one file. * test: Move dialIn to misc/. * test: Adjust test titles. * Remove waitForAudioFromDialInParticipant test.
2025-10-09 14:11:20 -05:00
* Returns the local video track's codec.
*
Reorganize tests by feature, minor test updates (#16518) * test: Move lockRoom under moderation/. * ref: Cleanup lockRoom test. * test: Move lockRoomDigitsOnly to ui/. * test: Add a setPasswordAvailable expectation. * ref: Move the lobby test to moderation/. * test: Move tests to media/. * test: Add a useTenant expectation. * test: Move mute to media/. * test: Move audioOnly to media/. * test: Move startMuted to media/. * test: Move codecSelection to media/. * ref: Simplify, log the "actual" codec value. * test: Move stopVideo to media/. * test: Move videoLayout to ui/. * test: Move chatPanel to ui/. * test: Move switchVideo to media/pinning.spec.ts. * test: Move audioVideoModeration to media/. * test: Move displayName to ui/. * test: Move preJoin to ui/. * test: Move endConference to ui/. * test: Move selfView to ui/. * test: Move oneOnOne to ui/. * test: Move tileView to ui/. * test: Move singlePort and udp to misc/connectivity.spec.ts. * test: Move avatars to misc/. * test: Move polls to misc/. * test: Move breakoutRooms to misc/. * test: Move followMe to misc/. * test: Move invite to dial/dialInUi.spec.ts. * test: Move dialInAudio to dial/dialIn.spec.ts. * test: Only log expectations in the main wdio process. * test: Move fakeDialInAudio to dial/. * test: Move subject to misc/. * test: Check for subject set remotely. * test: Remove references to "2way", "3way". * test: Consolidate all dial-in tests in one file. * test: Move dialIn to misc/. * test: Adjust test titles. * Remove waitForAudioFromDialInParticipant test.
2025-10-09 14:11:20 -05:00
* @returns {string?} The local video track's codec.
*/
Reorganize tests by feature, minor test updates (#16518) * test: Move lockRoom under moderation/. * ref: Cleanup lockRoom test. * test: Move lockRoomDigitsOnly to ui/. * test: Add a setPasswordAvailable expectation. * ref: Move the lobby test to moderation/. * test: Move tests to media/. * test: Add a useTenant expectation. * test: Move mute to media/. * test: Move audioOnly to media/. * test: Move startMuted to media/. * test: Move codecSelection to media/. * ref: Simplify, log the "actual" codec value. * test: Move stopVideo to media/. * test: Move videoLayout to ui/. * test: Move chatPanel to ui/. * test: Move switchVideo to media/pinning.spec.ts. * test: Move audioVideoModeration to media/. * test: Move displayName to ui/. * test: Move preJoin to ui/. * test: Move endConference to ui/. * test: Move selfView to ui/. * test: Move oneOnOne to ui/. * test: Move tileView to ui/. * test: Move singlePort and udp to misc/connectivity.spec.ts. * test: Move avatars to misc/. * test: Move polls to misc/. * test: Move breakoutRooms to misc/. * test: Move followMe to misc/. * test: Move invite to dial/dialInUi.spec.ts. * test: Move dialInAudio to dial/dialIn.spec.ts. * test: Only log expectations in the main wdio process. * test: Move fakeDialInAudio to dial/. * test: Move subject to misc/. * test: Check for subject set remotely. * test: Remove references to "2way", "3way". * test: Consolidate all dial-in tests in one file. * test: Move dialIn to misc/. * test: Adjust test titles. * Remove waitForAudioFromDialInParticipant test.
2025-10-09 14:11:20 -05:00
export function getLocalCameraEncoding({ getState }: IStore): string | undefined {
return getLocalVideoTrack(getState()['features/base/tracks'])?.codec?.toLowerCase();
}
/**
* Returns whether the last media event received for a remote video indicates that the video is playing, if not muted.
*
* @param {IStore} store - The redux store.
* @param {string} id - The participant ID for the remote video.
* @returns {boolean}
*/
export function isRemoteVideoReceived({ getState }: IStore, id: string): boolean {
const state = getState();
const participant = getParticipantById(state, id);
const videoTrack = getVideoTrackByParticipant(state, participant);
return Boolean(videoTrack && !videoTrack.muted && isTrackStreamingStatusActive(videoTrack));
}
/**
* Mutes the local audio. Same as clicking the audio mute button.
*
* @param {IStore} store - The redux store.
* @returns {Promise} Resolves when the action is complete.
*/
export function audioMute({ dispatch }: IStore) {
return dispatch(muteLocal(true, MEDIA_TYPE.AUDIO));
}
/**
* Unmutes the local audio. Same as clicking the audio unmute button.
*
* @param {IStore} store - The redux store.
* @returns {Promise} Resolves when the action is complete.
*/
export function audioUnmute({ dispatch }: IStore) {
return dispatch(muteLocal(false, MEDIA_TYPE.AUDIO));
}
/**
* Mutes the local video. Same as clicking the video mute button.
*
* @param {IStore} store - The redux store.
* @returns {Promise} Resolves when the action is complete.
*/
export function videoMute({ dispatch }: IStore) {
return dispatch(handleToggleVideoMuted(true, true, true));
}
/**
* Unmutes the local video. Same as clicking the video unmute button.
*
* @param {IStore} store - The redux store.
* @returns {Promise} Resolves when the action is complete.
*/
export function videoUnmute({ dispatch }: IStore) {
return dispatch(handleToggleVideoMuted(false, true, true));
}