Merge pull request #2189 from crazyserver/MOBILE-3216

MOBILE-3216 core: Check if user agent is controlled by automation
main
Juan Leyva 2019-12-04 16:57:28 +01:00 committed by GitHub
commit 6959940c45
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 1 deletions

View File

@ -101,7 +101,9 @@ export class CoreAppProvider {
}, 100);
// Export the app provider so Behat tests can change the forceOffline flag.
(<any> window).appProvider = this;
if (CoreAppProvider.isAutomated()) {
(<any> window).appProvider = this;
}
}
/**
@ -159,6 +161,15 @@ export class CoreAppProvider {
return this.appCtrl.getRootNavs()[0];
}
/**
* Returns whether the user agent is controlled by automation. I.e. Behat testing.
*
* @return {boolean} True if the user agent is controlled by automation, false otherwise.
*/
static isAutomated(): boolean {
return !!navigator.webdriver;
}
/**
* Checks if the app is running in a 64 bits desktop environment (not browser).
*

View File

@ -17,6 +17,7 @@ import { TranslateService } from '@ngx-translate/core';
import * as moment from 'moment';
import { Globalization } from '@ionic-native/globalization';
import { Platform, Config } from 'ionic-angular';
import { CoreAppProvider } from '@providers/app';
import { CoreConfigProvider } from './config';
import { CoreConfigConstants } from '../configconstants';
@ -39,6 +40,13 @@ export class CoreLangProvider {
translate.use(this.defaultLanguage);
platform.ready().then(() => {
if (CoreAppProvider.isAutomated()) {
// Force current language to English when Behat is running.
this.changeCurrentLanguage('en');
return;
}
this.getCurrentLanguage().then((language) => {
this.changeCurrentLanguage(language);
});