2021-09-28 11:21:14 +08:00
|
|
|
const Page = require('../core/page');
|
|
|
|
const Presentation = require('./presentation');
|
2021-10-21 01:23:24 +08:00
|
|
|
const { closePages } = require('../core/util');
|
2020-10-09 03:25:35 +08:00
|
|
|
const { toMatchImageSnapshot } = require('jest-image-snapshot');
|
2021-09-28 11:21:14 +08:00
|
|
|
const { MAX_PRESENTATION_TEST_TIMEOUT } = require('../core/constants'); // core constants (Timeouts vars imported)
|
2020-10-09 03:25:35 +08:00
|
|
|
|
|
|
|
expect.extend({ toMatchImageSnapshot });
|
2020-08-06 02:44:17 +08:00
|
|
|
|
|
|
|
const presentationTest = () => {
|
|
|
|
beforeEach(() => {
|
2021-02-17 04:57:10 +08:00
|
|
|
jest.setTimeout(MAX_PRESENTATION_TEST_TIMEOUT);
|
2020-08-06 02:44:17 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
test('Skip slide', async () => {
|
2021-09-08 22:20:57 +08:00
|
|
|
const test = new Presentation();
|
2020-08-06 02:44:17 +08:00
|
|
|
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 = 'skipSlide';
|
2021-09-08 22:20:57 +08:00
|
|
|
await test.modPage.logger('begin of ', testName);
|
|
|
|
await test.initModPage(testName);
|
|
|
|
await test.modPage.startRecording(testName);
|
|
|
|
response = await test.skipSlide();
|
|
|
|
await test.modPage.stopRecording(testName);
|
2021-09-09 01:18:01 +08:00
|
|
|
screenshot = await test.modPage.page.screenshot();
|
2021-09-08 22:20:57 +08:00
|
|
|
await test.modPage.logger('end of ', testName);
|
2021-08-26 22:13:18 +08:00
|
|
|
} catch (err) {
|
2021-09-08 22:20:57 +08:00
|
|
|
await test.modPage.logger(err);
|
2020-08-06 02:44:17 +08:00
|
|
|
} finally {
|
2021-10-21 01:23:24 +08:00
|
|
|
await test.modPage.close();
|
2020-08-06 02:44:17 +08:00
|
|
|
}
|
|
|
|
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('Upload presentation', async () => {
|
2021-09-08 22:20:57 +08:00
|
|
|
const test = new Presentation();
|
2020-08-06 02:44:17 +08:00
|
|
|
let response;
|
2020-10-09 03:25:35 +08:00
|
|
|
let screenshot;
|
2020-08-06 02:44:17 +08:00
|
|
|
try {
|
2020-08-14 10:41:14 +08:00
|
|
|
const testName = 'uploadPresentation';
|
2021-09-08 22:20:57 +08:00
|
|
|
await test.modPage.logger('begin of ', testName);
|
|
|
|
await test.initModPage(testName);
|
|
|
|
await test.modPage.startRecording(testName);
|
|
|
|
response = await test.uploadPresentation(testName);
|
|
|
|
await test.modPage.stopRecording();
|
2021-09-09 01:18:01 +08:00
|
|
|
screenshot = await test.modPage.page.screenshot();
|
2021-09-08 22:20:57 +08:00
|
|
|
await test.modPage.logger('end of ', testName);
|
2021-08-26 22:13:18 +08:00
|
|
|
} catch (err) {
|
2021-09-08 22:20:57 +08:00
|
|
|
await test.modPage.logger(err);
|
2020-08-06 02:44:17 +08:00
|
|
|
} finally {
|
2021-10-21 01:23:24 +08:00
|
|
|
await test.modPage.close();
|
2020-08-06 02:44:17 +08:00
|
|
|
}
|
|
|
|
expect(response).toBe(true);
|
2021-10-01 02:45:59 +08:00
|
|
|
Page.checkRegression(24.62, screenshot);
|
2020-08-06 02:44:17 +08:00
|
|
|
});
|
2021-08-27 02:42:07 +08:00
|
|
|
|
|
|
|
test('Allow and disallow presentation download', async () => {
|
|
|
|
const test = new Presentation();
|
|
|
|
let response;
|
|
|
|
let screenshot;
|
|
|
|
try {
|
|
|
|
const testName = 'allowAndDisallowPresentationDownload';
|
|
|
|
await test.modPage.logger('begin of ', testName);
|
|
|
|
await test.initPages(testName);
|
|
|
|
await test.modPage.startRecording(testName);
|
|
|
|
response = await test.allowAndDisallowDownload(testName);
|
|
|
|
await test.modPage.stopRecording();
|
2021-09-09 01:18:01 +08:00
|
|
|
screenshot = await test.modPage.page.screenshot();
|
|
|
|
await test.modPage.logger('end of ', testName);
|
|
|
|
} catch (e) {
|
|
|
|
await test.modPage.logger(e);
|
|
|
|
} finally {
|
2021-10-21 01:23:24 +08:00
|
|
|
await closePages(test.modPage, test.userPage);
|
2021-09-09 01:18:01 +08:00
|
|
|
}
|
|
|
|
expect(response).toBe(true);
|
2021-10-01 02:45:59 +08:00
|
|
|
Page.checkRegression(24.62, screenshot);
|
2021-09-09 01:18:01 +08:00
|
|
|
});
|
|
|
|
|
2021-09-09 03:08:03 +08:00
|
|
|
test('Remove all presentation', async () => {
|
2021-09-09 01:18:01 +08:00
|
|
|
const test = new Presentation();
|
|
|
|
let response;
|
|
|
|
let screenshot;
|
|
|
|
try {
|
|
|
|
const testName = 'removeAllPresentation';
|
|
|
|
await test.modPage.logger('begin of ', testName);
|
|
|
|
await test.initPages(testName);
|
|
|
|
await test.modPage.startRecording(testName);
|
|
|
|
response = await test.removeAllPresentation(testName);
|
|
|
|
await test.modPage.stopRecording();
|
|
|
|
screenshot = await test.modPage.page.screenshot();
|
2021-08-27 02:42:07 +08:00
|
|
|
await test.modPage.logger('end of ', testName);
|
|
|
|
} catch (e) {
|
|
|
|
await test.modPage.logger(e);
|
|
|
|
} finally {
|
2021-10-21 01:23:24 +08:00
|
|
|
await closePages(test.modPage, test.userPage);
|
2021-08-27 02:42:07 +08:00
|
|
|
}
|
|
|
|
expect(response).toBe(true);
|
2021-10-01 02:45:59 +08:00
|
|
|
Page.checkRegression(24.62, screenshot);
|
2021-08-27 02:42:07 +08:00
|
|
|
});
|
2021-10-27 01:57:40 +08:00
|
|
|
|
|
|
|
test('Hide/Restore presentation', async () => {
|
|
|
|
const test = new Presentation();
|
|
|
|
let response;
|
|
|
|
let screenshot;
|
|
|
|
try {
|
|
|
|
const testName = 'hideAndRestorePresentation';
|
|
|
|
await test.modPage.logger('begin of ', testName);
|
|
|
|
await test.initModPage(testName);
|
|
|
|
await test.modPage.startRecording(testName);
|
|
|
|
response = await test.hideAndRestorePresentation(testName);
|
|
|
|
await test.modPage.stopRecording();
|
|
|
|
screenshot = await test.modPage.page.screenshot();
|
|
|
|
await test.modPage.logger('end of ', testName);
|
|
|
|
} catch (e) {
|
|
|
|
await test.modPage.logger(e);
|
|
|
|
} finally {
|
|
|
|
await test.modPage.close();
|
|
|
|
}
|
|
|
|
expect(response).toBe(true);
|
|
|
|
Page.checkRegression(24.62, screenshot);
|
|
|
|
});
|
2021-10-29 02:37:56 +08:00
|
|
|
|
|
|
|
test('Start external video', async () => {
|
|
|
|
const test = new Presentation();
|
|
|
|
let response;
|
|
|
|
let screenshot;
|
|
|
|
try {
|
|
|
|
const testName = 'startExternalVideo';
|
|
|
|
await test.modPage.logger('begin of ', testName);
|
2021-11-06 04:16:42 +08:00
|
|
|
await test.initPages(testName, ['--disable-features=IsolateOrigins,site-per-process']);
|
2021-10-29 02:37:56 +08:00
|
|
|
await test.modPage.startRecording(testName);
|
|
|
|
response = await test.startExternalVideo(testName);
|
|
|
|
await test.modPage.stopRecording();
|
|
|
|
screenshot = await test.modPage.page.screenshot();
|
|
|
|
await test.modPage.logger('end of ', testName);
|
|
|
|
} catch (e) {
|
|
|
|
await test.modPage.logger(e);
|
|
|
|
} finally {
|
|
|
|
await closePages(test.modPage, test.userPage);
|
|
|
|
}
|
|
|
|
expect(response).toBe(true);
|
|
|
|
Page.checkRegression(24.62, screenshot);
|
|
|
|
});
|
2020-08-06 02:44:17 +08:00
|
|
|
};
|
2021-10-29 02:37:56 +08:00
|
|
|
|
2020-08-06 02:44:17 +08:00
|
|
|
module.exports = exports = presentationTest;
|