2021-04-15 00:16:41 +08:00
|
|
|
const { toMatchImageSnapshot } = require('jest-image-snapshot');
|
2021-09-28 11:21:14 +08:00
|
|
|
const CustomParameters = require('../customparameters/customparameters');
|
|
|
|
const Multiusers = require('../user/multiusers');
|
|
|
|
const Polling = require('./poll');
|
|
|
|
const Page = require('../core/page');
|
|
|
|
const Poll = require('../chat/poll');
|
|
|
|
const ce = require('../customparameters/constants');
|
|
|
|
const { MAX_POLLING_TEST_TIMEOUT, TEST_DURATION_TIME } = require('../core/constants'); // core constants (Timeouts vars imported)
|
2021-02-17 04:57:10 +08:00
|
|
|
|
|
|
|
expect.extend({ toMatchImageSnapshot });
|
|
|
|
|
|
|
|
const pollingTest = () => {
|
|
|
|
beforeEach(() => {
|
|
|
|
jest.setTimeout(MAX_POLLING_TEST_TIMEOUT);
|
|
|
|
});
|
|
|
|
|
2021-03-09 05:11:36 +08:00
|
|
|
// Create Poll
|
|
|
|
test('Create Poll', async () => {
|
|
|
|
const test = new Polling();
|
|
|
|
let response;
|
|
|
|
let screenshot;
|
|
|
|
try {
|
|
|
|
const testName = 'createPoll';
|
|
|
|
await test.logger('begin of ', testName);
|
2021-09-30 20:36:08 +08:00
|
|
|
await test.init(true, testName);
|
2021-03-09 05:11:36 +08:00
|
|
|
await test.startRecording(testName);
|
2021-04-15 00:16:41 +08:00
|
|
|
response = await test.test(testName);
|
2021-03-09 05:11:36 +08:00
|
|
|
await test.logger('end of ', testName);
|
|
|
|
await test.stopRecording();
|
|
|
|
screenshot = await test.page.screenshot();
|
2021-08-26 22:13:18 +08:00
|
|
|
} catch (err) {
|
|
|
|
await test.logger(err);
|
2021-03-09 05:11:36 +08:00
|
|
|
} finally {
|
|
|
|
await test.close();
|
|
|
|
}
|
|
|
|
expect(response).toBe(true);
|
2021-10-01 02:45:59 +08:00
|
|
|
Page.checkRegression(1.37, screenshot);
|
2021-04-15 00:16:41 +08:00
|
|
|
}, TEST_DURATION_TIME);
|
2021-02-17 04:57:10 +08:00
|
|
|
|
2021-03-09 05:11:36 +08:00
|
|
|
// Check for Poll Results chat message and return true when it appears
|
|
|
|
test('Poll Results chat message', async () => {
|
|
|
|
const test = new Poll();
|
|
|
|
let response;
|
|
|
|
let screenshot;
|
|
|
|
try {
|
|
|
|
const testName = 'pollResultsChatMessage';
|
|
|
|
await test.page3.logger('begin of ', testName);
|
2021-09-30 20:36:08 +08:00
|
|
|
await test.initUser3(true, testName);
|
2021-03-09 05:11:36 +08:00
|
|
|
await test.page3.startRecording(testName);
|
|
|
|
response = await test.test(testName);
|
|
|
|
await test.page3.logger('end of ', testName);
|
|
|
|
await test.page3.stopRecording();
|
|
|
|
screenshot = await test.page3.page.screenshot();
|
2021-08-26 22:13:18 +08:00
|
|
|
} catch (err) {
|
|
|
|
await test.page3.logger(err);
|
2021-03-09 05:11:36 +08:00
|
|
|
} finally {
|
|
|
|
await test.closePage(test.page3);
|
|
|
|
}
|
|
|
|
expect(response).toBe(true);
|
2021-10-01 02:45:59 +08:00
|
|
|
Page.checkRegression(0.9, screenshot);
|
2021-04-15 00:16:41 +08:00
|
|
|
}, TEST_DURATION_TIME);
|
2021-03-08 07:53:58 +08:00
|
|
|
|
2021-03-09 05:11:36 +08:00
|
|
|
// This test spec sets the userdata-bbb_force_restore_presentation_on_new_events parameter to true
|
|
|
|
// and checks that the viewers get the presentation restored forcefully when the Moderator zooms
|
|
|
|
// publishes a poll result
|
|
|
|
test('Force Restore Presentation On New Poll Result', async () => {
|
|
|
|
const test = new CustomParameters();
|
|
|
|
let response;
|
|
|
|
let screenshot;
|
|
|
|
try {
|
|
|
|
const testName = 'forceRestorePresentationOnNewPollResult';
|
|
|
|
await test.page1.logger('begin of ', testName);
|
2021-09-30 20:36:08 +08:00
|
|
|
response = await test.forceRestorePresentationOnNewPollResult(ce.forceRestorePresentationOnNewEvents, testName);
|
2021-03-09 05:11:36 +08:00
|
|
|
await test.page1.logger('end of ', testName);
|
|
|
|
await test.page2.stopRecording();
|
|
|
|
screenshot = await test.page1.page.screenshot();
|
2021-08-26 22:13:18 +08:00
|
|
|
} catch (err) {
|
|
|
|
await test.page1.logger(err);
|
2021-03-09 05:11:36 +08:00
|
|
|
} finally {
|
|
|
|
await test.close(test.page1, test.page2);
|
|
|
|
}
|
|
|
|
expect(response).toBe(true);
|
2021-10-01 02:45:59 +08:00
|
|
|
Page.checkRegression(0.5, screenshot);
|
2021-04-15 00:16:41 +08:00
|
|
|
}, TEST_DURATION_TIME);
|
2021-02-17 04:57:10 +08:00
|
|
|
|
2021-03-09 05:11:36 +08:00
|
|
|
// This Test chooses randomly a polling case, runs it
|
|
|
|
// and expects having it answered by the other user
|
2021-03-08 07:53:58 +08:00
|
|
|
test('Random Poll', async () => {
|
|
|
|
const test = new Multiusers();
|
2021-02-17 04:57:10 +08:00
|
|
|
let response;
|
|
|
|
let screenshot;
|
|
|
|
try {
|
2021-03-08 07:53:58 +08:00
|
|
|
const testName = 'randomPoll';
|
2021-02-17 04:57:10 +08:00
|
|
|
await test.page1.logger('begin of ', testName);
|
2021-09-30 20:36:08 +08:00
|
|
|
await test.init(testName);
|
2021-03-08 07:53:58 +08:00
|
|
|
response = await test.randomPoll(testName);
|
2021-02-17 04:57:10 +08:00
|
|
|
await test.page1.logger('end of ', testName);
|
2021-03-08 07:53:58 +08:00
|
|
|
await test.page1.stopRecording();
|
2021-03-09 05:11:36 +08:00
|
|
|
await test.page2.stopRecording();
|
2021-02-17 04:57:10 +08:00
|
|
|
screenshot = await test.page1.page.screenshot();
|
2021-08-26 22:13:18 +08:00
|
|
|
} catch (err) {
|
|
|
|
await test.page1.logger(err);
|
2021-02-17 04:57:10 +08:00
|
|
|
} finally {
|
|
|
|
await test.close(test.page1, test.page2);
|
|
|
|
}
|
|
|
|
expect(response).toBe(true);
|
2021-10-01 02:45:59 +08:00
|
|
|
Page.checkRegression(0.5, screenshot);
|
2021-04-15 00:16:41 +08:00
|
|
|
}, TEST_DURATION_TIME);
|
2021-02-17 04:57:10 +08:00
|
|
|
};
|
2021-09-30 20:36:08 +08:00
|
|
|
module.exports = exports = pollingTest;
|