bigbluebutton-Github/bigbluebutton-tests/playwright/audio/util.js

35 lines
1.3 KiB
JavaScript
Raw Normal View History

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);
}
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;