bigbluebutton-Github/bigbluebutton-tests/puppeteer/stress/stress.js

38 lines
1.3 KiB
JavaScript
Raw Normal View History

2021-08-10 04:36:16 +08:00
const Page = require('../core/page');
const e = require('../core/elements');
const c = require('../core/constants');
2021-08-21 04:33:57 +08:00
const util = require('./util');
2021-08-10 04:36:16 +08:00
class Stress extends Page {
constructor() {
2021-09-23 03:22:47 +08:00
super();
2021-08-10 04:36:16 +08:00
}
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++) {
2021-09-30 20:36:08 +08:00
await this.init(true, true, testName, `Moderator-${i}`);
await this.waitForSelector(e.userAvatar);
const hasPresenterClass = await this.page.evaluate(util.checkIncludeClass, e.userAvatar, e.presenterClassName);
await this.waitAndClick(e.actions);
2021-10-07 22:29:18 +08:00
const canStartPoll = await this.hasElement(e.polling);
2021-08-10 04:36:16 +08:00
if (!hasPresenterClass || !canStartPoll) {
failureCount++;
2021-09-30 20:36:08 +08:00
await this.screenshot(testName, `loop-${i}-failure-${testName}`);
2021-08-10 04:36:16 +08:00
}
await this.close();
await this.logger(`Loop ${i} of ${c.JOIN_AS_MODERATOR_TEST_ROUNDS} completed`);
if (failureCount > maxFailRate) return false;
}
return true;
} catch (err) {
2021-08-10 04:36:16 +08:00
await this.close();
this.logger(err);
2021-08-10 04:36:16 +08:00
return false;
}
}
}
module.exports = exports = Stress;