2020-08-06 02:44:17 +08:00
|
|
|
const Page = require('./core/page');
|
|
|
|
const Slide = require('./presentation/slide');
|
|
|
|
const Upload = require('./presentation/upload');
|
2020-10-09 03:25:35 +08:00
|
|
|
const { toMatchImageSnapshot } = require('jest-image-snapshot');
|
2021-02-17 04:57:10 +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 () => {
|
|
|
|
const test = new Slide();
|
|
|
|
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';
|
|
|
|
await test.logger('begin of ', testName);
|
2021-02-26 23:52:17 +08:00
|
|
|
await test.init(Page.getArgs(), undefined, undefined, undefined, testName);
|
|
|
|
await test.startRecording(testName);
|
2020-08-06 02:44:17 +08:00
|
|
|
await test.closeAudioModal();
|
|
|
|
response = await test.test();
|
2021-02-26 23:52:17 +08:00
|
|
|
await test.stopRecording(testName);
|
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);
|
2020-08-06 02:44:17 +08:00
|
|
|
} catch (e) {
|
2021-02-17 04:57:10 +08:00
|
|
|
await test.logger(e);
|
2020-08-06 02:44:17 +08:00
|
|
|
} finally {
|
|
|
|
await test.close();
|
|
|
|
}
|
|
|
|
expect(response).toBe(true);
|
2020-10-09 03:25:35 +08:00
|
|
|
if (process.env.REGRESSION_TESTING === 'true') {
|
|
|
|
expect(screenshot).toMatchImageSnapshot({
|
2020-10-27 23:54:55 +08:00
|
|
|
failureThreshold: 0.81,
|
2020-10-09 03:25:35 +08:00
|
|
|
failureThresholdType: 'percent',
|
|
|
|
});
|
|
|
|
}
|
2020-08-06 02:44:17 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
test('Upload presentation', async () => {
|
|
|
|
const test = new Upload();
|
|
|
|
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-02-17 04:57:10 +08:00
|
|
|
await test.logger('begin of ', testName);
|
2021-02-26 23:52:17 +08:00
|
|
|
await test.init(Page.getArgs(), undefined, undefined, undefined, testName);
|
|
|
|
await test.startRecording(testName);
|
2020-08-06 02:44:17 +08:00
|
|
|
await test.closeAudioModal();
|
2020-08-14 10:41:14 +08:00
|
|
|
response = await test.test(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-02-17 04:57:10 +08:00
|
|
|
await test.logger('end of ', testName);
|
2020-08-06 02:44:17 +08:00
|
|
|
} catch (e) {
|
2021-02-17 04:57:10 +08:00
|
|
|
await test.logger(e);
|
2020-08-06 02:44:17 +08:00
|
|
|
} finally {
|
|
|
|
await test.close();
|
|
|
|
}
|
|
|
|
expect(response).toBe(true);
|
2020-10-09 03:25:35 +08:00
|
|
|
if (process.env.REGRESSION_TESTING === 'true') {
|
|
|
|
expect(screenshot).toMatchImageSnapshot({
|
2021-02-17 04:57:10 +08:00
|
|
|
failureThreshold: 24.62,
|
2020-10-09 03:25:35 +08:00
|
|
|
failureThresholdType: 'percent',
|
|
|
|
});
|
|
|
|
}
|
2020-08-06 02:44:17 +08:00
|
|
|
});
|
|
|
|
};
|
|
|
|
module.exports = exports = presentationTest;
|