2021-09-28 11:21:14 +08:00
|
|
|
const Share = require('./share');
|
|
|
|
const Check = require('./check');
|
|
|
|
const Page = require('../core/page');
|
2020-10-09 03:25:35 +08:00
|
|
|
const { toMatchImageSnapshot } = require('jest-image-snapshot');
|
2021-09-28 11:21:14 +08:00
|
|
|
const { MAX_WEBCAM_TEST_TIMEOUT } = require('../core/constants');
|
2020-10-09 03:25:35 +08:00
|
|
|
|
|
|
|
expect.extend({ toMatchImageSnapshot });
|
2020-08-06 02:44:17 +08:00
|
|
|
|
|
|
|
const webcamTest = () => {
|
|
|
|
beforeEach(() => {
|
2021-02-17 04:57:10 +08:00
|
|
|
jest.setTimeout(MAX_WEBCAM_TEST_TIMEOUT);
|
2020-08-06 02:44:17 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
test('Shares webcam', async () => {
|
|
|
|
const test = new Share();
|
|
|
|
let response;
|
2020-10-09 03:25:35 +08:00
|
|
|
let screenshot;
|
2020-08-06 02:44:17 +08:00
|
|
|
try {
|
2021-02-17 04:57:10 +08:00
|
|
|
const testName = 'shareWebcam';
|
|
|
|
await test.logger('begin of ', testName);
|
2021-09-30 20:36:08 +08:00
|
|
|
await test.init(true, true, testName);
|
2021-02-26 23:52:17 +08:00
|
|
|
await test.startRecording(testName);
|
2020-08-06 02:44:17 +08:00
|
|
|
response = await test.test();
|
2021-02-26 23:52:17 +08:00
|
|
|
await test.stopRecording();
|
2020-10-09 03:25:35 +08:00
|
|
|
screenshot = await test.page.screenshot();
|
2021-02-17 04:57:10 +08:00
|
|
|
await test.logger('end of ', testName);
|
2021-08-26 22:13:18 +08:00
|
|
|
} catch (err) {
|
|
|
|
await test.logger(err);
|
2020-08-06 02:44:17 +08:00
|
|
|
} finally {
|
|
|
|
await test.close();
|
|
|
|
}
|
|
|
|
expect(response).toBe(true);
|
2021-10-01 02:45:59 +08:00
|
|
|
Page.checkRegression(0.81, screenshot);
|
2020-08-06 02:44:17 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
test('Checks content of webcam', async () => {
|
|
|
|
const test = new Check();
|
|
|
|
let response;
|
2020-10-09 03:25:35 +08:00
|
|
|
let screenshot;
|
2020-08-06 02:44:17 +08:00
|
|
|
try {
|
2021-02-17 04:57:10 +08:00
|
|
|
const testName = 'checkWebcamContent';
|
|
|
|
await test.logger('begin of ', testName);
|
2021-09-30 20:36:08 +08:00
|
|
|
await test.init(true, true, testName);
|
2021-02-26 23:52:17 +08:00
|
|
|
await test.startRecording(testName);
|
2020-08-06 02:44:17 +08:00
|
|
|
response = await test.test();
|
2021-02-26 23:52:17 +08:00
|
|
|
await test.stopRecording();
|
2020-10-09 03:25:35 +08:00
|
|
|
screenshot = await test.page.screenshot();
|
2021-02-17 04:57:10 +08:00
|
|
|
await test.logger('end of ', testName);
|
2021-08-26 22:13:18 +08:00
|
|
|
} catch (err) {
|
|
|
|
await test.logger(err);
|
2020-08-06 02:44:17 +08:00
|
|
|
} finally {
|
|
|
|
await test.close();
|
|
|
|
}
|
|
|
|
expect(response).toBe(true);
|
2021-10-01 02:45:59 +08:00
|
|
|
Page.checkRegression(7.5, screenshot);
|
2020-08-06 02:44:17 +08:00
|
|
|
});
|
2021-10-27 01:51:24 +08:00
|
|
|
|
|
|
|
test('Checks webcam talking indicator', async () => {
|
|
|
|
const test = new Share();
|
|
|
|
let response;
|
|
|
|
let screenshot;
|
|
|
|
try {
|
|
|
|
const testName = 'joinWebcamAndMicrophone';
|
|
|
|
await test.logger('begin of ', testName);
|
|
|
|
await test.init(true, false, testName);
|
|
|
|
await test.startRecording(testName);
|
|
|
|
await test.webcamLayoutStart();
|
|
|
|
response = await test.webcamLayoutTest(testName);
|
|
|
|
await test.logger('end of ', testName);
|
|
|
|
await test.stopRecording();
|
|
|
|
screenshot = await test.page.screenshot();
|
|
|
|
} catch (err) {
|
|
|
|
await test.logger(err);
|
|
|
|
} finally {
|
|
|
|
await test.close();
|
|
|
|
}
|
|
|
|
expect(response).toBe(true);
|
|
|
|
Page.checkRegression(10.83, screenshot);
|
|
|
|
});
|
2020-08-06 02:44:17 +08:00
|
|
|
};
|
|
|
|
module.exports = exports = webcamTest;
|