2020-05-08 04:55:40 +08:00
|
|
|
const Page = require('../core/page');
|
|
|
|
const params = require('../params');
|
2021-02-17 04:57:10 +08:00
|
|
|
const { USER_LIST_VLIST_BOTS_LISTENING, ELEMENT_WAIT_TIME } = require('../core/constants');
|
|
|
|
const ue = require('../user/elements');
|
2021-08-21 04:33:57 +08:00
|
|
|
const { getElementLength } = require('../core/util')
|
2020-05-08 04:55:40 +08:00
|
|
|
|
|
|
|
class VirtualizeList {
|
|
|
|
constructor() {
|
|
|
|
this.page1 = new Page();
|
|
|
|
this.pagesArray = [];
|
|
|
|
}
|
|
|
|
|
|
|
|
// Join BigBlueButton meeting
|
2021-02-26 23:52:17 +08:00
|
|
|
async init(meetingId, testName) {
|
2020-05-08 04:55:40 +08:00
|
|
|
try {
|
2021-02-26 23:52:17 +08:00
|
|
|
await this.page1.init(Page.getArgs(), meetingId, { ...params, fullName: 'BroadCaster1' }, undefined, testName);
|
2020-07-21 06:01:25 +08:00
|
|
|
await this.page1.closeAudioModal();
|
2021-02-17 04:57:10 +08:00
|
|
|
await this.page1.waitForSelector(ue.anyUser, ELEMENT_WAIT_TIME);
|
|
|
|
for (let i = 1; i <= parseInt(USER_LIST_VLIST_BOTS_LISTENING); i++) {
|
2020-05-08 04:55:40 +08:00
|
|
|
const viewerPage = new Page();
|
2021-02-26 23:52:17 +08:00
|
|
|
await viewerPage.init(Page.getArgs(), this.page1.meetingId, { ...params, fullName: `Viewer${i}`, moderatorPW: '' }, undefined, testName);
|
2020-07-21 06:01:25 +08:00
|
|
|
await viewerPage.closeAudioModal();
|
2020-05-08 04:55:40 +08:00
|
|
|
await this.pagesArray.push(viewerPage);
|
|
|
|
|
|
|
|
await this.page1.getMetrics();
|
|
|
|
}
|
|
|
|
await this.page1.getMetrics();
|
2021-08-26 22:13:18 +08:00
|
|
|
} catch (err) {
|
|
|
|
await this.page1.logger(err);
|
2020-05-08 04:55:40 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
async test() {
|
|
|
|
try {
|
2021-08-21 04:33:57 +08:00
|
|
|
const USER_LIST_VLIST_VISIBLE_USERS = await this.page1.page.evaluate(getElementLength, ue.anyUser);
|
2020-05-08 04:55:40 +08:00
|
|
|
const totalNumberOfUsersMongo = await this.page1.page.evaluate(() => {
|
2021-04-21 00:59:04 +08:00
|
|
|
const collection = require('/imports/api/users/index.js');
|
|
|
|
const users = collection.default._collection.find().count();
|
2020-05-08 04:55:40 +08:00
|
|
|
return users;
|
|
|
|
});
|
|
|
|
if (USER_LIST_VLIST_VISIBLE_USERS === totalNumberOfUsersMongo) {
|
|
|
|
return false;
|
|
|
|
} if ((USER_LIST_VLIST_VISIBLE_USERS !== totalNumberOfUsersMongo) && (USER_LIST_VLIST_VISIBLE_USERS < totalNumberOfUsersMongo)) {
|
|
|
|
return true;
|
|
|
|
}
|
2021-08-26 22:13:18 +08:00
|
|
|
} catch (err) {
|
|
|
|
await this.page1.logger(err);
|
2021-08-14 01:35:00 +08:00
|
|
|
return false;
|
2020-05-08 04:55:40 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
async close() {
|
|
|
|
try {
|
|
|
|
this.page1.close();
|
|
|
|
this.pagesArray.forEach(page => page.close());
|
2021-08-26 22:13:18 +08:00
|
|
|
} catch (err) {
|
|
|
|
await this.page1.logger(err);
|
2020-05-08 04:55:40 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = exports = VirtualizeList;
|