2021-11-23 01:06:59 +08:00
|
|
|
const e = require('../core/elements');
|
2022-07-16 04:54:16 +08:00
|
|
|
const { ELEMENT_WAIT_LONGER_TIME } = require('../core/constants');
|
|
|
|
const { connectMicrophone, isAudioItemSelected } = require('./util');
|
2023-05-16 20:51:25 +08:00
|
|
|
const { MultiUsers } = require('../user/multiusers');
|
2023-06-15 09:36:18 +08:00
|
|
|
const { generateSettingsData } = require('../core/settings');
|
2023-05-19 22:22:51 +08:00
|
|
|
const { expect } = require('@playwright/test');
|
2021-11-23 01:06:59 +08:00
|
|
|
|
2023-05-16 20:51:25 +08:00
|
|
|
|
|
|
|
class Audio extends MultiUsers {
|
|
|
|
constructor(browser, context) {
|
|
|
|
super(browser, context);
|
2021-11-23 01:06:59 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
async joinAudio() {
|
2023-05-16 20:51:25 +08:00
|
|
|
this.modPage.settings = await generateSettingsData(this.modPage);
|
|
|
|
const { autoJoinAudioModal, listenOnlyCallTimeout } = this.modPage.settings;
|
2023-05-23 21:43:08 +08:00
|
|
|
if (!autoJoinAudioModal) await this.modPage.waitAndClick(e.joinAudio);
|
|
|
|
await this.modPage.waitAndClick(e.joinAudio);
|
2023-05-16 20:51:25 +08:00
|
|
|
await this.modPage.waitAndClick(e.listenOnlyButton);
|
|
|
|
await this.modPage.waitForSelector(e.establishingAudioLabel);
|
2024-07-31 06:49:02 +08:00
|
|
|
await this.modPage.wasRemoved(e.establishingAudioLabel, 'Should have audio established.', ELEMENT_WAIT_LONGER_TIME);
|
2023-05-16 20:51:25 +08:00
|
|
|
await this.modPage.waitForSelector(e.leaveListenOnly, listenOnlyCallTimeout);
|
|
|
|
await this.modPage.waitAndClick(e.audioDropdownMenu);
|
2024-07-31 06:49:02 +08:00
|
|
|
await this.modPage.hasElement(e.leaveAudio, 'Should have the microphone connected.');
|
2023-05-16 20:51:25 +08:00
|
|
|
await this.modPage.waitAndClick(e.leaveAudio);
|
2021-11-23 01:06:59 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
async joinMicrophone() {
|
2023-05-23 21:43:08 +08:00
|
|
|
await this.modPage.waitAndClick(e.joinAudio);
|
|
|
|
await connectMicrophone(this.modPage);
|
2023-05-19 22:22:51 +08:00
|
|
|
|
2024-07-31 06:49:02 +08:00
|
|
|
await this.modPage.hasElement(e.muteMicButton, 'Should have the microphone connected.');
|
2023-05-16 20:51:25 +08:00
|
|
|
await this.modPage.waitAndClick(e.audioDropdownMenu);
|
2024-07-31 06:49:02 +08:00
|
|
|
await this.modPage.hasElement(e.leaveAudio, 'Should have the microphone connected.');
|
2023-05-16 20:51:25 +08:00
|
|
|
await this.modPage.waitAndClick(e.leaveAudio);
|
2022-07-16 04:54:16 +08:00
|
|
|
}
|
2022-03-29 21:53:07 +08:00
|
|
|
|
2022-07-16 04:54:16 +08:00
|
|
|
async muteYourselfByButton() {
|
2023-05-23 21:43:08 +08:00
|
|
|
await this.modPage.waitAndClick(e.joinAudio);
|
|
|
|
await connectMicrophone(this.modPage);
|
2023-05-18 20:39:06 +08:00
|
|
|
|
2024-07-31 06:49:02 +08:00
|
|
|
await this.modPage.hasElement(e.isTalking, 'Moderator should be talking.');
|
2023-05-16 20:51:25 +08:00
|
|
|
await this.modPage.waitAndClick(e.muteMicButton);
|
2024-07-31 06:49:02 +08:00
|
|
|
await this.modPage.wasRemoved(e.isTalking, 'Moderator should stop talking.');
|
|
|
|
await this.modPage.hasElement(e.wasTalking, 'Should stop talking.');
|
|
|
|
await this.modPage.wasRemoved(e.muteMicButton, 'Should be muted.');
|
|
|
|
await this.modPage.hasElement(e.unmuteMicButton, 'Should have the unmute mic button.');
|
|
|
|
await this.modPage.wasRemoved(e.talkingIndicator, 'Talking indicator should disappear', ELEMENT_WAIT_LONGER_TIME);
|
2023-05-18 20:39:06 +08:00
|
|
|
await this.modPage.waitAndClick(e.unmuteMicButton);
|
2023-05-16 20:51:25 +08:00
|
|
|
await this.modPage.waitAndClick(e.audioDropdownMenu);
|
|
|
|
await this.modPage.waitAndClick(e.leaveAudio);
|
2022-07-16 04:54:16 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
async changeAudioInput() {
|
2023-05-23 21:43:08 +08:00
|
|
|
await this.modPage.waitAndClick(e.joinAudio);
|
2023-06-15 09:36:18 +08:00
|
|
|
await connectMicrophone(this.modPage);
|
|
|
|
|
2023-05-16 20:51:25 +08:00
|
|
|
await this.modPage.waitAndClick(e.audioDropdownMenu);
|
|
|
|
await isAudioItemSelected(this.modPage, e.defaultInputAudioDevice);
|
|
|
|
await this.modPage.waitAndClick(e.secondInputAudioDevice);
|
2024-07-31 06:49:02 +08:00
|
|
|
await this.modPage.hasElement(e.isTalking, 'should be talking.');
|
|
|
|
await this.modPage.hasElement(e.muteMicButton, 'should have the mute microphone button displayed.');
|
2023-05-16 20:51:25 +08:00
|
|
|
await this.modPage.waitAndClick(e.audioDropdownMenu);
|
|
|
|
await isAudioItemSelected(this.modPage, e.secondInputAudioDevice);
|
2023-05-18 20:39:06 +08:00
|
|
|
await this.modPage.waitAndClick(e.leaveAudio);
|
2022-07-16 04:54:16 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
async keepMuteStateOnRejoin() {
|
2023-05-23 21:43:08 +08:00
|
|
|
await this.modPage.waitAndClick(e.joinAudio);
|
2023-06-15 09:36:18 +08:00
|
|
|
await connectMicrophone(this.modPage);
|
|
|
|
|
|
|
|
const isMuted = await this.modPage.checkElement(e.unmuteMicButton);
|
|
|
|
if (isMuted) {
|
|
|
|
await this.modPage.waitAndClick(e.unmuteMicButton);
|
2024-07-31 06:49:02 +08:00
|
|
|
await this.modPage.hasElement(e.isTalking, 'should be talking.');
|
2023-06-15 09:36:18 +08:00
|
|
|
}
|
2024-07-31 06:49:02 +08:00
|
|
|
await this.modPage.hasElement(e.isTalking, 'should be talking');
|
2023-05-18 20:39:06 +08:00
|
|
|
await this.modPage.waitAndClick(e.muteMicButton);
|
2024-07-31 06:49:02 +08:00
|
|
|
await this.modPage.hasElement(e.wasTalking, 'should stopped talking');
|
|
|
|
await this.modPage.wasRemoved(e.muteMicButton, 'should be muted');
|
|
|
|
await this.modPage.hasElement(e.unmuteMicButton, 'should be muted.');
|
2023-05-18 20:39:06 +08:00
|
|
|
await this.modPage.waitAndClick(e.audioDropdownMenu);
|
|
|
|
await this.modPage.waitAndClick(e.leaveAudio);
|
|
|
|
await this.modPage.waitAndClick(e.joinAudio);
|
|
|
|
await this.modPage.waitAndClick(e.microphoneButton);
|
|
|
|
await this.modPage.waitAndClick(e.joinEchoTestButton);
|
|
|
|
await this.modPage.waitForSelector(e.establishingAudioLabel);
|
2024-07-31 06:49:02 +08:00
|
|
|
await this.modPage.wasRemoved(e.establishingAudioLabel, 'Audio should be established.', ELEMENT_WAIT_LONGER_TIME);
|
|
|
|
await this.modPage.hasElement(e.unmuteMicButton, 'should be muted');
|
2023-05-19 22:22:51 +08:00
|
|
|
await this.modPage.waitAndClick(e.unmuteMicButton);
|
|
|
|
await this.modPage.waitAndClick(e.audioDropdownMenu);
|
|
|
|
await this.modPage.waitAndClick(e.leaveAudio);
|
2022-07-16 04:54:16 +08:00
|
|
|
}
|
|
|
|
|
2023-04-06 05:08:21 +08:00
|
|
|
async muteYourselfByTalkingIndicator() {
|
2023-05-23 21:43:08 +08:00
|
|
|
await this.modPage.waitAndClick(e.joinAudio);
|
|
|
|
await connectMicrophone(this.modPage);
|
|
|
|
|
2023-06-15 09:36:18 +08:00
|
|
|
const isMuted = await this.modPage.checkElement(e.unmuteMicButton);
|
|
|
|
if (isMuted) {
|
|
|
|
await this.modPage.waitAndClick(e.unmuteMicButton);
|
2024-07-31 06:49:02 +08:00
|
|
|
await this.modPage.hasElement(e.isTalking, 'Should be talking');
|
2023-06-15 09:36:18 +08:00
|
|
|
}
|
2023-05-19 22:22:51 +08:00
|
|
|
await this.modPage.waitAndClick(e.talkingIndicator);
|
2024-07-31 06:49:02 +08:00
|
|
|
await this.modPage.hasElement(e.wasTalking, 'should stops talking');
|
|
|
|
await this.modPage.wasRemoved(e.muteMicButton, 'should be unmuted');
|
|
|
|
await this.modPage.hasElement(e.unmuteMicButton, 'should be muted');
|
|
|
|
await this.modPage.wasRemoved(e.isTalking, 'should stop talking');
|
|
|
|
await this.modPage.wasRemoved(e.talkingIndicator, 'talking indicator should disappear', ELEMENT_WAIT_LONGER_TIME);
|
2023-05-19 22:22:51 +08:00
|
|
|
await this.modPage.waitAndClick(e.audioDropdownMenu);
|
|
|
|
await this.modPage.waitAndClick(e.leaveAudio);
|
|
|
|
}
|
|
|
|
|
|
|
|
async muteAnotherUser() {
|
2024-07-31 06:49:02 +08:00
|
|
|
// tirar o audio do moderator!!!!!
|
2023-05-23 21:43:08 +08:00
|
|
|
await this.modPage.waitAndClick(e.joinAudio);
|
|
|
|
await connectMicrophone(this.modPage);
|
|
|
|
await this.userPage.waitAndClick(e.joinAudio);
|
|
|
|
await this.userPage.joinMicrophone();
|
2023-05-19 22:22:51 +08:00
|
|
|
|
|
|
|
await this.userPage.waitAndClick(e.muteMicButton);
|
|
|
|
await this.modPage.waitAndClick(e.isTalking);
|
2024-07-31 06:49:02 +08:00
|
|
|
await this.userPage.hasElement(e.unmuteMicButton, 'attendee should be muted');
|
2023-05-19 22:22:51 +08:00
|
|
|
|
|
|
|
const moderatorWasTalkingLocator = await this.modPage.getLocator(e.wasTalking).first();
|
|
|
|
const userWasTalkingLocator = await this.userPage.getLocator(e.wasTalking).last();
|
|
|
|
|
|
|
|
await expect(moderatorWasTalkingLocator).toBeVisible();
|
2024-07-31 06:49:02 +08:00
|
|
|
await expect(userWasTalkingLocator, 'should stop displaying isTalking element and display the element with high opacity for the attende').toBeVisible();
|
|
|
|
await this.userPage.wasRemoved(e.talkingIndicator, 'attende should be muted', ELEMENT_WAIT_LONGER_TIME);
|
|
|
|
await this.modPage.wasRemoved(e.talkingIndicator, 'moderator should be muted');
|
2021-11-23 01:06:59 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-12-04 01:01:36 +08:00
|
|
|
exports.Audio = Audio;
|