Merge branch 'dev' into rrt/dev

This commit is contained in:
Aaron Louie 2020-06-14 12:34:34 -04:00
commit b259b680b3
5 changed files with 39 additions and 50 deletions

View File

@ -12,15 +12,11 @@
"test:coverage": "ng test --codeCoverage=true --watch=false --browsers=ChromeHeadless", "test:coverage": "ng test --codeCoverage=true --watch=false --browsers=ChromeHeadless",
"lint": "ng lint", "lint": "ng lint",
"e2e": "./node_modules/protractor/bin/webdriver-manager update && ng e2e", "e2e": "./node_modules/protractor/bin/webdriver-manager update && ng e2e",
"e2e:with-wf": "npm run e2e-wf && ng e2e && npm run e2e-wf:stop && npm run e2e-wf:clean", "e2e:with-wf": "npm run e2e-wf && ng e2e && npm run e2e-wf:stop",
"e2e-wf:stop": "docker stop db || true && docker stop backend || true && docker stop pb || true", "e2e-wf:stop": "cd docker && docker-compose down && cd ..",
"e2e-wf:clean": "docker system prune -f && cd docker && docker-compose rm -f -v -s && cd ..", "e2e-wf:build": "cd docker && docker-compose pull && docker-compose build && cd ..",
"e2e-wf:build": "cd docker && docker-compose pull && docker-compose build --no-cache && cd ..", "e2e-wf:start": "cd docker && docker-compose up -d --force-recreate && cd ..",
"e2e-wf:start": "cd docker && docker-compose up -d && cd ..", "e2e-wf": "npm run e2e-wf:stop && npm run e2e-wf:build && npm run e2e-wf:start",
"e2e-wf:db-upgrade": "docker exec -it backend pipenv run flask db upgrade",
"e2e-wf:db-setup": "docker exec -it backend pipenv run flask load-example-data",
"e2e-wf:pb-setup": "docker exec -it pb pipenv run flask db upgrade",
"e2e-wf": "npm run e2e-wf:stop && npm run e2e-wf:clean && npm run e2e-wf:build && npm run e2e-wf:start && npm run e2e-wf:db-upgrade && npm run e2e-wf:db-setup && npm run e2e-wf:pb-setup",
"env": "chmod +x ./docker/substitute-env-variables.sh && ./docker/substitute-env-variables.sh src/index.html PRODUCTION,API_URL,IRB_URL,HOME_ROUTE,BASE_HREF,DEPLOY_URL,PORT0,GOOGLE_ANALYTICS_KEY,SENTRY_KEY,TITLE", "env": "chmod +x ./docker/substitute-env-variables.sh && ./docker/substitute-env-variables.sh src/index.html PRODUCTION,API_URL,IRB_URL,HOME_ROUTE,BASE_HREF,DEPLOY_URL,PORT0,GOOGLE_ANALYTICS_KEY,SENTRY_KEY,TITLE",
"ci": "npm run lint && npm run test:coverage && npm run env && npm run e2e:with-wf && sonar-scanner" "ci": "npm run lint && npm run test:coverage && npm run env && npm run e2e:with-wf && sonar-scanner"
}, },

View File

@ -1,5 +1,5 @@
<div class="mat-typography"> <div class="mat-typography">
<app-navbar *ngIf="isSignedIn" class="mat-elevation-z6" id="globalHeader"></app-navbar> <app-navbar></app-navbar>
<router-outlet></router-outlet> <router-outlet></router-outlet>
<app-footer></app-footer> <app-footer></app-footer>
</div> </div>

View File

@ -1,7 +0,0 @@
#globalHeader {
position: fixed;
top: 0;
left: 0;
right: 0;
z-index: 2;
}

View File

