From eb38313075eef8f73315a7a88dfa20a1ffc5224b Mon Sep 17 00:00:00 2001 From: Diego Mello Date: Tue, 27 Apr 2021 13:18:15 -0300 Subject: [PATCH 1/2] [REGRESSION] Fallback not working when device's language is available (#3091) * Always add 'en' i18n * Add tests --- app/i18n/index.js | 1 + app/i18n/locales/nl.json | 1 - e2e/tests/assorted/04-setting.spec.js | 13 --- e2e/tests/assorted/12-i18n.spec.js | 114 ++++++++++++++++++++++++++ 4 files changed, 115 insertions(+), 14 deletions(-) create mode 100644 e2e/tests/assorted/12-i18n.spec.js diff --git a/app/i18n/index.js b/app/i18n/index.js index c82e9e17e..ebe430769 100644 --- a/app/i18n/index.js +++ b/app/i18n/index.js @@ -95,6 +95,7 @@ export const setLanguage = (l) => { moment.locale(toMomentLocale(locale)); }; +i18n.translations = { en: translations.en?.() }; const defaultLanguage = { languageTag: 'en', isRTL: false }; const availableLanguages = Object.keys(translations); const { languageTag } = RNLocalize.findBestAvailableLanguage(availableLanguages) || defaultLanguage; diff --git a/app/i18n/locales/nl.json b/app/i18n/locales/nl.json index 903da5e1f..fee4b826f 100644 --- a/app/i18n/locales/nl.json +++ b/app/i18n/locales/nl.json @@ -123,7 +123,6 @@ "creating_invite": "uitnodiging maken", "Channel_Name": "Kanaal Name", "Channels": "Kanalen", - "Chats": "Chats", "Call_already_ended": "Gesprek al beeïndigd!", "Click_to_join": "Klik om lid te worden!", "Close": "Sluiten", diff --git a/e2e/tests/assorted/04-setting.spec.js b/e2e/tests/assorted/04-setting.spec.js index a83b5b653..14bdbe71f 100644 --- a/e2e/tests/assorted/04-setting.spec.js +++ b/e2e/tests/assorted/04-setting.spec.js @@ -63,19 +63,6 @@ describe('Settings screen', () => { }); describe('Usage', async() => { - it('should navigate to language view', async() => { - await element(by.id('settings-view-language')).tap(); - await waitFor(element(by.id('language-view'))).toBeVisible().withTimeout(60000); - await expect(element(by.id('language-view-zh-CN'))).toExist(); - await expect(element(by.id('language-view-de'))).toExist(); - await expect(element(by.id('language-view-en'))).toExist(); - await expect(element(by.id('language-view-fr'))).toExist(); - await expect(element(by.id('language-view-pt-BR'))).toExist(); - await expect(element(by.id('language-view-pt-PT'))).toExist(); - await expect(element(by.id('language-view-ru'))).toExist(); - await tapBack(); - }); - it('should tap clear cache and navigate to roomslistview', async() => { await waitFor(element(by.id('settings-view'))).toBeVisible().withTimeout(2000); await element(by.id('settings-view-clear-cache')).tap(); diff --git a/e2e/tests/assorted/12-i18n.spec.js b/e2e/tests/assorted/12-i18n.spec.js new file mode 100644 index 000000000..13e7c79be --- /dev/null +++ b/e2e/tests/assorted/12-i18n.spec.js @@ -0,0 +1,114 @@ +const { + device, element, by, waitFor +} = require('detox'); +const { navigateToLogin, login, sleep } = require('../../helpers/app'); +const { post } = require('../../helpers/data_setup'); + +const data = require('../../data'); +const testuser = data.users.regular +const defaultLaunchArgs = { permissions: { notifications: 'YES' } }; + +const navToLanguage = async() => { + 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); + await waitFor(element(by.id('sidebar-settings'))).toBeVisible().withTimeout(2000); + await element(by.id('sidebar-settings')).tap(); + await waitFor(element(by.id('settings-view'))).toBeVisible().withTimeout(2000); + await element(by.id('settings-view-language')).tap(); + await waitFor(element(by.id('language-view'))).toBeVisible().withTimeout(10000); +}; + +describe('i18n', () => { + describe('OS language', () => { + it('OS set to \'en\' and proper translate to \'en\'', async() => { + await device.launchApp({ + ...defaultLaunchArgs, + languageAndLocale: { + language: "en", + locale: "en" + }, + delete: true + }); + 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(); + }); + + it('OS set to unavailable language and fallback to \'en\'', async() => { + await device.launchApp({ + ...defaultLaunchArgs, + languageAndLocale: { + language: "es-MX", + locale: "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(); + }); + + /** + * 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 + */ + 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 waitFor(element(by.id('onboarding-view'))).toBeVisible().withTimeout(20000); + await expect(element(by.id('join-workspace').and(by.label('Join a workspace')))).toBeVisible(); // Missing nl translation + await expect(element(by.id('create-workspace-button').and(by.label('Een nieuwe workspace maken')))).toBeVisible(); + }); + }); + + describe('Rocket.Chat language', () => { + before(async() => { + await device.launchApp(defaultLaunchArgs); + await navigateToLogin(); + await login(testuser.username, testuser.password); + }); + + it('should select \'en\'', async() => { + await navToLanguage(); + await element(by.id('language-view-en')).tap(); + 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); + 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(); + }); + + it('should select \'nl\' and fallback to \'en\'', async() => { + await navToLanguage(); + await element(by.id('language-view-nl')).tap(); + 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); + 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(); + }); + + 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 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 + }); + }) +}); \ No newline at end of file From 6798f039f3ba7565bd61930083ad582fa7dda8d0 Mon Sep 17 00:00:00 2001 From: Diego Mello Date: Tue, 27 Apr 2021 13:21:22 -0300 Subject: [PATCH 2/2] Bump version to 4.16.2 (#3092) --- android/app/build.gradle | 2 +- ios/RocketChatRN.xcodeproj/project.pbxproj | 4 ++-- ios/RocketChatRN/Info.plist | 2 +- ios/ShareRocketChatRN/Info.plist | 2 +- package.json | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/android/app/build.gradle b/android/app/build.gradle index e3da57bb9..69975e5d7 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -144,7 +144,7 @@ android { minSdkVersion rootProject.ext.minSdkVersion targetSdkVersion rootProject.ext.targetSdkVersion versionCode VERSIONCODE as Integer - versionName "4.17.0" + versionName "4.16.2" vectorDrawables.useSupportLibrary = true if (!isFoss) { manifestPlaceholders = [BugsnagAPIKey: BugsnagAPIKey as String] diff --git a/ios/RocketChatRN.xcodeproj/project.pbxproj b/ios/RocketChatRN.xcodeproj/project.pbxproj index bbebd2ee7..13f5b8cac 100644 --- a/ios/RocketChatRN.xcodeproj/project.pbxproj +++ b/ios/RocketChatRN.xcodeproj/project.pbxproj @@ -1694,7 +1694,7 @@ INFOPLIST_FILE = NotificationService/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 11.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks"; - MARKETING_VERSION = 4.17.0; + MARKETING_VERSION = 4.16.2; MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; MTL_FAST_MATH = YES; PRODUCT_BUNDLE_IDENTIFIER = chat.rocket.reactnative.NotificationService; @@ -1731,7 +1731,7 @@ INFOPLIST_FILE = NotificationService/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 11.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks"; - MARKETING_VERSION = 4.17.0; + MARKETING_VERSION = 4.16.2; MTL_FAST_MATH = YES; PRODUCT_BUNDLE_IDENTIFIER = chat.rocket.reactnative.NotificationService; PRODUCT_NAME = "$(TARGET_NAME)"; diff --git a/ios/RocketChatRN/Info.plist b/ios/RocketChatRN/Info.plist index 4357a8abb..e6129268e 100644 --- a/ios/RocketChatRN/Info.plist +++ b/ios/RocketChatRN/Info.plist @@ -23,7 +23,7 @@ CFBundlePackageType APPL CFBundleShortVersionString - 4.17.0 + 4.16.2 CFBundleSignature ???? CFBundleURLTypes diff --git a/ios/ShareRocketChatRN/Info.plist b/ios/ShareRocketChatRN/Info.plist index e38798d73..38a2e4cf6 100644 --- a/ios/ShareRocketChatRN/Info.plist +++ b/ios/ShareRocketChatRN/Info.plist @@ -21,7 +21,7 @@ CFBundlePackageType XPC! CFBundleShortVersionString - 4.17.0 + 4.16.2 CFBundleVersion 1 KeychainGroup diff --git a/package.json b/package.json index 7e0e5d6da..855b1df73 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "rocket-chat-reactnative", - "version": "4.17.0", + "version": "4.16.2", "private": true, "scripts": { "start": "react-native start",