bigbluebutton-Github/bigbluebutton-tests/puppeteer/chat/chat.obj.js

158 lines
4.9 KiB
JavaScript
Raw Normal View History

const Page = require('../core/page');
const Send = require('./send');
const Clear = require('./clear');
const Copy = require('./copy');
const Save = require('./save');
const MultiUsers = require('../user/multiusers');
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');
const { MAX_CHAT_TEST_TIMEOUT } = require('../core/constants'); // core constants (Timeouts vars imported)
2020-10-09 03:25:35 +08:00
expect.extend({ toMatchImageSnapshot });
const chatTest = () => {
beforeEach(() => {
jest.setTimeout(MAX_CHAT_TEST_TIMEOUT);
});
// Send public chat message and check if it appears
test('Send message', async () => {
const test = new Send();
let response;
2020-10-09 03:25:35 +08:00
let screenshot;
try {
const testName = 'sendChat';
await test.logger('begin of ', testName);
2021-09-30 20:36:08 +08:00
await test.init(true, true, testName);
await test.startRecording(testName);
response = await test.test(testName);
await test.stopRecording();
2020-10-09 03:25:35 +08:00
screenshot = await test.page.screenshot();
await test.logger('end of ', testName);
2021-08-26 22:13:18 +08:00
} catch (err) {
await test.logger(err);
} finally {
await test.close();
}
expect(response).toBe(true);
2021-10-01 02:45:59 +08:00
Page.checkRegression(0.9, screenshot);
});
// Clear chat box and make sure that no chat public messages appear in chat box
test('Clear chat', async () => {
const test = new Clear();
let response;
2020-10-09 03:25:35 +08:00
let screenshot;
try {
const testName = 'clearChat';
await test.logger('begin of ', testName);
2021-09-30 20:36:08 +08:00
await test.init(true, true, testName);
await test.startRecording(testName);
response = await test.test(testName);
await test.stopRecording();
2020-10-09 03:25:35 +08:00
screenshot = await test.page.screenshot();
await test.logger('end of ', testName);
2021-08-26 22:13:18 +08:00
} catch (err) {
await test.logger(err);
} finally {
await test.close();
}
expect(response).toBe(true);
2021-10-01 02:45:59 +08:00
Page.checkRegression(0.9, screenshot);
});
// Check if clipboard copied content contains the expected copied text
test('Copy chat', async () => {
const test = new Copy();
let response;
2020-10-09 03:25:35 +08:00
let screenshot;
try {
const testName = 'copyChat';
await test.logger('begin of ', testName);
2021-09-30 20:36:08 +08:00
await test.init(true, true, testName);
await test.startRecording(testName);
response = await test.test(testName);
await test.stopRecording();
2020-10-09 03:25:35 +08:00
screenshot = await test.page.screenshot();
await test.logger('end of ', testName);
2021-08-26 22:13:18 +08:00
} catch (err) {
await test.logger(err);
} finally {
await test.close();
}
2021-06-06 04:12:47 +08:00
expect(response).toBe(true);
2021-10-01 02:45:59 +08:00
Page.checkRegression(0.9, screenshot);
});
// Wait for chat history to start downloading
test('Save chat', async () => {
const test = new Save();
let response;
2020-10-09 03:25:35 +08:00
let screenshot;
try {
const testName = 'saveChat';
await test.logger('begin of ', testName);
2021-09-30 20:36:08 +08:00
await test.init(true, true, testName);
await test.startRecording(testName);
response = await test.test(testName);
await test.stopRecording();
2020-10-09 03:25:35 +08:00
screenshot = await test.page.screenshot();
await test.logger('end of ', testName);
2021-08-26 22:13:18 +08:00
} catch (err) {
await test.logger(err);
} finally {
await test.close();
}
expect(response).toBe(true);
2021-10-01 02:45:59 +08:00
Page.checkRegression(0.9, screenshot);
});
// Check for public chat message and return true when it appears
test('Send public chat', async () => {
const test = new MultiUsers();
let response;
2020-10-09 03:25:35 +08:00
let screenshot;
try {
const testName = 'sendPublicChat';
await test.page1.logger('begin of ', testName);
2021-09-30 20:36:08 +08:00
await test.init(testName);
await test.page1.startRecording(testName);
response = await test.multiUsersPublicChat(testName);
await test.page1.stopRecording();
2020-10-09 03:25:35 +08:00
screenshot = await test.page1.page.screenshot();
await test.page1.logger('end of ', testName);
2021-08-26 22:13:18 +08:00
} catch (err) {
await test.page1.logger(err);
} finally {
2021-10-21 01:23:24 +08:00
await closePages(test.page1, test.page2);
}
expect(response).toBe(true);
2021-10-01 02:45:59 +08:00
Page.checkRegression(0.9, screenshot);
});
// Check for private chat message and return true when it appears
test('Send private chat to other User', async () => {
const test = new MultiUsers();
let response;
2020-10-09 03:25:35 +08:00
let screenshot;
try {
const testName = 'sendPrivateChat';
await test.page1.logger('begin of ', testName);
2021-09-30 20:36:08 +08:00
await test.init(testName);
await test.page1.startRecording(testName);
response = await test.multiUsersPrivateChat(testName);
await test.page1.stopRecording();
2020-10-09 03:25:35 +08:00
screenshot = await test.page1.page.screenshot();
await test.page1.logger('end of ', testName);
2021-08-26 22:13:18 +08:00
} catch (err) {
await test.page1.logger(err);
} finally {
2021-10-21 01:23:24 +08:00
await closePages(test.page1, test.page2);
}
expect(response).toBe(true);
2021-10-01 02:45:59 +08:00
Page.checkRegression(0.9, screenshot);
});
};
module.exports = exports = chatTest;