2022-07-16 04:54:16 +08:00
|
|
|
const { expect } = require('@playwright/test');
|
|
|
|
const e = require('../core/elements');
|
|
|
|
const { ELEMENT_WAIT_LONGER_TIME } = require('../core/constants');
|
|
|
|
|
|
|
|
async function connectMicrophone(testPage) {
|
|
|
|
const {
|
|
|
|
autoJoinAudioModal,
|
|
|
|
skipEchoTest,
|
|
|
|
skipEchoTestOnJoin,
|
|
|
|
} = testPage.settings;
|
|
|
|
|
|
|
|
if (!autoJoinAudioModal) await testPage.waitAndClick(e.joinAudio);
|
|
|
|
await testPage.waitAndClick(e.microphoneButton);
|
|
|
|
const shouldSkipEchoTest = skipEchoTest || skipEchoTestOnJoin;
|
|
|
|
if (!shouldSkipEchoTest) {
|
|
|
|
await testPage.waitForSelector(e.stopHearingButton);
|
|
|
|
await testPage.waitAndClick(e.joinEchoTestButton);
|
|
|
|
await testPage.waitForSelector(e.establishingAudioLabel);
|
|
|
|
await testPage.wasRemoved(e.establishingAudioLabel, ELEMENT_WAIT_LONGER_TIME);
|
|
|
|
}
|
2023-06-15 09:36:18 +08:00
|
|
|
await testPage.wasRemoved(e.joinAudio);
|
|
|
|
await testPage.hasElement(e.audioDropdownMenu);
|
2022-07-16 04:54:16 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
async function isAudioItemSelected(testPage, audioSelector) {
|
|
|
|
await testPage.waitForSelector(audioSelector);
|
|
|
|
const isSelected = await testPage.page.evaluate(([selector, icon]) => {
|
|
|
|
return !!document.querySelector(selector).firstChild.querySelector(icon);
|
|
|
|
}, [audioSelector, e.checkedIcon]);
|
|
|
|
await expect(isSelected).toBeTruthy();
|
|
|
|
}
|
|
|
|
|
|
|
|
exports.connectMicrophone = connectMicrophone;
|
|
|
|
exports.isAudioItemSelected = isAudioItemSelected;
|