[AAE-2021] Unit tests for about components (#5496)

* * Added unit tests to the about-github-link component.
* Removed unused css

* * Added unit tests to the about module and prodcut-version components

* * After rebase
This commit is contained in:
siva kumar
2020-02-21 15:42:42 +05:30
committed by GitHub
parent 2874e6469b
commit bf11cd65ec
11 changed files with 581 additions and 43 deletions

View File

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

View File

@@ -1,10 +1,3 @@
.adf-about-container {
.adf-github-link-container {
padding: 10px;
}
.adf-table-version {
width: 60%;
border: 0;
border-spacing: 0;
text-align: center;
}

View File

@@ -0,0 +1,87 @@
/*!
* @license
* Copyright 2019 Alfresco Software, Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
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]
});
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();
});
afterEach(() => {
fixture.destroy();
});
it('Should fetch appName for app.config and display as title', () => {
const titleElement = fixture.nativeElement.querySelector('[data-automation-id="adf-github-app-title"]');
expect(titleElement === null).toBeFalsy();
expect(titleElement.innerText).toEqual('mock-application-name');
});
it('should display version', async() => {
component.version = aboutGithubDetails.version;
fixture.detectChanges();
await fixture.whenStable();
const version = fixture.nativeElement.querySelector('[data-automation-id="adf-github-version"]');
expect(version.innerText).toEqual('ABOUT.VERSION: 0.0.7');
});
it('should display adf github link as default if url is not specified', async() => {
fixture.detectChanges();
await fixture.whenStable();
const githubUrl = fixture.nativeElement.querySelector('[data-automation-id="adf-github-url"]');
expect(githubUrl.innerText).toEqual(aboutGithubDetails.defualrUrl);
});
it('should display the github link', async() => {
component.url = aboutGithubDetails.url;
fixture.detectChanges();
await fixture.whenStable();
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);
});
});