bigbluebutton-Github/bigbluebutton-tests/playwright/chat/util.js

42 lines
1.5 KiB
JavaScript
Raw Normal View History

const { expect } = require('@playwright/test');
2021-11-18 04:07:14 +08:00
const e = require('../core/elements');
2022-03-29 21:53:07 +08:00
const { getSettings } = require('../core/settings');
async function openPublicChat(testPage) {
2022-03-29 21:53:07 +08:00
const { chatEnabled } = getSettings();
2023-11-01 20:26:35 +08:00
if(!chatEnabled) {
return testPage.wasRemoved(e.chatButton, 'public chat should not be desplayed');
2023-11-01 20:26:35 +08:00
}
2022-03-29 21:53:07 +08:00
await testPage.hasElement(e.chatBox, 'should display the chat box for messaging');
await testPage.hasElement(e.chatMessages, 'should display the chat messages');
try {
await testPage.hasElement(e.chatWelcomeMessageText, 'should display the chat welcome message');
} catch {
await testPage.waitAndClick(e.chatMessages);
await testPage.down('Home');
await testPage.hasElement(e.chatWelcomeMessageText, 'should display the chat welcome message');
await testPage.down('End');
}
2022-03-29 21:53:07 +08:00
}
async function openPrivateChat(testPage) {
const { chatEnabled } = getSettings();
await testPage.waitAndClick(e.userListItem);
2023-11-01 22:28:38 +08:00
if(!chatEnabled) {
return await testPage.wasRemoved(e.startPrivateChat, 'should not display the private chat');
2023-11-01 22:28:38 +08:00
}
2022-03-29 21:53:07 +08:00
await testPage.waitAndClick(e.startPrivateChat);
}
2023-04-27 20:36:19 +08:00
async function checkLastMessageSent(testPage, expectedMessage) {
const lastMessageSent = await testPage.getLocator(e.chatUserMessageText).last();
await expect(lastMessageSent, 'should display the last message sent on the chat').toHaveText(expectedMessage);
2023-04-27 20:36:19 +08:00
}
exports.openPublicChat = openPublicChat;
2022-03-29 21:53:07 +08:00
exports.openPrivateChat = openPrivateChat;
2023-04-27 20:36:19 +08:00
exports.checkLastMessageSent = checkLastMessageSent;