Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions local_moodleappbehat/tests/behat/behat_app.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
require_once(__DIR__ . '/../../../../lib/behat/behat_base.php');
require_once(__DIR__ . '/behat_app_helper.php');

use Behat\Behat\Hook\Scope\ScenarioScope;
use Behat\Gherkin\Node\TableNode;
use Behat\Mink\Exception\DriverException;
use Behat\Mink\Exception\ExpectationException;
Expand All @@ -45,6 +46,27 @@ class behat_app extends behat_app_helper {

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.
*
Expand Down
3 changes: 1 addition & 2 deletions src/addons/mod/quiz/services/quiz-sync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import { Injectable } from '@angular/core';

import { CoreError } from '@classes/errors/error';
import { CoreSite } from '@classes/site';
import { CoreCourseActivitySyncBaseProvider } from '@features/course/classes/activity-sync';
import { CoreCourse, CoreCourseModuleBasicInfo } from '@features/course/services/course';
import { CoreCourseLogHelper } from '@features/course/services/log-helper';
Expand Down Expand Up @@ -314,7 +313,7 @@ export class AddonModQuizSyncProvider extends CoreCourseActivitySyncBaseProvider

if (!CoreNetwork.isOnline()) {
// 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()!;
Expand Down
7 changes: 4 additions & 3 deletions src/core/classes/site.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,8 @@ export class CoreSite {
'3.10': 2020110900,
'3.11': 2021051700,
'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.
Expand Down Expand Up @@ -806,7 +807,7 @@ export class CoreSite {
): Promise<T> {
if (preSets.forceOffline) {
// 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 {
Expand Down Expand Up @@ -1694,7 +1695,7 @@ export class CoreSite {
.catch(async () => {
if (cachePreSets.forceOffline) {
// 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.
Expand Down
6 changes: 2 additions & 4 deletions src/core/features/login/pages/site/site.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ import { CoreErrorInfoComponent } from '@components/error-info/error-info';
import { CoreUserSupportConfig } from '@features/user/classes/support/support-config';
import { CoreUserGuestSupportConfig } from '@features/user/classes/support/guest-support-config';
import { CoreLoginError } from '@classes/errors/loginerror';
import { CoreSite } from '@classes/site';

/**
* Site (url) chooser when adding a new site.
Expand Down Expand Up @@ -420,7 +419,7 @@ export class CoreLoginSitePage implements OnInit {
text: Translate.instant('core.contactsupport'),
handler: () => CoreUserSupport.contact({
supportConfig: alertSupportConfig,
subject: Translate.instant('core.cannotconnect', { $a: CoreSite.MINIMUM_MOODLE_VERSION }),
subject: Translate.instant('core.cannotconnect'),
message: `Error: ${errorCode}\n\n${errorDetails}`,
}),
}
Expand All @@ -435,11 +434,10 @@ export class CoreLoginSitePage implements OnInit {
),
].filter(button => !!button);

// @todo Remove CoreSite.MINIMUM_MOODLE_VERSION, not used on translations since 3.9.0.
const alertElement = await CoreDomUtils.showAlertWithOptions({
header: errorTitle ?? (
siteExists
? Translate.instant('core.cannotconnect', { $a: CoreSite.MINIMUM_MOODLE_VERSION })
? Translate.instant('core.cannotconnect')
: Translate.instant('core.sitenotfound')
),
message: errorMessage ?? Translate.instant('core.sitenotfoundhelp'),
Expand Down
3 changes: 1 addition & 2 deletions src/core/services/db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import { SQLiteDB } from '@classes/sqlitedb';
import { SQLiteDBMock } from '@features/emulator/classes/sqlitedb';
import { CoreBrowser } from '@singletons/browser';
import { makeSingleton, SQLite } from '@singletons';
import { CoreAppProvider } from './app';
import { CorePlatform } from '@services/platform';

const tableNameRegex = new RegExp([
Expand Down Expand Up @@ -47,7 +46,7 @@ export class CoreDbProvider {
* @returns Whether queries should be logged.
*/
loggingEnabled(): boolean {
return CoreBrowser.hasDevelopmentSetting('DBLoggingEnabled') || CoreAppProvider.isAutomated();
return CoreBrowser.hasDevelopmentSetting('DBLoggingEnabled');
}

/**
Expand Down
3 changes: 1 addition & 2 deletions src/core/services/filepool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ import { lazyMap, LazyMap } from '../utils/lazy-map';
import { asyncInstance, AsyncInstance } from '../utils/async-instance';
import { CorePath } from '@singletons/path';
import { CorePromisedValue } from '@classes/promised-value';
import { CoreSite } from '@classes/site';

/*
* Factory for handling downloading files and retrieve downloaded files.
Expand Down Expand Up @@ -510,7 +509,7 @@ export class CoreFilepoolProvider {
} else {
if (!CoreNetwork.isOnline()) {
// 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);
Expand Down
4 changes: 2 additions & 2 deletions src/core/services/sites.ts
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ export class CoreSitesProvider {
if (error instanceof CoreAjaxError || !('errorcode' in error)) {
// The WS didn't return data, probably cannot connect.
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 }),
errorcode: 'publicconfigfailed',
errorDetails: error.message || '',
Expand All @@ -374,7 +374,7 @@ export class CoreSitesProvider {
// Service supported but an error happened. Return error.
const options: CoreLoginErrorOptions = {
critical: true,
title: Translate.instant('core.cannotconnect', { $a: CoreSite.MINIMUM_MOODLE_VERSION }),
title: Translate.instant('core.cannotconnect'),
message: Translate.instant('core.siteunavailablehelp', { site: siteUrl }),
errorcode: error.errorcode,
supportConfig: error.supportConfig,
Expand Down
3 changes: 1 addition & 2 deletions src/core/services/utils/dom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ import { CoreNetwork } from '@services/network';
import { CoreSiteError } from '@classes/errors/siteerror';
import { CoreUserSupport } from '@features/user/services/support';
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.
Expand Down Expand Up @@ -1373,7 +1372,7 @@ export class CoreDomUtilsProvider {
} else if (this.isSiteUnavailableError(message)) {
alertOptions.header = CoreSites.isLoggedIn()
? Translate.instant('core.connectionlost')
: Translate.instant('core.cannotconnect', { $a: CoreSite.MINIMUM_MOODLE_VERSION });
: Translate.instant('core.cannotconnect');
} else {
alertOptions.header = Translate.instant('core.error');
}
Expand Down