108 lines
3.7 KiB
JavaScript
108 lines
3.7 KiB
JavaScript
const Page = require('../core/page');
|
|
const Poll = require('./poll');
|
|
const { closePages } = require('../core/util');
|
|
const { MAX_POLLING_TEST_TIMEOUT, TEST_DURATION_TIME } = require('../core/constants'); // core constants (Timeouts vars imported)
|
|
const { toMatchImageSnapshot } = require('jest-image-snapshot');
|
|
|
|
expect.extend({ toMatchImageSnapshot });
|
|
|
|
const pollingTest = () => {
|
|
beforeEach(() => {
|
|
jest.setTimeout(MAX_POLLING_TEST_TIMEOUT);
|
|
});
|
|
|
|
// Create Poll
|
|
test('Create Poll', async () => {
|
|
const test = new Poll();
|
|
let response;
|
|
let screenshot;
|
|
try {
|
|
const testName = 'createPoll';
|
|
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();
|
|
} catch (err) {
|
|
await test.modPage.logger(err);
|
|
} finally {
|
|
await test.modPage.close();
|
|
}
|
|
expect(response).toBe(true);
|
|
Page.checkRegression(1.37, screenshot);
|
|
}, TEST_DURATION_TIME);
|
|
|
|
// Check for Poll Results in chat message and return true when it appears
|
|
test('Poll results in chat message', async () => {
|
|
const test = new Poll();
|
|
let response;
|
|
let screenshot;
|
|
try {
|
|
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();
|
|
} catch (err) {
|
|
await test.modPage.logger(err);
|
|
} finally {
|
|
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 whiteboard', async () => {
|
|
const test = new Poll();
|
|
let response;
|
|
let screenshot;
|
|
try {
|
|
const testName = 'pollResultsInWhiteboard';
|
|
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 {
|
|
await test.modPage.close();
|
|
}
|
|
expect(response).toBe(true);
|
|
Page.checkRegression(0.9, screenshot);
|
|
}, TEST_DURATION_TIME);
|
|
|
|
// This Test chooses randomly a polling case, runs it
|
|
// and expects having it answered by the other user
|
|
test('Random Poll', async () => {
|
|
const test = new Poll();
|
|
let response;
|
|
let screenshot;
|
|
try {
|
|
const testName = 'randomPoll';
|
|
await test.modPage.logger('begin of ', testName);
|
|
await test.initPages(testName);
|
|
response = await test.randomPoll(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);
|
|
};
|
|
|
|
module.exports = exports = pollingTest; |