diff --git a/src/app/app-root/monitor-starter/monitor-starter.component.spec.ts b/src/app/app-root/monitor-starter/monitor-starter.component.spec.ts index af77f81c74d2402ce8fa80e5177664cea9a5a0aa..0d54690f2897ccab674a192af5883d56514cea42 100644 --- a/src/app/app-root/monitor-starter/monitor-starter.component.spec.ts +++ b/src/app/app-root/monitor-starter/monitor-starter.component.spec.ts @@ -1,6 +1,10 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { MonitorStarterComponent } from './monitor-starter.component'; +import {AppRoutingModule} from "../../app-routing.module"; +import {BackendService} from "../../test-controller/backend.service"; +import {MainDataService} from "../../maindata.service"; +import {HttpClientModule} from "@angular/common/http"; describe('MonitorStarterComponent', () => { let component: MonitorStarterComponent; @@ -8,7 +12,12 @@ describe('MonitorStarterComponent', () => { beforeEach(async(() => { TestBed.configureTestingModule({ - declarations: [ MonitorStarterComponent ] + declarations: [ MonitorStarterComponent ], + imports: [AppRoutingModule, HttpClientModule], + providers: [ + MainDataService, + BackendService + ], }) .compileComponents(); })); diff --git a/src/app/test-controller/backend.service.ts b/src/app/test-controller/backend.service.ts index 7e9490f1d814b42b6f30c9a4201088b6ad4ea7f4..eef29267ae3cd8b309d4662fe701e87e0f295dae 100644 --- a/src/app/test-controller/backend.service.ts +++ b/src/app/test-controller/backend.service.ts @@ -13,24 +13,27 @@ export class BackendService { constructor( @Inject('SERVER_URL') private serverUrl: string, private http: HttpClient - ) { - } + ) { } saveUnitReview(testId: string, unitName: string, priority: number, categories: string, entry: string) : Observable<boolean> { - // TODO endpoint does not give any return, only status 200 return this.http - .put<boolean>(this.serverUrl + `test/${testId}/unit/${unitName}/review`, {priority, categories, entry}) - .pipe(catchError(() => of(false))); + .put(this.serverUrl + `test/${testId}/unit/${unitName}/review`, {priority, categories, entry}) + .pipe( + map(() => true), + catchError(() => of(false)) + ); } saveBookletReview(testId: string, priority: number, categories: string, entry: string): Observable<boolean> { - // TODO endpoint does not give any return, only status 200 return this.http - .put<boolean>(this.serverUrl + `test/${testId}/review`, {priority, categories, entry}) - .pipe(catchError(() => of(false))); + .put(this.serverUrl + `test/${testId}/review`, {priority, categories, entry}) + .pipe( + map(() => true), + catchError(() => of(false)) + ); } @@ -68,50 +71,62 @@ export class BackendService { addUnitLog(testId: string, timestamp: number, unitName: string, entry: string): Observable<boolean> { - // TODO endpoint does not give any return, only status 200 return this.http - .put<boolean>(this.serverUrl + `test/${testId}/unit/${unitName}/log`, {timestamp, entry}) - .pipe(catchError(() => of(false))); + .put(this.serverUrl + `test/${testId}/unit/${unitName}/log`, {timestamp, entry}) + .pipe( + map(() => true), + catchError(() => of(false)) + ); } addBookletLog(testId: string, timestamp: number, entry: string): Observable<boolean> { - // TODO endpoint does not give any return, only status 200 return this.http - .put<boolean>(this.serverUrl + `test/${testId}/log`, {timestamp, entry}) - .pipe(catchError(() => of(false))); + .put(this.serverUrl + `test/${testId}/log`, {timestamp, entry}) + .pipe( + map(() => true), + catchError(() => of(false)) + ); } setUnitState(testId: string, unitName: string, stateKey: string, state: string): Observable<boolean> { - // TODO endpoint does not give any return, only status 200 return this.http - .patch<boolean>(this.serverUrl + `test/${testId}/unit/${unitName}/state`, {key: stateKey, value: state}) - .pipe(catchError(() => of(false))); + .patch(this.serverUrl + `test/${testId}/unit/${unitName}/state`, {key: stateKey, value: state}) + .pipe( + map(() => true), + catchError(() => of(false)) + ); } setBookletState(testId: string, stateKey: string, state: string): Observable<boolean> { - // TODO endpoint does not give any return, only status 200 return this.http - .patch<boolean>(this.serverUrl + `test/${testId}/state`, {key: stateKey, value: state}) - .pipe(catchError(() => of(false))); + .patch(this.serverUrl + `test/${testId}/state`, {key: stateKey, value: state}) + .pipe( + map(() => true), + catchError(() => of(false)) + ); } newUnitResponse(testId: string, timestamp: number, unitName: string, response: string, responseType: string) : Observable<boolean> { - // TODO endpoint does not give any return, only status 200 return this.http - .put<boolean>(this.serverUrl + `test/${testId}/unit/${unitName}/response`, {timestamp, response, responseType}) - .pipe(catchError(() => of(false))); + .put(this.serverUrl + `test/${testId}/unit/${unitName}/response`, {timestamp, response, responseType}) + .pipe( + map(() => true), + catchError(() => of(false)) + ); } newUnitRestorePoint(testId: string, unitName: string, timestamp: number, restorePoint: string): Observable<boolean> { - // TODO endpoint does not give any return, only status 200 return this.http - .patch<boolean>(this.serverUrl + `test/${testId}/unit/${unitName}/restorepoint`, {timestamp, restorePoint}) - .pipe(catchError(() => of(false))); + .patch(this.serverUrl + `test/${testId}/unit/${unitName}/restorepoint`, {timestamp, restorePoint}) + .pipe( + map(() => true), + catchError(() => of(false)) + ); } } diff --git a/src/app/test-controller/no-unit/no-unit.component.spec.ts b/src/app/test-controller/no-unit/no-unit.component.spec.ts index ae483796157c239a3f8e7def38c6999ced3eca66..6f379eab48dc6a5dcb33f431e17c6a48961c7c88 100644 --- a/src/app/test-controller/no-unit/no-unit.component.spec.ts +++ b/src/app/test-controller/no-unit/no-unit.component.spec.ts @@ -1,6 +1,7 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { NoUnitComponent } from './no-unit.component'; +import {AppRoutingModule} from "../../app-routing.module"; describe('NoUnitComponent', () => { let component: NoUnitComponent; @@ -8,7 +9,8 @@ describe('NoUnitComponent', () => { beforeEach(async(() => { TestBed.configureTestingModule({ - declarations: [ NoUnitComponent ] + declarations: [ NoUnitComponent ], + imports: [AppRoutingModule] }) .compileComponents(); })); diff --git a/src/app/test-controller/test-controller.component.ts b/src/app/test-controller/test-controller.component.ts index 65682231a360df04c471d9f5565587b46e3360a6..7523cec938c6306850162e3616dd11091a527df9 100644 --- a/src/app/test-controller/test-controller.component.ts +++ b/src/app/test-controller/test-controller.component.ts @@ -33,7 +33,7 @@ export class TestControllerComponent implements OnInit, OnDestroy { private unitLoadQueueSubscription1: Subscription = null; private unitLoadQueueSubscription2: Subscription = null; - public showProgress = true; + public showProgress = false; private lastUnitSequenceId = 0; private lastTestletIndex = 0; diff --git a/src/app/test-controller/test-controller.service.spec.ts b/src/app/test-controller/test-controller.service.spec.ts index af0f96afcf4e7d331df7e601b0b7c64cc6057c2d..ae136e0d4a810504eb2d3899d1e05b64f69103c5 100644 --- a/src/app/test-controller/test-controller.service.spec.ts +++ b/src/app/test-controller/test-controller.service.spec.ts @@ -3,6 +3,7 @@ import { TestBed, inject } from '@angular/core/testing'; import { TestControllerService } from './test-controller.service'; import {HttpClientModule} from "@angular/common/http"; import {BackendService} from "./backend.service"; +import {AppRoutingModule} from "../app-routing.module"; describe('TestControllerService', () => { beforeEach(() => { @@ -12,7 +13,8 @@ describe('TestControllerService', () => { BackendService ], imports: [ - HttpClientModule + HttpClientModule, + AppRoutingModule ] }); }); diff --git a/src/app/test-controller/test-controller.service.ts b/src/app/test-controller/test-controller.service.ts index 06b488f9921cfb2ce08d530c93c07f3a66f214f8..875efd53b60684c1fb33200db3c7c4371b0ba96e 100644 --- a/src/app/test-controller/test-controller.service.ts +++ b/src/app/test-controller/test-controller.service.ts @@ -8,7 +8,6 @@ import { } from './test-controller.interfaces'; import { BackendService } from './backend.service'; import {Router} from "@angular/router"; -import {MatSnackBar} from "@angular/material/snack-bar"; @Injectable({ providedIn: 'root' @@ -82,7 +81,6 @@ export class TestControllerService { constructor ( private router: Router, - private snackBar: MatSnackBar, private bs: BackendService ) { this.restorePointsToSave$.pipe( @@ -90,7 +88,7 @@ export class TestControllerService { this.bs.newUnitRestorePoint(this.testId, restorePoint.unitDbKey, Date.now(), JSON.stringify(restorePoint.restorePoint)).subscribe(ok => { if (!ok) { - console.log('((((((((((((((((newUnitRestorePoint'); + console.warn('newUnitRestorePoint failed'); } }); } @@ -102,7 +100,7 @@ export class TestControllerService { this.bs.newUnitResponse(this.testId, Date.now(), response.unitDbKey, JSON.stringify(response.response), response.responseType).subscribe(ok => { if (!ok) { - console.log('((((((((((((((((newUnitResponse'); + console.warn('newUnitResponse failed'); } }); } @@ -207,7 +205,7 @@ export class TestControllerService { const entryData = entry.length > 0 ? logKey + ': ' + JSON.stringify(entry) : logKey; this.bs.addBookletLog(this.testId, Date.now(), entryData).subscribe(ok => { if (!ok) { - console.log('((((((((((((((((addBookletLog'); + console.warn('addBookletLog failed'); } }); } @@ -216,7 +214,7 @@ export class TestControllerService { if (this.mode !== 'run-review') { this.bs.setBookletState(this.testId, stateKey, state).subscribe(ok => { if (!ok) { - console.log('((((((((((((((((setBookletState'); + console.warn('setBookletState failed'); } }); } @@ -226,7 +224,7 @@ export class TestControllerService { this.bs.addUnitLog(this.testId, Date.now(), unitDbKey, entry.length > 0 ? logKey + ': ' + JSON.stringify(entry) : logKey).subscribe(ok => { if (!ok) { - console.log('((((((((((((((((addUnitLog'); + console.warn('addUnitLog failed'); } }); } @@ -255,7 +253,7 @@ export class TestControllerService { this.addUnitLog(unitDbKey, LogEntryKey.PRESENTATIONCOMPLETE, presentationComplete); this.bs.setUnitState(this.testId, unitDbKey, LastStateKey.PRESENTATIONCOMPLETE, presentationComplete).subscribe(ok => { if (!ok) { - console.log('((((((((((((((((setUnitState'); + console.warn('setUnitState failed'); } }); } @@ -309,7 +307,7 @@ export class TestControllerService { public setUnitNavigationRequest(navString: string) { if (!this.rootTestlet) { - this.snackBar.open('Kein Testheft verfügbar.', '', {duration: 3000}); + console.warn(`TestControllerService.setUnitNavigationRequest: Kein Testheft für "${navString}" verfügbar.`); } else { if (!navString) { navString = '#next'; diff --git a/src/app/test-controller/unithost/unit-routing-guards.spec.ts b/src/app/test-controller/unithost/unit-routing-guards.spec.ts index cbaadf6fec402f0bee2c0d8b875b91e2a009be0c..913dac94f12860be985bca85319808a96f6e01fe 100644 --- a/src/app/test-controller/unithost/unit-routing-guards.spec.ts +++ b/src/app/test-controller/unithost/unit-routing-guards.spec.ts @@ -4,12 +4,17 @@ import { UnitActivateGuard, UnitDeactivateGuard } from './unit-routing-guards'; import {HttpClientModule} from "@angular/common/http"; import {MatDialogModule} from "@angular/material/dialog"; import {MatSnackBarModule} from "@angular/material/snack-bar"; +import {MainDataService} from "../../maindata.service"; +import {BackendService} from "../backend.service"; +import {CustomtextService} from "iqb-components"; +import {TestControllerService} from "../test-controller.service"; +import {AppRoutingModule} from "../../app-routing.module"; describe('UnitActivateGuard', () => { beforeEach(() => { TestBed.configureTestingModule({ - providers: [UnitActivateGuard], - imports: [HttpClientModule, MatDialogModule, MatSnackBarModule] + providers: [UnitActivateGuard, MainDataService, TestControllerService, BackendService, CustomtextService], + imports: [HttpClientModule, AppRoutingModule, MatDialogModule, MatSnackBarModule] }); }); @@ -22,8 +27,8 @@ describe('UnitActivateGuard', () => { describe('UnitDeactivateGuard', () => { beforeEach(() => { TestBed.configureTestingModule({ - providers: [UnitDeactivateGuard], - imports: [HttpClientModule] + providers: [UnitDeactivateGuard, TestControllerService], + imports: [HttpClientModule, AppRoutingModule] }); });