bigbluebutton-Github/bigbluebutton-html5/tests/puppeteer/notifications.obj.js
Mohamed Amine Ben Salah d8c5aa46d9
multiple automated tests suites updates + add missing polling specs and move them with old ones to a polling test suite (#10766)
* updating old tests + collecting more snapshots [WIP]

* updates old test suites and collects more visual regressions screenshots

* remove snapshots and their collection temporary

* run tests from packages.json

* update test execution command/export constants from .env to core/constants.js

* update tests/puppeteer/README.md file

* update LOOP_INTERVAL variable call and assign timeouts to the webcam share spec

* redefine waitForSelector func in page.js, update chat test suite specs and add poll chat message test spec

* Merge remote-tracking branch 'upstream/develop' into updating-old-tests-visual-with-visual-regressions

* update webcam test specs collecting videoPreviewTimeout and use it to wait for videoPreview selector

* update custom parameters test suite

* update breakout test suite

* update webcam layout test suite

* update multiusers test suite

* update notifications test suite

* update presentation test suite

* whiteboard test suite

* screenshare test suite

* update sharednotes test suite

* user ELEMENT_WAIT_TIME variable from timeouts constants.js

* list TEST CONSTANTS by category

* add poll test suite and assigns the right unassigned timeouts

* set test pages to headless
2021-02-16 15:57:10 -05:00

217 lines
7.0 KiB
JavaScript

const Notifications = require('./notifications/notifications');
const ShareScreen = require('./screenshare/screenshare');
const Audio = require('./audio/audio');
const Page = require('./core/page');
const { toMatchImageSnapshot } = require('jest-image-snapshot');
const { MAX_NOTIFICATIONS_TEST_TIMEOUT } = require('./core/constants'); // core constants (Timeouts vars imported)
expect.extend({ toMatchImageSnapshot });
const notificationsTest = () => {
beforeEach(() => {
jest.setTimeout(MAX_NOTIFICATIONS_TEST_TIMEOUT);
});
test('Save settings notification', async () => {
const test = new Notifications();
let response;
let screenshot;
try {
const testName = 'saveSettingsNotification';
await test.page1.logger('begin of ', testName);
response = await test.saveSettingsNotification(testName);
await test.page1.logger('end of ', testName);
screenshot = await test.page1.page.screenshot();
} catch (e) {
await test.page1.logger(e);
} finally {
await test.close(test.page1, test.page2);
await test.page1.logger('Save Setting notification !');
}
expect(response).toBe(true);
if (process.env.REGRESSION_TESTING === 'true') {
expect(screenshot).toMatchImageSnapshot({
failureThreshold: 1.56,
failureThresholdType: 'percent',
});
}
});
test('Public Chat notification', async () => {
const test = new Notifications();
let response;
let screenshot;
try {
const testName = 'publicChatNotification';
await test.page1.logger('begin of ', testName);
response = await test.publicChatNotification(testName);
await test.page1.logger('end of ', testName);
screenshot = await test.page1.page.screenshot();
} catch (e) {
await test.page1.logger(e);
} finally {
await test.close(test.page1, test.page2);
await test.page1.logger('Public Chat notification !');
}
expect(response).toBe(true);
if (process.env.REGRESSION_TESTING === 'true') {
expect(screenshot).toMatchImageSnapshot({
failureThreshold: 1,
failureThresholdType: 'percent',
});
}
});
test('Private Chat notification', async () => {
const test = new Notifications();
let response;
let screenshot;
try {
const testName = 'privateChatNotification';
await test.page1.logger('begin of ', testName);
response = await test.privateChatNotification(testName);
await test.page1.logger('end of ', testName);
screenshot = await test.page1.page.screenshot();
} catch (e) {
await test.page1.logger(e);
} finally {
await test.close(test.page1, test.page2);
await test.page1.logger('Private Chat notification !');
}
expect(response).toBe(true);
if (process.env.REGRESSION_TESTING === 'true') {
expect(screenshot).toMatchImageSnapshot({
failureThreshold: 0.6,
failureThresholdType: 'percent',
});
}
});
test('User join notification', async () => {
const test = new Notifications();
let response;
let screenshot;
try {
const testName = 'userJoinNotification';
await test.page1.logger('begin of ', testName);
response = await test.getUserJoinPopupResponse(testName);
await test.page1.logger('end of ', testName);
screenshot = await test.page3.page.screenshot();
} catch (e) {
await test.page1.logger(e);
} finally {
await test.closePages();
await test.page1.logger('User join notification !');
}
expect(response).toBe(true);
if (process.env.REGRESSION_TESTING === 'true') {
expect(screenshot).toMatchImageSnapshot({
failureThreshold: 0.6,
failureThresholdType: 'percent',
});
}
});
test('Presentation upload notification', async () => {
const test = new Notifications();
let response;
let screenshot;
try {
const testName = 'uploadPresentationNotification';
await test.page1.logger('begin of ', testName);
response = await test.fileUploaderNotification(testName);
await test.page1.logger('end of ', testName);
screenshot = await test.page3.page.screenshot();
} catch (e) {
await test.page1.logger(e);
} finally {
await test.closePage(test.page3);
await test.page3.logger('Presentation upload notification !');
}
expect(response).toBe(true);
if (process.env.REGRESSION_TESTING === 'true') {
expect(screenshot).toMatchImageSnapshot({
failureThreshold: 2.64,
failureThresholdType: 'percent',
});
}
});
test('Poll results notification', async () => {
const test = new Notifications();
let response;
let screenshot;
try {
const testName = 'pollResultsNotification';
await test.page1.logger('begin of ', testName);
await test.initUser3(Page.getArgs(), undefined);
response = await test.publishPollResults(testName);
await test.page1.logger('end of ', testName);
screenshot = await test.page3.page.screenshot();
} catch (e) {
await test.page1.logger(e);
} finally {
await test.closePage(test.page3);
await test.page3.logger('Poll results notification !');
}
expect(response).toContain('Poll results were published');
if (process.env.REGRESSION_TESTING === 'true') {
expect(screenshot).toMatchImageSnapshot({
failureThreshold: 7.26,
failureThresholdType: 'percent',
});
}
});
test('Screenshare notification', async () => {
const page = new Notifications();
let response;
let screenshot;
try {
const testName = 'screenShareNotification';
await page.page1.logger('begin of ', testName);
response = await page.screenshareToast(testName);
await page.page1.logger('end of ', testName);
screenshot = await page.page3.page.screenshot();
} catch (e) {
await page.page1.logger(e);
} finally {
await page.closePage(page.page3);
await page.page3.logger('Screenshare notification !');
}
expect(response).toBe('Screenshare has started');
if (process.env.REGRESSION_TESTING === 'true') {
expect(screenshot).toMatchImageSnapshot({
failureThreshold: 7.25,
failureThresholdType: 'percent',
});
}
});
test('Audio notifications', async () => {
const test = new Notifications();
let response;
let screenshot;
try {
const testName = 'audioNotification';
await test.page1.logger('begin of ', testName);
response = await test.audioNotification(testName);
await test.page1.logger('end of ', testName);
screenshot = await test.page3.page.screenshot();
} catch (e) {
await test.page1.logger(e);
} finally {
await test.closePage(test.page3);
await test.page3.logger('Audio notification !');
}
expect(response).toBe(true);
if (process.env.REGRESSION_TESTING === 'true') {
expect(screenshot).toMatchImageSnapshot({
failureThreshold: 1.05,
failureThresholdType: 'percent',
});
}
});
};
module.exports = exports = notificationsTest;