diff --git a/src/app/_dialogs/open-file-dialog/open-file-dialog.component.spec.ts b/src/app/_dialogs/open-file-dialog/open-file-dialog.component.spec.ts index 9ccc7fc..610baa1 100644 --- a/src/app/_dialogs/open-file-dialog/open-file-dialog.component.spec.ts +++ b/src/app/_dialogs/open-file-dialog/open-file-dialog.component.spec.ts @@ -1,3 +1,4 @@ +import {APP_BASE_HREF} from '@angular/common'; import {HttpClientTestingModule, HttpTestingController} from '@angular/common/http/testing'; import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import {FormsModule, ReactiveFormsModule} from '@angular/forms'; @@ -37,6 +38,7 @@ describe('OpenFileDialogComponent', () => { providers: [ ApiService, {provide: 'APP_ENVIRONMENT', useClass: MockEnvironment}, + {provide: APP_BASE_HREF, useValue: ''}, { provide: MatDialogRef, useValue: { diff --git a/src/app/_dialogs/workflow-spec-dialog/workflow-spec-dialog.component.spec.ts b/src/app/_dialogs/workflow-spec-dialog/workflow-spec-dialog.component.spec.ts index 4be8eec..278e443 100644 --- a/src/app/_dialogs/workflow-spec-dialog/workflow-spec-dialog.component.spec.ts +++ b/src/app/_dialogs/workflow-spec-dialog/workflow-spec-dialog.component.spec.ts @@ -1,5 +1,6 @@ +import {APP_BASE_HREF} from '@angular/common'; import {HttpClientTestingModule, HttpTestingController} from '@angular/common/http/testing'; -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +import {async, ComponentFixture, TestBed} from '@angular/core/testing'; import {FormsModule, ReactiveFormsModule} from '@angular/forms'; import {MAT_DIALOG_DATA, MatDialog, MatDialogModule, MatDialogRef} from '@angular/material/dialog'; import {MatFormFieldModule} from '@angular/material/form-field'; @@ -13,7 +14,7 @@ import {FormlyMaterialModule} from '@ngx-formly/material'; import {ApiService, MockEnvironment, mockWorkflowSpec0, mockWorkflowSpecCategories} from 'sartography-workflow-lib'; import {WorkflowSpecDialogData} from '../../_interfaces/dialog-data'; -import { WorkflowSpecDialogComponent } from './workflow-spec-dialog.component'; +import {WorkflowSpecDialogComponent} from './workflow-spec-dialog.component'; describe('WorkflowSpecDialogComponent', () => { let httpMock: HttpTestingController; @@ -37,10 +38,11 @@ describe('WorkflowSpecDialogComponent', () => { ReactiveFormsModule, RouterTestingModule, ], - declarations: [ WorkflowSpecDialogComponent ], + declarations: [WorkflowSpecDialogComponent], providers: [ ApiService, {provide: 'APP_ENVIRONMENT', useClass: MockEnvironment}, + {provide: APP_BASE_HREF, useValue: ''}, { provide: MatDialogRef, useValue: { @@ -59,7 +61,7 @@ describe('WorkflowSpecDialogComponent', () => { {provide: Router, useValue: mockRouter}, ] }) - .compileComponents(); + .compileComponents(); })); beforeEach(() => { diff --git a/src/app/app-routing.module.ts b/src/app/app-routing.module.ts index 7c1e144..91c5558 100644 --- a/src/app/app-routing.module.ts +++ b/src/app/app-routing.module.ts @@ -7,8 +7,6 @@ import {HomeComponent} from './home/home.component'; import {ModelerComponent} from './modeler/modeler.component'; import {ProtocolBuilderComponent} from './protocol-builder/protocol-builder.component'; import {ReferenceFilesComponent} from './reference-files/reference-files.component'; -import {SignInComponent} from './sign-in/sign-in.component'; -import {SignOutComponent} from './sign-out/sign-out.component'; @Injectable() export class ThisEnvironment implements AppEnvironment { @@ -16,7 +14,6 @@ export class ThisEnvironment implements AppEnvironment { production = environment.production; api = environment.api; irbUrl = environment.irbUrl; - baseHref = environment.baseHref; } const routes: Routes = [ @@ -45,14 +42,6 @@ const routes: Routes = [ path: 'modeler/:workflowSpecId/:fileMetaId', component: ModelerComponent }, - { - path: 'sign-in', - component: SignInComponent - }, - { - path: 'sign-out', - component: SignOutComponent - }, { path: 'session/:token', component: SessionRedirectComponent diff --git a/src/app/app.component.spec.ts b/src/app/app.component.spec.ts index 8a70483..e619fbd 100644 --- a/src/app/app.component.spec.ts +++ b/src/app/app.component.spec.ts @@ -1,3 +1,4 @@ +import {APP_BASE_HREF} from '@angular/common'; import {HttpClient} from '@angular/common/http'; import {HttpClientTestingModule} from '@angular/common/http/testing'; import {Component} from '@angular/core'; @@ -42,6 +43,7 @@ describe('AppComponent', () => { HttpClient, ApiService, {provide: 'APP_ENVIRONMENT', useClass: MockEnvironment}, + {provide: APP_BASE_HREF, useValue: ''}, ], }) .compileComponents(); diff --git a/src/app/app.module.ts b/src/app/app.module.ts index c320af8..4facb4a 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -49,8 +49,6 @@ import {ModelerComponent} from './modeler/modeler.component'; import {NavbarComponent} from './navbar/navbar.component'; import {ProtocolBuilderComponent} from './protocol-builder/protocol-builder.component'; import {ReferenceFilesComponent} from './reference-files/reference-files.component'; -import {SignInComponent} from './sign-in/sign-in.component'; -import {SignOutComponent} from './sign-out/sign-out.component'; import {WorkflowSpecCardComponent} from './workflow-spec-card/workflow-spec-card.component'; import {WorkflowSpecListComponent} from './workflow-spec-list/workflow-spec-list.component'; @@ -60,7 +58,6 @@ export class ThisEnvironment implements AppEnvironment { production = environment.production; api = environment.api; irbUrl = environment.irbUrl; - baseHref = environment.baseHref; } /** @@ -93,8 +90,6 @@ export function getBaseHref(platformLocation: PlatformLocation): string { NavbarComponent, NewFileDialogComponent, OpenFileDialogComponent, - SignInComponent, - SignOutComponent, WorkflowSpecCategoryDialogComponent, WorkflowSpecDialogComponent, WorkflowSpecListComponent, @@ -145,11 +140,9 @@ export function getBaseHref(platformLocation: PlatformLocation): string { providers: [ {provide: MAT_FORM_FIELD_DEFAULT_OPTIONS, useValue: {appearance: 'outline'}}, {provide: 'APP_ENVIRONMENT', useClass: ThisEnvironment}, - // {provide: APP_BASE_HREF, useValue: environment.baseHref}, {provide: HTTP_INTERCEPTORS, useClass: AuthInterceptor, multi: true}, {provide: HTTP_INTERCEPTORS, useClass: ErrorInterceptor, multi: true}, - {provide: APP_BASE_HREF, useFactory: getBaseHref, deps: [PlatformLocation] - } + {provide: APP_BASE_HREF, useFactory: getBaseHref, deps: [PlatformLocation]} ] }) export class AppModule { diff --git a/src/app/diagram/diagram.component.spec.ts b/src/app/diagram/diagram.component.spec.ts index 2937bde..6db23ff 100644 --- a/src/app/diagram/diagram.component.spec.ts +++ b/src/app/diagram/diagram.component.spec.ts @@ -1,3 +1,4 @@ +import {APP_BASE_HREF} from '@angular/common'; import {HttpClientTestingModule, HttpTestingController} from '@angular/common/http/testing'; import {DebugNode} from '@angular/core'; import {async, ComponentFixture, TestBed} from '@angular/core/testing'; @@ -31,6 +32,7 @@ describe('DiagramComponent', () => { providers: [ ApiService, {provide: 'APP_ENVIRONMENT', useClass: MockEnvironment}, + {provide: APP_BASE_HREF, useValue: ''}, {provide: Router, useValue: mockRouter}, ] }); diff --git a/src/app/file-list/file-list.component.spec.ts b/src/app/file-list/file-list.component.spec.ts index 902d47a..f67e6c5 100644 --- a/src/app/file-list/file-list.component.spec.ts +++ b/src/app/file-list/file-list.component.spec.ts @@ -1,3 +1,4 @@ +import {APP_BASE_HREF} from '@angular/common'; import {HttpHeaders} from '@angular/common/http'; import {HttpClientTestingModule, HttpTestingController} from '@angular/common/http/testing'; import {async, ComponentFixture, TestBed} from '@angular/core/testing'; @@ -8,6 +9,7 @@ import {MatSnackBarModule} from '@angular/material/snack-bar'; import {BrowserDynamicTestingModule} from '@angular/platform-browser-dynamic/testing'; import {BrowserAnimationsModule} from '@angular/platform-browser/animations'; import {RouterTestingModule} from '@angular/router/testing'; +import createClone from 'rfdc'; import {of} from 'rxjs'; import { ApiService, @@ -22,7 +24,6 @@ import {DeleteFileDialogComponent} from '../_dialogs/delete-file-dialog/delete-f import {DeleteFileDialogData} from '../_interfaces/dialog-data'; import {GetIconCodePipe} from '../_pipes/get-icon-code.pipe'; import {FileListComponent} from './file-list.component'; -import createClone from 'rfdc'; describe('FileListComponent', () => { @@ -49,6 +50,7 @@ describe('FileListComponent', () => { providers: [ ApiService, {provide: 'APP_ENVIRONMENT', useClass: MockEnvironment}, + {provide: APP_BASE_HREF, useValue: ''}, { provide: MatDialogRef, useValue: { diff --git a/src/app/home/home.component.spec.ts b/src/app/home/home.component.spec.ts index 2a42f0b..35e50b9 100644 --- a/src/app/home/home.component.spec.ts +++ b/src/app/home/home.component.spec.ts @@ -1,3 +1,4 @@ +import {APP_BASE_HREF} from '@angular/common'; import {HttpClient} from '@angular/common/http'; import {HttpClientTestingModule} from '@angular/common/http/testing'; import {Component} from '@angular/core'; @@ -43,6 +44,7 @@ describe('HomeComponent', () => { HttpClient, ApiService, {provide: 'APP_ENVIRONMENT', useClass: MockEnvironment}, + {provide: APP_BASE_HREF, useValue: ''}, {provide: Router, useValue: mockRouter}, ] }) diff --git a/src/app/modeler/modeler.component.spec.ts b/src/app/modeler/modeler.component.spec.ts index 3ea2904..dafe1a9 100644 --- a/src/app/modeler/modeler.component.spec.ts +++ b/src/app/modeler/modeler.component.spec.ts @@ -1,3 +1,4 @@ +import {APP_BASE_HREF} from '@angular/common'; import {HttpErrorResponse, HttpHeaders, HttpResponse} from '@angular/common/http'; import {HttpClientTestingModule, HttpTestingController} from '@angular/common/http/testing'; import {DebugNode} from '@angular/core'; @@ -75,6 +76,7 @@ describe('ModelerComponent', () => { providers: [ ApiService, {provide: 'APP_ENVIRONMENT', useClass: MockEnvironment}, + {provide: APP_BASE_HREF, useValue: ''}, { provide: MatDialogRef, useValue: { diff --git a/src/app/navbar/navbar.component.spec.ts b/src/app/navbar/navbar.component.spec.ts index 0a3b679..8898ab5 100644 --- a/src/app/navbar/navbar.component.spec.ts +++ b/src/app/navbar/navbar.component.spec.ts @@ -1,3 +1,4 @@ +import {APP_BASE_HREF} from '@angular/common'; import {HttpClientTestingModule, HttpTestingController} from '@angular/common/http/testing'; import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import {MatIconModule} from '@angular/material/icon'; @@ -32,6 +33,7 @@ describe('NavbarComponent', () => { useValue: mockRouter }, {provide: 'APP_ENVIRONMENT', useClass: MockEnvironment}, + {provide: APP_BASE_HREF, useValue: ''}, ], }) .compileComponents(); diff --git a/src/app/reference-files/reference-files.component.spec.ts b/src/app/reference-files/reference-files.component.spec.ts index e65b11d..1f5c6f0 100644 --- a/src/app/reference-files/reference-files.component.spec.ts +++ b/src/app/reference-files/reference-files.component.spec.ts @@ -1,6 +1,7 @@ +import {APP_BASE_HREF} from '@angular/common'; import {HttpHeaders} from '@angular/common/http'; import {HttpClientTestingModule, HttpTestingController} from '@angular/common/http/testing'; -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +import {async, ComponentFixture, TestBed} from '@angular/core/testing'; import {MAT_DIALOG_DATA, MatDialogModule, MatDialogRef} from '@angular/material/dialog'; import {MatIconModule} from '@angular/material/icon'; import {MatSnackBarModule} from '@angular/material/snack-bar'; @@ -8,12 +9,12 @@ import {BrowserDynamicTestingModule} from '@angular/platform-browser-dynamic/tes import {BrowserAnimationsModule} from '@angular/platform-browser/animations'; import {Router} from '@angular/router'; import {RouterTestingModule} from '@angular/router/testing'; +import * as FileSaver from 'file-saver'; +import createClone from 'rfdc'; import {of} from 'rxjs'; import {ApiService, FileMeta, FileType, MockEnvironment, mockFileMetaReference0} from 'sartography-workflow-lib'; import {OpenFileDialogComponent} from '../_dialogs/open-file-dialog/open-file-dialog.component'; -import * as FileSaver from 'file-saver'; -import { ReferenceFilesComponent } from './reference-files.component'; -import createClone from 'rfdc'; +import {ReferenceFilesComponent} from './reference-files.component'; describe('ReferenceFilesComponent', () => { let httpMock: HttpTestingController; @@ -53,6 +54,7 @@ describe('ReferenceFilesComponent', () => { providers: [ ApiService, {provide: 'APP_ENVIRONMENT', useClass: MockEnvironment}, + {provide: APP_BASE_HREF, useValue: ''}, { provide: MatDialogRef, useValue: { @@ -70,7 +72,7 @@ describe('ReferenceFilesComponent', () => { ] } }) - .compileComponents(); + .compileComponents(); })); beforeEach(() => { @@ -96,7 +98,12 @@ describe('ReferenceFilesComponent', () => { it('should update existing file from file dialog', () => { const openDialogSpy = spyOn(component.dialog, 'open') - .and.returnValue({afterClosed: () => of({fileMetaId: mockFileMetaReference0.id, file: mockFileMetaReference0.file})} as any); + .and.returnValue({ + afterClosed: () => of({ + fileMetaId: mockFileMetaReference0.id, + file: mockFileMetaReference0.file + }) + } as any); const _loadReferenceFilesSpy = spyOn((component as any), '_loadReferenceFiles').and.stub(); component.openFileDialog(mockFileMetaReference0); diff --git a/src/app/sign-in/sign-in.component.html b/src/app/sign-in/sign-in.component.html deleted file mode 100644 index 427ead6..0000000 --- a/src/app/sign-in/sign-in.component.html +++ /dev/null @@ -1,15 +0,0 @@ -
-

Fake UVA NetBadge Sign In (for testing only)

- - {{error}} - - -
diff --git a/src/app/sign-in/sign-in.component.scss b/src/app/sign-in/sign-in.component.scss deleted file mode 100644 index 4b95763..0000000 --- a/src/app/sign-in/sign-in.component.scss +++ /dev/null @@ -1,9 +0,0 @@ -form { - min-width: 150px; - max-width: 500px; - width: 100%; -} - -.full-width { - width: 100%; -} diff --git a/src/app/sign-in/sign-in.component.spec.ts b/src/app/sign-in/sign-in.component.spec.ts deleted file mode 100644 index 2e39e7c..0000000 --- a/src/app/sign-in/sign-in.component.spec.ts +++ /dev/null @@ -1,100 +0,0 @@ -import {HttpClientTestingModule, HttpTestingController} from '@angular/common/http/testing'; -import {async, ComponentFixture, TestBed} from '@angular/core/testing'; -import {FormsModule} from '@angular/forms'; -import {MatFormFieldModule} from '@angular/material/form-field'; -import {MatInputModule} from '@angular/material/input'; -import {BrowserAnimationsModule, NoopAnimationsModule} from '@angular/platform-browser/animations'; -import {ActivatedRoute, convertToParamMap, Router} from '@angular/router'; -import {RouterTestingModule} from '@angular/router/testing'; -import {FormlyModule} from '@ngx-formly/core'; -import {FormlyMaterialModule} from '@ngx-formly/material'; -import {of} from 'rxjs'; -import {ApiService, MockEnvironment, mockUser} from 'sartography-workflow-lib'; -import {EmailValidator, EmailValidatorMessage} from '../_forms/validators/formly.validator'; -import {SignInComponent} from './sign-in.component'; - -describe('SignInComponent', () => { - let component: SignInComponent; - let fixture: ComponentFixture; - let httpMock: HttpTestingController; - const mockRouter = {navigate: jasmine.createSpy('navigate')}; - - beforeEach(async(() => { - TestBed.configureTestingModule({ - declarations: [SignInComponent], - imports: [ - BrowserAnimationsModule, - FormlyModule.forRoot({ - validators: [ - {name: 'email', validation: EmailValidator}, - ], - validationMessages: [ - {name: 'email', message: EmailValidatorMessage}, - ], - }), - FormlyMaterialModule, - HttpClientTestingModule, - FormsModule, - MatFormFieldModule, - MatInputModule, - NoopAnimationsModule, - RouterTestingModule, - ], - providers: [ - ApiService, - { - provide: ActivatedRoute, - useValue: {paramMap: of(convertToParamMap({study_id: '0', workflow_id: '0', task_id: '0'}))} - }, - { - provide: Router, - useValue: mockRouter - }, - {provide: 'APP_ENVIRONMENT', useClass: MockEnvironment}, - ], - - }) - .compileComponents(); - })); - - beforeEach(() => { - httpMock = TestBed.inject(HttpTestingController); - fixture = TestBed.createComponent(SignInComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); - - afterEach(() => { - httpMock.verify(); - fixture.destroy(); - }); - - it('should create', () => { - expect(component).toBeTruthy(); - }); - - it('should fake sign in during testing', () => { - const redirectToLoginSpy = spyOn((component as any).api, 'redirectToLogin').and.stub(); - (component as any).environment.production = false; - component.model = mockUser; - component.signIn(); - expect(redirectToLoginSpy).toHaveBeenCalledWith(jasmine.any(String), mockUser); - expect(component.error).toBeUndefined(); - }); - - it('should display an error if sign in is called on production', () => { - const redirectToLoginSpy = spyOn((component as any).api, 'redirectToLogin').and.stub(); - (component as any).environment.production = true; - component.signIn(); - expect(redirectToLoginSpy).not.toHaveBeenCalled(); - expect(component.error).toBeTruthy(); - }); - - it('should verify the user and redirect to home page on production', () => { - const getUserSpy = spyOn((component as any).api, 'getUser').and.returnValue(of(mockUser)); - (component as any).environment.production = true; - (component as any)._redirectOnProduction(); - expect(getUserSpy).toHaveBeenCalled(); - expect(mockRouter.navigate).toHaveBeenCalledWith(['/']); - }); -}); diff --git a/src/app/sign-in/sign-in.component.ts b/src/app/sign-in/sign-in.component.ts deleted file mode 100644 index 020e3de..0000000 --- a/src/app/sign-in/sign-in.component.ts +++ /dev/null @@ -1,90 +0,0 @@ -import {PlatformLocation} from '@angular/common'; -import {Component, Inject, OnInit} from '@angular/core'; -import {FormGroup} from '@angular/forms'; -import {Router} from '@angular/router'; -import {FormlyFieldConfig} from '@ngx-formly/core'; -import {ApiService, AppEnvironment, User} from 'sartography-workflow-lib'; - -@Component({ - selector: 'app-sign-in', - templateUrl: './sign-in.component.html', - styleUrls: ['./sign-in.component.scss'] -}) -export class SignInComponent implements OnInit { - form = new FormGroup({}); - model: any = {}; - fields: FormlyFieldConfig[] = [ - { - key: 'uid', - type: 'input', - defaultValue: 'czn1z', - templateOptions: { - required: true, - label: 'UVA Computing ID', - }, - }, - { - key: 'email_address', - type: 'input', - defaultValue: 'czn1z@virginia.edu', - templateOptions: { - required: true, - type: 'email', - label: 'UVA Email Address', - }, - validators: {validation: ['email']}, - }, - { - key: 'first_name', - type: 'input', - defaultValue: 'Addison', - templateOptions: { - label: 'First Name', - }, - }, - { - key: 'last_name', - type: 'input', - defaultValue: 'Minh', - templateOptions: { - label: 'First Name', - }, - }, - ]; - error: Error; - - - constructor( - @Inject('APP_ENVIRONMENT') private environment: AppEnvironment, - private router: Router, - private api: ApiService - ) { - } - - ngOnInit() { - this._redirectOnProduction(); - } - - signIn() { - this.error = undefined; - localStorage.removeItem('token'); - - // For testing purposes, create a user to simulate login. - this.api.redirectToLogin(); - } - - // If this is production, verify the user and redirect to home page. - private _redirectOnProduction() { - if (this.environment.production) { - this.api.getUser().subscribe((user: User) => { - this.router.navigate(['/']); - }, e => { - this.error = e; - localStorage.removeItem('token'); - this.router.navigate(['/']); - }); - } else { - localStorage.removeItem('token'); - } - } -} diff --git a/src/app/sign-out/sign-out.component.html b/src/app/sign-out/sign-out.component.html deleted file mode 100644 index dcec1dc..0000000 --- a/src/app/sign-out/sign-out.component.html +++ /dev/null @@ -1,7 +0,0 @@ -
-

You have been signed out.

- -
diff --git a/src/app/sign-out/sign-out.component.scss b/src/app/sign-out/sign-out.component.scss deleted file mode 100644 index e69de29..0000000 diff --git a/src/app/sign-out/sign-out.component.spec.ts b/src/app/sign-out/sign-out.component.spec.ts deleted file mode 100644 index aa7a885..0000000 --- a/src/app/sign-out/sign-out.component.spec.ts +++ /dev/null @@ -1,49 +0,0 @@ -import {HttpClientTestingModule, HttpTestingController} from '@angular/common/http/testing'; -import {async, ComponentFixture, TestBed} from '@angular/core/testing'; -import {RouterTestingModule} from '@angular/router/testing'; -import {ApiService, MockEnvironment} from 'sartography-workflow-lib'; - -import {SignOutComponent} from './sign-out.component'; - -describe('SignOutComponent', () => { - let component: SignOutComponent; - let fixture: ComponentFixture; - let httpMock: HttpTestingController; - - beforeEach(async(() => { - TestBed.configureTestingModule({ - declarations: [SignOutComponent], - imports: [ - HttpClientTestingModule, - RouterTestingModule, - ], - providers: [ - ApiService, - {provide: 'APP_ENVIRONMENT', useClass: MockEnvironment}, - ], - }) - .compileComponents(); - })); - - beforeEach(() => { - httpMock = TestBed.inject(HttpTestingController); - fixture = TestBed.createComponent(SignOutComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); - - afterEach(() => { - httpMock.verify(); - fixture.destroy(); - }); - - it('should create', () => { - expect(component).toBeTruthy(); - }); - - it('should go home', () => { - const openUrlSpy = spyOn((component as any).api, 'openUrl').and.stub(); - component.goHome(); - expect(openUrlSpy).toHaveBeenCalledWith('/'); - }); -}); diff --git a/src/app/sign-out/sign-out.component.ts b/src/app/sign-out/sign-out.component.ts deleted file mode 100644 index ee8971b..0000000 --- a/src/app/sign-out/sign-out.component.ts +++ /dev/null @@ -1,22 +0,0 @@ -import {Component, OnInit} from '@angular/core'; -import {ApiService} from 'sartography-workflow-lib'; -import {Router} from '@angular/router'; - -@Component({ - selector: 'app-sign-out', - templateUrl: './sign-out.component.html', - styleUrls: ['./sign-out.component.scss'] -}) -export class SignOutComponent implements OnInit { - - constructor(private api: ApiService, private router: Router) { - localStorage.removeItem('token'); - } - - ngOnInit() { - } - - goHome() { - this.router.navigate(['/']); - } -} diff --git a/src/app/workflow-spec-card/workflow-spec-card.component.spec.ts b/src/app/workflow-spec-card/workflow-spec-card.component.spec.ts index a28ca65..f8d9047 100644 --- a/src/app/workflow-spec-card/workflow-spec-card.component.spec.ts +++ b/src/app/workflow-spec-card/workflow-spec-card.component.spec.ts @@ -1,3 +1,4 @@ +import {APP_BASE_HREF} from '@angular/common'; import {HttpClientTestingModule} from '@angular/common/http/testing'; import {async, ComponentFixture, TestBed} from '@angular/core/testing'; import {MatCardModule} from '@angular/material/card'; @@ -34,6 +35,7 @@ describe('WorkflowSpecCardComponent', () => { providers: [ ApiService, {provide: 'APP_ENVIRONMENT', useClass: MockEnvironment}, + {provide: APP_BASE_HREF, useValue: ''}, { provide: MatDialogRef, useValue: { diff --git a/src/app/workflow-spec-list/workflow-spec-list.component.spec.ts b/src/app/workflow-spec-list/workflow-spec-list.component.spec.ts index 0424769..fd65069 100644 --- a/src/app/workflow-spec-list/workflow-spec-list.component.spec.ts +++ b/src/app/workflow-spec-list/workflow-spec-list.component.spec.ts @@ -1,3 +1,4 @@ +import {APP_BASE_HREF} from '@angular/common'; import {HttpClientTestingModule, HttpTestingController} from '@angular/common/http/testing'; import {async, ComponentFixture, TestBed} from '@angular/core/testing'; import {MAT_BOTTOM_SHEET_DATA, MatBottomSheetModule, MatBottomSheetRef} from '@angular/material/bottom-sheet'; @@ -15,11 +16,14 @@ import { ApiService, MockEnvironment, mockWorkflowSpec0, - mockWorkflowSpec1, mockWorkflowSpec2, + mockWorkflowSpec1, + mockWorkflowSpec2, mockWorkflowSpecCategories, mockWorkflowSpecCategory0, - mockWorkflowSpecCategory1, mockWorkflowSpecCategory2, - mockWorkflowSpecs, moveArrayElementUp, WorkflowSpec, WorkflowSpecCategory + mockWorkflowSpecCategory1, + mockWorkflowSpecCategory2, + mockWorkflowSpecs, + WorkflowSpec } from 'sartography-workflow-lib'; import {ApiError} from 'sartography-workflow-lib/lib/types/api'; import {DeleteWorkflowSpecDialogComponent} from '../_dialogs/delete-workflow-spec-dialog/delete-workflow-spec-dialog.component'; @@ -32,7 +36,7 @@ import { import {GetIconCodePipe} from '../_pipes/get-icon-code.pipe'; import {ApiErrorsComponent} from '../api-errors/api-errors.component'; import {FileListComponent} from '../file-list/file-list.component'; -import {WorkflowSpecCategoryGroup, WorkflowSpecListComponent} from './workflow-spec-list.component'; +import {WorkflowSpecListComponent} from './workflow-spec-list.component'; describe('WorkflowSpecListComponent', () => { let httpMock: HttpTestingController; @@ -62,6 +66,7 @@ describe('WorkflowSpecListComponent', () => { providers: [ ApiService, {provide: 'APP_ENVIRONMENT', useClass: MockEnvironment}, + {provide: APP_BASE_HREF, useValue: ''}, { provide: MatDialogRef, useValue: { @@ -366,7 +371,7 @@ describe('WorkflowSpecListComponent', () => { const snackBarSpy = spyOn((component as any).snackBar, 'open').and.stub(); const moveUpSpy = spyOn(component, 'moveUp').and.callThrough(); const moveDownSpy = spyOn(component, 'moveDown').and.callThrough(); - const expectedCatsAfter = [ mockWorkflowSpecCategory1, mockWorkflowSpecCategory0, mockWorkflowSpecCategory2 ]; + const expectedCatsAfter = [mockWorkflowSpecCategory1, mockWorkflowSpecCategory0, mockWorkflowSpecCategory2]; expect((component as any)._reorder(99, 1, mockWorkflowSpecCategories)).toEqual([]); expect(snackBarSpy).toHaveBeenCalled(); diff --git a/src/environments/environment.runtime.ts b/src/environments/environment.runtime.ts index d661f74..17a3a9f 100644 --- a/src/environments/environment.runtime.ts +++ b/src/environments/environment.runtime.ts @@ -9,5 +9,4 @@ export const environment: AppEnvironment = { production: _has(ENV, 'production', '$PRODUCTION') ? (ENV.production === 'true') : false, api: _has(ENV, 'api', '$API_URL') ? ENV.api : 'http://localhost:5000/v1.0', irbUrl: _has(ENV, 'irbUrl', '$IRB_URL') ? ENV.irbUrl : 'http://localhost:5001', - baseHref: _has(ENV, 'baseHref', '$BASE_HREF') ? ENV.baseHref : '/', }; diff --git a/src/environments/environment.spec.ts b/src/environments/environment.spec.ts index b281892..f5ffbe4 100644 --- a/src/environments/environment.spec.ts +++ b/src/environments/environment.spec.ts @@ -10,7 +10,6 @@ describe('Environments', () => { expect(environment.api).toEqual('apiRoot'); expect(environment.irbUrl).toEqual('irbUrl'); expect(environment.homeRoute).toEqual('home'); - expect(environment.baseHref).toEqual('/'); }); it('should check if environment variables are defined', () => { @@ -19,37 +18,31 @@ describe('Environments', () => { production: '$PRODUCTION', api: '$API_URL', irbUrl: '$IRB_URL', - baseHref: '$BASE_HREF', }; expect(_has(env, 'homeRoute', '$HOME_ROUTE')).toBeFalse(); expect(_has(env, 'production', '$PRODUCTION')).toBeFalse(); expect(_has(env, 'api', '$API_URL')).toBeFalse(); expect(_has(env, 'irbUrl', '$IRB_URL')).toBeFalse(); - expect(_has(env, 'baseHref', '$BASE_HREF')).toBeFalse(); env.homeRoute = undefined; env.production = undefined; env.api = undefined; env.irbUrl = undefined; - env.baseHref = undefined; expect(_has(env, 'homeRoute', '$HOME_ROUTE')).toBeFalse(); expect(_has(env, 'production', '$PRODUCTION')).toBeFalse(); expect(_has(env, 'api', '$API_URL')).toBeFalse(); expect(_has(env, 'irbUrl', '$IRB_URL')).toBeFalse(); - expect(_has(env, 'baseHref', '$BASE_HREF')).toBeFalse(); env.homeRoute = 'something'; env.production = 'something'; env.api = 'something'; env.irbUrl = 'something'; - env.baseHref = 'something'; expect(_has(env, 'homeRoute', '$HOME_ROUTE')).toBeTrue(); expect(_has(env, 'production', '$PRODUCTION')).toBeTrue(); expect(_has(env, 'api', '$API_URL')).toBeTrue(); expect(_has(env, 'irbUrl', '$IRB_URL')).toBeTrue(); - expect(_has(env, 'baseHref', '$BASE_HREF')).toBeTrue(); }); });