Merge pull request #3531 from NoelDeMartin/MOBILE-4239

MOBILE-4239 Tweaks
main
Dani Palou 2023-01-24 08:18:04 +01:00 committed by GitHub
commit 6cc23c0c1f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 34 additions and 17 deletions

View File

@ -19,6 +19,7 @@
require_once(__DIR__ . '/../../../../lib/behat/behat_base.php'); require_once(__DIR__ . '/../../../../lib/behat/behat_base.php');
require_once(__DIR__ . '/behat_app_helper.php'); require_once(__DIR__ . '/behat_app_helper.php');
use Behat\Behat\Hook\Scope\ScenarioScope;
use Behat\Gherkin\Node\TableNode; use Behat\Gherkin\Node\TableNode;
use Behat\Mink\Exception\DriverException; use Behat\Mink\Exception\DriverException;
use Behat\Mink\Exception\ExpectationException; use Behat\Mink\Exception\ExpectationException;
@ -45,6 +46,27 @@ class behat_app extends behat_app_helper {
protected $windowsize = '360x720'; protected $windowsize = '360x720';
/**
* @BeforeScenario
*/
public function before_scenario(ScenarioScope $scope) {
if (!$scope->getFeature()->hasTag('app')) {
return;
}
global $CFG;
$performanceLogs = $CFG->behat_profiles['default']['capabilities']['extra_capabilities']['goog:loggingPrefs']['performance'] ?? null;
if ($performanceLogs !== 'ALL') {
return;
}
// Enable DB Logging only for app tests with performance logs activated.
$this->getSession()->visit($this->get_app_url() . '/assets/env.json');
$this->execute_script("document.cookie = 'MoodleAppDBLoggingEnabled=true;path=/';");
}
/** /**
* Opens the Moodle App in the browser and optionally logs in. * Opens the Moodle App in the browser and optionally logs in.
* *

View File

@ -15,7 +15,6 @@
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { CoreError } from '@classes/errors/error'; import { CoreError } from '@classes/errors/error';
import { CoreSite } from '@classes/site';
import { CoreCourseActivitySyncBaseProvider } from '@features/course/classes/activity-sync'; import { CoreCourseActivitySyncBaseProvider } from '@features/course/classes/activity-sync';
import { CoreCourse, CoreCourseModuleBasicInfo } from '@features/course/services/course'; import { CoreCourse, CoreCourseModuleBasicInfo } from '@features/course/services/course';
import { CoreCourseLogHelper } from '@features/course/services/log-helper'; import { CoreCourseLogHelper } from '@features/course/services/log-helper';
@ -314,7 +313,7 @@ export class AddonModQuizSyncProvider extends CoreCourseActivitySyncBaseProvider
if (!CoreNetwork.isOnline()) { if (!CoreNetwork.isOnline()) {
// Cannot sync in offline. // Cannot sync in offline.
throw new CoreError(Translate.instant('core.cannotconnect', { $a: CoreSite.MINIMUM_MOODLE_VERSION })); throw new CoreError(Translate.instant('core.cannotconnect'));
} }
const offlineAttempt = offlineAttempts.pop()!; const offlineAttempt = offlineAttempts.pop()!;

View File

@ -106,7 +106,8 @@ export class CoreSite {
'3.10': 2020110900, '3.10': 2020110900,
'3.11': 2021051700, '3.11': 2021051700,
'4.0': 2022041900, '4.0': 2022041900,
'4.1': 2022111100, // @todo [4.1] replace with right value when released. Using a tmp value to be able to test new things. '4.1': 2022112800,
'4.2': 2023011300, // @todo [4.2] replace with right value when released. Using a tmp value to be able to test new things.
}; };
// Possible cache update frequencies. // Possible cache update frequencies.
@ -806,7 +807,7 @@ export class CoreSite {
): Promise<T> { ): Promise<T> {
if (preSets.forceOffline) { if (preSets.forceOffline) {
// Don't call the WS, just fail. // Don't call the WS, just fail.
throw new CoreError(Translate.instant('core.cannotconnect', { $a: CoreSite.MINIMUM_MOODLE_VERSION })); throw new CoreError(Translate.instant('core.cannotconnect'));
} }
try { try {
@ -1694,7 +1695,7 @@ export class CoreSite {
.catch(async () => { .catch(async () => {
if (cachePreSets.forceOffline) { if (cachePreSets.forceOffline) {
// Don't call the WS, just fail. // Don't call the WS, just fail.
throw new CoreError(Translate.instant('core.cannotconnect', { $a: CoreSite.MINIMUM_MOODLE_VERSION })); throw new CoreError(Translate.instant('core.cannotconnect'));
} }
// Call the WS. // Call the WS.

View File

@ -45,7 +45,6 @@ import { CoreErrorInfoComponent } from '@components/error-info/error-info';
import { CoreUserSupportConfig } from '@features/user/classes/support/support-config'; import { CoreUserSupportConfig } from '@features/user/classes/support/support-config';
import { CoreUserGuestSupportConfig } from '@features/user/classes/support/guest-support-config'; import { CoreUserGuestSupportConfig } from '@features/user/classes/support/guest-support-config';
import { CoreLoginError } from '@classes/errors/loginerror'; import { CoreLoginError } from '@classes/errors/loginerror';
import { CoreSite } from '@classes/site';
/** /**
* Site (url) chooser when adding a new site. * Site (url) chooser when adding a new site.
@ -420,7 +419,7 @@ export class CoreLoginSitePage implements OnInit {
text: Translate.instant('core.contactsupport'), text: Translate.instant('core.contactsupport'),
handler: () => CoreUserSupport.contact({ handler: () => CoreUserSupport.contact({
supportConfig: alertSupportConfig, supportConfig: alertSupportConfig,
subject: Translate.instant('core.cannotconnect', { $a: CoreSite.MINIMUM_MOODLE_VERSION }), subject: Translate.instant('core.cannotconnect'),
message: `Error: ${errorCode}\n\n${errorDetails}`, message: `Error: ${errorCode}\n\n${errorDetails}`,
}), }),
} }
@ -435,11 +434,10 @@ export class CoreLoginSitePage implements OnInit {
), ),
].filter(button => !!button); ].filter(button => !!button);
// @todo Remove CoreSite.MINIMUM_MOODLE_VERSION, not used on translations since 3.9.0.
const alertElement = await CoreDomUtils.showAlertWithOptions({ const alertElement = await CoreDomUtils.showAlertWithOptions({
header: errorTitle ?? ( header: errorTitle ?? (
siteExists siteExists
? Translate.instant('core.cannotconnect', { $a: CoreSite.MINIMUM_MOODLE_VERSION }) ? Translate.instant('core.cannotconnect')
: Translate.instant('core.sitenotfound') : Translate.instant('core.sitenotfound')
), ),
message: errorMessage ?? Translate.instant('core.sitenotfoundhelp'), message: errorMessage ?? Translate.instant('core.sitenotfoundhelp'),

View File

@ -18,7 +18,6 @@ import { SQLiteDB } from '@classes/sqlitedb';
import { SQLiteDBMock } from '@features/emulator/classes/sqlitedb'; import { SQLiteDBMock } from '@features/emulator/classes/sqlitedb';
import { CoreBrowser } from '@singletons/browser'; import { CoreBrowser } from '@singletons/browser';
import { makeSingleton, SQLite } from '@singletons'; import { makeSingleton, SQLite } from '@singletons';
import { CoreAppProvider } from './app';
import { CorePlatform } from '@services/platform'; import { CorePlatform } from '@services/platform';
const tableNameRegex = new RegExp([ const tableNameRegex = new RegExp([
@ -47,7 +46,7 @@ export class CoreDbProvider {
* @returns Whether queries should be logged. * @returns Whether queries should be logged.
*/ */
loggingEnabled(): boolean { loggingEnabled(): boolean {
return CoreBrowser.hasDevelopmentSetting('DBLoggingEnabled') || CoreAppProvider.isAutomated(); return CoreBrowser.hasDevelopmentSetting('DBLoggingEnabled');
} }
/** /**

View File

@ -55,7 +55,6 @@ import { lazyMap, LazyMap } from '../utils/lazy-map';
import { asyncInstance, AsyncInstance } from '../utils/async-instance'; import { asyncInstance, AsyncInstance } from '../utils/async-instance';
import { CorePath } from '@singletons/path'; import { CorePath } from '@singletons/path';
import { CorePromisedValue } from '@classes/promised-value'; import { CorePromisedValue } from '@classes/promised-value';
import { CoreSite } from '@classes/site';
/* /*
* Factory for handling downloading files and retrieve downloaded files. * Factory for handling downloading files and retrieve downloaded files.
@ -510,7 +509,7 @@ export class CoreFilepoolProvider {
} else { } else {
if (!CoreNetwork.isOnline()) { if (!CoreNetwork.isOnline()) {
// Cannot check size in offline, stop. // Cannot check size in offline, stop.
throw new CoreError(Translate.instant('core.cannotconnect', { $a: CoreSite.MINIMUM_MOODLE_VERSION })); throw new CoreError(Translate.instant('core.cannotconnect'));
} }
size = await CoreWS.getRemoteFileSize(fileUrl); size = await CoreWS.getRemoteFileSize(fileUrl);

View File

@ -363,7 +363,7 @@ export class CoreSitesProvider {
if (error instanceof CoreAjaxError || !('errorcode' in error)) { if (error instanceof CoreAjaxError || !('errorcode' in error)) {
// The WS didn't return data, probably cannot connect. // The WS didn't return data, probably cannot connect.
return new CoreLoginError({ return new CoreLoginError({
title: Translate.instant('core.cannotconnect', { $a: CoreSite.MINIMUM_MOODLE_VERSION }), title: Translate.instant('core.cannotconnect'),
message: Translate.instant('core.siteunavailablehelp', { site: siteUrl }), message: Translate.instant('core.siteunavailablehelp', { site: siteUrl }),
errorcode: 'publicconfigfailed', errorcode: 'publicconfigfailed',
errorDetails: error.message || '', errorDetails: error.message || '',
@ -374,7 +374,7 @@ export class CoreSitesProvider {
// Service supported but an error happened. Return error. // Service supported but an error happened. Return error.
const options: CoreLoginErrorOptions = { const options: CoreLoginErrorOptions = {
critical: true, critical: true,
title: Translate.instant('core.cannotconnect', { $a: CoreSite.MINIMUM_MOODLE_VERSION }), title: Translate.instant('core.cannotconnect'),
message: Translate.instant('core.siteunavailablehelp', { site: siteUrl }), message: Translate.instant('core.siteunavailablehelp', { site: siteUrl }),
errorcode: error.errorcode, errorcode: error.errorcode,
supportConfig: error.supportConfig, supportConfig: error.supportConfig,

View File

@ -57,7 +57,6 @@ import { CoreNetwork } from '@services/network';
import { CoreSiteError } from '@classes/errors/siteerror'; import { CoreSiteError } from '@classes/errors/siteerror';
import { CoreUserSupport } from '@features/user/services/support'; import { CoreUserSupport } from '@features/user/services/support';
import { CoreErrorInfoComponent } from '@components/error-info/error-info'; import { CoreErrorInfoComponent } from '@components/error-info/error-info';
import { CoreSite } from '@classes/site';
/* /*
* "Utils" service with helper functions for UI, DOM elements and HTML code. * "Utils" service with helper functions for UI, DOM elements and HTML code.
@ -1373,7 +1372,7 @@ export class CoreDomUtilsProvider {
} else if (this.isSiteUnavailableError(message)) { } else if (this.isSiteUnavailableError(message)) {
alertOptions.header = CoreSites.isLoggedIn() alertOptions.header = CoreSites.isLoggedIn()
? Translate.instant('core.connectionlost') ? Translate.instant('core.connectionlost')
: Translate.instant('core.cannotconnect', { $a: CoreSite.MINIMUM_MOODLE_VERSION }); : Translate.instant('core.cannotconnect');
} else { } else {
alertOptions.header = Translate.instant('core.error'); alertOptions.header = Translate.instant('core.error');
} }