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

42 lines
1.3 KiB
JavaScript
Raw Normal View History

2023-04-27 20:36:19 +08:00
const { default: test, 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);
2023-11-01 20:26:35 +08:00
}
2022-03-29 21:53:07 +08:00
await testPage.waitForSelector(e.chatBox);
await testPage.waitForSelector(e.chatMessages);
try {
await testPage.waitForSelector(e.chatWelcomeMessageText);
} catch {
await testPage.waitAndClick(e.chatMessages);
await testPage.down('Home');
await testPage.waitForSelector(e.chatWelcomeMessageText);
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);
}
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).toHaveText(expectedMessage);
}
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;