MOBILE-4116 moment: Force timezone for moment in behat tests

main
Dani Palou 2022-07-27 08:45:51 +02:00
parent 00170e090c
commit 88a19ea066
22 changed files with 42 additions and 23 deletions

8
package-lock.json generated
View File

@ -23663,6 +23663,14 @@
"resolved": "https://registry.npmjs.org/moment/-/moment-2.29.2.tgz", "resolved": "https://registry.npmjs.org/moment/-/moment-2.29.2.tgz",
"integrity": "sha512-UgzG4rvxYpN15jgCmVJwac49h9ly9NurikMWGPdVxm8GZD6XjkKPxDTjQQ43gtGgnV3X0cAyWDdP2Wexoquifg==" "integrity": "sha512-UgzG4rvxYpN15jgCmVJwac49h9ly9NurikMWGPdVxm8GZD6XjkKPxDTjQQ43gtGgnV3X0cAyWDdP2Wexoquifg=="
}, },
"moment-timezone": {
"version": "0.5.34",
"resolved": "https://registry.npmjs.org/moment-timezone/-/moment-timezone-0.5.34.tgz",
"integrity": "sha512-3zAEHh2hKUs3EXLESx/wsgw6IQdusOT8Bxm3D9UrHPQR7zlMmzwybC8zHEM1tQ4LJwP7fcxrWr8tuBg05fFCbg==",
"requires": {
"moment": ">= 2.9.0"
}
},
"move-concurrently": { "move-concurrently": {
"version": "1.0.1", "version": "1.0.1",
"resolved": "https://registry.npmjs.org/move-concurrently/-/move-concurrently-1.0.1.tgz", "resolved": "https://registry.npmjs.org/move-concurrently/-/move-concurrently-1.0.1.tgz",

View File

@ -119,6 +119,7 @@
"jszip": "^3.7.1", "jszip": "^3.7.1",
"mathjax": "2.7.7", "mathjax": "2.7.7",
"moment": "^2.29.2", "moment": "^2.29.2",
"moment-timezone": "^0.5.34",
"nl.kingsquare.cordova.background-audio": "^1.0.1", "nl.kingsquare.cordova.background-audio": "^1.0.1",
"rxjs": "~6.5.5", "rxjs": "~6.5.5",
"ts-md5": "^1.2.7", "ts-md5": "^1.2.7",

View File

@ -22,7 +22,7 @@ import {
AddonCalendarGetActionEventsByTimesortWSParams, AddonCalendarGetActionEventsByTimesortWSParams,
AddonCalendarGetActionEventsByCoursesWSParams, AddonCalendarGetActionEventsByCoursesWSParams,
} from '@addons/calendar/services/calendar'; } from '@addons/calendar/services/calendar';
import moment from 'moment'; import moment from 'moment-timezone';
import { makeSingleton } from '@singletons'; import { makeSingleton } from '@singletons';
import { CoreSiteWSPreSets } from '@classes/site'; import { CoreSiteWSPreSets } from '@classes/site';

View File

@ -48,7 +48,7 @@ import {
CoreSwipeSlidesDynamicItemsManagerSource, CoreSwipeSlidesDynamicItemsManagerSource,
} from '@classes/items-management/swipe-slides-dynamic-items-manager-source'; } from '@classes/items-management/swipe-slides-dynamic-items-manager-source';
import { CoreSwipeSlidesDynamicItemsManager } from '@classes/items-management/swipe-slides-dynamic-items-manager'; import { CoreSwipeSlidesDynamicItemsManager } from '@classes/items-management/swipe-slides-dynamic-items-manager';
import moment from 'moment'; import moment from 'moment-timezone';
/** /**
* Component that displays a calendar. * Component that displays a calendar.

View File

@ -32,7 +32,7 @@ import { AddonCalendarSync, AddonCalendarSyncProvider } from '../../services/cal
import { CoreCategoryData, CoreCourses, CoreEnrolledCourseData } from '@features/courses/services/courses'; import { CoreCategoryData, CoreCourses, CoreEnrolledCourseData } from '@features/courses/services/courses';
import { CoreCoursesHelper } from '@features/courses/services/courses-helper'; import { CoreCoursesHelper } from '@features/courses/services/courses-helper';
import { AddonCalendarFilterComponent } from '../../components/filter/filter'; import { AddonCalendarFilterComponent } from '../../components/filter/filter';
import moment from 'moment'; import moment from 'moment-timezone';
import { NgZone } from '@singletons'; import { NgZone } from '@singletons';
import { CoreNavigator } from '@services/navigator'; import { CoreNavigator } from '@services/navigator';
import { Params } from '@angular/router'; import { Params } from '@angular/router';

View File

@ -31,7 +31,7 @@ import { CoreConfig } from '@services/config';
import { CoreUtils } from '@services/utils/utils'; import { CoreUtils } from '@services/utils/utils';
import { CoreCourse } from '@features/course/services/course'; import { CoreCourse } from '@features/course/services/course';
import { ContextLevel, CoreConstants } from '@/core/constants'; import { ContextLevel, CoreConstants } from '@/core/constants';
import moment from 'moment'; import moment from 'moment-timezone';
import { makeSingleton } from '@singletons'; import { makeSingleton } from '@singletons';
import { AddonCalendarSyncInvalidateEvent } from './calendar-sync'; import { AddonCalendarSyncInvalidateEvent } from './calendar-sync';
import { AddonCalendarOfflineEventDBRecord } from './database/calendar-offline'; import { AddonCalendarOfflineEventDBRecord } from './database/calendar-offline';

View File

@ -29,7 +29,7 @@ import { AddonCalendarHelper } from './calendar-helper';
import { makeSingleton, Translate } from '@singletons'; import { makeSingleton, Translate } from '@singletons';
import { CoreSync } from '@services/sync'; import { CoreSync } from '@services/sync';
import { CoreNetworkError } from '@classes/errors/network-error'; import { CoreNetworkError } from '@classes/errors/network-error';
import moment from 'moment'; import moment from 'moment-timezone';
/** /**
* Service to sync calendar. * Service to sync calendar.

View File

@ -27,7 +27,7 @@ import { ILocalNotification } from '@ionic-native/local-notifications';
import { AddonCalendarOffline } from './calendar-offline'; import { AddonCalendarOffline } from './calendar-offline';
import { CoreUser } from '@features/user/services/user'; import { CoreUser } from '@features/user/services/user';
import { CoreWSExternalWarning, CoreWSDate } from '@services/ws'; import { CoreWSExternalWarning, CoreWSDate } from '@services/ws';
import moment from 'moment'; import moment from 'moment-timezone';
import { AddonCalendarEventDBRecord, AddonCalendarReminderDBRecord, EVENTS_TABLE, REMINDERS_TABLE } from './database/calendar'; import { AddonCalendarEventDBRecord, AddonCalendarReminderDBRecord, EVENTS_TABLE, REMINDERS_TABLE } from './database/calendar';
import { CoreCourses } from '@features/courses/services/courses'; import { CoreCourses } from '@features/courses/services/courses';
import { ContextLevel, CoreConstants } from '@/core/constants'; import { ContextLevel, CoreConstants } from '@/core/constants';

View File

@ -36,7 +36,7 @@ import { CoreLogger } from '@singletons/logger';
import { CoreApp } from '@services/app'; import { CoreApp } from '@services/app';
import { CoreInfiniteLoadingComponent } from '@components/infinite-loading/infinite-loading'; import { CoreInfiniteLoadingComponent } from '@components/infinite-loading/infinite-loading';
import { Md5 } from 'ts-md5/dist/md5'; import { Md5 } from 'ts-md5/dist/md5';
import moment from 'moment'; import moment from 'moment-timezone';
import { CoreError } from '@classes/errors/error'; import { CoreError } from '@classes/errors/error';
import { Translate } from '@singletons'; import { Translate } from '@singletons';
import { CoreNavigator } from '@services/navigator'; import { CoreNavigator } from '@services/navigator';

View File

@ -17,7 +17,7 @@ Feature: Test basic usage of assignment activity in app
| student1 | C1 | student | | student1 | C1 | student |
And the following "activities" exist: And the following "activities" exist:
| activity | course | idnumber | name | intro | assignsubmission_onlinetext_enabled | duedate | attemptreopenmethod | | activity | course | idnumber | name | intro | assignsubmission_onlinetext_enabled | duedate | attemptreopenmethod |
| assign | C1 | assign1 | assignment1 | Test assignment description1 | 1 | 1029844800 | manual | | assign | C1 | assign1 | assignment1 | Test assignment description1 | 1 | ## 20 August 2002 12:00 PM ## | manual |
Scenario: View assign description, due date & View list of student submissions (as teacher) & View own submission or student submission Scenario: View assign description, due date & View list of student submissions (as teacher) & View own submission or student submission
# Create, edit and submit as a student # Create, edit and submit as a student

View File

@ -17,7 +17,7 @@ Feature: Test basic usage of assignment activity in app
| student1 | C1 | student | | student1 | C1 | student |
And the following "activities" exist: And the following "activities" exist:
| activity | course | idnumber | name | intro | assignsubmission_onlinetext_enabled | duedate | attemptreopenmethod | | activity | course | idnumber | name | intro | assignsubmission_onlinetext_enabled | duedate | attemptreopenmethod |
| assign | C1 | assign1 | assignment1 | Test assignment description1 | 1 | 1029844800 | manual | | assign | C1 | assign1 | assignment1 | Test assignment description1 | 1 | ## 20 August 2002 12:00 PM ## | manual |
@lms_from3.11 @lms_from3.11
Scenario: View assign description, due date & View list of student submissions (as teacher) & View own submission or student submission Scenario: View assign description, due date & View list of student submissions (as teacher) & View own submission or student submission

View File

@ -14,7 +14,7 @@
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { makeSingleton, Translate } from '@singletons'; import { makeSingleton, Translate } from '@singletons';
import * as moment from 'moment'; import moment from 'moment-timezone';
import { AddonModChatMessage, AddonModChatSessionMessage } from './chat'; import { AddonModChatMessage, AddonModChatSessionMessage } from './chat';
const patternTo = new RegExp(/^To\s([^:]+):(.*)/); const patternTo = new RegExp(/^To\s([^:]+):(.*)/);

View File

@ -40,7 +40,7 @@ import { CoreCommentsDBRecord } from '@features/comments/services/database/comme
import { CoreTimeUtils } from '@services/utils/time'; import { CoreTimeUtils } from '@services/utils/time';
import { CoreApp } from '@services/app'; import { CoreApp } from '@services/app';
import { CoreNetwork } from '@services/network'; import { CoreNetwork } from '@services/network';
import moment from 'moment'; import moment from 'moment-timezone';
import { Subscription } from 'rxjs'; import { Subscription } from 'rxjs';
import { CoreAnimations } from '@components/animations'; import { CoreAnimations } from '@components/animations';

View File

@ -72,7 +72,7 @@ import { DomSanitizer } from '@angular/platform-browser';
import { FormBuilder, Validators } from '@angular/forms'; import { FormBuilder, Validators } from '@angular/forms';
import { HttpClient } from '@angular/common/http'; import { HttpClient } from '@angular/common/http';
import { CoreConstants } from '@/core/constants'; import { CoreConstants } from '@/core/constants';
import moment from 'moment'; import moment from 'moment-timezone';
import { Md5 } from 'ts-md5/dist/md5'; import { Md5 } from 'ts-md5/dist/md5';
// Import core classes that can be useful for site plugins. // Import core classes that can be useful for site plugins.

View File

@ -14,7 +14,7 @@
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { Params } from '@angular/router'; import { Params } from '@angular/router';
import moment from 'moment'; import moment from 'moment-timezone';
import { CoreSites, CoreSitesReadingStrategy } from '@services/sites'; import { CoreSites, CoreSitesReadingStrategy } from '@services/sites';
import { import {

View File

@ -25,7 +25,7 @@ import {
import { makeSingleton, Translate } from '@singletons'; import { makeSingleton, Translate } from '@singletons';
import { CoreWSExternalFile } from '@services/ws'; import { CoreWSExternalFile } from '@services/ws';
import { AddonCourseCompletion } from '@addons/coursecompletion/services/coursecompletion'; import { AddonCourseCompletion } from '@addons/coursecompletion/services/coursecompletion';
import moment from 'moment'; import moment from 'moment-timezone';
/** /**
* Helper to gather some common courses functions. * Helper to gather some common courses functions.

View File

@ -13,7 +13,7 @@
// limitations under the License. // limitations under the License.
import { Pipe, PipeTransform } from '@angular/core'; import { Pipe, PipeTransform } from '@angular/core';
import moment from 'moment'; import moment from 'moment-timezone';
import { CoreTimeUtils } from '@services/utils/time'; import { CoreTimeUtils } from '@services/utils/time';
import { Translate } from '@singletons'; import { Translate } from '@singletons';

View File

@ -15,7 +15,7 @@
import { Pipe, PipeTransform } from '@angular/core'; import { Pipe, PipeTransform } from '@angular/core';
import { Translate } from '@singletons'; import { Translate } from '@singletons';
import { CoreLogger } from '@singletons/logger'; import { CoreLogger } from '@singletons/logger';
import moment from 'moment'; import moment from 'moment-timezone';
/** /**
* Pipe to turn a UNIX timestamp to "time ago". * Pipe to turn a UNIX timestamp to "time ago".

View File

@ -21,7 +21,7 @@ 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';
import * as moment from 'moment'; import moment from 'moment-timezone';
import { CoreSite } from '../classes/site'; import { CoreSite } from '../classes/site';
import { CorePlatform } from '@services/platform'; import { CorePlatform } from '@services/platform';

View File

@ -14,7 +14,7 @@
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import moment, { LongDateFormatKey } from 'moment'; import moment, { LongDateFormatKey } from 'moment-timezone';
import { makeSingleton, Translate } from '@singletons'; import { makeSingleton, Translate } from '@singletons';
import { CoreTime } from '@singletons/time'; import { CoreTime } from '@singletons/time';

View File

@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
import moment from 'moment'; import moment from 'moment-timezone';
import { CoreConstants } from '@/core/constants'; import { CoreConstants } from '@/core/constants';

View File

@ -14,23 +14,33 @@
import { APP_INITIALIZER, NgModule } from '@angular/core'; import { APP_INITIALIZER, NgModule } from '@angular/core';
import { CoreAppProvider } from '@services/app'; import { CoreAppProvider } from '@services/app';
import moment from 'moment-timezone';
import { TestingBehatRuntime, TestingBehatRuntimeService } from './services/behat-runtime'; import { TestingBehatRuntime, TestingBehatRuntimeService } from './services/behat-runtime';
type AutomatedTestsWindow = Window & { type AutomatedTestsWindow = Window & {
behat?: TestingBehatRuntimeService; behat?: TestingBehatRuntimeService;
}; };
function initializeAutomatedTestsWindow(window: AutomatedTestsWindow) { function initializeAutomatedTests(window: AutomatedTestsWindow) {
if (!CoreAppProvider.isAutomated()) { if (!CoreAppProvider.isAutomated()) {
return; return;
} }
window.behat = TestingBehatRuntime.instance; window.behat = TestingBehatRuntime.instance;
// Force timezone for automated tests. Use the same timezone forced for LMS in tests.
moment.tz.setDefault('Australia/Perth');
} }
@NgModule({ @NgModule({
providers: [ providers: [
{ provide: APP_INITIALIZER, multi: true, useValue: () => initializeAutomatedTestsWindow(window) }, {
provide: APP_INITIALIZER,
multi: true,
useValue: () => {
initializeAutomatedTests(window);
},
},
], ],
}) })
export class TestingModule {} export class TestingModule {}