Skip to content

Commit 6cc23c0

Browse files
authored
Merge pull request #3531 from NoelDeMartin/MOBILE-4239
MOBILE-4239 Tweaks
2 parents 5ecea64 + 6515d03 commit 6cc23c0

File tree

8 files changed

+34
-17
lines changed

8 files changed

+34
-17
lines changed

local_moodleappbehat/tests/behat/behat_app.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
require_once(__DIR__ . '/../../../../lib/behat/behat_base.php');
2020
require_once(__DIR__ . '/behat_app_helper.php');
2121

22+
use Behat\Behat\Hook\Scope\ScenarioScope;
2223
use Behat\Gherkin\Node\TableNode;
2324
use Behat\Mink\Exception\DriverException;
2425
use Behat\Mink\Exception\ExpectationException;
@@ -45,6 +46,27 @@ class behat_app extends behat_app_helper {
4546

4647
protected $windowsize = '360x720';
4748

49+
/**
50+
* @BeforeScenario
51+
*/
52+
public function before_scenario(ScenarioScope $scope) {
53+
if (!$scope->getFeature()->hasTag('app')) {
54+
return;
55+
}
56+
57+
global $CFG;
58+
59+
$performanceLogs = $CFG->behat_profiles['default']['capabilities']['extra_capabilities']['goog:loggingPrefs']['performance'] ?? null;
60+
61+
if ($performanceLogs !== 'ALL') {
62+
return;
63+
}
64+
65+
// Enable DB Logging only for app tests with performance logs activated.
66+
$this->getSession()->visit($this->get_app_url() . '/assets/env.json');
67+
$this->execute_script("document.cookie = 'MoodleAppDBLoggingEnabled=true;path=/';");
68+
}
69+
4870
/**
4971
* Opens the Moodle App in the browser and optionally logs in.
5072
*

src/addons/mod/quiz/services/quiz-sync.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
import { Injectable } from '@angular/core';
1616

1717
import { CoreError } from '@classes/errors/error';
18-
import { CoreSite } from '@classes/site';
1918
import { CoreCourseActivitySyncBaseProvider } from '@features/course/classes/activity-sync';
2019
import { CoreCourse, CoreCourseModuleBasicInfo } from '@features/course/services/course';
2120
import { CoreCourseLogHelper } from '@features/course/services/log-helper';
@@ -314,7 +313,7 @@ export class AddonModQuizSyncProvider extends CoreCourseActivitySyncBaseProvider
314313

315314
if (!CoreNetwork.isOnline()) {
316315
// Cannot sync in offline.
317-
throw new CoreError(Translate.instant('core.cannotconnect', { $a: CoreSite.MINIMUM_MOODLE_VERSION }));
316+
throw new CoreError(Translate.instant('core.cannotconnect'));
318317
}
319318

320319
const offlineAttempt = offlineAttempts.pop()!;

src/core/classes/site.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,8 @@ export class CoreSite {
106106
'3.10': 2020110900,
107107
'3.11': 2021051700,
108108
'4.0': 2022041900,
109-
'4.1': 2022111100, // @todo [4.1] replace with right value when released. Using a tmp value to be able to test new things.
109+
'4.1': 2022112800,
110+
'4.2': 2023011300, // @todo [4.2] replace with right value when released. Using a tmp value to be able to test new things.
110111
};
111112

112113
// Possible cache update frequencies.
@@ -806,7 +807,7 @@ export class CoreSite {
806807
): Promise<T> {
807808
if (preSets.forceOffline) {
808809
// Don't call the WS, just fail.
809-
throw new CoreError(Translate.instant('core.cannotconnect', { $a: CoreSite.MINIMUM_MOODLE_VERSION }));
810+
throw new CoreError(Translate.instant('core.cannotconnect'));
810811
}
811812

812813
try {
@@ -1694,7 +1695,7 @@ export class CoreSite {
16941695
.catch(async () => {
16951696
if (cachePreSets.forceOffline) {
16961697
// Don't call the WS, just fail.
1697-
throw new CoreError(Translate.instant('core.cannotconnect', { $a: CoreSite.MINIMUM_MOODLE_VERSION }));
1698+
throw new CoreError(Translate.instant('core.cannotconnect'));
16981699
}
16991700

17001701
// Call the WS.

src/core/features/login/pages/site/site.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ import { CoreErrorInfoComponent } from '@components/error-info/error-info';
4545
import { CoreUserSupportConfig } from '@features/user/classes/support/support-config';
4646
import { CoreUserGuestSupportConfig } from '@features/user/classes/support/guest-support-config';
4747
import { CoreLoginError } from '@classes/errors/loginerror';
48-
import { CoreSite } from '@classes/site';
4948

5049
/**
5150
* Site (url) chooser when adding a new site.
@@ -420,7 +419,7 @@ export class CoreLoginSitePage implements OnInit {
420419
text: Translate.instant('core.contactsupport'),
421420
handler: () => CoreUserSupport.contact({
422421
supportConfig: alertSupportConfig,
423-
subject: Translate.instant('core.cannotconnect', { $a: CoreSite.MINIMUM_MOODLE_VERSION }),
422+
subject: Translate.instant('core.cannotconnect'),
424423
message: `Error: ${errorCode}\n\n${errorDetails}`,
425424
}),
426425
}
@@ -435,11 +434,10 @@ export class CoreLoginSitePage implements OnInit {
435434
),
436435
].filter(button => !!button);
437436

438-
// @todo Remove CoreSite.MINIMUM_MOODLE_VERSION, not used on translations since 3.9.0.
439437
const alertElement = await CoreDomUtils.showAlertWithOptions({
440438
header: errorTitle ?? (
441439
siteExists
442-
? Translate.instant('core.cannotconnect', { $a: CoreSite.MINIMUM_MOODLE_VERSION })
440+
? Translate.instant('core.cannotconnect')
443441
: Translate.instant('core.sitenotfound')
444442
),
445443
message: errorMessage ?? Translate.instant('core.sitenotfoundhelp'),

src/core/services/db.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import { SQLiteDB } from '@classes/sqlitedb';
1818
import { SQLiteDBMock } from '@features/emulator/classes/sqlitedb';
1919
import { CoreBrowser } from '@singletons/browser';
2020
import { makeSingleton, SQLite } from '@singletons';
21-
import { CoreAppProvider } from './app';
2221
import { CorePlatform } from '@services/platform';
2322

2423
const tableNameRegex = new RegExp([
@@ -47,7 +46,7 @@ export class CoreDbProvider {
4746
* @returns Whether queries should be logged.
4847
*/
4948
loggingEnabled(): boolean {
50-
return CoreBrowser.hasDevelopmentSetting('DBLoggingEnabled') || CoreAppProvider.isAutomated();
49+
return CoreBrowser.hasDevelopmentSetting('DBLoggingEnabled');
5150
}
5251

5352
/**

src/core/services/filepool.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ import { lazyMap, LazyMap } from '../utils/lazy-map';
5555
import { asyncInstance, AsyncInstance } from '../utils/async-instance';
5656
import { CorePath } from '@singletons/path';
5757
import { CorePromisedValue } from '@classes/promised-value';
58-
import { CoreSite } from '@classes/site';
5958

6059
/*
6160
* Factory for handling downloading files and retrieve downloaded files.
@@ -510,7 +509,7 @@ export class CoreFilepoolProvider {
510509
} else {
511510
if (!CoreNetwork.isOnline()) {
512511
// Cannot check size in offline, stop.
513-
throw new CoreError(Translate.instant('core.cannotconnect', { $a: CoreSite.MINIMUM_MOODLE_VERSION }));
512+
throw new CoreError(Translate.instant('core.cannotconnect'));
514513
}
515514

516515
size = await CoreWS.getRemoteFileSize(fileUrl);

src/core/services/sites.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ export class CoreSitesProvider {
363363
if (error instanceof CoreAjaxError || !('errorcode' in error)) {
364364
// The WS didn't return data, probably cannot connect.
365365
return new CoreLoginError({
366-
title: Translate.instant('core.cannotconnect', { $a: CoreSite.MINIMUM_MOODLE_VERSION }),
366+
title: Translate.instant('core.cannotconnect'),
367367
message: Translate.instant('core.siteunavailablehelp', { site: siteUrl }),
368368
errorcode: 'publicconfigfailed',
369369
errorDetails: error.message || '',
@@ -374,7 +374,7 @@ export class CoreSitesProvider {
374374
// Service supported but an error happened. Return error.
375375
const options: CoreLoginErrorOptions = {
376376
critical: true,
377-
title: Translate.instant('core.cannotconnect', { $a: CoreSite.MINIMUM_MOODLE_VERSION }),
377+
title: Translate.instant('core.cannotconnect'),
378378
message: Translate.instant('core.siteunavailablehelp', { site: siteUrl }),
379379
errorcode: error.errorcode,
380380
supportConfig: error.supportConfig,

src/core/services/utils/dom.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ import { CoreNetwork } from '@services/network';
5757
import { CoreSiteError } from '@classes/errors/siteerror';
5858
import { CoreUserSupport } from '@features/user/services/support';
5959
import { CoreErrorInfoComponent } from '@components/error-info/error-info';
60-
import { CoreSite } from '@classes/site';
6160

6261
/*
6362
* "Utils" service with helper functions for UI, DOM elements and HTML code.
@@ -1373,7 +1372,7 @@ export class CoreDomUtilsProvider {
13731372
} else if (this.isSiteUnavailableError(message)) {
13741373
alertOptions.header = CoreSites.isLoggedIn()
13751374
? Translate.instant('core.connectionlost')
1376-
: Translate.instant('core.cannotconnect', { $a: CoreSite.MINIMUM_MOODLE_VERSION });
1375+
: Translate.instant('core.cannotconnect');
13771376
} else {
13781377
alertOptions.header = Translate.instant('core.error');
13791378
}

0 commit comments

Comments
 (0)