2021-09-28 11:21:14 +08:00
|
|
|
const Page = require('../core/page');
|
2021-10-20 04:12:00 +08:00
|
|
|
const Poll = require('./poll');
|
|
|
|
const { closePages } = require('../core/util');
|
2021-09-28 11:21:14 +08:00
|
|
|
const { MAX_POLLING_TEST_TIMEOUT, TEST_DURATION_TIME } = require('../core/constants'); // core constants (Timeouts vars imported)
|
2021-10-20 04:12:00 +08:00
|
|
|
const { toMatchImageSnapshot } = require('jest-image-snapshot');
|
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 () => {
|
2021-10-20 04:12:00 +08:00
|
|
|
const test = new Poll();
|
2021-03-09 05:11:36 +08:00
|
|
|
let response;
|
|
|
|
let screenshot;
|
|
|
|
try {
|
|
|
|
const testName = 'createPoll';
|
2021-10-20 04:12:00 +08:00
|
|
|
await test.modPage.logger('begin of ', testName);
|
|
|
|
await test.initModPage(true, testName);
|
|
|
|
await test.modPage.startRecording(testName);
|
|
|
|
response = await test.createPoll(testName);
|
|
|
|
await test.modPage.logger('end of ', testName);
|
|
|
|
await test.modPage.stopRecording();
|
|
|
|
screenshot = await test.modPage.page.screenshot();
|
2021-08-26 22:13:18 +08:00
|
|
|
} catch (err) {
|
2021-10-20 04:12:00 +08:00
|
|
|
await test.modPage.logger(err);
|
2021-03-09 05:11:36 +08:00
|
|
|
} finally {
|
2021-10-20 04:12:00 +08:00
|
|
|
await test.modPage.close();
|
2021-03-09 05:11:36 +08:00
|
|
|
}
|
|
|
|
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-10-21 22:11:43 +08:00
|
|
|
// Create anonymous poll and check if its possible to see the user's response
|
|
|
|
test('Create anonymous poll', async () => {
|
|
|
|
const test = new Poll();
|
|
|
|
let response;
|
|
|
|
let screenshot;
|
|
|
|
try {
|
|
|
|
const testName = 'pollAnonymous';
|
|
|
|
await test.modPage.logger('begin of ', testName);
|
|
|
|
await test.initPages(testName);
|
|
|
|
await test.modPage.startRecording(testName);
|
|
|
|
response = await test.pollAnonymous(testName);
|
|
|
|
await test.modPage.logger('end of ', testName);
|
|
|
|
await test.modPage.stopRecording();
|
|
|
|
screenshot = await test.modPage.page.screenshot();
|
|
|
|
} catch (err) {
|
|
|
|
await test.modPage.logger(err);
|
|
|
|
} finally {
|
|
|
|
await closePages(test.modPage, test.userPage);
|
|
|
|
}
|
|
|
|
expect(response).toBe(true);
|
|
|
|
Page.checkRegression(0.9, screenshot);
|
|
|
|
}, TEST_DURATION_TIME);
|
|
|
|
|
2021-10-22 23:37:37 +08:00
|
|
|
// Create quick poll
|
|
|
|
test('Create quick poll - from the slide', async () => {
|
|
|
|
const test = new Poll();
|
|
|
|
let response;
|
|
|
|
let screenshot;
|
|
|
|
try {
|
|
|
|
const testName = 'createQuickPoll';
|
|
|
|
await test.modPage.logger('begin of ', testName);
|
|
|
|
await test.initPages(testName);
|
|
|
|
await test.modPage.startRecording(testName);
|
|
|
|
response = await test.quickPoll(testName);
|
|
|
|
await test.modPage.logger('end of ', testName);
|
|
|
|
await test.modPage.stopRecording();
|
|
|
|
screenshot = await test.modPage.page.screenshot();
|
|
|
|
} catch (err) {
|
|
|
|
await test.modPage.logger(err);
|
|
|
|
} finally {
|
|
|
|
await closePages(test.modPage, test.userPage);
|
|
|
|
}
|
|
|
|
expect(response).toBe(true);
|
|
|
|
Page.checkRegression(0.9, screenshot);
|
|
|
|
}, TEST_DURATION_TIME);
|
|
|
|
|
2021-10-25 23:01:40 +08:00
|
|
|
test('Create poll with user response', async () => {
|
|
|
|
const test = new Poll();
|
|
|
|
let response;
|
|
|
|
let screenshot;
|
|
|
|
try {
|
|
|
|
const testName = 'pollUserResponse';
|
|
|
|
await test.modPage.logger('begin of ', testName);
|
|
|
|
await test.initPages(testName);
|
|
|
|
response = await test.pollUserResponse(testName);
|
|
|
|
await test.modPage.logger('end of ', testName);
|
|
|
|
await test.modPage.stopRecording();
|
|
|
|
await test.userPage.stopRecording();
|
|
|
|
screenshot = await test.modPage.page.screenshot();
|
|
|
|
} catch (err) {
|
|
|
|
await test.modPage.logger(err);
|
|
|
|
} finally {
|
|
|
|
await closePages(test.modPage, test.userPage);
|
|
|
|
}
|
|
|
|
expect(response).toBe(true);
|
|
|
|
Page.checkRegression(0.5, screenshot);
|
|
|
|
}, TEST_DURATION_TIME);
|
|
|
|
|
2021-10-23 01:21:17 +08:00
|
|
|
// Stop a poll manually
|
|
|
|
test('Stop a poll manually', async () => {
|
|
|
|
const test = new Poll();
|
|
|
|
let response;
|
|
|
|
let screenshot;
|
|
|
|
try {
|
|
|
|
const testName = 'stopManuallyPoll';
|
|
|
|
await test.modPage.logger('begin of ', testName);
|
|
|
|
await test.initPages(testName);
|
|
|
|
await test.modPage.startRecording(testName);
|
|
|
|
response = await test.stopPoll(testName);
|
|
|
|
await test.modPage.logger('end of ', testName);
|
|
|
|
await test.modPage.stopRecording();
|
|
|
|
screenshot = await test.modPage.page.screenshot();
|
|
|
|
} catch (err) {
|
|
|
|
await test.modPage.logger(err);
|
|
|
|
} finally {
|
|
|
|
await closePages(test.modPage, test.userPage);
|
|
|
|
}
|
|
|
|
expect(response).toBe(true);
|
|
|
|
Page.checkRegression(0.9, screenshot);
|
|
|
|
}, TEST_DURATION_TIME);
|
|
|
|
|
2021-10-20 04:12:00 +08:00
|
|
|
// Check for Poll Results in chat message and return true when it appears
|
|
|
|
test('Poll results in chat message', async () => {
|
2021-03-09 05:11:36 +08:00
|
|
|
const test = new Poll();
|
|
|
|
let response;
|
|
|
|
let screenshot;
|
|
|
|
try {
|
2021-10-20 04:12:00 +08:00
|
|
|
const testName = 'pollResultsInChatMessage';
|
|
|
|
await test.modPage.logger('begin of ', testName);
|
|
|
|
await test.initModPage(true, testName);
|
|
|
|
await test.modPage.startRecording(testName);
|
|
|
|
response = await test.pollResultsOnChat(testName);
|
|
|
|
await test.modPage.logger('end of ', testName);
|
|
|
|
await test.modPage.stopRecording();
|
|
|
|
screenshot = await test.modPage.page.screenshot();
|
2021-08-26 22:13:18 +08:00
|
|
|
} catch (err) {
|
2021-10-20 04:12:00 +08:00
|
|
|
await test.modPage.logger(err);
|
2021-03-09 05:11:36 +08:00
|
|
|
} finally {
|
2021-10-21 01:39:36 +08:00
|
|
|
await test.modPage.close();
|
|
|
|
}
|
|
|
|
expect(response).toBe(true);
|
|
|
|
Page.checkRegression(0.9, screenshot);
|
|
|
|
}, TEST_DURATION_TIME);
|
|
|
|
|
2021-10-23 01:22:23 +08:00
|
|
|
// Check for Poll Results on the whiteboard and return true when it appears
|
|
|
|
test('Poll results on whiteboard', async () => {
|
2021-10-21 01:39:36 +08:00
|
|
|
const test = new Poll();
|
|
|
|
let response;
|
|
|
|
let screenshot;
|
|
|
|
try {
|
2021-10-23 01:22:23 +08:00
|
|
|
const testName = 'pollResultsOnWhiteboard';
|
2021-10-21 01:39:36 +08:00
|
|
|
await test.modPage.logger('begin of ', testName);
|
|
|
|
await test.initModPage(true, testName);
|
|
|
|
await test.modPage.startRecording(testName);
|
|
|
|
response = await test.pollResultsOnWhiteboard(testName);
|
|
|
|
await test.modPage.logger('end of ', testName);
|
|
|
|
await test.modPage.stopRecording();
|
|
|
|
screenshot = await test.modPage.page.screenshot();
|
|
|
|
} catch (err) {
|
|
|
|
await test.modPage.logger(err);
|
|
|
|
} finally {
|
2021-10-23 03:22:34 +08:00
|
|
|
await test.modPage.close();
|
|
|
|
}
|
|
|
|
expect(response).toBe(true);
|
|
|
|
Page.checkRegression(0.9, screenshot);
|
|
|
|
}, TEST_DURATION_TIME);
|
|
|
|
|
|
|
|
// Check for Poll Results in whiteboard and return true when it appears
|
|
|
|
test('Poll results in a different presentation', async () => {
|
|
|
|
const test = new Poll();
|
|
|
|
let response;
|
|
|
|
let screenshot;
|
|
|
|
try {
|
|
|
|
const testName = 'pollResultsInDifferentPresentation';
|
|
|
|
await test.modPage.logger('begin of ', testName);
|
|
|
|
await test.initModPage(true, testName);
|
|
|
|
await test.modPage.startRecording(testName);
|
|
|
|
response = await test.pollResultsInDifferentPresentation(testName);
|
|
|
|
await test.modPage.logger('end of ', testName);
|
|
|
|
await test.modPage.stopRecording();
|
|
|
|
screenshot = await test.modPage.page.screenshot();
|
|
|
|
} catch (err) {
|
|
|
|
await test.modPage.logger(err);
|
|
|
|
} finally {
|
2021-10-20 04:12:00 +08:00
|
|
|
await test.modPage.close();
|
2021-03-09 05:11:36 +08:00
|
|
|
}
|
|
|
|
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-10-25 23:01:40 +08:00
|
|
|
// This test check all possible actions with
|
|
|
|
// response choice: add, delete and edit
|
|
|
|
test('Manage response choices', async () => {
|
2021-10-20 04:12:00 +08:00
|
|
|
const test = new Poll();
|
2021-02-17 04:57:10 +08:00
|
|
|
let response;
|
|
|
|
let screenshot;
|
|
|
|
try {
|
2021-10-25 23:01:40 +08:00
|
|
|
const testName = 'manageResponseChoices';
|
2021-10-20 04:12:00 +08:00
|
|
|
await test.modPage.logger('begin of ', testName);
|
|
|
|
await test.initPages(testName);
|
2021-10-25 23:01:40 +08:00
|
|
|
response = await test.manageResponseChoices(testName);
|
2021-10-20 04:12:00 +08:00
|
|
|
await test.modPage.logger('end of ', testName);
|
|
|
|
await test.modPage.stopRecording();
|
|
|
|
await test.userPage.stopRecording();
|
|
|
|
screenshot = await test.modPage.page.screenshot();
|
2021-08-26 22:13:18 +08:00
|
|
|
} catch (err) {
|
2021-10-20 04:12:00 +08:00
|
|
|
await test.modPage.logger(err);
|
2021-02-17 04:57:10 +08:00
|
|
|
} finally {
|
2021-10-20 04:12:00 +08:00
|
|
|
await closePages(test.modPage, test.userPage);
|
2021-02-17 04:57:10 +08:00
|
|
|
}
|
|
|
|
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-10-20 04:12:00 +08:00
|
|
|
|
2021-09-30 20:36:08 +08:00
|
|
|
module.exports = exports = pollingTest;
|