bigbluebutton-Github/bigbluebutton-tests/playwright/options/util.js
2022-08-15 09:37:52 -03:00

40 lines
1.3 KiB
JavaScript

const e = require('../core/elements');
const defaultLocale = require('../../../bigbluebutton-html5/public/locales/en.json');
async function openSettings(test) {
await test.waitAndClick(e.optionsButton);
await test.waitAndClick(e.settings);
}
async function getLocaleValues(elements, locale) {
const currentValues = {};
let currentLocale = {};
try {
currentLocale = require(`../../../bigbluebutton-html5/public/locales/${locale.replace('-', '_')}.json`);
} catch (err) { }
for (const selector in elements) {
const currentKey = elements[selector];
currentValues[selector] = currentLocale[currentKey] ? currentLocale[currentKey] : getValueFromSecondaryLocale();
function getValueFromSecondaryLocale() {
const generalLocaleName = locale.split('-')[0];
let generalLocale = {};
try {
generalLocale = require(`../../../bigbluebutton-html5/public/locales/${generalLocaleName}.json`);
} catch (err) { }
return generalLocale[currentKey] ? generalLocale[currentKey] : defaultLocale[currentKey];
}
}
return currentValues;
}
async function openAboutModal(test) {
await test.waitAndClick(e.optionsButton);
await test.waitAndClick(e.showAboutModalButton);
}
exports.openAboutModal = openAboutModal;
exports.openSettings = openSettings;
exports.getLocaleValues = getLocaleValues;