2020-08-06 02:44:17 +08:00
|
|
|
const Page = require('./core/page');
|
|
|
|
const Send = require('./chat/send');
|
|
|
|
const Clear = require('./chat/clear');
|
|
|
|
const Copy = require('./chat/copy');
|
|
|
|
const Save = require('./chat/save');
|
2021-02-17 04:57:10 +08:00
|
|
|
const Poll = require('./chat/poll');
|
2020-08-06 02:44:17 +08:00
|
|
|
const MultiUsers = require('./user/multiusers');
|
2020-10-09 03:25:35 +08:00
|
|
|
const { toMatchImageSnapshot } = require('jest-image-snapshot');
|
2021-02-17 04:57:10 +08:00
|
|
|
const { MAX_CHAT_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 chatTest = () => {
|
|
|
|
beforeEach(() => {
|
2021-02-17 04:57:10 +08:00
|
|
|
jest.setTimeout(MAX_CHAT_TEST_TIMEOUT);
|
2020-08-06 02:44:17 +08:00
|
|
|
});
|
|
|
|
|
2021-02-17 04:57:10 +08:00
|
|
|
// Send public chat message and check if it appears
|
2020-08-06 02:44:17 +08:00
|
|
|
test('Send message', async () => {
|
|
|
|
const test = new Send();
|
|
|
|
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 = 'sendChat';
|
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);
|
2021-06-06 04:12:47 +08:00
|
|
|
await Page.checkRegression(0.9);
|
2020-08-06 02:44:17 +08:00
|
|
|
});
|
|
|
|
|
2021-02-17 04:57:10 +08:00
|
|
|
// Clear chat box and make sure that no chat public messages appear in chat box
|
2020-08-06 02:44:17 +08:00
|
|
|
test('Clear chat', async () => {
|
|
|
|
const test = new Clear();
|
|
|
|
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 = 'clearChat';
|
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);
|
2021-06-06 04:12:47 +08:00
|
|
|
await Page.checkRegression(0.9);
|
2020-08-06 02:44:17 +08:00
|
|
|
});
|
|
|
|
|
2021-02-17 04:57:10 +08:00
|
|
|
// Check if clipboard copied content contains the expected copied text
|
2020-08-06 02:44:17 +08:00
|
|
|
test('Copy chat', async () => {
|
|
|
|
const test = new Copy();
|
|
|
|
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 = 'copyChat';
|
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();
|
|
|
|
}
|
2021-06-06 04:12:47 +08:00
|
|
|
expect(response).toBe(true);
|
|
|
|
await Page.checkRegression(0.9);
|
2020-08-06 02:44:17 +08:00
|
|
|
});
|
|
|
|
|
2021-02-17 04:57:10 +08:00
|
|
|
// Wait for chat history to start downloading
|
2020-08-06 02:44:17 +08:00
|
|
|
test('Save chat', async () => {
|
|
|
|
const test = new Save();
|
|
|
|
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 = 'saveChat';
|
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);
|
2021-06-06 04:12:47 +08:00
|
|
|
await Page.checkRegression(0.9);
|
2020-08-06 02:44:17 +08:00
|
|
|
});
|
|
|
|
|
2021-02-17 04:57:10 +08:00
|
|
|
// Check for public chat message and return true when it appears
|
|
|
|
test('Send public chat', async () => {
|
2020-08-06 02:44:17 +08:00
|
|
|
const test = new MultiUsers();
|
|
|
|
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 = 'sendPublicChat';
|
|
|
|
await test.page1.logger('begin of ', testName);
|
2021-02-26 23:52:17 +08:00
|
|
|
await test.init(undefined, testName);
|
|
|
|
await test.page1.startRecording(testName);
|
2020-08-06 02:44:17 +08:00
|
|
|
await test.page1.closeAudioModal();
|
|
|
|
await test.page2.closeAudioModal();
|
2021-02-17 04:57:10 +08:00
|
|
|
response = await test.multiUsersPublicChat(testName);
|
2021-02-26 23:52:17 +08:00
|
|
|
await test.page1.stopRecording();
|
2020-10-09 03:25:35 +08:00
|
|
|
screenshot = await test.page1.page.screenshot();
|
2021-02-17 04:57:10 +08:00
|
|
|
await test.page1.logger('end of ', testName);
|
2020-08-06 02:44:17 +08:00
|
|
|
} catch (e) {
|
2021-02-17 04:57:10 +08:00
|
|
|
await test.page1.logger(e);
|
2020-08-06 02:44:17 +08:00
|
|
|
} finally {
|
|
|
|
await test.close(test.page1, test.page2);
|
|
|
|
}
|
|
|
|
expect(response).toBe(true);
|
2021-06-06 04:12:47 +08:00
|
|
|
await Page.checkRegression(0.9);
|
2020-08-06 02:44:17 +08:00
|
|
|
});
|
|
|
|
|
2021-02-17 04:57:10 +08:00
|
|
|
// Check for private chat message and return true when it appears
|
|
|
|
test('Send private chat to other User', async () => {
|
2020-08-06 02:44:17 +08:00
|
|
|
const test = new MultiUsers();
|
|
|
|
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 = 'sendPrivateChat';
|
|
|
|
await test.page1.logger('begin of ', testName);
|
2021-02-26 23:52:17 +08:00
|
|
|
await test.init(undefined, testName);
|
|
|
|
await test.page1.startRecording(testName);
|
2020-08-06 02:44:17 +08:00
|
|
|
await test.page1.closeAudioModal();
|
|
|
|
await test.page2.closeAudioModal();
|
2021-02-17 04:57:10 +08:00
|
|
|
response = await test.multiUsersPrivateChat(testName);
|
2021-02-26 23:52:17 +08:00
|
|
|
await test.page1.stopRecording();
|
2020-10-09 03:25:35 +08:00
|
|
|
screenshot = await test.page1.page.screenshot();
|
2021-02-17 04:57:10 +08:00
|
|
|
await test.page1.logger('end of ', testName);
|
2020-08-06 02:44:17 +08:00
|
|
|
} catch (e) {
|
2021-02-17 04:57:10 +08:00
|
|
|
await test.page1.logger(e);
|
2020-08-06 02:44:17 +08:00
|
|
|
} finally {
|
|
|
|
await test.close(test.page1, test.page2);
|
|
|
|
}
|
|
|
|
expect(response).toBe(true);
|
2021-06-06 04:12:47 +08:00
|
|
|
await Page.checkRegression(0.9);
|
2020-08-06 02:44:17 +08:00
|
|
|
});
|
2021-02-17 04:57:10 +08:00
|
|
|
|
|
|
|
// Check for Poll Results chat message and return true when it appears
|
|
|
|
test('Poll Results chat message', async () => {
|
|
|
|
const test = new Poll();
|
|
|
|
let response;
|
|
|
|
let screenshot;
|
|
|
|
try {
|
|
|
|
const testName = 'pollResultsChatMessage';
|
|
|
|
await test.page3.logger('begin of ', testName);
|
2021-02-26 23:52:17 +08:00
|
|
|
await test.initUser3(Page.getArgs(), undefined, testName);
|
|
|
|
await test.page3.startRecording(testName);
|
2021-02-17 04:57:10 +08:00
|
|
|
response = await test.test(testName);
|
2021-02-26 23:52:17 +08:00
|
|
|
await test.page3.startRecording();
|
2021-02-17 04:57:10 +08:00
|
|
|
screenshot = await test.page3.page.screenshot();
|
|
|
|
await test.page3.logger('end of ', testName);
|
|
|
|
} catch (e) {
|
|
|
|
await test.page3.logger(e);
|
|
|
|
} finally {
|
|
|
|
await test.closePage(test.page3);
|
|
|
|
}
|
|
|
|
expect(response).toBe(true);
|
2021-06-06 04:12:47 +08:00
|
|
|
await Page.checkRegression(0.9);
|
2021-02-17 04:57:10 +08:00
|
|
|
});
|
2020-08-06 02:44:17 +08:00
|
|
|
};
|
|
|
|
module.exports = exports = chatTest;
|