From 8e004ea5c87764f79a7788d24fea1c66a1ee801d Mon Sep 17 00:00:00 2001 From: Anant Bhasin Date: Sun, 4 Jul 2021 13:47:10 +0530 Subject: [PATCH] Skip platform language tests on Detox --- .../main/res/xml/network_security_config.xml | 14 +++--- e2e/tests/assorted/12-i18n.spec.js | 45 +++++++++++++------ 2 files changed, 39 insertions(+), 20 deletions(-) diff --git a/android/app/src/main/res/xml/network_security_config.xml b/android/app/src/main/res/xml/network_security_config.xml index 94f5c1d0f..ef899d459 100644 --- a/android/app/src/main/res/xml/network_security_config.xml +++ b/android/app/src/main/res/xml/network_security_config.xml @@ -1,10 +1,10 @@ - - - - - - + + + + + + \ No newline at end of file diff --git a/e2e/tests/assorted/12-i18n.spec.js b/e2e/tests/assorted/12-i18n.spec.js index 60482b068..afadbcd92 100644 --- a/e2e/tests/assorted/12-i18n.spec.js +++ b/e2e/tests/assorted/12-i18n.spec.js @@ -1,12 +1,10 @@ -const { - device, element, by, waitFor -} = require('detox'); const { navigateToLogin, login, sleep } = require('../../helpers/app'); +const { prepareAndroid } = require('../../helpers/platformFunctions'); const { post } = require('../../helpers/data_setup'); -const { launchWithLanguage, prepareAndroid } = require('../../helpers/platformFunctions'); const data = require('../../data'); -const testuser = data.users.regular + +const testuser = data.users.regular; const defaultLaunchArgs = { permissions: { notifications: 'YES' } }; const navToLanguage = async() => { @@ -21,31 +19,52 @@ const navToLanguage = async() => { }; describe('i18n', () => { + before(async () => { + await prepareAndroid(); + }); + describe('OS language', () => { it('OS set to \'en\' and proper translate to \'en\'', async() => { - await launchWithLanguage('en', "US", { + if(device.getPlatform() === "android") return; // Not run on android + await device.launchApp({ ...defaultLaunchArgs, + languageAndLocale: { + language: 'en', + locale: 'en' + }, delete: true }); - await prepareAndroid(); 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 launchWithLanguage('es', 'MX'); + if(device.getPlatform() === "android") return; // Not run on android + 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 launchWithLanguage('nl'); + // 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('Word lid van een werkruimte')))).toBeVisible(); // await expect(element(by.id('create-workspace-button').and(by.label('Een nieuwe werkruimte aanmaken')))).toBeVisible(); @@ -85,7 +104,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 launchWithLanguage("en"); + 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); @@ -96,5 +115,5 @@ describe('i18n', () => { 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