diff --git a/docs/core/error-content.component.md b/docs/core/error-content.component.md index db6d8742c2..aef145e4e7 100644 --- a/docs/core/error-content.component.md +++ b/docs/core/error-content.component.md @@ -16,41 +16,15 @@ Once you have caught the error in your server you will need to redirect to `/err this.router.navigate(['/error', errorCode]); ``` -```html -
-

- {{ errorCode }} -

-
-

- {{ 'ERROR_CONTENT.' + errorCode + '.TITLE' | translate }} -

-

- {{ 'ERROR_CONTENT.' + errorCode + '.DESCRIPTION' | translate }} -

-
- - {{ 'ERROR_CONTENT.' + errorCode + '.SECONDARY_BUTTON.TEXT' | translate | uppercase }} - - - {{ 'ERROR_CONTENT.' + this.errorCode + '.RETURN_BUTTON.TEXT' | translate | uppercase }} - -
-
-``` - ## Properties ### Error Content Component -| Name | Type | Description | -| ---- | ---- | ----------- | -| errorCode | string | Error code | -| returnButtonUrl | string | URL for the return button | -| secondaryButtonText | string | (Optional) Text that will be displayed inside the secondary button | -| secondaryButtonUrl | string | (Optional) URL for the secondary button | +| Name | Type | Default | Description | +| ---- | ---- |---- | ----------- | +| errorCode | string | |Error code | +| returnButtonUrl | string | "/" |URL for the return button | +| secondaryButtonUrl | string | "report-issue" |(Optional) URL for the secondary button | Note that you will also have to provide values for the variables used in the view template. @@ -65,12 +39,10 @@ You can customize your error messages by adding them to the translate files insi "TITLE": "An error occurred.", "DESCRIPTION": "We couldn’t find the page you were looking for.", "SECONDARY_BUTTON": { - "TEXT": "", - "URL": "" + "TEXT": "" }, "RETURN_BUTTON": { - "TEXT": "Back to home", - "ROUTE": "home" + "TEXT": "Back to home" } } } @@ -78,4 +50,4 @@ You can customize your error messages by adding them to the translate files insi ## See also -- [Empty Content component](empty-content.component.md) \ No newline at end of file +- [Empty Content component](empty-content.component.md) diff --git a/e2e/core/error_component.e2e.ts b/e2e/core/error_component.e2e.ts index 2cdf91395d..8332063f15 100644 --- a/e2e/core/error_component.e2e.ts +++ b/e2e/core/error_component.e2e.ts @@ -44,11 +44,34 @@ describe('Error Component', () => { }); - it('[C277302] Error message displayed without permissions', () => { + it('[C277302] Should display the error 403 when access to unathorized page', () => { browser.get(TestConfig.adf.url + '/error/403'); expect(errorPage.getErrorCode()).toBe('403'); expect(errorPage.getErrorTitle()).toBe('You don\'t have permission to access this server.'); expect(errorPage.getErrorDescription()).toBe('You\'re not allowed access to this resource on the server.'); }); + it('[C280563] Should back home button navigate to the home page', () => { + browser.get(TestConfig.adf.url + '/error/404'); + + errorPage.clickBackButton(); + + expect(browser.getCurrentUrl()).toBe(TestConfig.adf.url + '/'); + }); + + it('[C280564] Should secondary button by default redirect to report-issue URL', () => { + browser.get(TestConfig.adf.url + '/error/403'); + + errorPage.clickSecondButton(); + + expect(browser.getCurrentUrl()).toBe(TestConfig.adf.url + '/report-issue'); + }); + + it('[C277304] We couldn’t find the page you were looking for.\' to be \'You\'re not allowed access to this resource on the server.', () => { + browser.get(TestConfig.adf.url + '/error/404'); + expect(errorPage.getErrorCode()).toBe('404'); + expect(errorPage.getErrorTitle()).toBe('An error occurred.'); + expect(errorPage.getErrorDescription()).toBe('We couldn’t find the page you were looking for.'); + }); + }); diff --git a/e2e/core/user_info_component.e2e.ts b/e2e/core/user_info_component.e2e.ts index 8bf2c2d86d..1541767e42 100644 --- a/e2e/core/user_info_component.e2e.ts +++ b/e2e/core/user_info_component.e2e.ts @@ -15,8 +15,6 @@ * limitations under the License. */ -import { protractor } from 'protractor'; - import AdfSettingsPage = require('../pages/adf/settingsPage'); import LoginPage = require('../pages/adf/loginPage'); import UserInfoDialog = require('../pages/adf/dialog/userInfoDialog'); diff --git a/e2e/pages/adf/cardViewPageComponent.js b/e2e/pages/adf/cardViewPageComponent.js index 577208e180..96d3b963ef 100644 --- a/e2e/pages/adf/cardViewPageComponent.js +++ b/e2e/pages/adf/cardViewPageComponent.js @@ -68,7 +68,7 @@ var CardViewComponentPage = function () { return saveIcon.click(); }; - this.getTextFieldText = function (text) { + this.getTextFieldText = function () { var textField = element(by.css("span[data-automation-id='card-textitem-value-name']")); Util.waitUntilElementIsVisible(textField); return textField.getText(); @@ -108,13 +108,13 @@ var CardViewComponentPage = function () { return this; }; - this.getIntFieldText = function (text) { + this.getIntFieldText = function () { var textField = element(by.css('span[data-automation-id="card-textitem-value-int"]')); Util.waitUntilElementIsVisible(textField); return textField.getText(); }; - this.getErrorInt = function (text) { + this.getErrorInt = function () { let errorElement = element(by.css('mat-error[data-automation-id="card-textitem-error-int"]')); Util.waitUntilElementIsVisible(errorElement); return errorElement.getText(); @@ -147,13 +147,13 @@ var CardViewComponentPage = function () { return this; }; - this.getFloatFieldText = function (text) { + this.getFloatFieldText = function () { var textField = element(by.css('span[data-automation-id="card-textitem-value-float"]')); Util.waitUntilElementIsVisible(textField); return textField.getText(); }; - this.getErrorFloat = function (text) { + this.getErrorFloat = function () { let errorElement = element(by.css('mat-error[data-automation-id="card-textitem-error-float"]')); Util.waitUntilElementIsVisible(errorElement); return errorElement.getText(); diff --git a/e2e/pages/adf/contentServicesPage.js b/e2e/pages/adf/contentServicesPage.js index 3b21b89e49..b566d16f9a 100644 --- a/e2e/pages/adf/contentServicesPage.js +++ b/e2e/pages/adf/contentServicesPage.js @@ -20,6 +20,7 @@ var ContentList = require('./dialog/contentList'); var CreateFolderDialog = require('./dialog/createFolderDialog'); var path = require('path'); var TestConfig = require('../../test.config'); +var NavigationBarPage = require('./navigationBarPage'); var ContentServicesPage = function () { @@ -116,7 +117,8 @@ var ContentServicesPage = function () { }; this.navigateToDocumentList = function () { - browser.driver.get(contentServicesURL); + var navigationBarPage = new NavigationBarPage(); + navigationBarPage.clickContentServicesButton(); this.checkAcsContainer(); }; @@ -261,7 +263,7 @@ var ContentServicesPage = function () { }; this.checkContentsAreDisplayed = function (content) { - for (i = 0; i < content.length; i++) { + for (var i = 0; i < content.length; i++) { this.checkContentIsDisplayed(content[i]); } return this; @@ -273,7 +275,7 @@ var ContentServicesPage = function () { }; this.checkContentsAreNotDisplayed = function (content) { - for (i = 0; i < content.length; i++) { + for (var i = 0; i < content.length; i++) { this.checkContentIsNotDisplayed(content[i]); } return this; @@ -327,7 +329,6 @@ var ContentServicesPage = function () { for (var i = 1; i < files.length; i++) { allFiles = allFiles + "\n" + path.resolve(path.join(TestConfig.main.rootPath, files[i])); } - ; uploadMultipleFileButton.sendKeys(allFiles); Util.waitUntilElementIsVisible(uploadMultipleFileButton); return this; @@ -371,11 +372,11 @@ var ContentServicesPage = function () { }; this.deleteContents = function (content) { - for (i = 0; i < content.length; i++) { + for (var i = 0; i < content.length; i++) { this.deleteContent(content[i]); this.checkContentIsNotDisplayed(content[i]); browser.driver.sleep(1000); - }; + } return this; }; diff --git a/e2e/pages/adf/dialog/contentList.js b/e2e/pages/adf/dialog/contentList.js index b81d69cbb4..b69ea8d2c6 100644 --- a/e2e/pages/adf/dialog/contentList.js +++ b/e2e/pages/adf/dialog/contentList.js @@ -68,7 +68,6 @@ var ContentList = function () { if (text !== '') { initialList.push(text); } - ; }); }).then(function () { deferred.fulfill(initialList); diff --git a/e2e/pages/adf/dialog/searchDialog.js b/e2e/pages/adf/dialog/searchDialog.js index 69cf4f6f41..f1c9881b65 100644 --- a/e2e/pages/adf/dialog/searchDialog.js +++ b/e2e/pages/adf/dialog/searchDialog.js @@ -123,7 +123,7 @@ var SearchDialog = function () { this.clearText = function () { Util.waitUntilElementIsVisible(searchBar); var deferred = protractor.promise.defer(); - searchBar.clear().then(function (value) { + searchBar.clear().then(function () { searchBar.sendKeys(protractor.Key.ESCAPE); }); return deferred.promise; diff --git a/e2e/pages/adf/dialog/uploadDialog.js b/e2e/pages/adf/dialog/uploadDialog.js index a7f22499f4..4b54f61c5d 100644 --- a/e2e/pages/adf/dialog/uploadDialog.js +++ b/e2e/pages/adf/dialog/uploadDialog.js @@ -85,7 +85,7 @@ var UploadDialog = function () { }; this.filesAreUploaded = function (content) { - for (i=0; i
{{ 'ERROR_CONTENT.' + errorCode + '.SECONDARY_BUTTON.TEXT' | translate | uppercase }} diff --git a/lib/core/templates/error-content/error-content.component.spec.ts b/lib/core/templates/error-content/error-content.component.spec.ts index 4438767ed9..830e6b7686 100644 --- a/lib/core/templates/error-content/error-content.component.spec.ts +++ b/lib/core/templates/error-content/error-content.component.spec.ts @@ -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('/'); }); })); diff --git a/lib/core/templates/error-content/error-content.component.ts b/lib/core/templates/error-content/error-content.component.ts index 4278a2e5da..4070093e99 100644 --- a/lib/core/templates/error-content/error-content.component.ts +++ b/lib/core/templates/error-content/error-content.component.ts @@ -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() {