Skip to content

Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.

fix(tests): Avoids being blocked by notification when clicking toolbar buttons

Дамян Минков486a1f6511ae
diff --git a/react/features/base/testing/functions.ts b/react/features/base/testing/functions.ts
index ffc18fb402..c2bc203b15 100644
--- a/react/features/base/testing/functions.ts
+++ b/react/features/base/testing/functions.ts
@@ -1,5 +1,7 @@
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 {
@@ -78,3 +80,43 @@ export function isRemoteVideoReceived({ getState }: IStore, id: string): boolean
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));
+}
diff --git a/react/features/base/testing/middleware.ts b/react/features/base/testing/middleware.ts
index bbece60550..395652350d 100644
--- a/react/features/base/testing/middleware.ts
+++ b/react/features/base/testing/middleware.ts
@@ -8,11 +8,15 @@ import { getJitsiMeetGlobalNS } from '../util/helpers';
import { setConnectionState } from './actions';
import {
+ audioMute,
+ audioUnmute,
getLocalCameraEncoding,
getRemoteVideoType,
isLargeVideoReceived,
isRemoteVideoReceived,
- isTestModeEnabled
+ isTestModeEnabled,
+ videoMute,
+ videoUnmute
} from './functions';
import logger from './logger';
@@ -85,10 +89,14 @@ function _bindTortureHelpers(store: IStore) {
// All torture helper methods go in here
getJitsiMeetGlobalNS().testing = {
+ audioMute: audioMute.bind(null, store),
+ audioUnmute: audioUnmute.bind(null, store),
getRemoteVideoType: getRemoteVideoType.bind(null, store),
isLargeVideoReceived: isLargeVideoReceived.bind(null, store),
getLocalCameraEncoding: getLocalCameraEncoding.bind(null, store),
- isRemoteVideoReceived: isRemoteVideoReceived.bind(null, store)
+ isRemoteVideoReceived: isRemoteVideoReceived.bind(null, store),
+ videoMute: videoMute.bind(null, store),
+ videoUnmute: videoUnmute.bind(null, store),
};
}
diff --git a/tests/pageobjects/Toolbar.ts b/tests/pageobjects/Toolbar.ts
index 8e4da99d18..39cdad2549 100644
--- a/tests/pageobjects/Toolbar.ts
+++ b/tests/pageobjects/Toolbar.ts
@@ -58,7 +58,12 @@ export default class Toolbar extends BasePageObject {
async clickAudioMuteButton(): Promise<void> {
await this.participant.log('Clicking on: Audio Mute Button');
- return this.audioMuteBtn.click();
+ await this.audioMuteBtn.waitForExist({
+ timeout: 2000, timeoutMsg: 'Audio mute button not found'
+ });
+
+ // not directly clicking the button to avoid issues of UI notifications preventing it
+ return this.participant.execute(() => JitsiMeetJS.app.testing.audioMute());
}
/**
@@ -69,7 +74,12 @@ export default class Toolbar extends BasePageObject {
async clickAudioUnmuteButton(): Promise<void> {
await this.participant.log('Clicking on: Audio Unmute Button');
- return this.audioUnMuteBtn.click();
+ await this.audioUnMuteBtn.waitForExist({
+ timeout: 2000, timeoutMsg: 'Audio unmute button not found'
+ });
+
+ // not directly clicking the button to avoid issues of UI notifications preventing it
+ return this.participant.execute(() => JitsiMeetJS.app.testing.audioUnmute());
}
/**
@@ -94,7 +104,12 @@ export default class Toolbar extends BasePageObject {
async clickVideoMuteButton(): Promise<void> {
await this.participant.log('Clicking on: Video Mute Button');
- return this.videoMuteBtn.click();
+ await this.videoMuteBtn.waitForExist({
+ timeout: 2000, timeoutMsg: 'Video mute button not found'
+ });
+
+ // not directly clicking the button to avoid issues of UI notifications preventing it
+ return this.participant.execute(() => JitsiMeetJS.app.testing.videoMute());
}
/**
@@ -105,7 +120,12 @@ export default class Toolbar extends BasePageObject {
async clickVideoUnmuteButton(): Promise<void> {
await this.participant.log('Clicking on: Video Unmute Button');
- return this.videoUnMuteBtn.click();
+ await this.videoUnMuteBtn.waitForExist({
+ timeout: 2000, timeoutMsg: 'Video unmute button not found'
+ });
+
+ // not directly clicking the button to avoid issues of UI notifications preventing it
+ return this.participant.execute(() => JitsiMeetJS.app.testing.videoUnmute());
}
/**