2021-08-10 04:36:16 +08:00
|
|
|
const Page = require('../core/page');
|
|
|
|
const params = require('../params');
|
2021-08-21 04:33:57 +08:00
|
|
|
const c = require('../core/constants');
|
2021-08-10 04:36:16 +08:00
|
|
|
const ne = require('../notifications/elements');
|
|
|
|
const ue = require('../user/elements');
|
|
|
|
const e = require('../core/elements');
|
2021-08-21 04:33:57 +08:00
|
|
|
const util = require('./util');
|
|
|
|
const { checkElementLengthEqualTo } = require('../core/util');
|
2021-08-10 04:36:16 +08:00
|
|
|
|
|
|
|
class Stress extends Page {
|
|
|
|
constructor() {
|
|
|
|
super('stress');
|
|
|
|
}
|
|
|
|
|
|
|
|
async moderatorAsPresenter(testName) {
|
|
|
|
try {
|
|
|
|
const maxFailRate = c.JOIN_AS_MODERATOR_TEST_ROUNDS * c.MAX_JOIN_AS_MODERATOR_FAIL_RATE;
|
|
|
|
let failureCount = 0;
|
|
|
|
for (let i = 1; i <= c.JOIN_AS_MODERATOR_TEST_ROUNDS; i++) {
|
|
|
|
await this.init(Page.getArgs(), undefined, { ...params, fullName: `Moderator-${i}` }, undefined, testName);
|
|
|
|
await this.closeAudioModal();
|
|
|
|
await this.page.waitForSelector(ue.statusIcon, { timeout: c.ELEMENT_WAIT_TIME });
|
2021-08-21 04:33:57 +08:00
|
|
|
const hasPresenterClass = await this.page.evaluate(util.checkIncludeClass, ue.statusIcon, e.presenterClassName);
|
2021-08-10 04:36:16 +08:00
|
|
|
await this.click(e.actions);
|
2021-08-21 04:33:57 +08:00
|
|
|
const canStartPoll = await this.page.evaluate(checkElementLengthEqualTo, ne.polling, 1);
|
2021-08-10 04:36:16 +08:00
|
|
|
if (!hasPresenterClass || !canStartPoll) {
|
|
|
|
failureCount++;
|
|
|
|
await this.screenshot(`${testName}`, `loop-${i}-failure-${testName}`);
|
|
|
|
}
|
|
|
|
await this.close();
|
|
|
|
await this.logger(`Loop ${i} of ${c.JOIN_AS_MODERATOR_TEST_ROUNDS} completed`);
|
|
|
|
if (failureCount > maxFailRate) return false;
|
|
|
|
}
|
|
|
|
return true;
|
2021-08-10 22:24:55 +08:00
|
|
|
} catch (err) {
|
2021-08-10 04:36:16 +08:00
|
|
|
await this.close();
|
2021-08-10 22:24:55 +08:00
|
|
|
this.logger(err);
|
2021-08-10 04:36:16 +08:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = exports = Stress;
|