test: fix audio modal data-test props and audio tests related

This commit is contained in:
Anton B 2023-06-14 22:36:18 -03:00
parent 8c28449d3c
commit 9391ac2009
5 changed files with 58 additions and 35 deletions

View File

@ -1,17 +1,25 @@
import React, { useCallback, useEffect } from 'react';
import Styled from './styles';
const BaseModal = (props) => {
const { setIsOpen, modalName, children,
isOpen, onRequestClose, className, overlayClassName,
const BaseModal = (props) => {
const {
setIsOpen,
modalName,
children,
isOpen,
onRequestClose,
className,
overlayClassName,
dataTest,
priority,
} = props;
const closeEventHandler = useCallback (() => {
setIsOpen(false);
} , []);
useEffect( () => {
const closeEventHandler = useCallback(() => {
setIsOpen(false);
}, []);
useEffect(() => {
// Only add event listener if name is specified
if(!modalName) return;
if (!modalName) return;
const closeEventName = `CLOSE_MODAL_${modalName.toUpperCase()}`;
@ -23,18 +31,25 @@ const BaseModal = (props) => {
document.removeEventListener(closeEventName, closeEventHandler);
};
}, []);
const priority = props.priority ? props.priority : "low"
return (<Styled.BaseModal
portalClassName={`modal-${priority}`}
parentSelector={()=>document.querySelector('#modals-container')}
isOpen={isOpen}
onRequestClose={onRequestClose}
className={className}
overlayClassName={overlayClassName}
shouldReturnFocusAfterClose={false}
>
{children}
</Styled.BaseModal>
)}
const priorityValue = priority || 'low';
return (
<Styled.BaseModal
portalClassName={`modal-${priorityValue}`}
parentSelector={() => document.querySelector('#modals-container')}
isOpen={isOpen}
onRequestClose={onRequestClose}
className={className}
overlayClassName={overlayClassName}
shouldReturnFocusAfterClose={false}
data={{
test: dataTest,
}}
{...props}
>
{children}
</Styled.BaseModal>
);
};
export default { BaseModal };

View File

@ -84,9 +84,7 @@ class ModalSimple extends Component {
className={className}
onRequestClose={handleRequestClose}
contentLabel={title || contentLabel}
data={{
test: dataTest ?? null,
}}
dataTest={dataTest}
{...otherProps}
>
<Styled.Header

View File

@ -1,9 +1,8 @@
const Page = require('../core/page');
const e = require('../core/elements');
const { ELEMENT_WAIT_LONGER_TIME } = require('../core/constants');
const { connectMicrophone, isAudioItemSelected } = require('./util');
const { MultiUsers } = require('../user/multiusers');
const { getSettings, generateSettingsData } = require('../core/settings');
const { generateSettingsData } = require('../core/settings');
const { expect } = require('@playwright/test');
@ -53,8 +52,8 @@ class Audio extends MultiUsers {
async changeAudioInput() {
await this.modPage.waitAndClick(e.joinAudio);
await connectMicrophone(this.modPage);
await connectMicrophone(this.modPage);
await this.modPage.waitAndClick(e.audioDropdownMenu);
await isAudioItemSelected(this.modPage, e.defaultInputAudioDevice);
await this.modPage.waitAndClick(e.secondInputAudioDevice);
@ -67,8 +66,13 @@ class Audio extends MultiUsers {
async keepMuteStateOnRejoin() {
await this.modPage.waitAndClick(e.joinAudio);
await connectMicrophone(this.modPage);
await connectMicrophone(this.modPage);
const isMuted = await this.modPage.checkElement(e.unmuteMicButton);
if (isMuted) {
await this.modPage.waitAndClick(e.unmuteMicButton);
await this.modPage.hasElement(e.isTalking);
}
await this.modPage.waitAndClick(e.muteMicButton);
await this.modPage.hasElement(e.wasTalking);
await this.modPage.wasRemoved(e.muteMicButton);
@ -90,6 +94,11 @@ class Audio extends MultiUsers {
await this.modPage.waitAndClick(e.joinAudio);
await connectMicrophone(this.modPage);
const isMuted = await this.modPage.checkElement(e.unmuteMicButton);
if (isMuted) {
await this.modPage.waitAndClick(e.unmuteMicButton);
await this.modPage.hasElement(e.isTalking);
}
await this.modPage.waitAndClick(e.talkingIndicator);
await this.modPage.hasElement(e.wasTalking);
await this.modPage.wasRemoved(e.muteMicButton);

View File

@ -21,15 +21,15 @@ test.describe.serial('Audio', () => {
await audio.joinMicrophone();
});
test('Change audio input and keep it connected', async () => {
await audio.changeAudioInput();
});
// https://docs.bigbluebutton.org/2.6/release-tests.html#muteunmute
test('Mute yourself by clicking the mute button', async () => {
await audio.muteYourselfByButton();
});
test('Change audio input and keep it connected', async () => {
await audio.changeAudioInput();
});
// https://docs.bigbluebutton.org/2.6/release-tests.html#choosing-different-sources
test('Keep the last mute state after rejoining audio @ci', async () => {
await audio.keepMuteStateOnRejoin();

View File

@ -18,7 +18,8 @@ async function connectMicrophone(testPage) {
await testPage.waitForSelector(e.establishingAudioLabel);
await testPage.wasRemoved(e.establishingAudioLabel, ELEMENT_WAIT_LONGER_TIME);
}
await testPage.hasElement(e.isTalking);
await testPage.wasRemoved(e.joinAudio);
await testPage.hasElement(e.audioDropdownMenu);
}
async function isAudioItemSelected(testPage, audioSelector) {