From d05ed23c1a3917e8bd4e5c925c6aca0ce8d05edd Mon Sep 17 00:00:00 2001
From: mechtelm <nicht@mehr.fragen>
Date: Wed, 25 Mar 2020 15:47:14 +0100
Subject: [PATCH] tests done

---
 src/app/app.module.ts                         |  3 +-
 .../newpassword/newpassword.component.html    |  2 +-
 .../newpassword/newpassword.component.spec.ts | 17 ++++++-
 .../newpassword/newpassword.component.ts      | 20 +++-----
 .../users/newuser/newuser.component.html      |  2 +-
 .../users/newuser/newuser.component.spec.ts   | 18 ++++++-
 .../users/newuser/newuser.component.ts        | 21 +++-----
 src/app/superadmin/users/users.component.ts   |  9 +---
 .../editworkspace.component.html              |  4 +-
 .../editworkspace.component.spec.ts           | 17 ++++++-
 .../editworkspace/editworkspace.component.ts  | 20 +++-----
 .../newworkspace/newworkspace.component.html  |  2 +-
 .../newworkspace.component.spec.ts            | 18 +++++--
 .../newworkspace/newworkspace.component.ts    | 20 +++-----
 .../workspaces/workspaces.component.ts        |  5 +-
 .../environment-check.component.spec.ts       |  4 +-
 src/app/sys-check/report/report.component.ts  | 49 ++++++++++---------
 .../save-report/save-report.component.spec.ts | 16 +++++-
 .../save-report/save-report.component.ts      | 21 +++-----
 .../review-dialog.component.spec.ts           | 31 +++++++++++-
 .../review-dialog/review-dialog.component.ts  | 30 +++++-------
 .../start-lock-input.component.html           | 11 +++--
 .../start-lock-input.component.spec.ts        | 42 ++++++++++++++--
 .../start-lock-input.component.ts             | 27 ++++------
 .../test-controller.component.ts              | 12 ++++-
 .../test-controller.interfaces.ts             |  7 +++
 .../unithost/unit-routing-guards.ts           | 11 +++--
 27 files changed, 271 insertions(+), 168 deletions(-)

diff --git a/src/app/app.module.ts b/src/app/app.module.ts
index 59feb204..49e159b3 100644
--- a/src/app/app.module.ts
+++ b/src/app/app.module.ts
@@ -17,7 +17,7 @@ import { IqbComponentsModule } from 'iqb-components';
 import {MatButtonModule} from "@angular/material/button";
 import {MatCardModule} from "@angular/material/card";
 import {MatCheckboxModule} from "@angular/material/checkbox";
-import { MatDialogModule } from '@angular/material/dialog';
+import {MatDialog, MatDialogModule} from '@angular/material/dialog';
 import {MatFormFieldModule} from "@angular/material/form-field";
 import {MatIconModule} from "@angular/material/icon";
 import {MatInputModule} from "@angular/material/input";
