2021-09-22 21:11:56 +08:00
|
|
|
const { ELEMENT_WAIT_LONGER_TIME } = require('../core/constants');
|
2018-11-23 20:55:16 +08:00
|
|
|
const Page = require('../core/page');
|
2021-09-22 11:51:29 +08:00
|
|
|
const e = require('../core/elements');
|
2018-11-23 20:55:16 +08:00
|
|
|
const util = require('./util');
|
2021-03-31 21:10:57 +08:00
|
|
|
const utilWebcam = require('../webcam/util');
|
|
|
|
const utilScreenshare = require('../screenshare/util');
|
|
|
|
const { sleep } = require('../core/helper');
|
2021-09-22 21:11:56 +08:00
|
|
|
const { checkElementLengthEqualTo, checkElementLengthDifferentTo } = require('../core/util');
|
2018-11-23 20:55:16 +08:00
|
|
|
|
|
|
|
class Status extends Page {
|
|
|
|
constructor() {
|
|
|
|
super('user-status');
|
|
|
|
}
|
|
|
|
|
|
|
|
async test() {
|
2021-08-14 01:35:00 +08:00
|
|
|
try {
|
|
|
|
await util.setStatus(this, e.applaud);
|
2021-09-03 02:31:24 +08:00
|
|
|
const resp1 = await this.page.evaluate(checkElementLengthDifferentTo, e.applauseIcon, 0);
|
2021-08-14 01:35:00 +08:00
|
|
|
await util.setStatus(this, e.away);
|
2021-09-03 02:31:24 +08:00
|
|
|
const resp2 = await this.page.evaluate(checkElementLengthDifferentTo, e.awayIcon, 0);
|
2018-11-23 20:55:16 +08:00
|
|
|
|
2021-09-22 21:11:56 +08:00
|
|
|
await this.waitAndClick(e.firstUser);
|
|
|
|
await this.waitAndClick(e.clearStatus);
|
2021-08-14 01:35:00 +08:00
|
|
|
return resp1 === resp2;
|
2021-08-26 22:13:18 +08:00
|
|
|
} catch (err) {
|
|
|
|
await this.logger(err);
|
2021-08-14 01:35:00 +08:00
|
|
|
return false;
|
|
|
|
}
|
2018-11-23 20:55:16 +08:00
|
|
|
}
|
2021-03-31 21:10:57 +08:00
|
|
|
|
2021-04-02 08:54:55 +08:00
|
|
|
async mobileTagName() {
|
2021-08-14 01:35:00 +08:00
|
|
|
try {
|
2021-09-22 21:11:56 +08:00
|
|
|
await this.waitAndClick(e.userList);
|
|
|
|
await this.waitForSelector(e.firstUser);
|
2021-04-02 08:54:55 +08:00
|
|
|
|
2021-09-03 02:31:24 +08:00
|
|
|
const response = await this.page.evaluate(checkElementLengthDifferentTo, e.mobileUser, 0);
|
2021-08-14 01:35:00 +08:00
|
|
|
return response === true;
|
2021-08-26 22:13:18 +08:00
|
|
|
} catch (err) {
|
|
|
|
await this.logger(err);
|
2021-08-14 01:35:00 +08:00
|
|
|
return false;
|
|
|
|
}
|
2021-04-02 08:54:55 +08:00
|
|
|
}
|
|
|
|
|
2021-03-31 21:10:57 +08:00
|
|
|
async findConnectionStatusModal() {
|
2021-08-14 01:35:00 +08:00
|
|
|
try {
|
2021-09-22 21:11:56 +08:00
|
|
|
await util.connectionStatus(this);
|
2021-09-03 02:31:24 +08:00
|
|
|
const resp = await this.page.evaluate(checkElementLengthDifferentTo, e.connectionStatusModal, 0);
|
2021-08-14 01:35:00 +08:00
|
|
|
return resp === true;
|
2021-08-26 22:13:18 +08:00
|
|
|
} catch (err) {
|
|
|
|
await this.logger(err);
|
2021-08-14 01:35:00 +08:00
|
|
|
return false;
|
|
|
|
}
|
2021-03-31 21:10:57 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
async disableWebcamsFromConnectionStatus() {
|
|
|
|
try {
|
|
|
|
await this.closeAudioModal();
|
|
|
|
await utilWebcam.enableWebcam(this, ELEMENT_WAIT_LONGER_TIME);
|
|
|
|
await util.connectionStatus(this);
|
2021-09-22 21:11:56 +08:00
|
|
|
await this.waitAndClickElement(e.dataSavingWebcams);
|
|
|
|
await this.waitAndClickElement(e.closeConnectionStatusModal);
|
2021-03-31 21:10:57 +08:00
|
|
|
await sleep(2000);
|
2021-08-21 04:33:57 +08:00
|
|
|
const webcamsIsDisabledInDataSaving = await this.page.evaluate(checkElementLengthDifferentTo, e.webcamsIsDisabledInDataSaving, 0);
|
2021-03-31 21:10:57 +08:00
|
|
|
return webcamsIsDisabledInDataSaving === true;
|
2021-08-26 22:13:18 +08:00
|
|
|
} catch (err) {
|
|
|
|
await this.logger(err);
|
2021-03-31 21:10:57 +08:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
async disableScreenshareFromConnectionStatus() {
|
|
|
|
try {
|
|
|
|
await this.closeAudioModal();
|
|
|
|
await utilScreenshare.startScreenshare(this);
|
|
|
|
await utilScreenshare.waitForScreenshareContainer(this);
|
|
|
|
await util.connectionStatus(this);
|
2021-09-22 21:11:56 +08:00
|
|
|
await this.waitAndClickElement(e.dataSavingScreenshare);
|
|
|
|
await this.waitAndClickElement(e.closeConnectionStatusModal);
|
2021-03-31 21:10:57 +08:00
|
|
|
await sleep(2000);
|
2021-08-21 04:33:57 +08:00
|
|
|
const webcamsIsDisabledInDataSaving = await this.page.evaluate(checkElementLengthEqualTo, e.screenshareLocked, 0);
|
2021-03-31 21:10:57 +08:00
|
|
|
return webcamsIsDisabledInDataSaving === true;
|
2021-08-26 22:13:18 +08:00
|
|
|
} catch (err) {
|
|
|
|
await this.logger(err);
|
2021-03-31 21:10:57 +08:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
2018-11-23 20:55:16 +08:00
|
|
|
|
2021-04-01 21:55:27 +08:00
|
|
|
async reportUserInConnectionIssues() {
|
|
|
|
try {
|
2021-04-02 10:14:37 +08:00
|
|
|
await this.page.evaluate(() => window.dispatchEvent(new CustomEvent('socketstats', { detail: { rtt: 2000 } })));
|
2021-04-01 21:55:27 +08:00
|
|
|
await this.joinMicrophone();
|
|
|
|
await utilWebcam.enableWebcam(this, ELEMENT_WAIT_LONGER_TIME);
|
|
|
|
await utilScreenshare.startScreenshare(this);
|
|
|
|
await utilScreenshare.waitForScreenshareContainer(this);
|
|
|
|
await util.connectionStatus(this);
|
2021-04-02 10:14:37 +08:00
|
|
|
await sleep(5000);
|
2021-08-21 04:33:57 +08:00
|
|
|
const connectionStatusItemEmpty = await this.page.evaluate(checkElementLengthEqualTo, e.connectionStatusItemEmpty, 0);
|
|
|
|
const connectionStatusItemUser = await this.page.evaluate(checkElementLengthDifferentTo, e.connectionStatusItemUser, 0);
|
2021-04-01 21:55:27 +08:00
|
|
|
return connectionStatusItemUser && connectionStatusItemEmpty;
|
2021-08-26 22:13:18 +08:00
|
|
|
} catch (err) {
|
|
|
|
await this.logger(err);
|
2021-04-01 21:55:27 +08:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-08-14 01:35:00 +08:00
|
|
|
|
2018-11-23 20:55:16 +08:00
|
|
|
module.exports = exports = Status;
|