MOBILE-4496 reminders: Timeout permission request in behat
parent
208ec01b6c
commit
da5827190f
|
@ -48,6 +48,7 @@ import { CoreUpdateManagerProvider } from '@services/update-manager';
|
||||||
import { CoreUrlUtilsProvider } from '@services/utils/url';
|
import { CoreUrlUtilsProvider } from '@services/utils/url';
|
||||||
import { CoreUtilsProvider } from '@services/utils/utils';
|
import { CoreUtilsProvider } from '@services/utils/utils';
|
||||||
import { CoreWSProvider } from '@services/ws';
|
import { CoreWSProvider } from '@services/ws';
|
||||||
|
import { CorePlatformService } from '@services/platform';
|
||||||
|
|
||||||
export const CORE_SERVICES: Type<unknown>[] = [
|
export const CORE_SERVICES: Type<unknown>[] = [
|
||||||
CoreAppProvider,
|
CoreAppProvider,
|
||||||
|
@ -68,6 +69,7 @@ export const CORE_SERVICES: Type<unknown>[] = [
|
||||||
CoreMimetypeUtilsProvider,
|
CoreMimetypeUtilsProvider,
|
||||||
CoreNavigatorService,
|
CoreNavigatorService,
|
||||||
CorePluginFileDelegateService,
|
CorePluginFileDelegateService,
|
||||||
|
CorePlatformService,
|
||||||
CoreScreenService,
|
CoreScreenService,
|
||||||
CoreSitesProvider,
|
CoreSitesProvider,
|
||||||
CoreSyncProvider,
|
CoreSyncProvider,
|
||||||
|
|
|
@ -15,6 +15,8 @@
|
||||||
import { CoreError } from '@classes/errors/error';
|
import { CoreError } from '@classes/errors/error';
|
||||||
import { ILocalNotification, ILocalNotificationAction, LocalNotifications } from '@awesome-cordova-plugins/local-notifications/ngx';
|
import { ILocalNotification, ILocalNotificationAction, LocalNotifications } from '@awesome-cordova-plugins/local-notifications/ngx';
|
||||||
import { Observable, Subject } from 'rxjs';
|
import { Observable, Subject } from 'rxjs';
|
||||||
|
import { CoreUtils } from '@services/utils/utils';
|
||||||
|
import { CorePlatform } from '@services/platform';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Mock LocalNotifications service.
|
* Mock LocalNotifications service.
|
||||||
|
@ -332,7 +334,16 @@ export class LocalNotificationsMock extends LocalNotifications {
|
||||||
*/
|
*/
|
||||||
async registerPermission(): Promise<boolean> {
|
async registerPermission(): Promise<boolean> {
|
||||||
// We need to ask the user for permission
|
// We need to ask the user for permission
|
||||||
const permission = await Notification.requestPermission();
|
const permissionRequests = [Notification.requestPermission()];
|
||||||
|
|
||||||
|
if (CorePlatform.isAutomated()) {
|
||||||
|
// In some testing environments, Notification.requestPermission gets stuck and never returns.
|
||||||
|
// Given that we don't actually need browser notifications to work in Behat tests, we can just
|
||||||
|
// continue if the permissions haven't been granted after 1 second.
|
||||||
|
permissionRequests.push(CoreUtils.wait(1000).then(() => 'granted'));
|
||||||
|
}
|
||||||
|
|
||||||
|
const permission = await Promise.race(permissionRequests);
|
||||||
|
|
||||||
this.hasGranted = permission === 'granted';
|
this.hasGranted = permission === 'granted';
|
||||||
|
|
||||||
|
|
|
@ -41,9 +41,9 @@ import { CoreNavigator } from '@services/navigator';
|
||||||
import { makeSingleton, Translate } from '@singletons';
|
import { makeSingleton, Translate } from '@singletons';
|
||||||
import { CoreError } from '@classes/errors/error';
|
import { CoreError } from '@classes/errors/error';
|
||||||
import { CoreCourseHelper } from '@features/course/services/course-helper';
|
import { CoreCourseHelper } from '@features/course/services/course-helper';
|
||||||
import { CoreAppProvider } from '@services/app';
|
|
||||||
import { CoreCourseModuleDelegate } from '@features/course/services/module-delegate';
|
import { CoreCourseModuleDelegate } from '@features/course/services/module-delegate';
|
||||||
import { CoreCourseAccess } from '@features/course/services/course-options-delegate';
|
import { CoreCourseAccess } from '@features/course/services/course-options-delegate';
|
||||||
|
import { CorePlatform } from '@services/platform';
|
||||||
|
|
||||||
export const GRADES_PAGE_NAME = 'grades';
|
export const GRADES_PAGE_NAME = 'grades';
|
||||||
export const GRADES_PARTICIPANTS_PAGE_NAME = 'participant-grades';
|
export const GRADES_PARTICIPANTS_PAGE_NAME = 'participant-grades';
|
||||||
|
@ -105,7 +105,7 @@ export class CoreGradesHelperProvider {
|
||||||
row.rowclass += itemNameColumn.class.indexOf('hidden') >= 0 ? ' hidden' : '';
|
row.rowclass += itemNameColumn.class.indexOf('hidden') >= 0 ? ' hidden' : '';
|
||||||
row.rowclass += itemNameColumn.class.indexOf('dimmed_text') >= 0 ? ' dimmed_text' : '';
|
row.rowclass += itemNameColumn.class.indexOf('dimmed_text') >= 0 ? ' dimmed_text' : '';
|
||||||
|
|
||||||
if (!useLegacyLayout && !CoreAppProvider.isAutomated()) {
|
if (!useLegacyLayout && !CorePlatform.isAutomated()) {
|
||||||
// Activity name is only included in the webservice response from the latest version when behat is not running.
|
// Activity name is only included in the webservice response from the latest version when behat is not running.
|
||||||
content = content.replace(/<span[^>]+>.+?<\/span>/i, '');
|
content = content.replace(/<span[^>]+>.+?<\/span>/i, '');
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,10 +70,11 @@ export class CoreAppProvider {
|
||||||
/**
|
/**
|
||||||
* Returns whether the user agent is controlled by automation. I.e. Behat testing.
|
* Returns whether the user agent is controlled by automation. I.e. Behat testing.
|
||||||
*
|
*
|
||||||
|
* @deprecated since 4.4. Use CorePlatform.isAutomated() instead.
|
||||||
* @returns True if the user agent is controlled by automation, false otherwise.
|
* @returns True if the user agent is controlled by automation, false otherwise.
|
||||||
*/
|
*/
|
||||||
static isAutomated(): boolean {
|
static isAutomated(): boolean {
|
||||||
return !!navigator.webdriver;
|
return CorePlatform.isAutomated();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -82,7 +83,7 @@ export class CoreAppProvider {
|
||||||
* @returns Timezone. Undefined to use the user's timezone.
|
* @returns Timezone. Undefined to use the user's timezone.
|
||||||
*/
|
*/
|
||||||
static getForcedTimezone(): string | undefined {
|
static getForcedTimezone(): string | undefined {
|
||||||
if (CoreAppProvider.isAutomated()) {
|
if (CorePlatform.isAutomated()) {
|
||||||
// Use the same timezone forced for LMS in tests.
|
// Use the same timezone forced for LMS in tests.
|
||||||
return 'Australia/Perth';
|
return 'Australia/Perth';
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,6 @@ import { Injectable } from '@angular/core';
|
||||||
|
|
||||||
import { CoreConstants } from '@/core/constants';
|
import { CoreConstants } from '@/core/constants';
|
||||||
import { LangChangeEvent } from '@ngx-translate/core';
|
import { LangChangeEvent } from '@ngx-translate/core';
|
||||||
import { CoreAppProvider } from '@services/app';
|
|
||||||
import { CoreConfig } from '@services/config';
|
import { CoreConfig } from '@services/config';
|
||||||
import { CoreSubscriptions } from '@singletons/subscriptions';
|
import { CoreSubscriptions } from '@singletons/subscriptions';
|
||||||
import { makeSingleton, Translate, Http } from '@singletons';
|
import { makeSingleton, Translate, Http } from '@singletons';
|
||||||
|
@ -71,7 +70,7 @@ export class CoreLangProvider {
|
||||||
|
|
||||||
let language: string;
|
let language: string;
|
||||||
|
|
||||||
if (CoreAppProvider.isAutomated()) {
|
if (CorePlatform.isAutomated()) {
|
||||||
// Force current language to English when Behat is running.
|
// Force current language to English when Behat is running.
|
||||||
language = 'en';
|
language = 'en';
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -44,6 +44,15 @@ export class CorePlatformService extends Platform {
|
||||||
return this.isMobile() && this.is('android');
|
return this.isMobile() && this.is('android');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns whether the user agent is controlled by automation. I.e. Behat testing.
|
||||||
|
*
|
||||||
|
* @returns True if the user agent is controlled by automation, false otherwise.
|
||||||
|
*/
|
||||||
|
isAutomated(): boolean {
|
||||||
|
return !!navigator.webdriver;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if the app is running in an iOS mobile or tablet device.
|
* Checks if the app is running in an iOS mobile or tablet device.
|
||||||
*
|
*
|
||||||
|
|
|
@ -16,6 +16,7 @@ import { APP_INITIALIZER, NgModule } from '@angular/core';
|
||||||
import { CoreAppProvider } from '@services/app';
|
import { CoreAppProvider } from '@services/app';
|
||||||
import moment from 'moment-timezone';
|
import moment from 'moment-timezone';
|
||||||
import { TestingBehatRuntime, TestingBehatRuntimeService } from './services/behat-runtime';
|
import { TestingBehatRuntime, TestingBehatRuntimeService } from './services/behat-runtime';
|
||||||
|
import { CorePlatform } from '@services/platform';
|
||||||
|
|
||||||
type AutomatedTestsWindow = Window & {
|
type AutomatedTestsWindow = Window & {
|
||||||
behat?: TestingBehatRuntimeService;
|
behat?: TestingBehatRuntimeService;
|
||||||
|
@ -27,7 +28,7 @@ type AutomatedTestsWindow = Window & {
|
||||||
* @param window Window.
|
* @param window Window.
|
||||||
*/
|
*/
|
||||||
function initializeAutomatedTests(window: AutomatedTestsWindow) {
|
function initializeAutomatedTests(window: AutomatedTestsWindow) {
|
||||||
if (!CoreAppProvider.isAutomated()) {
|
if (!CorePlatform.isAutomated()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,7 @@ For more information about upgrading, read the official documentation: https://m
|
||||||
- With the upgrade to Ionic 7 ion-slides is no longer supported and now you need to use swiper-container and swiper-slide. More info here: https://ionicframework.com/docs/angular/slides
|
- With the upgrade to Ionic 7 ion-slides is no longer supported and now you need to use swiper-container and swiper-slide. More info here: https://ionicframework.com/docs/angular/slides
|
||||||
- With the upgrade to Ionic7 ion-datetime has changed its usage. We recommend using ion-datetime-button. More info here: https://ionicframework.com/docs/updating/6-0#datetime
|
- With the upgrade to Ionic7 ion-datetime has changed its usage. We recommend using ion-datetime-button. More info here: https://ionicframework.com/docs/updating/6-0#datetime
|
||||||
- CoreLoginHelper.getErrorMessages has been removed. Please create the messages object yourself.
|
- CoreLoginHelper.getErrorMessages has been removed. Please create the messages object yourself.
|
||||||
|
- CoreAppProvider.isAutomated() has been deprecated, use CorePlatformService.isAutomated() instead.
|
||||||
|
|
||||||
=== 4.3.0 ===
|
=== 4.3.0 ===
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue