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

40 lines
1.3 KiB
JavaScript
Raw Normal View History

const e = require('../core/elements');
const defaultLocale = require('../../../bigbluebutton-html5/public/locales/en.json');
2022-01-20 03:50:59 +08:00
async function openSettings(test) {
2022-01-20 21:03:18 +08:00
await test.waitAndClick(e.optionsButton);
2022-01-20 03:50:59 +08:00
await test.waitAndClick(e.settings);
}
2022-02-04 02:44:48 +08:00
async function getLocaleValues(elements, locale) {
const currentValues = {};
let currentLocale = {};
try {
currentLocale = require(`../../../bigbluebutton-html5/public/locales/${locale.replace('-', '_')}.json`);
} catch (err) { }
2022-02-04 02:44:48 +08:00
for (const selector in elements) {
const currentKey = elements[selector];
currentValues[selector] = currentLocale[currentKey] ? currentLocale[currentKey] : getValueFromSecondaryLocale();
2022-02-04 02:44:48 +08:00
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];
2022-02-04 02:44:48 +08:00
}
}
return currentValues;
}
async function openAboutModal(test) {
await test.waitAndClick(e.optionsButton);
await test.waitAndClick(e.showAboutModalButton);
}
exports.openAboutModal = openAboutModal;
exports.openSettings = openSettings;
2022-02-04 02:44:48 +08:00
exports.getLocaleValues = getLocaleValues;