avoid using static timeouts and fix Random Poll test

This commit is contained in:
Anton Barboza 2021-09-22 13:51:35 -03:00
parent ae21124005
commit dce318e1ad
6 changed files with 31 additions and 36 deletions

View File

@ -269,7 +269,7 @@ class ScreenshareComponent extends React.Component {
{ {
isGloballyBroadcasting isGloballyBroadcasting
? ( ? (
<div> <div data-test="isSharingScreen">
{!switched {!switched
&& ScreenshareComponent.renderScreenshareContainerInside( && ScreenshareComponent.renderScreenshareContainerInside(
intl.formatMessage(intlMessages.presenterSharingLabel), intl.formatMessage(intlMessages.presenterSharingLabel),

View File

@ -17,7 +17,6 @@ async function sendPublicChatMessage(page1, page2) {
async function openPrivateChatMessage(page1, page2) { async function openPrivateChatMessage(page1, page2) {
// Open private Chat with the other User // Open private Chat with the other User
Object.values(arguments).forEach(async argument => await argument.waitForSelector(e.userListItem));
await page1.waitAndClick(e.userListItem); await page1.waitAndClick(e.userListItem);
await page2.waitAndClick(e.userListItem); await page2.waitAndClick(e.userListItem);
await page1.waitAndClick(e.activeChat); await page1.waitAndClick(e.activeChat);

View File

@ -3,6 +3,7 @@ exports.actions = 'button[aria-label="Actions"]';
exports.options = 'button[aria-label="Options"]'; exports.options = 'button[aria-label="Options"]';
exports.screenshareConnecting = 'div[data-test="screenshareConnecting"]'; exports.screenshareConnecting = 'div[data-test="screenshareConnecting"]';
exports.screenShareVideo = 'video[id="screenshareVideo"]'; exports.screenShareVideo = 'video[id="screenshareVideo"]';
exports.isSharingScreen = 'div[data-test="isSharingScreen"]';
exports.raiseHandLabel = 'button[data-test="raiseHandLabel"]'; exports.raiseHandLabel = 'button[data-test="raiseHandLabel"]';
exports.lowerHandLabel = 'button[data-test="lowerHandLabel"]'; exports.lowerHandLabel = 'button[data-test="lowerHandLabel"]';
exports.logout = 'li[data-test="logout"]'; exports.logout = 'li[data-test="logout"]';
@ -137,6 +138,7 @@ exports.startPoll = 'button[data-test="startPoll"]';
exports.restartPoll = 'button[data-test="restartPoll"]'; exports.restartPoll = 'button[data-test="restartPoll"]';
exports.receivedAnswer = 'td[data-test="receivedAnswer"]'; exports.receivedAnswer = 'td[data-test="receivedAnswer"]';
exports.publishLabel = 'button[data-test="publishLabel"]'; exports.publishLabel = 'button[data-test="publishLabel"]';
exports.pollResults = 'g[data-test="pollResultAria"]';
// Presentation // Presentation
exports.startScreenSharing = 'button[data-test="startScreenShare"]'; exports.startScreenSharing = 'button[data-test="startScreenShare"]';

View File

@ -13,11 +13,11 @@ class ShareScreen extends Page {
async test() { async test() {
try { try {
await util.startScreenshare(this); await util.startScreenshare(this);
await this.page.waitForSelector(e.screenshareConnecting); await this.waitForSelector(e.screenshareConnecting);
await this.page.waitForSelector(e.screenShareVideo, VIDEO_LOADING_WAIT_TIME); await this.waitForSelector(e.screenShareVideo, VIDEO_LOADING_WAIT_TIME);
await sleep(5000); const response = await this.hasElement(e.isSharingScreen, true);
const response = await util.getScreenShareContainer(this);
return response; return response === true;
} catch (err) { } catch (err) {
await this.logger(err); await this.logger(err);
return false; return false;

View File

@ -11,11 +11,6 @@ async function waitForScreenshareContainer(test) {
await test.waitForSelector(e.screenShareVideo, VIDEO_LOADING_WAIT_TIME); await test.waitForSelector(e.screenShareVideo, VIDEO_LOADING_WAIT_TIME);
} }
async function getScreenShareContainer(test) {
await test.waitForSelector(e.screenShareVideo, VIDEO_LOADING_WAIT_TIME);
return test.page.evaluate(checkElement, e.screenShareVideo);
}
async function getScreenShareBreakoutContainer(test) { async function getScreenShareBreakoutContainer(test) {
await test.waitForSelector(e.screenshareConnecting, VIDEO_LOADING_WAIT_TIME); await test.waitForSelector(e.screenshareConnecting, VIDEO_LOADING_WAIT_TIME);
await test.waitForSelector(e.screenShareVideo, VIDEO_LOADING_WAIT_TIME); await test.waitForSelector(e.screenShareVideo, VIDEO_LOADING_WAIT_TIME);
@ -23,6 +18,5 @@ async function getScreenShareBreakoutContainer(test) {
} }
exports.getScreenShareBreakoutContainer = getScreenShareBreakoutContainer; exports.getScreenShareBreakoutContainer = getScreenShareBreakoutContainer;
exports.getScreenShareContainer = getScreenShareContainer;
exports.startScreenshare = startScreenshare; exports.startScreenshare = startScreenshare;
exports.waitForScreenshareContainer = waitForScreenshareContainer; exports.waitForScreenshareContainer = waitForScreenshareContainer;

View File

@ -50,11 +50,12 @@ class MultiUsers {
async multiUsersPrivateChat() { async multiUsersPrivateChat() {
try { try {
await util.openPrivateChatMessage(this.page1, this.page2); await util.openPrivateChatMessage(this.page1, this.page2);
const chat0 = await this.page1.page.evaluate(getElementLength, e.chatUserMessageText); const chat0 = await this.page1.page.evaluate(checkElementLengthEqualTo, e.chatUserMessageText, 0);
await util.sendPrivateChatMessage(this.page1, this.page2); await util.sendPrivateChatMessage(this.page1, this.page2);
await sleep(2000); const receivedMessages = await this.page1.hasElement(e.chatUserMessageText, true) && await this.page2.hasElement(e.chatUserMessageText, true);
const chat1 = await this.page1.page.evaluate(getElementLength, e.chatUserMessageText);
return chat0 !== chat1; return chat0 && receivedMessages;
} catch (err) { } catch (err) {
await this.page1.logger(err); await this.page1.logger(err);
return false; return false;
@ -129,7 +130,6 @@ class MultiUsers {
case 3: case 3:
// Do nothing to let Users write their single response answer // Do nothing to let Users write their single response answer
await this.page1.waitForSelector(e.responseChoices); await this.page1.waitForSelector(e.responseChoices);
await sleep(2000);
break; break;
} }
const condition = chosenRandomNb === 0 || chosenRandomNb === 1 || chosenRandomNb === 2; const condition = chosenRandomNb === 0 || chosenRandomNb === 1 || chosenRandomNb === 2;
@ -137,7 +137,7 @@ class MultiUsers {
await this.page2.waitForSelector(e.pollingContainer); await this.page2.waitForSelector(e.pollingContainer);
switch (condition) { switch (condition) {
case true: case true:
await this.page2.clickNItem(e.pollAnswerOptionBtn, true, 2); await this.page2.clickNItem(e.pollAnswerOptionBtn, false, 2);
break; break;
case false: case false:
await this.page2.page.focus(e.pollAnswerOptionInput); await this.page2.page.focus(e.pollAnswerOptionInput);
@ -145,10 +145,11 @@ class MultiUsers {
await this.page2.waitAndClick(e.pollSubmitAnswer); await this.page2.waitAndClick(e.pollSubmitAnswer);
break; break;
} }
await this.page1.waitAndClick(e.publishLabel); const receivedAnswerFound = await this.page1.hasElement(e.receivedAnswer, true);
await this.page1.waitAndClick(e.publishLabel, ELEMENT_WAIT_TIME, true);
await this.page1.waitForSelector(e.restartPoll); await this.page1.waitForSelector(e.restartPoll);
const receivedAnswerFound = await this.page1.page.evaluate(checkElementLengthDifferentTo, e.receivedAnswer, 0); const isPollResultsPublished = await this.page1.hasElement(e.pollResults, true);
return receivedAnswerFound; return receivedAnswerFound && isPollResultsPublished;
} catch (err) { } catch (err) {
await this.page1.logger(err); await this.page1.logger(err);
return false; return false;
@ -163,7 +164,7 @@ class MultiUsers {
await this.page1.waitForSelector(e.whiteboard); await this.page1.waitForSelector(e.whiteboard);
await this.page1.clickNItem(e.userListItem, true, 1); await this.page1.clickNItem(e.userListItem, true, 1);
await this.page1.clickNItem(e.changeWhiteboardAccess, true, 1); await this.page1.clickNItem(e.changeWhiteboardAccess, true, 1);
await sleep(2000); await this.page1.waitForSelector(e.multiWhiteboardTool);
const resp = await this.page1.page.evaluate((multiWhiteboardTool) => { const resp = await this.page1.page.evaluate((multiWhiteboardTool) => {
return document.querySelector(multiWhiteboardTool).children[0].innerText === '1'; return document.querySelector(multiWhiteboardTool).children[0].innerText === '1';
}, e.multiWhiteboardTool); }, e.multiWhiteboardTool);
@ -180,8 +181,8 @@ class MultiUsers {
await this.page1.closeAudioModal(); await this.page1.closeAudioModal();
await this.page2.closeAudioModal(); await this.page2.closeAudioModal();
await this.page2.waitAndClick(e.raiseHandLabel); await this.page2.waitAndClick(e.raiseHandLabel);
await sleep(2000); const resp = await this.page2.hasElement(e.lowerHandLabel, true);
const resp = await this.page2.page.evaluate(checkElementLengthDifferentTo, e.lowerHandLabel, 0);
return resp === true; return resp === true;
} catch (err) { } catch (err) {
await this.page1.logger(err); await this.page1.logger(err);
@ -193,8 +194,9 @@ class MultiUsers {
async lowerHandTest() { async lowerHandTest() {
try { try {
await this.page2.waitAndClick(e.lowerHandLabel); await this.page2.waitAndClick(e.lowerHandLabel);
await sleep(2000); await this.page2.waitAndClick(e.lowerHandLabel, ELEMENT_WAIT_TIME, true);
const resp = await this.page2.page.evaluate(checkElementLengthDifferentTo, e.raiseHandLabel, 0); const resp = await this.page2.hasElement(e.raiseHandLabel, true);
return resp === true; return resp === true;
} catch (err) { } catch (err) {
await this.page2.logger(err); await this.page2.logger(err);
@ -220,14 +222,12 @@ class MultiUsers {
await this.page2.closeAudioModal(); await this.page2.closeAudioModal();
await this.page2.page.evaluate(() => window.dispatchEvent(new CustomEvent('socketstats', { detail: { rtt: 2000 } }))); await this.page2.page.evaluate(() => window.dispatchEvent(new CustomEvent('socketstats', { detail: { rtt: 2000 } })));
await this.page2.page.setOfflineMode(true); await this.page2.page.setOfflineMode(true);
await sleep(3000);
await this.page2.close(); await this.page2.close();
await sleep(5000);
await utilUser.connectionStatus(this.page1); await utilUser.connectionStatus(this.page1);
await sleep(5000); const connectionStatusItemEmpty = await this.page1.wasRemoved(e.connectionStatusItemEmpty);
const connectionStatusItemEmpty = await this.page1.page.evaluate(checkElementLengthEqualTo, e.connectionStatusItemEmpty, 0); const connectionStatusOfflineUser = await this.page1.hasElement(e.connectionStatusOfflineUser, true);
const connectionStatusOfflineUser = await this.page1.page.evaluate(checkElementLengthDifferentTo, e.connectionStatusOfflineUser, 0) === true;
return connectionStatusOfflineUser && connectionStatusItemEmpty; return connectionStatusItemEmpty && connectionStatusOfflineUser;
} catch (err) { } catch (err) {
await this.page1.logger(err); await this.page1.logger(err);
return false; return false;
@ -255,8 +255,8 @@ class MultiUsers {
await this.page2.waitAndClick(e.userListButton); await this.page2.waitAndClick(e.userListButton);
await this.page2.waitAndClick(e.chatButtonKey); await this.page2.waitAndClick(e.chatButtonKey);
const onUserListPanel = await this.page1.isNotVisible(e.hidePresentation); const onUserListPanel = await this.page1.isNotVisible(e.hidePresentation);
const onChatPanel = await this.page2.page.evaluate(checkElementLengthEqualTo, e.hidePresentation, 0); const onChatPanel = await this.page2.isNotVisible(e.hidePresentation);
await sleep(2000);
return onUserListPanel && onChatPanel; return onUserListPanel && onChatPanel;
} catch (err) { } catch (err) {
await this.page1.logger(err); await this.page1.logger(err);
@ -272,7 +272,7 @@ class MultiUsers {
await this.page2.waitAndClick(e.chatButtonKey); await this.page2.waitAndClick(e.chatButtonKey);
const whiteboard = await this.page1.page.evaluate(checkElementLengthEqualTo, e.chatButtonKey, 0); const whiteboard = await this.page1.page.evaluate(checkElementLengthEqualTo, e.chatButtonKey, 0);
const onChatPanel = await this.page2.isNotVisible(e.chatButtonKey); const onChatPanel = await this.page2.isNotVisible(e.chatButtonKey);
await sleep(2000);
return whiteboard && onChatPanel; return whiteboard && onChatPanel;
} catch (err) { } catch (err) {
await this.page1.logger(err); await this.page1.logger(err);