e2e test error page and fix (#3672)

* fix wrong input parameter functionality

* not reload the page to go to the content service page

* navigate instead to reload to go to the process service page
This commit is contained in:
Eugenio Romano
2018-08-08 17:18:26 +01:00
committed by Eugenio Romano
parent 6cf6c9c0e4
commit 2e0945b0cc
32 changed files with 169 additions and 231 deletions

View File

@@ -11,7 +11,7 @@
</p>
<div class="adf-error-content-buttons">
<a a id="adf-secondary-button" mat-raised-button color="primary"
*ngIf="secondaryButtonText" (click)="onSecondButton()"
*ngIf="hasSecondButton" (click)="onSecondButton()"
class="adf-error-content-description-link">
{{ 'ERROR_CONTENT.' + errorCode + '.SECONDARY_BUTTON.TEXT' | translate | uppercase }}
</a>

View File

@@ -103,20 +103,18 @@ describe('ErrorContentComponent', () => {
});
fixture.detectChanges();
fixture.whenStable().then(() => {
expect(errorContentComponent.secondaryButtonText).toBe('Secondary Button');
const errorContentElement = element.querySelector('.adf-error-content-description-link');
const errorContentElement = element.querySelector('#adf-secondary-button');
expect(errorContentElement).not.toBeNull();
expect(errorContentElement).toBeDefined();
expect(errorContentElement.textContent).toContain('ERROR_CONTENT.UNKNOWN.SECONDARY_BUTTON.TEXT');
});
}));
it('should render return button with its value from the translate file', async(() => {
spyOn(translateService, 'instant').and.callFake((inputString) => {
return 'Home';
});
it('shoul the default value of return burron be /', async(() => {
fixture.detectChanges();
fixture.whenStable().then(() => {
expect(errorContentComponent.returnButtonUrl).toBe('Home');
expect(errorContentComponent.returnButtonUrl).toBe('/');
});
}));

View File

@@ -15,7 +15,14 @@
* limitations under the License.
*/
import { Component, ChangeDetectionStrategy, ViewEncapsulation, OnInit, AfterContentChecked } from '@angular/core';
import {
Component,
ChangeDetectionStrategy,
Input,
ViewEncapsulation,
OnInit,
AfterContentChecked
} from '@angular/core';
import { Params, ActivatedRoute, Router } from '@angular/router';
import { TranslationService } from '../../services/translation.service';
@@ -29,10 +36,16 @@ import { TranslationService } from '../../services/translation.service';
})
export class ErrorContentComponent implements OnInit, AfterContentChecked {
@Input()
secondaryButtonUrl: string = 'report-issue';
@Input()
returnButtonUrl: string = '/';
@Input()
errorCode: string;
secondaryButtonText: string;
secondaryButtonUrl: string;
returnButtonUrl: string;
hasSecondButton: boolean;
constructor(private route: ActivatedRoute,
private router: Router,
@@ -42,7 +55,7 @@ export class ErrorContentComponent implements OnInit, AfterContentChecked {
ngOnInit() {
if (this.route) {
this.route.params.forEach((params: Params) => {
if (params['id']) {
if (params['id'] && !this.errorCode) {
this.errorCode = params['id'];
let unknown = '';
this.translateService.get('ERROR_CONTENT.' + this.errorCode + '.TITLE').subscribe((errorTranslation: string) => {
@@ -56,21 +69,13 @@ export class ErrorContentComponent implements OnInit, AfterContentChecked {
}
}
ngAfterContentChecked() {
this.getTranslations();
getTranslations() {
this.hasSecondButton = this.translateService.instant(
'ERROR_CONTENT.' + this.errorCode + '.SECONDARY_BUTTON.TEXT') ? true : false;
}
getTranslations() {
this.returnButtonUrl = this.translateService.instant(
'ERROR_CONTENT.' + this.errorCode + '.RETURN_BUTTON.ROUTE');
this.secondaryButtonText = this.translateService.instant(
'ERROR_CONTENT.' + this.errorCode + '.SECONDARY_BUTTON.TEXT');
if (this.secondaryButtonText) {
this.secondaryButtonUrl = this.translateService.instant(
'ERROR_CONTENT.' + this.errorCode + '.SECONDARY_BUTTON.URL');
}
ngAfterContentChecked() {
this.getTranslations();
}
onSecondButton() {