i18n tests working on Android, and improving code
This commit is contained in:
parent
60768fced1
commit
523647b42f
|
@ -21,7 +21,7 @@ const Item = React.memo(({
|
|||
{left}
|
||||
</View>
|
||||
<View style={styles.itemCenter}>
|
||||
<Text style={[styles.itemText, { color: themes[theme].titleText }]} numberOfLines={1}>
|
||||
<Text style={[styles.itemText, { color: themes[theme].titleText }]} numberOfLines={1} accessibilityLabel={text}>
|
||||
{text}
|
||||
</Text>
|
||||
</View>
|
||||
|
|
|
@ -38,7 +38,7 @@ async function login(username, password) {
|
|||
|
||||
async function logout() {
|
||||
const deviceType = device.getPlatform();
|
||||
const scrollViewType = platformTypes[deviceType].scrollViewType;
|
||||
const { scrollViewType } = platformTypes[deviceType];
|
||||
await element(by.id('rooms-list-view-sidebar')).tap();
|
||||
await waitFor(element(by.id('sidebar-view'))).toBeVisible().withTimeout(2000);
|
||||
await waitFor(element(by.id('sidebar-settings'))).toBeVisible().withTimeout(2000);
|
||||
|
@ -87,7 +87,7 @@ async function pinMessage(message){
|
|||
|
||||
async function dismissReviewNag(){
|
||||
const deviceType = device.getPlatform();
|
||||
const alertButtonType = platformTypes[deviceType].alertButtonType;
|
||||
const { alertButtonType } = platformTypes[deviceType];
|
||||
await waitFor(element(by.text('Are you enjoying this app?'))).toExist().withTimeout(60000);
|
||||
await element(by.text('NO').and(by.type(alertButtonType))).tap(); // Tap `no` on ask for review alert
|
||||
}
|
||||
|
|
|
@ -0,0 +1,43 @@
|
|||
const { exec } = require('child_process');
|
||||
const { device } = require('detox');
|
||||
const { sleep } = require('./app');
|
||||
|
||||
const defaultLaunchArgs = { permissions: { notifications: 'YES' } };
|
||||
|
||||
function runCommand(command) {
|
||||
return new Promise((resolve, reject) => {
|
||||
exec(command, (error, stdout, stderr) => {
|
||||
if(error)
|
||||
{
|
||||
reject(new Error(`exec error: ${stderr}`));
|
||||
return;
|
||||
}
|
||||
resolve();
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
exports.launchWithLanguage = async (language, countryCode="US", launchArgs=defaultLaunchArgs) => {
|
||||
if(device.id === undefined)
|
||||
{
|
||||
await device.launchApp(launchArgs);
|
||||
}
|
||||
if(device.getPlatform() === 'android')
|
||||
{
|
||||
await runCommand('adb root');
|
||||
await runCommand(`adb shell "setprop persist.sys.locale ${language}-${countryCode}; setprop ctl.restart zygote"`);
|
||||
await sleep(5000);
|
||||
await device.launchApp(launchArgs);
|
||||
}
|
||||
else
|
||||
{
|
||||
const langLocale = typeof countryCode === 'string' ? `${language}-${countryCode}` : language;
|
||||
await device.launchApp({
|
||||
...launchArgs,
|
||||
languageAndLocale: {
|
||||
language: langLocale,
|
||||
locale: langLocale
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
|
@ -50,9 +50,7 @@ describe('E2E Encryption', () => {
|
|||
|
||||
before(async () => {
|
||||
await device.launchApp({ permissions: { notifications: 'YES' }, delete: true });
|
||||
const deviceType = device.getPlatform();
|
||||
alertButtonType = platformTypes[deviceType].alertButtonType;
|
||||
scrollViewType = platformTypes[deviceType].scrollViewType;
|
||||
({ alertButtonType, scrollViewType } = platformTypes[device.getPlatform()]);
|
||||
await navigateToLogin();
|
||||
await login(testuser.username, testuser.password);
|
||||
});
|
||||
|
|
|
@ -23,9 +23,7 @@ describe('Profile screen', () => {
|
|||
|
||||
before(async() => {
|
||||
await device.launchApp({ permissions: { notifications: 'YES' }, delete: true });
|
||||
const deviceType = device.getPlatform();
|
||||
textInputType = platformTypes[deviceType].textInputType;
|
||||
scrollViewType = platformTypes[deviceType].scrollViewType;
|
||||
({ textInputType, scrollViewType } = platformTypes[device.getPlatform()]);
|
||||
await navigateToLogin();
|
||||
await login(profileChangeUser.username, profileChangeUser.password);
|
||||
await element(by.id('rooms-list-view-sidebar')).tap();
|
||||
|
|
|
@ -24,8 +24,7 @@ describe('Join public room', () => {
|
|||
let scrollViewType;
|
||||
before(async() => {
|
||||
await device.launchApp({ permissions: { notifications: 'YES' }, delete: true });
|
||||
const deviceType = device.getPlatform();
|
||||
scrollViewType = platformTypes[deviceType].scrollViewType;
|
||||
({ scrollViewType } = platformTypes[device.getPlatform()]);
|
||||
await navigateToLogin();
|
||||
await login(testuser.username, testuser.password);
|
||||
await navigateToRoom();
|
||||
|
|
|
@ -10,9 +10,7 @@ describe('Delete server', () => {
|
|||
let scrollViewType, alertButtonType;
|
||||
before(async() => {
|
||||
await device.launchApp({ permissions: { notifications: 'YES' }, delete: true });
|
||||
const deviceType = device.getPlatform();
|
||||
alertButtonType = platformTypes[deviceType].alertButtonType;
|
||||
scrollViewType = platformTypes[deviceType].scrollViewType;
|
||||
({ alertButtonType, scrollViewType } = platformTypes[device.getPlatform()]);
|
||||
await navigateToLogin();
|
||||
await login(data.users.regular.username, data.users.regular.password);
|
||||
});
|
||||
|
|
|
@ -3,6 +3,7 @@ const {
|
|||
} = require('detox');
|
||||
const { navigateToLogin, login, sleep } = require('../../helpers/app');
|
||||
const { post } = require('../../helpers/data_setup');
|
||||
const { launchWithLanguage } = require('../../helpers/platformFunctions');
|
||||
|
||||
const data = require('../../data');
|
||||
const testuser = data.users.regular
|
||||
|
@ -22,12 +23,8 @@ const navToLanguage = async() => {
|
|||
describe('i18n', () => {
|
||||
describe('OS language', () => {
|
||||
it('OS set to \'en\' and proper translate to \'en\'', async() => {
|
||||
await device.launchApp({
|
||||
await launchWithLanguage('en', "US", {
|
||||
...defaultLaunchArgs,
|
||||
languageAndLocale: {
|
||||
language: "en",
|
||||
locale: "en"
|
||||
},
|
||||
delete: true
|
||||
});
|
||||
await waitFor(element(by.id('onboarding-view'))).toBeVisible().withTimeout(20000);
|
||||
|
@ -36,13 +33,7 @@ describe('i18n', () => {
|
|||
});
|
||||
|
||||
it('OS set to unavailable language and fallback to \'en\'', async() => {
|
||||
await device.launchApp({
|
||||
...defaultLaunchArgs,
|
||||
languageAndLocale: {
|
||||
language: "es-MX",
|
||||
locale: "es-MX"
|
||||
}
|
||||
});
|
||||
await launchWithLanguage('es', 'MX');
|
||||
await waitFor(element(by.id('onboarding-view'))).toBeVisible().withTimeout(20000);
|
||||
await expect(element(by.id('join-workspace').and(by.label('Join a workspace')))).toBeVisible();
|
||||
await expect(element(by.id('create-workspace-button').and(by.label('Create a new workspace')))).toBeVisible();
|
||||
|
@ -53,13 +44,7 @@ describe('i18n', () => {
|
|||
* Although this seems to be a bad approach, that's the intention for having fallback enabled
|
||||
*/
|
||||
// it('OS set to available language and fallback to \'en\' on strings missing translation', async() => {
|
||||
// await device.launchApp({
|
||||
// ...defaultLaunchArgs,
|
||||
// languageAndLocale: {
|
||||
// language: "nl",
|
||||
// locale: "nl"
|
||||
// }
|
||||
// });
|
||||
// await launchWithLanguage('nl');
|
||||
// await waitFor(element(by.id('onboarding-view'))).toBeVisible().withTimeout(20000);
|
||||
// await expect(element(by.id('join-workspace').and(by.label('Word lid van een werkruimte')))).toBeVisible();
|
||||
// await expect(element(by.id('create-workspace-button').and(by.label('Een nieuwe werkruimte aanmaken')))).toBeVisible();
|
||||
|
@ -99,7 +84,7 @@ describe('i18n', () => {
|
|||
|
||||
it('should set unsupported language and fallback to \'en\'', async() => {
|
||||
await post('users.setPreferences', { data: { language: 'eo' } }); // Set language to Esperanto
|
||||
await device.launchApp(defaultLaunchArgs);
|
||||
await launchWithLanguage("en");
|
||||
await waitFor(element(by.id('rooms-list-view'))).toBeVisible().withTimeout(10000);
|
||||
await element(by.id('rooms-list-view-sidebar')).tap();
|
||||
await waitFor(element(by.id('sidebar-view'))).toBeVisible().withTimeout(2000);
|
||||
|
|
|
@ -5,6 +5,8 @@ const data = require('../../data');
|
|||
const { navigateToLogin, login, tapBack, sleep, searchRoom, mockMessage, starMessage, pinMessage } = require('../../helpers/app');
|
||||
const { sendMessage } = require('../../helpers/data_setup')
|
||||
|
||||
const platformTypes = require('../../helpers/platformTypes');
|
||||
|
||||
async function navigateToRoomActions(type) {
|
||||
let room;
|
||||
if (type === 'd') {
|
||||
|
@ -36,11 +38,12 @@ async function waitForToast() {
|
|||
}
|
||||
|
||||
describe('Room actions screen', () => {
|
||||
|
||||
let alertButtonType;
|
||||
before(async() => {
|
||||
await device.launchApp({ permissions: { notifications: 'YES' }, delete: true });
|
||||
await navigateToLogin();
|
||||
await login(data.users.regular.username, data.users.regular.password);
|
||||
({ alertButtonType } = platformTypes[device.getPlatform()]);
|
||||
});
|
||||
|
||||
describe('Render', async() => {
|
||||
|
@ -389,7 +392,7 @@ describe('Room actions screen', () => {
|
|||
await openActionSheet('rocket.cat');
|
||||
await element(by.text('Remove from room')).tap();
|
||||
await waitFor(element(by.text('Are you sure?'))).toExist().withTimeout(5000);
|
||||
await element(by.text('Yes, remove user!').and(by.type('android.widget.Button'))).tap();
|
||||
await element(by.text('Yes, remove user!').and(by.type(alertButtonType))).tap();
|
||||
await waitFor(element(by.id('room-members-view-item-rocket.cat'))).toBeNotVisible().withTimeout(60000);
|
||||
});
|
||||
|
||||
|
@ -461,13 +464,13 @@ describe('Room actions screen', () => {
|
|||
await openActionSheet(user.username);
|
||||
await element(by.text('Mute')).tap();
|
||||
await waitFor(element(by.text('Are you sure?'))).toExist().withTimeout(5000);
|
||||
await element(by.text('Mute').and(by.type('android.widget.Button'))).tap();
|
||||
await element(by.text('Mute').and(by.type(alertButtonType))).tap();
|
||||
await waitForToast();
|
||||
|
||||
await openActionSheet(user.username);
|
||||
await element(by.text('Unmute')).tap();
|
||||
await waitFor(element(by.text('Are you sure?'))).toExist().withTimeout(5000);
|
||||
await element(by.text('Unmute').and(by.type('android.widget.Button'))).tap();
|
||||
await element(by.text('Unmute').and(by.type(alertButtonType))).tap();
|
||||
await waitForToast();
|
||||
|
||||
await openActionSheet(user.username);
|
||||
|
|
Loading…
Reference in New Issue