Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ async function joinAsChecker(
// Give time for the last answer to be saved
await page.waitForTimeout(500);
} catch (e) {
if (preset.pauseOnFailure) await page.pause();
console.error('Error running tests for checker ' + userNumber);
console.error(e);
await screenshot(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { ServalAdminAuthGuard } from './serval-administration/serval-admin-auth.
import { ServalAdministrationComponent } from './serval-administration/serval-administration.component';
import { ServalProjectComponent } from './serval-administration/serval-project.component';
import { SettingsComponent } from './settings/settings.component';
import { BlankPageComponent } from './shared/blank-page/blank-page.component';
import { PageNotFoundComponent } from './shared/page-not-found/page-not-found.component';
import { SettingsAuthGuard, SyncAuthGuard } from './shared/project-router.guard';
import { SyncComponent } from './sync/sync.component';
Expand All @@ -33,6 +34,7 @@ const routes: Routes = [
{ path: 'serval-administration/:projectId', component: ServalProjectComponent, canActivate: [ServalAdminAuthGuard] },
{ path: 'serval-administration', component: ServalAdministrationComponent, canActivate: [ServalAdminAuthGuard] },
{ path: 'system-administration', component: SystemAdministrationComponent, canActivate: [SystemAdminAuthGuard] },
{ path: 'blank-page', component: BlankPageComponent },
{ path: '**', component: PageNotFoundComponent }
];

Expand Down
186 changes: 108 additions & 78 deletions src/SIL.XForge.Scripture/ClientApp/src/app/app.component.spec.ts

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion src/SIL.XForge.Scripture/ClientApp/src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import { I18nService } from 'xforge-common/i18n.service';
import { LocationService } from 'xforge-common/location.service';
import { Breakpoint, MediaBreakpointService } from 'xforge-common/media-breakpoints/media-breakpoint.service';
import { DocSubscription } from 'xforge-common/models/realtime-doc';
import { UserDoc } from 'xforge-common/models/user-doc';
import { NoticeService } from 'xforge-common/notice.service';
import { OnlineStatusService } from 'xforge-common/online-status.service';
Expand Down Expand Up @@ -120,7 +121,7 @@
// Check authentication when coming back online
// This is also run on first load when the websocket connects for the first time
if (status && !this.isAppLoading) {
this.authService.checkOnlineAuth();

Check warning on line 124 in src/SIL.XForge.Scripture/ClientApp/src/app/app.component.ts

View workflow job for this annotation

GitHub Actions / Lint and Prettier (22.13.0, 10.9.2)

Promises must be awaited, end with a call to .catch, end with a call to .then with a rejection handler or be explicitly marked as ignored with the `void` operator
}
});

Expand Down Expand Up @@ -279,10 +280,11 @@
if (this._selectedProjectDoc == null || !this._selectedProjectDoc.isLoaded) {
return;
}
this.userService.setCurrentProjectId(this.currentUserDoc!, this._selectedProjectDoc.id);

Check warning on line 283 in src/SIL.XForge.Scripture/ClientApp/src/app/app.component.ts

View workflow job for this annotation

GitHub Actions / Lint and Prettier (22.13.0, 10.9.2)

Promises must be awaited, end with a call to .catch, end with a call to .then with a rejection handler or be explicitly marked as ignored with the `void` operator
this.projectUserConfigDoc = await this.projectService.getUserConfig(
this._selectedProjectDoc.id,
this.currentUserDoc!.id
this.currentUserDoc!.id,
new DocSubscription('AppComponent', this.destroyRef)
);
if (this.selectedProjectDeleteSub != null) {
this.selectedProjectDeleteSub.unsubscribe();
Expand All @@ -291,7 +293,7 @@
// handle remotely deleted project
const userDoc = this.currentUserDoc;
if (userDoc != null && this.userService.currentProjectId(userDoc) != null) {
this.showProjectDeletedDialog();

Check warning on line 296 in src/SIL.XForge.Scripture/ClientApp/src/app/app.component.ts

View workflow job for this annotation

GitHub Actions / Lint and Prettier (22.13.0, 10.9.2)

Promises must be awaited, end with a call to .catch, end with a call to .then with a rejection handler or be explicitly marked as ignored with the `void` operator
}
});

