2020-06-09 03:40:28 +08:00
|
|
|
const path = require('path');
|
2021-02-17 04:57:10 +08:00
|
|
|
const { ELEMENT_WAIT_TIME, ELEMENT_WAIT_LONGER_TIME } = require('../core/constants');
|
|
|
|
const ne = require('../notifications/elements');
|
|
|
|
const pe = require('../presentation/elements');
|
|
|
|
const ce = require('../customparameters/elements');
|
|
|
|
const we = require('../whiteboard/elements');
|
2021-03-02 05:47:08 +08:00
|
|
|
const poe = require('../polling/elemens');
|
2020-06-09 03:40:28 +08:00
|
|
|
|
2020-05-13 21:53:14 +08:00
|
|
|
async function autoJoinTest(test) {
|
2020-05-22 00:45:52 +08:00
|
|
|
const resp = await test.page.evaluate(async () => {
|
|
|
|
const rep = await document.querySelectorAll('div[aria-label="Join audio modal"]').length === 0;
|
|
|
|
return rep !== false;
|
|
|
|
});
|
2020-05-13 21:53:14 +08:00
|
|
|
return resp;
|
|
|
|
}
|
|
|
|
|
2020-05-13 23:26:30 +08:00
|
|
|
async function listenOnlyMode(test) {
|
|
|
|
try {
|
|
|
|
const resp = await test.page.evaluate(async () => {
|
|
|
|
await document.querySelectorAll('div[class^="connecting--"]')[0];
|
2020-05-15 22:49:03 +08:00
|
|
|
const audibleButton = await document.querySelectorAll('button[aria-label="Echo is audible"]').length !== 0;
|
|
|
|
return audibleButton !== false;
|
2020-05-13 23:26:30 +08:00
|
|
|
});
|
|
|
|
return resp;
|
|
|
|
} catch (e) {
|
|
|
|
console.log(e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-14 00:54:56 +08:00
|
|
|
async function forceListenOnly(test) {
|
|
|
|
try {
|
|
|
|
const resp = await test.page.evaluate(async () => {
|
|
|
|
await document.querySelectorAll('div[class^="connecting--"]')[0];
|
2020-05-22 00:45:52 +08:00
|
|
|
if (await document.querySelectorAll('button[aria-label="Echo is audible"]').length > 0) {
|
2020-05-15 22:49:03 +08:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
const audibleNotification = await document.querySelectorAll('div[class^="toastContainer--"]')[0].innerText === 'You have joined the audio conference';
|
|
|
|
return audibleNotification !== false;
|
2020-05-14 00:54:56 +08:00
|
|
|
});
|
|
|
|
return resp;
|
|
|
|
} catch (e) {
|
|
|
|
console.log(e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-15 22:49:03 +08:00
|
|
|
async function skipCheck(test) {
|
|
|
|
try {
|
2021-02-17 04:57:10 +08:00
|
|
|
await test.waitForSelector(ce.toastContainer, ELEMENT_WAIT_TIME);
|
2020-05-15 22:49:03 +08:00
|
|
|
const resp1 = await test.page.evaluate(async () => await document.querySelectorAll('div[class^="toastContainer--"]').length !== 0);
|
2021-02-17 04:57:10 +08:00
|
|
|
await test.waitForSelector(ce.muteBtn, ELEMENT_WAIT_TIME);
|
2020-05-15 22:49:03 +08:00
|
|
|
const resp2 = await test.page.evaluate(async () => await document.querySelectorAll('button[aria-label="Mute"]').length !== 0);
|
2020-06-16 01:21:44 +08:00
|
|
|
return resp1 === true && resp2 === true;
|
2020-05-15 22:49:03 +08:00
|
|
|
} catch (e) {
|
|
|
|
console.log(e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
async function countTestElements(element) {
|
|
|
|
return document.querySelectorAll(element).length !== 0;
|
|
|
|
}
|
|
|
|
|
2020-05-22 00:45:52 +08:00
|
|
|
async function getTestElement(element) {
|
|
|
|
return document.querySelectorAll(element).length === 0;
|
|
|
|
}
|
|
|
|
|
2020-06-02 02:42:56 +08:00
|
|
|
function hexToRgb(hex) {
|
|
|
|
const bigint = parseInt(hex, 16);
|
|
|
|
const r = (bigint >> 16) & 255;
|
|
|
|
const g = (bigint >> 8) & 255;
|
|
|
|
const b = bigint & 255;
|
|
|
|
return `rgb(${r}, ${g}, ${b})`;
|
|
|
|
}
|
|
|
|
|
2020-06-09 03:40:28 +08:00
|
|
|
async function zoomIn(test) {
|
|
|
|
try {
|
|
|
|
await test.page.evaluate(() => {
|
|
|
|
setInterval(() => {
|
|
|
|
document.querySelector('button[aria-label="Zoom in"]').scrollBy(0, 10);
|
|
|
|
}, 100);
|
|
|
|
});
|
|
|
|
return true;
|
|
|
|
} catch (e) {
|
|
|
|
console.log(e);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
async function zoomOut(test) {
|
|
|
|
try {
|
|
|
|
await test.page.evaluate(() => {
|
|
|
|
setInterval(() => {
|
|
|
|
document.querySelector('button[aria-label="Zoom in"]').scrollBy(10, 0);
|
|
|
|
}, 100);
|
|
|
|
}); return true;
|
|
|
|
} catch (e) {
|
|
|
|
console.log(e);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-02-17 04:57:10 +08:00
|
|
|
async function poll(page1, page2) {
|
2020-06-09 03:40:28 +08:00
|
|
|
try {
|
2021-02-17 04:57:10 +08:00
|
|
|
await page1.page.waitForSelector(ce.whiteboard, { visible: true, timeout: ELEMENT_WAIT_LONGER_TIME });
|
|
|
|
await page1.page.evaluate(async () => await document.querySelectorAll('button[aria-label="Actions"]')[0].click());
|
|
|
|
await page1.waitForSelector(ne.polling, ELEMENT_WAIT_TIME);
|
|
|
|
await page1.click(ne.polling, true);
|
2021-02-26 23:52:17 +08:00
|
|
|
await page1.waitForSelector(ne.pollYesNoAbstentionBtn, ELEMENT_WAIT_TIME);
|
|
|
|
await page1.click(ne.pollYesNoAbstentionBtn, true);
|
2021-03-02 05:47:08 +08:00
|
|
|
await page1.waitForSelector(ne.startPoll, ELEMENT_WAIT_TIME);
|
|
|
|
await page1.click(ne.startPoll, true);
|
|
|
|
await page2.waitForSelector(poe.pollingContainer, ELEMENT_WAIT_TIME);
|
2021-02-17 04:57:10 +08:00
|
|
|
await page2.waitForSelector(ne.yesBtn, ELEMENT_WAIT_TIME);
|
|
|
|
await page2.click(ne.yesBtn, true);
|
|
|
|
await page1.waitForSelector(ne.publishPollingResults, ELEMENT_WAIT_TIME);
|
|
|
|
await page1.click(ne.publishPollingResults, true);
|
2020-06-09 03:40:28 +08:00
|
|
|
return true;
|
|
|
|
} catch (e) {
|
|
|
|
console.log(e);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
async function previousSlide(test) {
|
|
|
|
try {
|
2021-02-17 04:57:10 +08:00
|
|
|
await test.waitForSelector(pe.prevSlide, ELEMENT_WAIT_TIME);
|
|
|
|
await test.click(pe.prevSlide, true);
|
2020-06-09 03:40:28 +08:00
|
|
|
return true;
|
|
|
|
} catch (e) {
|
|
|
|
console.log(e);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
async function nextSlide(test) {
|
|
|
|
try {
|
2021-02-17 04:57:10 +08:00
|
|
|
await test.waitForSelector(pe.nextSlide, ELEMENT_WAIT_TIME);
|
|
|
|
await test.click(pe.nextSlide, true);
|
2020-06-09 03:40:28 +08:00
|
|
|
return true;
|
|
|
|
} catch (e) {
|
|
|
|
console.log(e);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
async function annotation(test) {
|
2021-02-17 04:57:10 +08:00
|
|
|
await test.waitForSelector(ce.tools, ELEMENT_WAIT_TIME);
|
|
|
|
await test.click(ce.tools, true);
|
|
|
|
await test.waitForSelector(we.pencil, ELEMENT_WAIT_TIME);
|
|
|
|
await test.click(we.pencil, true);
|
|
|
|
await test.click(ce.whiteboard, true);
|
2020-06-09 03:40:28 +08:00
|
|
|
const annoted = await test.page.evaluate(async () => await document.querySelectorAll('[data-test="whiteboard"] > g > g')[1].innerHTML !== '');
|
|
|
|
return annoted;
|
|
|
|
}
|
|
|
|
|
|
|
|
async function presetationUpload(test) {
|
|
|
|
try {
|
2021-02-17 04:57:10 +08:00
|
|
|
await test.waitForSelector(ce.actions, ELEMENT_WAIT_TIME);
|
|
|
|
await test.click(ce.actions, true);
|
|
|
|
await test.waitForSelector(pe.uploadPresentation, ELEMENT_WAIT_TIME);
|
|
|
|
await test.click(pe.uploadPresentation, true);
|
2020-06-09 03:40:28 +08:00
|
|
|
const elementHandle = await test.page.$('input[type=file]');
|
|
|
|
await elementHandle.uploadFile(path.join(__dirname, '../media/DifferentSizes.pdf'));
|
2021-02-17 04:57:10 +08:00
|
|
|
await test.click(ce.confirmBtn, true);
|
2020-06-09 03:40:28 +08:00
|
|
|
return true;
|
|
|
|
} catch (e) {
|
|
|
|
console.log(e);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-08-03 01:46:17 +08:00
|
|
|
function encodeCustomParams(param) {
|
|
|
|
try {
|
|
|
|
let splited = param.split('=');
|
|
|
|
splited[1] = encodeURIComponent(splited[1]).replace(/%20/g, '+');
|
|
|
|
return splited.join('=');
|
|
|
|
} catch (e) {
|
|
|
|
console.log(e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-06-09 03:40:28 +08:00
|
|
|
exports.zoomIn = zoomIn;
|
|
|
|
exports.zoomOut = zoomOut;
|
|
|
|
exports.poll = poll;
|
|
|
|
exports.previousSlide = previousSlide;
|
|
|
|
exports.nextSlide = nextSlide;
|
|
|
|
exports.annotation = annotation;
|
|
|
|
exports.presetationUpload = presetationUpload;
|
2020-06-02 02:42:56 +08:00
|
|
|
exports.hexToRgb = hexToRgb;
|
2020-05-22 00:45:52 +08:00
|
|
|
exports.getTestElement = getTestElement;
|
2020-05-15 22:49:03 +08:00
|
|
|
exports.countTestElements = countTestElements;
|
2020-05-13 21:53:14 +08:00
|
|
|
exports.autoJoinTest = autoJoinTest;
|
2020-05-13 23:26:30 +08:00
|
|
|
exports.listenOnlyMode = listenOnlyMode;
|
2020-05-15 22:49:03 +08:00
|
|
|
exports.forceListenOnly = forceListenOnly;
|
|
|
|
exports.skipCheck = skipCheck;
|
2021-08-03 01:46:17 +08:00
|
|
|
exports.encodeCustomParams = encodeCustomParams;
|