fix unnecessary double checking when taking a screenshot

This commit is contained in:
Anton 2021-08-13 17:33:27 -03:00
parent dc587c4e0f
commit 760eac42f5
9 changed files with 63 additions and 94 deletions

View File

@ -113,30 +113,25 @@ class Create {
try {
await this.page1.closeAudioModal();
await this.page2.closeAudioModal();
if (process.env.GENERATE_EVIDENCES === 'true') {
await this.page1.screenshot(`${testName}`, `01-page01-initialized-${testName}`);
await this.page2.screenshot(`${testName}`, `01-page02-initialized-${testName}`);
}
await this.page1.screenshot(`${testName}`, `01-page01-initialized-${testName}`);
await this.page2.screenshot(`${testName}`, `01-page02-initialized-${testName}`);
await this.page1.page.evaluate(util.clickTestElement, be.manageUsers);
await this.page1.page.evaluate(util.clickTestElement, be.createBreakoutRooms);
if (process.env.GENERATE_EVIDENCES === 'true') {
await this.page1.screenshot(`${testName}`, `02-page01-creating-breakoutrooms-${testName}`);
}
await this.page1.screenshot(`${testName}`, `02-page01-creating-breakoutrooms-${testName}`);
await this.page1.waitForSelector(be.randomlyAssign, ELEMENT_WAIT_TIME);
await this.page1.page.evaluate(util.clickTestElement, be.randomlyAssign);
if (process.env.GENERATE_EVIDENCES === 'true') {
await this.page1.screenshot(`${testName}`, `03-page01-randomly-assign-user-${testName}`);
}
await this.page1.screenshot(`${testName}`, `03-page01-randomly-assign-user-${testName}`);
await this.page1.waitForSelector(be.modalConfirmButton, ELEMENT_WAIT_TIME);
await this.page1.page.evaluate(util.clickTestElement, be.modalConfirmButton);
if (process.env.GENERATE_EVIDENCES === 'true') {
await this.page1.screenshot(`${testName}`, `04-page01-confirm-breakoutrooms-creation-${testName}`);
}
await this.page1.screenshot(`${testName}`, `04-page01-confirm-breakoutrooms-creation-${testName}`);
await this.page2.waitForSelector(be.modalConfirmButton, ELEMENT_WAIT_TIME);
await this.page2.page.evaluate(util.clickTestElement, be.modalConfirmButton);
if (process.env.GENERATE_EVIDENCES === 'true') {
await this.page2.screenshot(`${testName}`, `02-page02-accept-invite-breakoutrooms-${testName}`);
}
await this.page2.screenshot(`${testName}`, `02-page02-accept-invite-breakoutrooms-${testName}`);
await this.page2.page.bringToFront();
await this.page2.waitForSelector(be.breakoutRoomsItem, ELEMENT_WAIT_TIME);
await this.page2.waitForSelector(be.chatButton, ELEMENT_WAIT_TIME);
@ -163,14 +158,12 @@ class Create {
try {
const resp = await this.page1.page.evaluate(() => document.querySelectorAll('div[data-test="breakoutRoomsItem"]').length !== 0);
if (resp === true) {
if (process.env.GENERATE_EVIDENCES === 'true') {
await this.page1.screenshot(`${testName}`, `05-page01-success-${testName}`);
}
await this.page1.screenshot(`${testName}`, `05-page01-success-${testName}`);
return true;
}
if (process.env.GENERATE_EVIDENCES === 'true') {
await this.page1.screenshot(`${testName}`, `05-page01-fail-${testName}`);
}
await this.page1.screenshot(`${testName}`, `05-page01-fail-${testName}`);
return false;
} catch (e) {
await this.page1.logger(e);

View File

@ -14,29 +14,25 @@ class Clear extends Page {
async test(testName) {
try {
await util.openChat(this);
if (process.env.GENERATE_EVIDENCES === 'true') {
await this.screenshot(`${testName}`, `01-before-chat-message-send-[${this.meetingId}]`);
}
await this.screenshot(`${testName}`, `01-before-chat-message-send-[${this.meetingId}]`);
// sending a message
await this.type(e.chatBox, e.message);
await this.click(e.sendButton, true);
if (process.env.GENERATE_EVIDENCES === 'true') {
await this.screenshot(`${testName}`, `02-after-chat-message-send-[${this.meetingId}]`);
}
await this.screenshot(`${testName}`, `02-after-chat-message-send-[${this.meetingId}]`);
const chat0 = await this.page.evaluate(() => document.querySelectorAll('p[data-test="chatClearMessageText"]').length === 0);
// clear
await this.click(e.chatOptions, true);
if (process.env.GENERATE_EVIDENCES === 'true') {
await this.screenshot(`${testName}`, `03-chat-options-clicked-[${this.meetingId}]`);
}
await this.screenshot(`${testName}`, `03-chat-options-clicked-[${this.meetingId}]`);
await this.click(e.chatClear, true);
if (process.env.GENERATE_EVIDENCES === 'true') {
await this.screenshot(`${testName}`, `04-chat-cleared-[${this.meetingId}]`);
}
await this.screenshot(`${testName}`, `04-chat-cleared-[${this.meetingId}]`);
const chatResp = await this.waitForSelector(e.chatClearMessageText, ELEMENT_WAIT_TIME).then(() => true);

View File

@ -14,19 +14,16 @@ class Copy extends Page {
async test(testName) {
try {
await util.openChat(this);
if (process.env.GENERATE_EVIDENCES === 'true') {
await this.screenshot(`${testName}`, `01-before-sending-chat-message-[${this.meetingId}]`);
}
await this.screenshot(`${testName}`, `01-before-sending-chat-message-[${this.meetingId}]`);
// sending a message
await this.type(e.chatBox, e.message);
await this.click(e.sendButton);
if (process.env.GENERATE_EVIDENCES === 'true') {
await this.screenshot(`${testName}`, `02-chat-message-sent-[${this.meetingId}]`);
}
await this.screenshot(`${testName}`, `02-chat-message-sent-[${this.meetingId}]`);
await this.click(e.chatOptions);
if (process.env.GENERATE_EVIDENCES === 'true') {
await this.screenshot(`${testName}`, `03-chat-options-clicked-[${this.meetingId}]`);
}
await this.screenshot(`${testName}`, `03-chat-options-clicked-[${this.meetingId}]`);
await this.waitForSelector(e.chatUserMessageText, ELEMENT_WAIT_TIME);
await this.click(e.chatCopy);
// enable access to browser context clipboard

View File

@ -14,9 +14,8 @@ class Poll extends Notifications {
try {
// 0 messages
const chat0 = await this.page3.page.evaluate(() => document.querySelectorAll('p[data-test="chatPollMessageText"]').length === 0);
if (process.env.GENERATE_EVIDENCES === 'true') {
await this.page3.screenshot(`${testName}`, `01-before-chat-message-send-[${this.page3.meetingId}]`);
}
await this.page3.screenshot(`${testName}`, `01-before-chat-message-send-[${this.page3.meetingId}]`);
await this.publishPollResults(testName);
await this.page3.waitForSelector(e.chatButton, ELEMENT_WAIT_TIME);

View File

@ -12,13 +12,11 @@ class Save extends Page {
async test(testName) {
try {
await util.openChat(this);
if (process.env.GENERATE_EVIDENCES === 'true') {
await this.screenshot(`${testName}`, `01-before-chat-options-click-[${this.meetingId}]`);
}
await this.screenshot(`${testName}`, `01-before-chat-options-click-[${this.meetingId}]`);
await this.click(e.chatOptions, true);
if (process.env.GENERATE_EVIDENCES === 'true') {
await this.screenshot(`${testName}`, `02-chat-options-clicked-[${this.meetingId}]`);
}
await this.screenshot(`${testName}`, `02-chat-options-clicked-[${this.meetingId}]`);
await this.click(e.chatSave, true);
let clicked = '';
clicked = await this.page.addListener('click', () => document.addEventListener('click'));

View File

@ -15,18 +15,15 @@ class Send extends Page {
// 0 messages
const chat0 = await this.page.evaluate((chatSelector) => document.querySelectorAll(chatSelector).length === 0, e.chatUserMessageText);
if (process.env.GENERATE_EVIDENCES === 'true') {
await this.screenshot(`${testName}`, `01-before-chat-message-send-[${this.meetingId}]`);
}
await this.screenshot(`${testName}`, `01-before-chat-message-send-[${this.meetingId}]`);
// send a message
await this.type(e.chatBox, e.message);
if (process.env.GENERATE_EVIDENCES === 'true') {
await this.screenshot(`${testName}`, `02-typing-chat-message-[${this.meetingId}]`);
}
await this.screenshot(`${testName}`, `02-typing-chat-message-[${this.meetingId}]`);
await this.click(e.sendButton, true);
if (process.env.GENERATE_EVIDENCES === 'true') {
await this.screenshot(`${testName}`, `03-after-chat-message-send-[${this.meetingId}]`);
}
await this.screenshot(`${testName}`, `03-after-chat-message-send-[${this.meetingId}]`);
await this.waitForSelector(e.chatUserMessageText);
// 1 message

View File

@ -12,18 +12,15 @@ class Trigger extends Page {
async triggerMeteorDisconnect(testName) {
try {
if (process.env.GENERATE_EVIDENCES === 'true') {
await this.screenshot(`${testName}`, `01-before-audio-modal-close-[${this.meetingId}]`);
}
await this.screenshot(`${testName}`, `01-before-audio-modal-close-[${this.meetingId}]`);
await this.closeAudioModal();
if (process.env.GENERATE_EVIDENCES === 'true') {
await this.screenshot(`${testName}`, `02-after-audio-modal-close-[${this.meetingId}]`);
}
await this.screenshot(`${testName}`, `02-after-audio-modal-close-[${this.meetingId}]`);
await sleep(5000);
await this.page.evaluate(() => Meteor.disconnect());
if (process.env.GENERATE_EVIDENCES === 'true') {
await this.screenshot(`${testName}`, `03-after-meteor-disconnection-[${this.meetingId}]`);
}
await this.screenshot(`${testName}`, `03-after-meteor-disconnection-[${this.meetingId}]`);
await sleep(CLIENT_RECONNECTION_TIMEOUT);
const meteorStatus = await this.page.evaluate(() => Meteor.status());
const meteorStatusConfirm = await meteorStatus.status === "offline";
@ -34,9 +31,8 @@ class Trigger extends Page {
await this.logger('Check if Connections Buttons are disabled => ', getAudioButton);
await this.page.evaluate(() => Meteor.reconnect());
await sleep(3000);
if (process.env.GENERATE_EVIDENCES === 'true') {
await this.screenshot(`${testName}`, `04-after-meteor-reconnection-[${this.meetingId}]`);
}
await this.screenshot(`${testName}`, `04-after-meteor-reconnection-[${this.meetingId}]`);
const findUnauthorized = await this.page.evaluate(util.countTestElements, e.unauthorized) === true;
await this.logger('Check if Unauthorized message appears => ', findUnauthorized);
return meteorStatusConfirm && getAudioButton && findUnauthorized;
@ -48,13 +44,11 @@ class Trigger extends Page {
async triggerNetworkServiceDisconnection(testName) {
try {
if (process.env.GENERATE_EVIDENCES === 'true') {
await this.screenshot(`${testName}`, `01-before-audio-modal-close-[${this.meetingId}]`);
}
await this.screenshot(`${testName}`, `01-before-audio-modal-close-[${this.meetingId}]`);
await this.closeAudioModal();
if (process.env.GENERATE_EVIDENCES === 'true') {
await this.screenshot(`${testName}`, `02-after-audio-modal-close-[${this.meetingId}]`);
}
await this.screenshot(`${testName}`, `02-after-audio-modal-close-[${this.meetingId}]`);
await sleep(5000);
await this.logger('Stopping Network Service...');
await exec('sh tests/puppeteer/events/stop-network.sh', (error, data, getter) => {
@ -71,9 +65,8 @@ class Trigger extends Page {
const meteorStatus = await this.page.evaluate(() => Meteor.status());
const meteorStatusConfirm = await meteorStatus.status === "offline";
await this.logger('Check if Meteor is Offline => ', meteorStatusConfirm);
if (process.env.GENERATE_EVIDENCES === 'true') {
await this.screenshot(`${testName}`, `03-after-network-service-shutdown-[${this.meetingId}]`);
}
await this.screenshot(`${testName}`, `03-after-network-service-shutdown-[${this.meetingId}]`);
await this.logger('Counting ', CLIENT_RECONNECTION_TIMEOUT / 6000, ' seconds...');
await sleep(CLIENT_RECONNECTION_TIMEOUT);
await this.logger('Restarting Network Service...');
@ -88,9 +81,8 @@ class Trigger extends Page {
}
console.log("data", data);
});
if (process.env.GENERATE_EVIDENCES === 'true') {
await this.screenshot(`${testName}`, `04-after-network-service-restart-[${this.meetingId}]`);
}
await this.screenshot(`${testName}`, `04-after-network-service-restart-[${this.meetingId}]`);
await this.page.reload();
await this.closeAudioModal();
const getAudioButton = await this.page.evaluate(() =>

View File

@ -10,9 +10,8 @@ class Polling extends Page {
async test(testName) {
try {
await utilNotification.startPoll(this);
if (process.env.GENERATE_EVIDENCES === 'true') {
await this.screenshot(`${testName}`, `01-before-chat-message-send-[${this.meetingId}]`);
}
await this.screenshot(`${testName}`, `01-before-chat-message-send-[${this.meetingId}]`);
const resp = this.page.evaluate(() => document.querySelectorAll('[data-test="pollMenuButton"]').length === 1);
return resp;
} catch (e) {

View File

@ -19,9 +19,8 @@ class Upload extends Page {
await this.click(ce.actions, true);
await this.click(e.uploadPresentation, true);
if (process.env.GENERATE_EVIDENCES === 'true') {
await this.screenshot(`${testName}`, `01-before-presentation-upload-[${testName}]`);
}
await this.screenshot(`${testName}`, `01-before-presentation-upload-[${testName}]`);
await this.waitForSelector(e.fileUpload, ELEMENT_WAIT_TIME);
const fileUpload = await this.page.$(e.fileUpload);
await fileUpload.uploadFile(`${__dirname}/upload-test.png`);
@ -39,9 +38,8 @@ class Upload extends Page {
await this.page.waitForFunction(
'document.querySelector("body").innerText.includes("Current presentation")',
);
if (process.env.GENERATE_EVIDENCES === 'true') {
await this.screenshot(`${testName}`, `02-after-presentation-upload-[${testName}]`);
}
await this.screenshot(`${testName}`, `02-after-presentation-upload-[${testName}]`);
const slides1 = await this.page.evaluate(async () => await document.querySelector('svg g g g').outerHTML);
await this.logger('\nSlides before presentation upload:');