Expand All @@ -311,8 +313,8 @@
// See if the user was removed from the project
if (!(this.currentUserDoc.id in this._selectedProjectDoc.data.userRoles)) {
// The user has been removed from the project
this.showProjectDeletedDialog();

Check warning on line 316 in src/SIL.XForge.Scripture/ClientApp/src/app/app.component.ts

View workflow job for this annotation

GitHub Actions / Lint and Prettier (22.13.0, 10.9.2)

Promises must be awaited, end with a call to .catch, end with a call to .then with a rejection handler or be explicitly marked as ignored with the `void` operator
this.projectService.localDelete(this._selectedProjectDoc.id);

Check warning on line 317 in src/SIL.XForge.Scripture/ClientApp/src/app/app.component.ts

View workflow job for this annotation

GitHub Actions / Lint and Prettier (22.13.0, 10.9.2)

Promises must be awaited, end with a call to .catch, end with a call to .then with a rejection handler or be explicitly marked as ignored with the `void` operator
}

if (this.projectUserConfigDoc != null) {
Expand Down Expand Up @@ -348,29 +350,29 @@

setLocale(locale: string): void {
this.i18n.setLocale(locale);
this.authService.updateInterfaceLanguage(locale);

Check warning on line 353 in src/SIL.XForge.Scripture/ClientApp/src/app/app.component.ts

View workflow job for this annotation

GitHub Actions / Lint and Prettier (22.13.0, 10.9.2)

Promises must be awaited, end with a call to .catch, end with a call to .then with a rejection handler or be explicitly marked as ignored with the `void` operator
}

changePassword(): void {
if (this.currentUser == null) {
return;
} else if (!this.isAppOnline) {
this.noticeService.show(this.i18n.translateStatic('app.action_not_available_offline'));

Check warning on line 360 in src/SIL.XForge.Scripture/ClientApp/src/app/app.component.ts

View workflow job for this annotation

GitHub Actions / Lint and Prettier (22.13.0, 10.9.2)

Promises must be awaited, end with a call to .catch, end with a call to .then with a rejection handler or be explicitly marked as ignored with the `void` operator
} else {
this.authService
.changePassword(this.currentUser.email)
.then(() => {
this.noticeService.show(this.i18n.translateStatic('app.password_reset_email_sent'));

Check warning on line 365 in src/SIL.XForge.Scripture/ClientApp/src/app/app.component.ts

View workflow job for this annotation

GitHub Actions / Lint and Prettier (22.13.0, 10.9.2)

Promises must be awaited, end with a call to .catch, end with a call to .then with a rejection handler or be explicitly marked as ignored with the `void` operator
})
.catch(() => {
this.dialogService.message('app.cannot_change_password');

Check warning on line 368 in src/SIL.XForge.Scripture/ClientApp/src/app/app.component.ts

View workflow job for this annotation

GitHub Actions / Lint and Prettier (22.13.0, 10.9.2)

Promises must be awaited, end with a call to .catch, end with a call to .then with a rejection handler or be explicitly marked as ignored with the `void` operator
});
}
}

editName(): void {
if (this.isAppOnline) {
this.userService.editDisplayName(false);

Check warning on line 375 in src/SIL.XForge.Scripture/ClientApp/src/app/app.component.ts

View workflow job for this annotation

GitHub Actions / Lint and Prettier (22.13.0, 10.9.2)

Promises must be awaited, end with a call to .catch, end with a call to .then with a rejection handler or be explicitly marked as ignored with the `void` operator
} else {
this.noticeService.show(this.i18n.translateStatic('app.action_not_available_offline'));
}
Expand Down
12 changes: 11 additions & 1 deletion src/SIL.XForge.Scripture/ClientApp/src/app/app.module.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { OverlayContainer } from '@angular/cdk/overlay';
import { DatePipe } from '@angular/common';
import { provideHttpClient, withInterceptorsFromDi } from '@angular/common/http';
import { APP_ID, ErrorHandler, NgModule, inject, provideAppInitializer } from '@angular/core';
import { APP_ID, ErrorHandler, inject, NgModule, provideAppInitializer } from '@angular/core';
import { MatRipple } from '@angular/material/core';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { ServiceWorkerModule } from '@angular/service-worker';
Expand Down Expand Up @@ -37,6 +37,7 @@ import { ProjectComponent } from './project/project.component';
import { ScriptureChooserDialogComponent } from './scripture-chooser-dialog/scripture-chooser-dialog.component';
import { DeleteProjectDialogComponent } from './settings/delete-project-dialog/delete-project-dialog.component';
import { SettingsComponent } from './settings/settings.component';
import { CacheService } from './shared/cache-service/cache.service';
import { GlobalNoticesComponent } from './shared/global-notices/global-notices.component';
import { SharedModule } from './shared/shared.module';
import { TextNoteDialogComponent } from './shared/text/text-note-dialog/text-note-dialog.component';
Expand All @@ -46,6 +47,11 @@ import { LynxInsightsModule } from './translate/editor/lynx/insights/lynx-insigh
import { TranslateModule } from './translate/translate.module';
import { UsersModule } from './users/users.module';

/** Initialization function for any services that need to be run but are not depended on by any component. */
function initializeGlobalServicesFactory(_cacheService: CacheService): () => Promise<any> {
return () => Promise.resolve();
}

@NgModule({
declarations: [
AppComponent,
Expand Down Expand Up @@ -97,6 +103,10 @@ import { UsersModule } from './users/users.module';
{ provide: ErrorHandler, useClass: ExceptionHandlingService },
{ provide: OverlayContainer, useClass: InAppRootOverlayContainer },
provideHttpClient(withInterceptorsFromDi()),
provideAppInitializer(() => {
const initializerFn = initializeGlobalServicesFactory(inject(CacheService));
return initializerFn();
}),
provideAppInitializer(() => {
const initializerFn = preloadEnglishTranslations(inject(TranslocoService));
return initializerFn();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -368,18 +368,18 @@ describe('ChapterAudioDialogComponent', () => {
expect(result.timingData[1].to).toEqual(1.296);
}));

it('will not save or upload if there is no audio', fakeAsync(() => {
it('will not save or upload if there is no audio', fakeAsync(async () => {
env.component.prepareTimingFileUpload(env.timingFile);
env.component.save();
await env.component.save();
env.fixture.detectChanges();

expect(env.numberOfTimesDialogClosed).toEqual(0);
expect(env.wrapperAudio.classList.contains('invalid')).toBe(true);
}));

it('will not save or upload if there is no timing data', fakeAsync(() => {
it('will not save or upload if there is no timing data', fakeAsync(async () => {
env.component.audioUpdate(env.audioFile);
env.component.save();
await env.component.save();
env.fixture.detectChanges();

expect(env.numberOfTimesDialogClosed).toEqual(0);
Expand Down Expand Up @@ -478,15 +478,15 @@ describe('ChapterAudioDialogComponent', () => {
expect(env.wrapperTiming.classList.contains('valid')).toBe(true);
}));

it('will not try to save dialog if offline', fakeAsync(() => {
it('will not try to save dialog if offline', fakeAsync(async () => {
env.onlineStatus = false;
env.component.audioUpdate(env.audioFile);
tick();
env.component.prepareTimingFileUpload(env.timingFile);
tick();

// SUT
env.component.save();
await env.component.save();
tick();
env.fixture.detectChanges();
flush();
Expand Down
Loading
Loading