2021-09-28 11:21:14 +08:00
|
|
|
const Page = require('../core/page');
|
|
|
|
const Trigger = require('./trigger');
|
2021-06-06 22:01:37 +08:00
|
|
|
const { toMatchImageSnapshot } = require('jest-image-snapshot');
|
2021-09-28 11:21:14 +08:00
|
|
|
const { MAX_TRIGGER_EVENTS_TEST_TIMEOUT } = require('../core/constants'); // core constants (Timeouts vars imported)
|
2021-06-06 22:01:37 +08:00
|
|
|
|
|
|
|
expect.extend({ toMatchImageSnapshot });
|
|
|
|
|
|
|
|
const triggerTest = () => {
|
|
|
|
beforeEach(() => {
|
|
|
|
jest.setTimeout(MAX_TRIGGER_EVENTS_TEST_TIMEOUT);
|
|
|
|
});
|
|
|
|
|
|
|
|
test('Trigger disconnection: Meteor.disconnect()/.status()', async () => {
|
|
|
|
const test = new Trigger();
|
|
|
|
let response;
|
|
|
|
let screenshot;
|
|
|
|
try {
|
|
|
|
const testName = 'triggerMeteorDisconnect';
|
|
|
|
await test.logger('begin of ', testName);
|
2021-09-30 20:36:08 +08:00
|
|
|
await test.init(true, true, testName);
|
2021-06-06 22:01:37 +08:00
|
|
|
response = await test.triggerMeteorDisconnect(testName);
|
|
|
|
screenshot = await test.page.screenshot();
|
2021-08-26 22:13:18 +08:00
|
|
|
} catch (err) {
|
|
|
|
await test.logger(err);
|
2021-06-06 22:01:37 +08:00
|
|
|
} finally {
|
|
|
|
await test.close();
|
|
|
|
}
|
|
|
|
expect(response).toBe(true);
|
2021-10-01 02:45:59 +08:00
|
|
|
Page.checkRegression(0.1, screenshot);
|
2021-06-06 22:01:37 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
test('Trigger disconnection: SHUTTING DOWN NETWORK SERVICE', async () => {
|
|
|
|
const test = new Trigger();
|
|
|
|
let response;
|
|
|
|
let screenshot;
|
|
|
|
try {
|
|
|
|
const testName = 'triggerNetworkServiceDisconnection';
|
|
|
|
await test.logger('begin of ', testName);
|
2021-09-30 20:36:08 +08:00
|
|
|
await test.init(true, true, testName);
|
2021-06-06 22:01:37 +08:00
|
|
|
response = await test.triggerNetworkServiceDisconnection(testName);
|
|
|
|
screenshot = await test.page.screenshot();
|
2021-08-26 22:13:18 +08:00
|
|
|
} catch (err) {
|
|
|
|
await test.logger(err);
|
2021-06-06 22:01:37 +08:00
|
|
|
} finally {
|
|
|
|
await test.close();
|
|
|
|
}
|
|
|
|
expect(response).toBe(true);
|
2021-10-01 02:45:59 +08:00
|
|
|
Page.checkRegression(0.1, screenshot);
|
2021-06-06 22:01:37 +08:00
|
|
|
});
|
2021-11-06 04:16:42 +08:00
|
|
|
|
|
|
|
test('Meteor Reconnection', async () => {
|
|
|
|
const test = new Trigger();
|
|
|
|
let response;
|
|
|
|
let screenshot;
|
|
|
|
try {
|
|
|
|
const testName = 'MeteorReconnection';
|
|
|
|
await test.logger('begin of ', testName);
|
|
|
|
response = await test.meteorReconnection(testName);
|
|
|
|
screenshot = await test.page.screenshot();
|
|
|
|
} catch (err) {
|
|
|
|
await test.logger(err);
|
|
|
|
} finally {
|
|
|
|
await test.close();
|
|
|
|
}
|
|
|
|
expect(response).toBe(true);
|
|
|
|
Page.checkRegression(0.1, screenshot);
|
|
|
|
});
|
2021-06-06 22:01:37 +08:00
|
|
|
};
|
2021-09-30 20:36:08 +08:00
|
|
|
|
|
|
|
module.exports = exports = triggerTest;
|