improve locale test

This commit is contained in:
Anton 2022-02-03 15:44:48 -03:00
parent 7152d23e39
commit d65c6d2e2e
5 changed files with 56 additions and 4 deletions

View File

@ -124,7 +124,7 @@ class UserMessages extends PureComponent {
<div className={styles.container}>
{
!compact ? (
<h2 className={styles.smallTitle}>
<h2 className={styles.smallTitle} data-test="messageTitle">
{intl.formatMessage(intlMessages.messagesTitle)}
</h2>
) : (

View File

@ -127,7 +127,7 @@ class UserNotes extends Component {
return (
<div className={styles.messages}>
<div className={styles.container}>
<h2 className={styles.smallTitle}>
<h2 className={styles.smallTitle} data-test="notesTitle">
{intl.formatMessage(intlMessages.title)}
</h2>
</div>

View File

@ -57,6 +57,7 @@ exports.chatTitle = 'div[data-test="chatTitle"]';
exports.startPrivateChat = 'li[data-test="startPrivateChat"]';
exports.publicChat = 'div[data-test="publicChat"]';
exports.privateChat = 'div[data-test="privateChat"]';
exports.hidePublicChat = 'button[data-test="hidePublicChat"]';
exports.hidePrivateChat = 'button[data-test="hidePrivateChat"]';
exports.typingIndicator = 'span[data-test="typingIndicator"]';
exports.chatUserMessageText = 'p[data-test="chatUserMessageText"]';
@ -181,6 +182,8 @@ exports.presentationUploadedToast = 'Current presentation';
// Settings
exports.languageSelector = 'select[id="langSelector"]';
exports.messageTitle = 'h2[data-test="messageTitle"]';
exports.notesTitle = 'h2[data-test="notesTitle"]';
// User
exports.userAvatar = 'div[data-test="userAvatar"]';

View File

@ -1,6 +1,7 @@
const Page = require('../core/page');
const { openSettings } = require('./util');
const { openSettings, getLocaleValues } = require('./util');
const e = require('../core/elements');
const { checkNotificationText } = require('../notifications/util');
class Language extends Page {
constructor(browser, page) {
@ -8,13 +9,36 @@ class Language extends Page {
}
async test() {
for(const locale of e.locales) {
const selectedKeysBySelector = {
[e.messageTitle]: 'app.userList.messagesTitle',
[e.notesTitle]: 'app.userList.notesTitle',
[e.userList]: 'app.navBar.userListToggleBtnLabel',
[e.hidePublicChat]: 'app.chat.titlePublic',
[e.sendButton]: 'app.chat.submitLabel',
[e.actions]: 'app.actionsBar.actionsDropdown.actionsLabel',
[e.joinAudio]: 'app.audio.joinAudio',
[e.joinVideo]: 'app.video.joinVideo',
[e.startScreenSharing]: 'app.actionsBar.actionsDropdown.desktopShareLabel',
[e.minimizePresentation]: 'app.actionsBar.actionsDropdown.minimizePresentationLabel',
[e.raiseHandBtn]: 'app.actionsBar.emojiMenu.raiseHandLabel',
[e.connectionStatusBtn]: 'app.connection-status.label',
[e.optionsButton]: 'app.navBar.settingsDropdown.optionsLabel',
}
for (const locale of e.locales) {
console.log(`Testing ${locale} locale`);
const currentValuesBySelector = await getLocaleValues(selectedKeysBySelector, locale);
await openSettings(this);
await this.waitForSelector(e.languageSelector);
const langDropdown = await this.page.$(e.languageSelector);
await langDropdown.selectOption({ value: locale });
await this.waitAndClick(e.modalConfirmButton);
await this.waitForSelector(e.toastContainer);
for (const selector in currentValuesBySelector) {
await this.hasText(selector, currentValuesBySelector[selector]);
}
}
}
}

View File

@ -1,8 +1,33 @@
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 (e) { }
for (const selector in elements) {
const currentKey = elements[selector];
currentValues[selector] = currentLocale[currentKey] ?? getValueFromSecondaryLocale();
function getValueFromSecondaryLocale() {
const generalLocaleName = locale.split('-')[0];
let generalLocale = {};
try {
generalLocale = require(`../../../bigbluebutton-html5/public/locales/${generalLocaleName}.json`);
} catch (e) { }
return generalLocale[currentKey] ?? defaultLocale[currentKey];
}
}
return currentValues;
}
exports.openSettings = openSettings;
exports.getLocaleValues = getLocaleValues;