2021-05-26 00:05:11 +08:00
|
|
|
const { toMatchImageSnapshot } = require('jest-image-snapshot');
|
2021-09-28 11:21:14 +08:00
|
|
|
const ShareScreen = require('./screenshare');
|
|
|
|
const Page = require('../core/page');
|
|
|
|
const { MAX_SCREENSHARE_TEST_TIMEOUT } = require('../core/constants'); // core constants (Timeouts vars imported)
|
|
|
|
const devices = require('../core/devices');
|
2021-05-26 00:05:11 +08:00
|
|
|
const iPhonex = devices['iPhone X'];
|
|
|
|
const galaxyNote3 = devices['Galaxy Note 3'];
|
|
|
|
const ipadPro = devices['iPad Pro'];
|
2020-10-09 03:25:35 +08:00
|
|
|
expect.extend({ toMatchImageSnapshot });
|
2020-08-06 02:44:17 +08:00
|
|
|
|
|
|
|
const screenShareTest = () => {
|
|
|
|
beforeEach(() => {
|
2021-02-17 04:57:10 +08:00
|
|
|
jest.setTimeout(MAX_SCREENSHARE_TEST_TIMEOUT);
|
2020-08-06 02:44:17 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
test('Share screen', async () => {
|
|
|
|
const test = new ShareScreen();
|
|
|
|
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 = 'shareScreen';
|
|
|
|
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);
|
2021-10-27 01:48:18 +08:00
|
|
|
response = await test.startSharing();
|
2021-02-17 04:57:10 +08:00
|
|
|
await test.logger('end of ', testName);
|
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-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(1.37, screenshot);
|
2020-08-06 02:44:17 +08:00
|
|
|
});
|
2021-05-26 00:05:11 +08:00
|
|
|
|
2021-06-06 04:12:47 +08:00
|
|
|
test('Share screen unavailable on Mobile Android', async () => {
|
2021-05-26 00:05:11 +08:00
|
|
|
process.env.IS_MOBILE = true;
|
|
|
|
const test = new ShareScreen();
|
|
|
|
let response;
|
|
|
|
let screenshot;
|
|
|
|
try {
|
|
|
|
const testName = 'shareScreenAndroidMobile';
|
|
|
|
await test.logger('begin of ', testName);
|
2021-09-30 20:36:08 +08:00
|
|
|
response = await test.testMobileDevice(testName, galaxyNote3);
|
2021-05-26 00:05:11 +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-05-26 00:05:11 +08:00
|
|
|
} finally {
|
|
|
|
await test.close();
|
|
|
|
}
|
|
|
|
expect(response).toBe(true);
|
2021-10-01 02:45:59 +08:00
|
|
|
Page.checkRegression(1.37, screenshot);
|
2021-05-26 00:05:11 +08:00
|
|
|
});
|
|
|
|
|
2021-06-06 04:12:47 +08:00
|
|
|
test('Share screen unavailable on Mobile iPhone', async () => {
|
2021-05-26 00:05:11 +08:00
|
|
|
process.env.IS_MOBILE = true;
|
|
|
|
const test = new ShareScreen();
|
|
|
|
let response;
|
|
|
|
let screenshot;
|
|
|
|
try {
|
|
|
|
const testName = 'shareScreenIphoneMobile';
|
|
|
|
await test.logger('begin of ', testName);
|
2021-09-30 20:36:08 +08:00
|
|
|
response = await test.testMobileDevice(testName, iPhonex);
|
2021-05-26 00:05:11 +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-05-26 00:05:11 +08:00
|
|
|
} finally {
|
|
|
|
await test.close();
|
|
|
|
}
|
|
|
|
expect(response).toBe(true);
|
2021-10-01 02:45:59 +08:00
|
|
|
Page.checkRegression(1.37, screenshot);
|
2021-05-26 00:05:11 +08:00
|
|
|
});
|
|
|
|
|
2021-06-06 04:12:47 +08:00
|
|
|
test('Share screen unavailable on Tablet iPad', async () => {
|
2021-05-26 00:05:11 +08:00
|
|
|
process.env.IS_MOBILE = true;
|
|
|
|
const test = new ShareScreen();
|
|
|
|
let response;
|
|
|
|
let screenshot;
|
|
|
|
try {
|
|
|
|
const testName = 'shareScreenTabletIpad';
|
|
|
|
await test.logger('begin of ', testName);
|
2021-09-30 20:36:08 +08:00
|
|
|
response = await test.testMobileDevice(testName, ipadPro);
|
2021-05-26 00:05:11 +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-05-26 00:05:11 +08:00
|
|
|
} finally {
|
|
|
|
await test.close();
|
|
|
|
}
|
|
|
|
expect(response).toBe(true);
|
2021-10-01 02:45:59 +08:00
|
|
|
Page.checkRegression(1.37, screenshot);
|
2021-05-26 00:05:11 +08:00
|
|
|
});
|
2020-08-06 02:44:17 +08:00
|
|
|
};
|
2023-04-04 04:23:26 +08:00
|
|
|
module.exports = exports = screenShareTest;
|