@ -1,61 +1,57 @@
import {APP_BASE_HREF} from '@angular/common'; import {APP_BASE_HREF} from '@angular/common';
import {HttpClient} from '@angular/common/http'; import {HttpClient} from '@angular/common/http';
import {HttpClientTestingModule} from '@angular/common/http/testing'; import {HttpClientTestingModule} from '@angular/common/http/testing';
import {Component} from '@angular/core';
import {async, ComponentFixture, TestBed} from '@angular/core/testing'; import {async, ComponentFixture, TestBed} from '@angular/core/testing';
import {BrowserAnimationsModule} from '@angular/platform-browser/animations'; import {MatIconModule} from '@angular/material/icon';
import {FakeMatIconRegistry} from '@angular/material/icon/testing';
import {MatMenuModule} from '@angular/material/menu';
import {RouterTestingModule} from '@angular/router/testing'; import {RouterTestingModule} from '@angular/router/testing';
import {ApiService, MockEnvironment} from 'sartography-workflow-lib'; import {ApiService, MockEnvironment} from 'sartography-workflow-lib';
import {AppComponent} from './app.component'; import {AppComponent} from './app.component';
import {FooterComponent} from './footer/footer.component';
import {NavbarComponent} from './navbar/navbar.component';
@Component({
selector: 'app-navbar',
template: ''
})
class MockNavbarComponent {
}
@Component({
selector: 'app-footer',
template: ''
})
class MockFooterComponent {
}
describe('AppComponent', () => { describe('AppComponent', () => {
let component: AppComponent; let component: AppComponent;
let fixture: ComponentFixture<AppComponent>; let fixture: ComponentFixture<AppComponent>;
const mockEnvironment = new MockEnvironment();
const mockTitle = `'Once,' said the Mock Title at last, with a deep sigh, 'I was a real Title.'`;
beforeEach(async(() => { beforeEach(async(() => {
TestBed.configureTestingModule({ TestBed.configureTestingModule({
declarations: [ declarations: [
AppComponent, AppComponent,
MockNavbarComponent, FooterComponent,
MockFooterComponent NavbarComponent,
], ],
imports: [ imports: [
HttpClientTestingModule, HttpClientTestingModule,
BrowserAnimationsModule, MatIconModule,
MatMenuModule,
RouterTestingModule, RouterTestingModule,
], ],
providers: [ providers: [
HttpClient, HttpClient,
FakeMatIconRegistry,
ApiService, ApiService,
{provide: 'APP_ENVIRONMENT', useClass: MockEnvironment}, {provide: 'APP_ENVIRONMENT', useValue: mockEnvironment},
{provide: APP_BASE_HREF, useValue: ''}, {provide: APP_BASE_HREF, useValue: ''},
], ]
}) }).compileComponents();
.compileComponents();
})); }));
beforeEach(() => { beforeEach(() => {
mockEnvironment.title = mockTitle;
fixture = TestBed.createComponent(AppComponent); fixture = TestBed.createComponent(AppComponent);
component = fixture.componentInstance; component = fixture.componentInstance;
fixture.detectChanges(); fixture.detectChanges();
}); });
it('should create', () => { it('should create the app', () => {
expect(component).toBeTruthy(); expect(component).toBeTruthy();
}); });
it(`should set the page title to match environment variable`, () => {
expect((component as any).titleService.getTitle()).toEqual(mockTitle);
});
}); });

View File

@ -1,5 +1,7 @@
import {Component, Inject} from '@angular/core'; import {Component, Inject} from '@angular/core';
import {ApiService, AppEnvironment, GoogleAnalyticsService} from 'sartography-workflow-lib'; import {MatIconRegistry} from '@angular/material/icon';
import {DomSanitizer, Title} from '@angular/platform-browser';
import {AppEnvironment, FileType, GoogleAnalyticsService} from 'sartography-workflow-lib';
@Component({ @Component({
selector: 'app-root', selector: 'app-root',
@ -7,17 +9,19 @@ import {ApiService, AppEnvironment, GoogleAnalyticsService} from 'sartography-wo
styleUrls: ['./app.component.scss'] styleUrls: ['./app.component.scss']
}) })
export class AppComponent { export class AppComponent {
title = 'CR Connect Configuration';
constructor( constructor(
@Inject('APP_ENVIRONMENT') private environment: AppEnvironment, @Inject('APP_ENVIRONMENT') private environment: AppEnvironment,
private apiService: ApiService, private titleService: Title,
private matIconRegistry: MatIconRegistry,
private domSanitizer: DomSanitizer,
private googleAnalyticsService: GoogleAnalyticsService, private googleAnalyticsService: GoogleAnalyticsService,
) { ) {
this.googleAnalyticsService.init(this.environment.googleAnalyticsKey); this.googleAnalyticsService.init(this.environment.googleAnalyticsKey);
} const fileTypes = Object.values(FileType);
fileTypes.forEach(t => {
get isSignedIn() { const url = this.domSanitizer.bypassSecurityTrustResourceUrl(`assets/icons/file_types/${t}.svg`)
return this.apiService.isSignedIn(); this.matIconRegistry.addSvgIconInNamespace('crc', t, url);
});
this.titleService.setTitle(this.environment.title);
} }
} }