bigbluebutton-Github/bigbluebutton-html5/imports/ui/components/audio/audio-controls/component.jsx
Mohamed Amine Ben Salah d8c5aa46d9
multiple automated tests suites updates + add missing polling specs and move them with old ones to a polling test suite (#10766)
* updating old tests + collecting more snapshots [WIP]

* updates old test suites and collects more visual regressions screenshots

* remove snapshots and their collection temporary

* run tests from packages.json

* update test execution command/export constants from .env to core/constants.js

* update tests/puppeteer/README.md file

* update LOOP_INTERVAL variable call and assign timeouts to the webcam share spec

* redefine waitForSelector func in page.js, update chat test suite specs and add poll chat message test spec

* Merge remote-tracking branch 'upstream/develop' into updating-old-tests-visual-with-visual-regressions

* update webcam test specs collecting videoPreviewTimeout and use it to wait for videoPreview selector

* update custom parameters test suite

* update breakout test suite

* update webcam layout test suite

* update multiusers test suite

* update notifications test suite

* update presentation test suite

* whiteboard test suite

* screenshare test suite

* update sharednotes test suite

* user ELEMENT_WAIT_TIME variable from timeouts constants.js

* list TEST CONSTANTS by category

* add poll test suite and assigns the right unassigned timeouts

* set test pages to headless
2021-02-16 15:57:10 -05:00

138 lines
4.1 KiB
JavaScript
Executable File

import React, { PureComponent } from 'react';
import PropTypes from 'prop-types';
import cx from 'classnames';
import { defineMessages, injectIntl } from 'react-intl';
import Button from '/imports/ui/components/button/component';
import getFromUserSettings from '/imports/ui/services/users-settings';
import withShortcutHelper from '/imports/ui/components/shortcut-help/service';
import MutedAlert from '/imports/ui/components/muted-alert/component';
import { styles } from './styles';
const intlMessages = defineMessages({
joinAudio: {
id: 'app.audio.joinAudio',
description: 'Join audio button label',
},
leaveAudio: {
id: 'app.audio.leaveAudio',
description: 'Leave audio button label',
},
muteAudio: {
id: 'app.actionsBar.muteLabel',
description: 'Mute audio button label',
},
unmuteAudio: {
id: 'app.actionsBar.unmuteLabel',
description: 'Unmute audio button label',
},
});
const propTypes = {
processToggleMuteFromOutside: PropTypes.func.isRequired,
handleToggleMuteMicrophone: PropTypes.func.isRequired,
handleJoinAudio: PropTypes.func.isRequired,
handleLeaveAudio: PropTypes.func.isRequired,
disable: PropTypes.bool.isRequired,
muted: PropTypes.bool.isRequired,
showMute: PropTypes.bool.isRequired,
inAudio: PropTypes.bool.isRequired,
listenOnly: PropTypes.bool.isRequired,
intl: PropTypes.object.isRequired,
talking: PropTypes.bool.isRequired,
};
class AudioControls extends PureComponent {
componentDidMount() {
const { processToggleMuteFromOutside } = this.props;
if (Meteor.settings.public.allowOutsideCommands.toggleSelfVoice
|| getFromUserSettings('bbb_outside_toggle_self_voice', false)) {
window.addEventListener('message', processToggleMuteFromOutside);
}
}
render() {
const {
handleToggleMuteMicrophone,
handleJoinAudio,
handleLeaveAudio,
showMute,
muted,
disable,
talking,
inAudio,
listenOnly,
intl,
shortcuts,
isVoiceUser,
inputStream,
isViewer,
isPresenter,
} = this.props;
let joinIcon = 'audio_off';
if (inAudio) {
if (listenOnly) {
joinIcon = 'listen';
} else {
joinIcon = 'audio_on';
}
}
const label = muted ? intl.formatMessage(intlMessages.unmuteAudio)
: intl.formatMessage(intlMessages.muteAudio);
const toggleMuteBtn = (
<Button
className={cx(styles.muteToggle, !talking || styles.glow, !muted || styles.btn)}
onClick={handleToggleMuteMicrophone}
disabled={disable}
hideLabel
label={label}
aria-label={label}
color={!muted ? 'primary' : 'default'}
ghost={muted}
icon={muted ? 'mute' : 'unmute'}
size="lg"
circle
accessKey={shortcuts.togglemute}
/>
);
const MUTE_ALERT_CONFIG = Meteor.settings.public.app.mutedAlert;
const { enabled: muteAlertEnabled } = MUTE_ALERT_CONFIG;
return (
<span className={styles.container}>
{inputStream && muteAlertEnabled ? (
<MutedAlert {...{
muted, inputStream, isViewer, isPresenter,
}}
/>
) : null}
{showMute && isVoiceUser ? toggleMuteBtn : null}
<Button
className={cx(inAudio || styles.btn)}
onClick={inAudio ? handleLeaveAudio : handleJoinAudio}
disabled={disable}
data-test={inAudio ? 'leaveAudio' : 'joinAudio'}
hideLabel
aria-label={inAudio ? intl.formatMessage(intlMessages.leaveAudio)
: intl.formatMessage(intlMessages.joinAudio)}
label={inAudio ? intl.formatMessage(intlMessages.leaveAudio)
: intl.formatMessage(intlMessages.joinAudio)}
color={inAudio ? 'primary' : 'default'}
ghost={!inAudio}
icon={joinIcon}
size="lg"
circle
accessKey={inAudio ? shortcuts.leaveaudio : shortcuts.joinaudio}
/>
</span>
);
}
}
AudioControls.propTypes = propTypes;
export default withShortcutHelper(injectIntl(AudioControls), ['joinAudio', 'leaveAudio', 'toggleMute']);