[ACA-3317] Split About component into smaller components (#5708)

This commit is contained in:
davidcanonieto
2020-05-18 09:39:58 +01:00
committed by GitHub
parent 22acd3f6e6
commit 1def8000f0
11 changed files with 142 additions and 59 deletions

View File

@@ -1,9 +1,8 @@
<div class="adf-github-link-container">
<h1 data-automation-id="adf-github-app-title">{{ application }}</h1>
<div>
<h3 data-automation-id="adf-github-source-code-title">{{ 'ABOUT.SOURCE_CODE.TITLE' | translate }}</h3>
<mat-card>
<h3 data-automation-id="adf-github-app-title">{{application}}</h3>
<p *ngIf="version" data-automation-id="adf-github-version">{{ 'ABOUT.VERSION' | translate }}: {{ version }}</p>
<div *ngIf="url">
@@ -14,15 +13,4 @@
</div>
</mat-card>
</div>
<h3 data-automation-id="adf-about-setting-title">{{ 'ABOUT.SERVER_SETTINGS.TITLE' | translate }}</h3>
<small>{{ 'ABOUT.SERVER_SETTINGS.DESCRIPTION' | translate }}</small>
<mat-card>
<p data-automation-id="adf-process-service-host">
{{ 'ABOUT.SERVER_SETTINGS.PROCESS_SERVICE_HOST' | translate: {value: bpmHost} }}
</p>
<p data-automation-id="adf-content-service-host">
{{ 'ABOUT.SERVER_SETTINGS.CONTENT_SERVICE_HOST' | translate: {value: ecmHost} }}
</p>
</mat-card>
</div>

View File

@@ -19,13 +19,11 @@ import { ComponentFixture, TestBed } from '@angular/core/testing';
import { CoreTestingModule } from '../../testing/core.testing.module';
import { setupTestBed } from '../../testing/setup-test-bed';
import { AboutGithubLinkComponent } from './about-github-link.component';
import { AppConfigService } from '../../app-config/app-config.service';
import { aboutGithubDetails } from '../about.mock';
describe('AboutGithubLinkComponent', () => {
let fixture: ComponentFixture<AboutGithubLinkComponent>;
let component: AboutGithubLinkComponent;
let appConfigService: AppConfigService;
setupTestBed({
imports: [CoreTestingModule]
@@ -34,14 +32,6 @@ describe('AboutGithubLinkComponent', () => {
beforeEach(() => {
fixture = TestBed.createComponent(AboutGithubLinkComponent);
component = fixture.componentInstance;
appConfigService = TestBed.get(AppConfigService);
appConfigService.config = Object.assign(appConfigService.config, {
'ecmHost': aboutGithubDetails.ecmHost,
'bpmHost': aboutGithubDetails.bpmHost,
'application': {
'name': aboutGithubDetails.appName
}
});
fixture.detectChanges();
});
@@ -49,7 +39,10 @@ describe('AboutGithubLinkComponent', () => {
fixture.destroy();
});
it('Should fetch appName for app.config and display as title', () => {
it('Should fetch appName for app.config and display as title', async () => {
component.application = 'mock-application-name';
fixture.detectChanges();
await fixture.whenStable();
const titleElement = fixture.nativeElement.querySelector('[data-automation-id="adf-github-app-title"]');
expect(titleElement === null).toBeFalsy();
expect(titleElement.innerText).toEqual('mock-application-name');
@@ -77,11 +70,4 @@ describe('AboutGithubLinkComponent', () => {
const githubUrl = fixture.nativeElement.querySelector('[data-automation-id="adf-github-url"]');
expect(githubUrl.innerText).toEqual(aboutGithubDetails.url);
});
it('should fetch process and content hosts from the app.config.json file', async() => {
await fixture.whenStable();
expect(component.application).toEqual(aboutGithubDetails.appName);
expect(component.bpmHost).toEqual(aboutGithubDetails.bpmHost);
expect(component.ecmHost).toEqual(aboutGithubDetails.ecmHost);
});
});

View File

@@ -15,16 +15,14 @@
* limitations under the License.
*/
import { Component, Input, OnInit, ViewEncapsulation } from '@angular/core';
import { AppConfigService, AppConfigValues } from '../../app-config/app-config.service';
import { Component, Input, ViewEncapsulation } from '@angular/core';
@Component({
selector: 'adf-about-github-link',
templateUrl: './about-github-link.component.html',
encapsulation: ViewEncapsulation.None
})
export class AboutGithubLinkComponent implements OnInit {
export class AboutGithubLinkComponent {
/** Commit corresponding to the version of ADF to be used. */
@Input()
url = 'https://github.com/Alfresco/alfresco-ng2-components/commits/';
@@ -32,15 +30,8 @@ export class AboutGithubLinkComponent implements OnInit {
/** Current version of the app running */
@Input() version: string;
ecmHost = '';
bpmHost = '';
application: string;
/** Current version of the app running */
@Input() application: string;
constructor(private appConfig: AppConfigService) {}
ngOnInit() {
this.ecmHost = this.appConfig.get<string>(AppConfigValues.ECMHOST);
this.bpmHost = this.appConfig.get<string>(AppConfigValues.BPMHOST);
this.application = this.appConfig.get<string>('application.name');
}
constructor() {}
}