2023-03-07 12:28:51 +00:00
|
|
|
import Detox, { device, waitFor, element, by, expect } from 'detox';
|
2022-09-12 14:51:33 +00:00
|
|
|
|
2023-05-18 21:09:33 +00:00
|
|
|
import { navigateToLogin, login } from '../../helpers/app';
|
2023-03-07 12:28:51 +00:00
|
|
|
import { createRandomUser, ITestUser } from '../../helpers/data_setup';
|
2021-07-02 17:39:39 +00:00
|
|
|
|
2022-09-12 14:51:33 +00:00
|
|
|
const defaultLaunchArgs = { permissions: { notifications: 'YES' } } as Detox.DeviceLaunchAppConfig;
|
2021-04-27 16:18:15 +00:00
|
|
|
|
2021-09-13 20:41:05 +00:00
|
|
|
const navToLanguage = async () => {
|
|
|
|
await waitFor(element(by.id('rooms-list-view')))
|
|
|
|
.toBeVisible()
|
|
|
|
.withTimeout(10000);
|
2021-04-27 16:18:15 +00:00
|
|
|
await element(by.id('rooms-list-view-sidebar')).tap();
|
2021-09-13 20:41:05 +00:00
|
|
|
await waitFor(element(by.id('sidebar-view')))
|
|
|
|
.toBeVisible()
|
|
|
|
.withTimeout(2000);
|
|
|
|
await waitFor(element(by.id('sidebar-settings')))
|
|
|
|
.toBeVisible()
|
|
|
|
.withTimeout(2000);
|
2021-04-27 16:18:15 +00:00
|
|
|
await element(by.id('sidebar-settings')).tap();
|
2021-09-13 20:41:05 +00:00
|
|
|
await waitFor(element(by.id('settings-view')))
|
|
|
|
.toBeVisible()
|
|
|
|
.withTimeout(2000);
|
2021-04-27 16:18:15 +00:00
|
|
|
await element(by.id('settings-view-language')).tap();
|
2021-09-13 20:41:05 +00:00
|
|
|
await waitFor(element(by.id('language-view')))
|
|
|
|
.toBeVisible()
|
|
|
|
.withTimeout(10000);
|
2021-04-27 16:18:15 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
describe('i18n', () => {
|
|
|
|
describe('OS language', () => {
|
2021-09-13 20:41:05 +00:00
|
|
|
it("OS set to 'en' and proper translate to 'en'", async () => {
|
2023-05-10 20:22:18 +00:00
|
|
|
if (device.getPlatform() === 'android') {
|
|
|
|
return; // FIXME: Passing language with launch parameters doesn't work with Android
|
|
|
|
}
|
2021-04-27 16:18:15 +00:00
|
|
|
await device.launchApp({
|
|
|
|
...defaultLaunchArgs,
|
|
|
|
languageAndLocale: {
|
2021-07-02 17:39:39 +00:00
|
|
|
language: 'en',
|
|
|
|
locale: 'en'
|
2021-04-27 16:18:15 +00:00
|
|
|
},
|
|
|
|
delete: true
|
|
|
|
});
|
2021-09-23 14:17:53 +00:00
|
|
|
await waitFor(element(by.id('new-server-view')))
|
2021-09-13 20:41:05 +00:00
|
|
|
.toBeVisible()
|
|
|
|
.withTimeout(20000);
|
2023-05-08 13:45:46 +00:00
|
|
|
await expect(element(by.id('new-server-view-open'))).toBeVisible();
|
2021-04-27 16:18:15 +00:00
|
|
|
});
|
2021-07-02 17:39:39 +00:00
|
|
|
|
2021-09-13 20:41:05 +00:00
|
|
|
it("OS set to unavailable language and fallback to 'en'", async () => {
|
2023-05-10 20:22:18 +00:00
|
|
|
if (device.getPlatform() === 'android') {
|
|
|
|
return; // FIXME: Passing language with launch parameters doesn't work with Android
|
|
|
|
}
|
2021-04-27 16:18:15 +00:00
|
|
|
await device.launchApp({
|
|
|
|
...defaultLaunchArgs,
|
|
|
|
languageAndLocale: {
|
2021-07-02 17:39:39 +00:00
|
|
|
language: 'es-MX',
|
|
|
|
locale: 'es-MX'
|
2021-04-27 16:18:15 +00:00
|
|
|
}
|
|
|
|
});
|
2021-09-23 14:17:53 +00:00
|
|
|
await waitFor(element(by.id('new-server-view')))
|
2021-09-13 20:41:05 +00:00
|
|
|
.toBeVisible()
|
|
|
|
.withTimeout(20000);
|
2023-05-08 13:45:46 +00:00
|
|
|
await expect(element(by.id('new-server-view-open'))).toBeVisible();
|
2021-04-27 16:18:15 +00:00
|
|
|
});
|
2021-07-02 17:39:39 +00:00
|
|
|
|
2021-04-27 16:18:15 +00:00
|
|
|
/**
|
|
|
|
* This test might become outdated as soon as we support the language
|
|
|
|
* Although this seems to be a bad approach, that's the intention for having fallback enabled
|
|
|
|
*/
|
2021-06-11 18:23:43 +00:00
|
|
|
// it('OS set to available language and fallback to \'en\' on strings missing translation', async() => {
|
|
|
|
// await device.launchApp({
|
|
|
|
// ...defaultLaunchArgs,
|
|
|
|
// languageAndLocale: {
|
|
|
|
// language: "nl",
|
|
|
|
// locale: "nl"
|
|
|
|
// }
|
|
|
|
// });
|
|
|
|
// });
|
2021-04-27 16:18:15 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
describe('Rocket.Chat language', () => {
|
2023-03-07 12:28:51 +00:00
|
|
|
let user: ITestUser;
|
|
|
|
beforeAll(async () => {
|
|
|
|
user = await createRandomUser();
|
2021-12-02 13:19:15 +00:00
|
|
|
await device.launchApp({ ...defaultLaunchArgs, delete: true });
|
2021-04-27 16:18:15 +00:00
|
|
|
await navigateToLogin();
|
2023-03-07 12:28:51 +00:00
|
|
|
await login(user.username, user.password);
|
2021-04-27 16:18:15 +00:00
|
|
|
});
|
|
|
|
|
2021-09-13 20:41:05 +00:00
|
|
|
it("should select 'en'", async () => {
|
2021-04-27 16:18:15 +00:00
|
|
|
await navToLanguage();
|
|
|
|
await element(by.id('language-view-en')).tap();
|
2021-09-13 20:41:05 +00:00
|
|
|
await waitFor(element(by.id('rooms-list-view')))
|
|
|
|
.toBeVisible()
|
|
|
|
.withTimeout(10000);
|
2021-04-27 16:18:15 +00:00
|
|
|
await element(by.id('rooms-list-view-sidebar')).tap();
|
2021-09-13 20:41:05 +00:00
|
|
|
await waitFor(element(by.id('sidebar-view')))
|
|
|
|
.toBeVisible()
|
|
|
|
.withTimeout(2000);
|
2021-04-27 16:18:15 +00:00
|
|
|
await expect(element(by.id('sidebar-chats').withDescendant(by.label('Chats')))).toBeVisible();
|
|
|
|
await expect(element(by.id('sidebar-profile').withDescendant(by.label('Profile')))).toBeVisible();
|
|
|
|
await expect(element(by.id('sidebar-settings').withDescendant(by.label('Settings')))).toBeVisible();
|
|
|
|
await element(by.id('sidebar-close-drawer')).tap();
|
|
|
|
});
|
|
|
|
|
2021-09-13 20:41:05 +00:00
|
|
|
it("should select 'nl' and fallback to 'en'", async () => {
|
2021-04-27 16:18:15 +00:00
|
|
|
await navToLanguage();
|
|
|
|
await element(by.id('language-view-nl')).tap();
|
2021-09-13 20:41:05 +00:00
|
|
|
await waitFor(element(by.id('rooms-list-view')))
|
|
|
|
.toBeVisible()
|
|
|
|
.withTimeout(10000);
|
2021-04-27 16:18:15 +00:00
|
|
|
await element(by.id('rooms-list-view-sidebar')).tap();
|
2021-09-13 20:41:05 +00:00
|
|
|
await waitFor(element(by.id('sidebar-view')))
|
|
|
|
.toBeVisible()
|
|
|
|
.withTimeout(2000);
|
2021-04-27 16:18:15 +00:00
|
|
|
await expect(element(by.id('sidebar-chats').withDescendant(by.label('Chats')))).toBeVisible(); // fallback to en
|
|
|
|
await expect(element(by.id('sidebar-profile').withDescendant(by.label('Profiel')))).toBeVisible();
|
|
|
|
await expect(element(by.id('sidebar-settings').withDescendant(by.label('Instellingen')))).toBeVisible();
|
|
|
|
await element(by.id('sidebar-close-drawer')).tap();
|
|
|
|
});
|
|
|
|
|
2023-03-07 12:28:51 +00:00
|
|
|
// 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, newInstance: true });
|
|
|
|
// 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);
|
|
|
|
// // give the app some time to apply new language
|
|
|
|
// await sleep(3000);
|
|
|
|
// await expect(element(by.id('sidebar-chats').withDescendant(by.label('Chats')))).toBeVisible();
|
|
|
|
// await expect(element(by.id('sidebar-profile').withDescendant(by.label('Profile')))).toBeVisible();
|
|
|
|
// await expect(element(by.id('sidebar-settings').withDescendant(by.label('Settings')))).toBeVisible();
|
|
|
|
// await post('users.setPreferences', { data: { language: 'en' } }); // Set back to english
|
|
|
|
// });
|
2021-07-02 17:39:39 +00:00
|
|
|
});
|
|
|
|
});
|