@@ -66,6 +66,7 @@ import {RouterModule} from "@angular/router";
   ],
   providers: [
     BackendService,
+    MatDialog,
     {
       provide: HTTP_INTERCEPTORS,
       useClass: AuthInterceptor,
diff --git a/src/app/superadmin/users/newpassword/newpassword.component.html b/src/app/superadmin/users/newpassword/newpassword.component.html
index 8685c172..49bc44b8 100644
--- a/src/app/superadmin/users/newpassword/newpassword.component.html
+++ b/src/app/superadmin/users/newpassword/newpassword.component.html
@@ -3,7 +3,7 @@
 
     <mat-dialog-content>
       <div class="infobox">
-        <p>Ändern des Kennwortes für Nutzer/in "{{ data.name }}".</p>
+        <p>Ändern des Kennwortes für Nutzer/in "{{ data }}".</p>
       </div>
       <p>
         <mat-form-field class="full-width">
diff --git a/src/app/superadmin/users/newpassword/newpassword.component.spec.ts b/src/app/superadmin/users/newpassword/newpassword.component.spec.ts
index c9d927fa..9e7ddf44 100644
--- a/src/app/superadmin/users/newpassword/newpassword.component.spec.ts
+++ b/src/app/superadmin/users/newpassword/newpassword.component.spec.ts
@@ -2,7 +2,10 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing';
 
 import { NewpasswordComponent } from './newpassword.component';
 import {ReactiveFormsModule} from "@angular/forms";
-import {MatDialogModule} from "@angular/material/dialog";
+import {MAT_DIALOG_DATA, MatDialog, MatDialogModule} from "@angular/material/dialog";
+import {MatInputModule} from "@angular/material/input";
+import {MatFormFieldModule} from "@angular/material/form-field";
+import {NoopAnimationsModule} from "@angular/platform-browser/animations";
 
 describe('NewpasswordComponent', () => {
   let component: NewpasswordComponent;
@@ -11,7 +14,17 @@ describe('NewpasswordComponent', () => {
   beforeEach(async(() => {
     TestBed.configureTestingModule({
       declarations: [ NewpasswordComponent ],
-      imports: [ReactiveFormsModule, MatDialogModule]
+      imports: [
+        MatDialogModule,
+        ReactiveFormsModule,
+        MatInputModule,
+        MatFormFieldModule,
+        NoopAnimationsModule
+      ],
+      providers: [
+        MatDialog,
+        { provide: MAT_DIALOG_DATA, useValue: 'Harry Sack' }
+      ]
     })
     .compileComponents();
   }));
diff --git a/src/app/superadmin/users/newpassword/newpassword.component.ts b/src/app/superadmin/users/newpassword/newpassword.component.ts
index 3a001265..c4b785f4 100644
--- a/src/app/superadmin/users/newpassword/newpassword.component.ts
+++ b/src/app/superadmin/users/newpassword/newpassword.component.ts
@@ -1,21 +1,17 @@
 import { MAT_DIALOG_DATA } from '@angular/material/dialog';
-import { Component, OnInit, Inject } from '@angular/core';
-import { FormGroup, FormBuilder, Validators } from '@angular/forms';
+import { Component, Inject } from '@angular/core';
+import {FormGroup, Validators, FormControl} from '@angular/forms';
 
 @Component({
   templateUrl: './newpassword.component.html',
   styleUrls: ['./newpassword.component.css']
 })
 
-export class NewpasswordComponent implements OnInit {
-  newpasswordform: FormGroup;
+export class NewpasswordComponent {
+  newpasswordform = new FormGroup({
+    pw: new FormControl('', [Validators.required, Validators.minLength(3)])
+  });
 
-  constructor(private fb: FormBuilder,
-    @Inject(MAT_DIALOG_DATA) public data: any) { }
-
-  ngOnInit() {
-    this.newpasswordform = this.fb.group({
-      pw: this.fb.control('', [Validators.required, Validators.minLength(3)])
-    });
-  }
+  constructor(
+    @Inject(MAT_DIALOG_DATA) public data: string) { }
 }
diff --git a/src/app/superadmin/users/newuser/newuser.component.html b/src/app/superadmin/users/newuser/newuser.component.html
index 4a4d5c11..32b548ef 100644
--- a/src/app/superadmin/users/newuser/newuser.component.html
+++ b/src/app/superadmin/users/newuser/newuser.component.html
@@ -4,7 +4,7 @@
   <mat-dialog-content>
     <p>
       <mat-form-field class="full-width">
-        <input matInput formControlName="name" placeholder="Name" [value]="data.name">
+        <input matInput formControlName="name" placeholder="Name">
       </mat-form-field>
     </p>
     <p>
diff --git a/src/app/superadmin/users/newuser/newuser.component.spec.ts b/src/app/superadmin/users/newuser/newuser.component.spec.ts
index f58f6764..75c49da6 100644
--- a/src/app/superadmin/users/newuser/newuser.component.spec.ts
+++ b/src/app/superadmin/users/newuser/newuser.component.spec.ts
@@ -2,7 +2,11 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing';
 
 import { NewuserComponent } from './newuser.component';
 import {ReactiveFormsModule} from "@angular/forms";
-import {MatDialogModule} from "@angular/material/dialog";
+import {MatDialog, MatDialogModule} from "@angular/material/dialog";
+import {MatInputModule} from "@angular/material/input";
+import {MatFormFieldModule} from "@angular/material/form-field";
+import {MatIconModule} from "@angular/material/icon";
+import {NoopAnimationsModule} from "@angular/platform-browser/animations";
 
 describe('NewuserComponent', () => {
   let component: NewuserComponent;
@@ -11,7 +15,17 @@ describe('NewuserComponent', () => {
   beforeEach(async(() => {
     TestBed.configureTestingModule({
       declarations: [ NewuserComponent ],
-      imports: [ReactiveFormsModule, MatDialogModule]
+      imports: [
+        MatDialogModule,
+        ReactiveFormsModule,
+        MatInputModule,
+        MatFormFieldModule,
+        MatIconModule,
+        NoopAnimationsModule
+      ],
+      providers: [
+        MatDialog
+        ]
     })
     .compileComponents();
   }));
diff --git a/src/app/superadmin/users/newuser/newuser.component.ts b/src/app/superadmin/users/newuser/newuser.component.ts
index 75ea8e3b..615a84f0 100644
--- a/src/app/superadmin/users/newuser/newuser.component.ts
+++ b/src/app/superadmin/users/newuser/newuser.component.ts
@@ -1,21 +1,14 @@
-import { MAT_DIALOG_DATA } from '@angular/material/dialog';
-import { Component, OnInit, Inject } from '@angular/core';
-import { FormGroup, FormBuilder, Validators } from '@angular/forms';
+import { Component } from '@angular/core';
+import {FormControl, FormGroup, Validators} from '@angular/forms';
 
 @Component({
   templateUrl: './newuser.component.html',
   styleUrls: ['./newuser.component.css']
 })
-export class NewuserComponent implements OnInit {
-  newuserform: FormGroup;
 
-  constructor(private fb: FormBuilder,
-    @Inject(MAT_DIALOG_DATA) public data: any) { }
-
-  ngOnInit() {
-    this.newuserform = this.fb.group({
-      name: this.fb.control('', [Validators.required, Validators.minLength(3)]),
-      pw: this.fb.control('', [Validators.required, Validators.minLength(3)])
-    });
-  }
+export class NewuserComponent {
+  newuserform = new FormGroup({
+    name: new FormControl('', [Validators.required, Validators.minLength(3)]),
+    pw: new FormControl('', [Validators.required, Validators.minLength(3)])
+  });
 }
diff --git a/src/app/superadmin/users/users.component.ts b/src/app/superadmin/users/users.component.ts
index f7b65289..c12db9a6 100644
--- a/src/app/superadmin/users/users.component.ts
+++ b/src/app/superadmin/users/users.component.ts
@@ -71,10 +71,7 @@ export class UsersComponent implements OnInit, OnDestroy {
   // ***********************************************************************************
   addObject() {
     const dialogRef = this.newuserDialog.open(NewuserComponent, {
-      width: '600px',
-      data: {
-        name: ''
-      }
+      width: '600px'
     });
 
     dialogRef.afterClosed().subscribe(result => {
@@ -112,9 +109,7 @@ export class UsersComponent implements OnInit, OnDestroy {
     } else {
       const dialogRef = this.newpasswordDialog.open(NewpasswordComponent, {
         width: '600px',
-        data: {
-          name: selectedRows[0]['name']
-        }
+        data: selectedRows[0]['name']
       });
 
       dialogRef.afterClosed().subscribe(result => {
diff --git a/src/app/superadmin/workspaces/editworkspace/editworkspace.component.html b/src/app/superadmin/workspaces/editworkspace/editworkspace.component.html
index ea8a1771..4d5d55c7 100644
--- a/src/app/superadmin/workspaces/editworkspace/editworkspace.component.html
+++ b/src/app/superadmin/workspaces/editworkspace/editworkspace.component.html
@@ -1,10 +1,10 @@
 <form [formGroup]="editworkspaceform">
-  <h1 mat-dialog-title>Arbeitsbereich "{{data.oldname}}" ändern</h1>
+  <h1 mat-dialog-title>Arbeitsbereich "{{data}}" ändern</h1>
 
   <mat-dialog-content>
     <p>
       <mat-form-field class="full-width">
-        <input matInput formControlName="name" placeholder="Name" [value]="data.name">
+        <input matInput formControlName="name" placeholder="Name" [value]="data">
       </mat-form-field>
     </p>
   </mat-dialog-content>
diff --git a/src/app/superadmin/workspaces/editworkspace/editworkspace.component.spec.ts b/src/app/superadmin/workspaces/editworkspace/editworkspace.component.spec.ts
index e8338731..e3ac6df1 100644
--- a/src/app/superadmin/workspaces/editworkspace/editworkspace.component.spec.ts
+++ b/src/app/superadmin/workspaces/editworkspace/editworkspace.component.spec.ts
@@ -2,7 +2,10 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing';
 
 import { EditworkspaceComponent } from './editworkspace.component';
 import {ReactiveFormsModule} from "@angular/forms";
-import {MatDialogModule} from "@angular/material/dialog";
+import {MAT_DIALOG_DATA, MatDialog, MatDialogModule} from "@angular/material/dialog";
+import {MatInputModule} from "@angular/material/input";
+import {MatFormFieldModule} from "@angular/material/form-field";
+import {NoopAnimationsModule} from "@angular/platform-browser/animations";
 
 describe('EditworkspaceComponent', () => {
   let component: EditworkspaceComponent;
@@ -11,7 +14,17 @@ describe('EditworkspaceComponent', () => {
   beforeEach(async(() => {
     TestBed.configureTestingModule({
       declarations: [ EditworkspaceComponent ],
-      imports: [ReactiveFormsModule, MatDialogModule]
+      imports: [
+        MatDialogModule,
+        ReactiveFormsModule,
+        MatInputModule,
+        MatFormFieldModule,
+        NoopAnimationsModule
+      ],
+      providers: [
+        MatDialog,
+        { provide: MAT_DIALOG_DATA, useValue: 'VERA 2020' }
+      ]
     })
     .compileComponents();
   }));
diff --git a/src/app/superadmin/workspaces/editworkspace/editworkspace.component.ts b/src/app/superadmin/workspaces/editworkspace/editworkspace.component.ts
index 55013ca2..819f1299 100644
--- a/src/app/superadmin/workspaces/editworkspace/editworkspace.component.ts
+++ b/src/app/superadmin/workspaces/editworkspace/editworkspace.component.ts
@@ -1,20 +1,16 @@
 import { MAT_DIALOG_DATA } from '@angular/material/dialog';
-import { Component, OnInit, Inject } from '@angular/core';
-import { FormGroup, FormBuilder, Validators } from '@angular/forms';
+import { Component, Inject } from '@angular/core';
+import {FormGroup, Validators, FormControl} from '@angular/forms';
 
 @Component({
   templateUrl: './editworkspace.component.html',
   styleUrls: ['./editworkspace.component.css']
 })
-export class EditworkspaceComponent implements OnInit {
-  editworkspaceform: FormGroup;
+export class EditworkspaceComponent {
+  editworkspaceform = new FormGroup({
+    name: new FormControl('', [Validators.required, Validators.minLength(3)])
+  });
 
-  constructor(private fb: FormBuilder,
-    @Inject(MAT_DIALOG_DATA) public data: any) { }
-
-  ngOnInit() {
-    this.editworkspaceform = this.fb.group({
-      name: this.fb.control('', [Validators.required, Validators.minLength(3)])
-    });
-  }
+  constructor(
+    @Inject(MAT_DIALOG_DATA) public data: string) { }
 }
diff --git a/src/app/superadmin/workspaces/newworkspace/newworkspace.component.html b/src/app/superadmin/workspaces/newworkspace/newworkspace.component.html
index 5f6e7c28..00ad5848 100644
--- a/src/app/superadmin/workspaces/newworkspace/newworkspace.component.html
+++ b/src/app/superadmin/workspaces/newworkspace/newworkspace.component.html
@@ -4,7 +4,7 @@
   <mat-dialog-content>
     <p>
       <mat-form-field class="full-width">
-        <input matInput formControlName="name" placeholder="Name" [value]="data.name">
+        <input matInput formControlName="name" placeholder="Name">
       </mat-form-field>
     </p>
     <div class="infobox">
diff --git a/src/app/superadmin/workspaces/newworkspace/newworkspace.component.spec.ts b/src/app/superadmin/workspaces/newworkspace/newworkspace.component.spec.ts
index 919ebd2e..0bf0a5c9 100644
--- a/src/app/superadmin/workspaces/newworkspace/newworkspace.component.spec.ts
+++ b/src/app/superadmin/workspaces/newworkspace/newworkspace.component.spec.ts
@@ -2,16 +2,28 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing';
 
 import { NewworkspaceComponent } from './newworkspace.component';
 import {ReactiveFormsModule} from "@angular/forms";
-import {MatDialogModule} from "@angular/material/dialog";
+import {MatDialog, MatDialogModule} from "@angular/material/dialog";
+import {MatInputModule} from "@angular/material/input";
+import {MatFormFieldModule} from "@angular/material/form-field";
+import {NoopAnimationsModule} from "@angular/platform-browser/animations";
 
-describe('NewworkspaceComponent', () => {
+describe('NewWorkspaceComponent', () => {
   let component: NewworkspaceComponent;
   let fixture: ComponentFixture<NewworkspaceComponent>;
 
   beforeEach(async(() => {
     TestBed.configureTestingModule({
       declarations: [ NewworkspaceComponent ],
-      imports: [ReactiveFormsModule, MatDialogModule]
+      imports: [
+        MatDialogModule,
+        ReactiveFormsModule,
+        MatInputModule,
+        MatFormFieldModule,
+        NoopAnimationsModule
+      ],
+      providers: [
+        MatDialog
+      ]
     })
     .compileComponents();
   }));
diff --git a/src/app/superadmin/workspaces/newworkspace/newworkspace.component.ts b/src/app/superadmin/workspaces/newworkspace/newworkspace.component.ts
index 02cf6f56..6fd83574 100644
--- a/src/app/superadmin/workspaces/newworkspace/newworkspace.component.ts
+++ b/src/app/superadmin/workspaces/newworkspace/newworkspace.component.ts
@@ -1,20 +1,12 @@
-import { MAT_DIALOG_DATA } from '@angular/material/dialog';
-import { Component, OnInit, Inject } from '@angular/core';
-import { FormGroup, FormBuilder, Validators } from '@angular/forms';
+import { Component } from '@angular/core';
+import {FormGroup, Validators, FormControl} from '@angular/forms';
 
 @Component({
   templateUrl: './newworkspace.component.html',
   styleUrls: ['./newworkspace.component.css']
 })
-export class NewworkspaceComponent implements OnInit {
-  newworkspaceform: FormGroup;
-
-  constructor(private fb: FormBuilder,
-    @Inject(MAT_DIALOG_DATA) public data: any) { }
-
-  ngOnInit() {
-    this.newworkspaceform = this.fb.group({
-      name: this.fb.control('', [Validators.required, Validators.minLength(3)])
-    });
-  }
+export class NewworkspaceComponent {
+  newworkspaceform = new FormGroup({
+    name: new FormControl('', [Validators.required, Validators.minLength(3)])
+  })
 }
diff --git a/src/app/superadmin/workspaces/workspaces.component.ts b/src/app/superadmin/workspaces/workspaces.component.ts
index e7ff8f3f..72ffe0ab 100644
--- a/src/app/superadmin/workspaces/workspaces.component.ts
+++ b/src/app/superadmin/workspaces/workspaces.component.ts
@@ -112,10 +112,7 @@ export class WorkspacesComponent implements OnInit, OnDestroy {
     } else {
       const dialogRef = this.editworkspaceDialog.open(EditworkspaceComponent, {
         width: '600px',
-        data: {
-          name: selectedRows[0].name,
-          oldname: selectedRows[0].name
-        }
+        data: selectedRows[0].name
       });
 
       dialogRef.afterClosed().subscribe(result => {
diff --git a/src/app/sys-check/environment-check/environment-check.component.spec.ts b/src/app/sys-check/environment-check/environment-check.component.spec.ts
index bd2f643a..c1b1ed99 100644
--- a/src/app/sys-check/environment-check/environment-check.component.spec.ts
+++ b/src/app/sys-check/environment-check/environment-check.component.spec.ts
@@ -1,6 +1,7 @@
 import { async, ComponentFixture, TestBed } from '@angular/core/testing';
 
 import { EnvironmentCheckComponent } from './environment-check.component';
+import {MatCardModule} from "@angular/material/card";
 
 describe('EnvironmentCheckComponent', () => {
   let component: EnvironmentCheckComponent;
@@ -8,7 +9,8 @@ describe('EnvironmentCheckComponent', () => {
 
   beforeEach(async(() => {
     TestBed.configureTestingModule({
-      declarations: [ EnvironmentCheckComponent ]
+      declarations: [ EnvironmentCheckComponent ],
+      imports: [MatCardModule]
     })
     .compileComponents();
   }));
diff --git a/src/app/sys-check/report/report.component.ts b/src/app/sys-check/report/report.component.ts
index 9a4d111f..8e419413 100644
--- a/src/app/sys-check/report/report.component.ts
+++ b/src/app/sys-check/report/report.component.ts
@@ -54,33 +54,34 @@ export class ReportComponent {
 
     const dialogRef = this.saveDialog.open(SaveReportComponent, {
       width: '500px',
-      height: '600px',
-      data: 'jojo'
+      height: '600px'
     });
     dialogRef.afterClosed().subscribe(result => {
-      if (result !== false) {
-        const reportKey = result.get('key').value as string;
-        const reportTitle = result.get('title').value as string;
-        const cd = this.ds.checkConfig$.getValue();
-        console.log('result', result);
-        this.bs.saveReport(
-            cd.workspaceId,
-            cd.name,
-            {
-              keyPhrase: reportKey,
-              title: reportTitle,
-              environment: this.ds.environmentData$.getValue(),
-              network: this.ds.networkData$.getValue(),
-              questionnaire: this.ds.questionnaireData$.getValue(),
-              unit: this.ds.unitData$.getValue()
+      if (typeof result !== 'undefined') {
+        if (result !== false) {
+          const reportKey = result.get('key').value as string;
+          const reportTitle = result.get('title').value as string;
+          const cd = this.ds.checkConfig$.getValue();
+          console.log('result', result);
+          this.bs.saveReport(
+              cd.workspaceId,
+              cd.name,
+              {
+                keyPhrase: reportKey,
+                title: reportTitle,
+                environment: this.ds.environmentData$.getValue(),
+                network: this.ds.networkData$.getValue(),
+                questionnaire: this.ds.questionnaireData$.getValue(),
+                unit: this.ds.unitData$.getValue()
+              }
+          ).subscribe((result: boolean|ServerError) => {
+            if (result instanceof ServerError) {
+              this.snackBar.open('Konnte Bericht nicht speichern.', '', {duration: 3000});
+            } else {
+              this.snackBar.open('Bericht gespeichert.', '', {duration: 3000});
             }
-        ).subscribe((result: boolean|ServerError) => {
-          if (result instanceof ServerError) {
-            this.snackBar.open('Konnte Bericht nicht speichern.', '', {duration: 3000});
-          } else {
-            this.snackBar.open('Bericht gespeichert.', '', {duration: 3000});
-          }
-        });
+          });
+        }
       }
     });
   }
diff --git a/src/app/sys-check/report/save-report/save-report.component.spec.ts b/src/app/sys-check/report/save-report/save-report.component.spec.ts
index c6331a85..e996a0b2 100644
--- a/src/app/sys-check/report/save-report/save-report.component.spec.ts
+++ b/src/app/sys-check/report/save-report/save-report.component.spec.ts
@@ -1,7 +1,10 @@
 import { SaveReportComponent } from './save-report.component';
 import { async, ComponentFixture, TestBed } from '@angular/core/testing';
 import {ReactiveFormsModule} from "@angular/forms";
-import {MatDialogModule} from "@angular/material/dialog";
+import {MatDialog, MatDialogModule} from "@angular/material/dialog";
+import {MatInputModule} from "@angular/material/input";
+import {MatFormFieldModule} from "@angular/material/form-field";
+import {NoopAnimationsModule} from "@angular/platform-browser/animations";
 
 describe('SaveReportComponent', () => {
   let component: SaveReportComponent;
@@ -10,7 +13,16 @@ describe('SaveReportComponent', () => {
   beforeEach(async(() => {
     TestBed.configureTestingModule({
       declarations: [ SaveReportComponent ],
-      imports: [ReactiveFormsModule, MatDialogModule]
+      imports: [
+        MatDialogModule,
+        ReactiveFormsModule,
+        MatInputModule,
+        MatFormFieldModule,
+        NoopAnimationsModule
+      ],
+      providers: [
+        MatDialog,
+      ]
     })
     .compileComponents();
   }));
diff --git a/src/app/sys-check/report/save-report/save-report.component.ts b/src/app/sys-check/report/save-report/save-report.component.ts
index 3c92665e..f5c5f7ed 100644
--- a/src/app/sys-check/report/save-report/save-report.component.ts
+++ b/src/app/sys-check/report/save-report/save-report.component.ts
@@ -1,22 +1,15 @@
-import { FormBuilder, FormGroup, Validators } from '@angular/forms';
-import { Component, OnInit, Inject } from '@angular/core';
-import {MAT_DIALOG_DATA} from "@angular/material/dialog";
+import { FormControl, FormGroup, Validators} from '@angular/forms';
+import { Component } from '@angular/core';
 
 @Component({
   selector: 'app-save-report',
   templateUrl: './save-report.component.html',
   styleUrls: ['./save-report.component.css']
 })
-export class SaveReportComponent implements OnInit {
-  savereportform: FormGroup;
 
-  constructor(private fb: FormBuilder,
-    @Inject(MAT_DIALOG_DATA) public data: string) { }
-
-  ngOnInit() {
-    this.savereportform = this.fb.group({
-      title: this.fb.control('', [Validators.required, Validators.minLength(3)]),
-      key: this.fb.control('', [Validators.required, Validators.minLength(3)])
-    });
-  }
+export class SaveReportComponent {
+  savereportform = new FormGroup({
+    title: new FormControl('', [Validators.required, Validators.minLength(3)]),
+    key: new FormControl('', [Validators.required, Validators.minLength(3)])
+  });
 }
diff --git a/src/app/test-controller/review-dialog/review-dialog.component.spec.ts b/src/app/test-controller/review-dialog/review-dialog.component.spec.ts
index ced09f85..6946039c 100644
--- a/src/app/test-controller/review-dialog/review-dialog.component.spec.ts
+++ b/src/app/test-controller/review-dialog/review-dialog.component.spec.ts
@@ -2,16 +2,43 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing';
 
 import { ReviewDialogComponent } from './review-dialog.component';
 import {ReactiveFormsModule} from "@angular/forms";
-import {MatDialogModule} from "@angular/material/dialog";
+import {MAT_DIALOG_DATA, MatDialog, MatDialogModule} from "@angular/material/dialog";
+import {MatRadioModule} from "@angular/material/radio";
+import {MatCheckboxModule} from "@angular/material/checkbox";
+import {MatInputModule} from "@angular/material/input";
+import {MatFormFieldModule} from "@angular/material/form-field";
+import {ReviewDialogData} from "../test-controller.interfaces";
+import {MatIconModule} from "@angular/material/icon";
+import {NoopAnimationsModule} from "@angular/platform-browser/animations";
 
 describe('ReviewDialogComponent', () => {
   let component: ReviewDialogComponent;
   let fixture: ComponentFixture<ReviewDialogComponent>;
 
+  const matDialogDataStub = <ReviewDialogData> {
+    loginname: 'loginname',
+    bookletname: 'bookletname',
+    unitDbKey: 'unitDbKey',
+    unitTitle: 'unitTitle'
+  };
+
   beforeEach(async(() => {
     TestBed.configureTestingModule({
       declarations: [ ReviewDialogComponent ],
-      imports: [ReactiveFormsModule, MatDialogModule]
+      imports: [
+        MatDialogModule,
+        ReactiveFormsModule,
+        MatRadioModule,
+        MatInputModule,
+        MatFormFieldModule,
+        MatIconModule,
+        MatCheckboxModule,
+        NoopAnimationsModule
+      ],
+      providers: [
+        MatDialog,
+        { provide: MAT_DIALOG_DATA, useValue: matDialogDataStub }
+      ]
     })
     .compileComponents();
   }));
diff --git a/src/app/test-controller/review-dialog/review-dialog.component.ts b/src/app/test-controller/review-dialog/review-dialog.component.ts
index 11ab351a..721ac804 100644
--- a/src/app/test-controller/review-dialog/review-dialog.component.ts
+++ b/src/app/test-controller/review-dialog/review-dialog.component.ts
@@ -1,27 +1,23 @@
-import { FormGroup, FormBuilder, Validators } from '@angular/forms';
+import {FormGroup, Validators, FormControl} from '@angular/forms';
 import { MAT_DIALOG_DATA } from '@angular/material/dialog';
-import { Component, OnInit, Inject } from '@angular/core';
+import { Component, Inject } from '@angular/core';
+import {ReviewDialogData} from "../test-controller.interfaces";
 
 @Component({
   templateUrl: './review-dialog.component.html'
 })
-export class ReviewDialogComponent implements OnInit {
-  reviewform: FormGroup;
+export class ReviewDialogComponent {
+  reviewform = new FormGroup({
+    target: new FormControl ('b', Validators.required),
+    priority: new FormControl('', Validators.required),
+    tech: new FormControl(''),
+    content: new FormControl(''),
+    design: new FormControl(''),
+    entry: new FormControl('', Validators.required)
+  });
 
   constructor(
-    private fb: FormBuilder,
-    @Inject(MAT_DIALOG_DATA) public data: any) { }
-
-  ngOnInit() {
-    this.reviewform = this.fb.group({
-      target: this.fb.control('b', Validators.required),
-      priority: this.fb.control('', Validators.required),
-      tech: this.fb.control(''),
-      content: this.fb.control(''),
-      design: this.fb.control(''),
-      entry: this.fb.control('', Validators.required)
-    });
-  }
+    @Inject(MAT_DIALOG_DATA) public data: ReviewDialogData) { }
 
   getCategories(): string {
     let myreturn = '';
diff --git a/src/app/test-controller/start-lock-input/start-lock-input.component.html b/src/app/test-controller/start-lock-input/start-lock-input.component.html
index f2b53dca..f9d8b6d9 100644
--- a/src/app/test-controller/start-lock-input/start-lock-input.component.html
+++ b/src/app/test-controller/start-lock-input/start-lock-input.component.html
@@ -1,18 +1,19 @@
-<form [formGroup]="startkeyform" fxLayout="column">
+<form #matform [formGroup]="startkeyform" fxLayout="column">
   <h1 mat-dialog-title>{{ data.title }}</h1>
 
   <mat-dialog-content>
     <p>{{ data.prompt }}</p>
     <mat-form-field *ngFor="let c of data.codes" fxLayout="column">
       <p>{{ c.prompt }}</p>
-      <input matInput [formControlName]="c.testletId" [(ngModel)]="c.value" (keyup.enter)="close()">
+      <input matInput [formControlName]="c.testletId" (keyup.enter)="matform.submit()">
     </mat-form-field>
   </mat-dialog-content>
 
   <mat-dialog-actions>
-    <button mat-raised-button #okButton color="primary"
-        [disabled]="startkeyform.invalid"
-        type="submit" [mat-dialog-close]="data.codes">Weiter</button>
+    <button mat-raised-button color="primary"
+            [disabled]="!startkeyform.valid"
+            type="submit"
+            [mat-dialog-close]="startkeyform">Weiter</button>
     <button mat-raised-button [mat-dialog-close]="false">Abbrechen</button>
   </mat-dialog-actions>
 </form>
diff --git a/src/app/test-controller/start-lock-input/start-lock-input.component.spec.ts b/src/app/test-controller/start-lock-input/start-lock-input.component.spec.ts
index b53a1a08..af6a17e5 100644
--- a/src/app/test-controller/start-lock-input/start-lock-input.component.spec.ts
+++ b/src/app/test-controller/start-lock-input/start-lock-input.component.spec.ts
@@ -2,16 +2,52 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing';
 
 import { StartLockInputComponent } from './start-lock-input.component';
 import {ReactiveFormsModule} from "@angular/forms";
-import {MAT_DIALOG_DATA, MatDialogModule, MatDialogRef} from "@angular/material/dialog";
+import {MAT_DIALOG_DATA, MatDialog, MatDialogModule, MatDialogRef} from "@angular/material/dialog";
+import {StartLockData} from "../test-controller.interfaces";
+import {MatInputModule} from "@angular/material/input";
+import {MatFormFieldModule} from "@angular/material/form-field";
+import {MatIconModule} from "@angular/material/icon";
+import {NoopAnimationsModule} from "@angular/platform-browser/animations";
 
 describe('StartLockInputComponent', () => {
   let component: StartLockInputComponent;
   let fixture: ComponentFixture<StartLockInputComponent>;
 
   beforeEach(async(() => {
+    const matDialogRefStub = {};
+    const matDialogDataStub = <StartLockData>{
+      title: 'title',
+      prompt: 'prompt',
+      codes: [
+        {
+          testletId: 'testletA',
+          prompt: 'promptA',
+          code: 'codeA',
+          value: 'valueA'
+        },
+        {
+          testletId: 'testletB',
+          prompt: 'promptB',
+          code: 'codeB',
+          value: 'valueB'
+        }
+      ]
+    };
     TestBed.configureTestingModule({
-      imports: [ReactiveFormsModule, MatDialogModule],
-      declarations: [ StartLockInputComponent, MatDialogRef, MAT_DIALOG_DATA ]
+      declarations: [ StartLockInputComponent ],
+      imports: [
+        MatDialogModule,
+        ReactiveFormsModule,
+        MatInputModule,
+        MatFormFieldModule,
+        MatIconModule,
+        NoopAnimationsModule
+      ],
+      providers: [
+        MatDialog,
+        { provide: MatDialogRef, useValue: matDialogRefStub },
+        { provide: MAT_DIALOG_DATA, useValue: matDialogDataStub }
+      ]
     })
     .compileComponents();
   }));
diff --git a/src/app/test-controller/start-lock-input/start-lock-input.component.ts b/src/app/test-controller/start-lock-input/start-lock-input.component.ts
index 12201962..6de789c7 100644
--- a/src/app/test-controller/start-lock-input/start-lock-input.component.ts
+++ b/src/app/test-controller/start-lock-input/start-lock-input.component.ts
@@ -1,29 +1,22 @@
-import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
-import { FormBuilder, FormGroup, Validators } from '@angular/forms';
-import { Component, OnInit, Inject } from '@angular/core';
-import { StartLockData } from '../test-controller.interfaces';
-
+import {Component, Inject} from '@angular/core';
+import {MAT_DIALOG_DATA} from '@angular/material/dialog';
+import {FormControl, FormGroup, Validators} from "@angular/forms";
+import {StartLockData} from "../test-controller.interfaces";
 
 @Component({
   templateUrl: './start-lock-input.component.html',
   styleUrls: ['./start-lock-input.component.css']
 })
-export class StartLockInputComponent implements OnInit {
+export class StartLockInputComponent {
   startkeyform: FormGroup;
 
-  constructor(private fb: FormBuilder,
-    private dialogRef: MatDialogRef<StartLockInputComponent>,
-    @Inject(MAT_DIALOG_DATA) public data: StartLockData) { }
+  constructor(
+    @Inject(MAT_DIALOG_DATA) public data: StartLockData) {
 
-  ngOnInit() {
-    const controlsConfig = {};
+    const myFormControls = {};
     this.data.codes.forEach(c => {
-      controlsConfig[c.testletId] = this.fb.control('', [Validators.required, Validators.minLength(3)]);
+      myFormControls[c.testletId] = new FormControl('', [Validators.required, Validators.minLength(3)]);
     });
-    this.startkeyform = this.fb.group(controlsConfig);
-  }
-
-  close() {
-    this.dialogRef.close(this.data.codes);
+    this.startkeyform = new FormGroup(myFormControls);
   }
 }
diff --git a/src/app/test-controller/test-controller.component.ts b/src/app/test-controller/test-controller.component.ts
index 3dde9f96..0e2c096e 100644
--- a/src/app/test-controller/test-controller.component.ts
+++ b/src/app/test-controller/test-controller.component.ts
@@ -7,7 +7,15 @@ import { BackendService } from './backend.service';
 import { TestControllerService } from './test-controller.service';
 import { Component, OnInit, OnDestroy, Inject } from '@angular/core';
 import { UnitDef, Testlet, EnvironmentData, MaxTimerData } from './test-controller.classes';
-import { LastStateKey, LogEntryKey, BookletData, UnitData, MaxTimerDataType, TaggedString } from './test-controller.interfaces';
+import {
+  LastStateKey,
+  LogEntryKey,
+  BookletData,
+  UnitData,
+  MaxTimerDataType,
+  TaggedString,
+  ReviewDialogData
+} from './test-controller.interfaces';
 import { Subscription, Observable, of, from } from 'rxjs';
 import { switchMap, concatMap } from 'rxjs/operators';
 import { CustomtextService, ServerError } from 'iqb-components';
@@ -603,7 +611,7 @@ export class TestControllerComponent implements OnInit, OnDestroy {
     } else {
       const dialogRef = this.reviewDialog.open(ReviewDialogComponent, {
         width: '700px',
-        data: {
+        data: <ReviewDialogData>{
           loginname: this.tcs.loginname,
           bookletname: this.tcs.rootTestlet.title,
           unitTitle: this.tcs.currentUnitTitle,
diff --git a/src/app/test-controller/test-controller.interfaces.ts b/src/app/test-controller/test-controller.interfaces.ts
index 18809f46..c3cf6e1e 100644
--- a/src/app/test-controller/test-controller.interfaces.ts
+++ b/src/app/test-controller/test-controller.interfaces.ts
@@ -105,3 +105,10 @@ export interface PageData {
     type: '#next' | '#previous' | '#goto';
     disabled: boolean;
 }
+
+export interface ReviewDialogData {
+  loginname: string;
+  bookletname: string;
+  unitDbKey: string;
+  unitTitle: string;
+}
diff --git a/src/app/test-controller/unithost/unit-routing-guards.ts b/src/app/test-controller/unithost/unit-routing-guards.ts
index 1e753b59..0a70ba93 100644
--- a/src/app/test-controller/unithost/unit-routing-guards.ts
+++ b/src/app/test-controller/unithost/unit-routing-guards.ts
@@ -131,10 +131,15 @@ export class UnitActivateGuard implements CanActivate {
               if ((typeof result === 'undefined') || (result === false)) {
                 return of(false);
               } else {
-                const codeData = result as CodeInputData[];
                 let codesOk = true;
-                for (const c of codeData) {
-                  if (c.value.toUpperCase().trim() !== c.code) {
+                for (const c of myCodes) {
+                  const testeeInput = result[c.testletId];
+                  if (testeeInput) {
+                    if (c.value.toUpperCase().trim() !== testeeInput.toUpperCase().trim()) {
+                      codesOk = false;
+                      break;
+                    }
+                  } else {
                     codesOk = false;
                     break;
                   }
-- 
GitLab