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

24 lines
694 B
JavaScript
Raw Normal View History

2022-03-21 23:04:43 +08:00
const { expect } = require("@playwright/test");
2021-11-26 02:23:58 +08:00
// Common
2021-12-01 22:02:26 +08:00
function checkElement([element, index = 0]) {
2021-11-26 02:23:58 +08:00
return document.querySelectorAll(element)[index] !== undefined;
}
// Length
2021-12-01 13:36:20 +08:00
function checkElementLengthEqualTo([element, count]) {
return document.querySelectorAll(element).length == count;
}
2022-03-21 23:04:43 +08:00
// Text
async function checkTextContent(baseContent, checkData) {
2022-03-29 21:53:07 +08:00
if (typeof checkData === 'string') checkData = new Array(checkData);
2022-03-21 23:04:43 +08:00
const check = checkData.every(word => baseContent.includes(word));
await expect(check).toBeTruthy();
}
2021-12-01 13:36:20 +08:00
exports.checkElement = checkElement;
2021-12-04 01:01:36 +08:00
exports.checkElementLengthEqualTo = checkElementLengthEqualTo;
2022-03-21 23:04:43 +08:00
exports.checkTextContent = checkTextContent;