2021-03-31 21:10:57 +08:00
const { ELEMENT _WAIT _TIME , ELEMENT _WAIT _LONGER _TIME } = require ( '../core/constants' ) ;
2018-11-23 20:55:16 +08:00
const Page = require ( '../core/page' ) ;
const e = require ( './elements' ) ;
const util = require ( './util' ) ;
2021-03-31 21:10:57 +08:00
const utilWebcam = require ( '../webcam/util' ) ;
const utilScreenshare = require ( '../screenshare/util' ) ;
const utilB = require ( '../breakout/util' ) ;
const { sleep } = require ( '../core/helper' ) ;
2018-11-23 20:55:16 +08:00
class Status extends Page {
constructor ( ) {
super ( 'user-status' ) ;
}
async test ( ) {
await util . setStatus ( this , e . applaud ) ;
2021-02-17 04:57:10 +08:00
const resp1 = await this . page . evaluate ( util . countTestElements , 'div[data-test="userAvatar"] > div > i[class="icon-bbb-applause"]' ) ;
2018-11-23 20:55:16 +08:00
await util . setStatus ( this , e . away ) ;
2021-02-17 04:57:10 +08:00
const resp2 = await this . page . evaluate ( util . countTestElements , 'div[data-test="userAvatar"] > div > i[class="icon-bbb-time"]' ) ;
2018-11-23 20:55:16 +08:00
2021-02-17 04:57:10 +08:00
await this . click ( e . firstUser , true ) ;
await this . waitForSelector ( e . clearStatus , ELEMENT _WAIT _TIME ) ;
2018-11-23 20:55:16 +08:00
await this . click ( e . clearStatus , true ) ;
2021-02-17 04:57:10 +08:00
return resp1 === resp2 ;
2018-11-23 20:55:16 +08:00
}
2021-03-31 21:10:57 +08:00
async findConnectionStatusModal ( ) {
await util . connectionStatus ( this . page ) ;
const resp = await ( await this . page . $$ ( 'div[aria-label="Connection status modal"]' ) ) . length === 1 ;
return resp ;
}
async disableWebcamsFromConnectionStatus ( ) {
try {
await this . closeAudioModal ( ) ;
await utilWebcam . enableWebcam ( this , ELEMENT _WAIT _LONGER _TIME ) ;
await util . connectionStatus ( this ) ;
await this . waitForSelector ( e . dataSavingWebcams , ELEMENT _WAIT _TIME ) ;
await this . page . evaluate ( utilB . clickTestElement , e . dataSavingWebcams ) ;
await this . waitForSelector ( e . closeConnectionStatusModal , ELEMENT _WAIT _TIME ) ;
await this . page . evaluate ( utilB . clickTestElement , e . closeConnectionStatusModal ) ;
await sleep ( 2000 ) ;
const webcamsIsDisabledInDataSaving = await this . page . evaluate ( ( ) => document . querySelectorAll ( 'button[aria-label="Webcam sharing is disabled in Data Saving"]' ) . length === 1 ) ;
return webcamsIsDisabledInDataSaving === true ;
} catch ( e ) {
console . log ( e ) ;
return false ;
}
}
async disableScreenshareFromConnectionStatus ( ) {
try {
await this . closeAudioModal ( ) ;
await utilScreenshare . startScreenshare ( this ) ;
await utilScreenshare . waitForScreenshareContainer ( this ) ;
await util . connectionStatus ( this ) ;
await this . waitForSelector ( e . dataSavingScreenshare , ELEMENT _WAIT _TIME ) ;
await this . page . evaluate ( utilB . clickTestElement , e . dataSavingScreenshare ) ;
await this . waitForSelector ( e . closeConnectionStatusModal , ELEMENT _WAIT _TIME ) ;
await this . page . evaluate ( utilB . clickTestElement , e . closeConnectionStatusModal ) ;
await sleep ( 2000 ) ;
const webcamsIsDisabledInDataSaving = await this . page . evaluate ( ( ) => document . querySelectorAll ( 'button[aria-label="Screenshare locked"]' ) . length === 1 ) ;
return webcamsIsDisabledInDataSaving === true ;
} catch ( e ) {
console . log ( e ) ;
return false ;
}
}
2018-11-23 20:55:16 +08:00
}
module . exports = exports = Status ;