diff --git a/lib/public/views/Error/ErrorModel.js b/lib/public/views/Error/ErrorModel.js index 8bae8e430e..b363c4d813 100644 --- a/lib/public/views/Error/ErrorModel.js +++ b/lib/public/views/Error/ErrorModel.js @@ -17,6 +17,14 @@ import { Observable } from '/js/src/index.js'; * Model representing handlers for errorPage.js */ export class ErrorModel extends Observable { + /** + * The Error object. + * @typedef {(Object)} Error + * @property {string} code - The error code + * @property {string} codeDescription - The description of the error code + * @property {string} message - The error message + */ + /** * The constructor for the Error model object * @returns {Object} Constructs the Error model @@ -32,7 +40,7 @@ export class ErrorModel extends Observable { /** * Sets the error object for the model - * @param {Object} error The error object to set, must contain a code, codeDescription and message + * @param {Error} error The error object * @returns {void} */ setError(error) { @@ -45,7 +53,7 @@ export class ErrorModel extends Observable { /** * Returns the error object for the model - * @returns {Object} The error object + * @returns {Error} The error object */ getError() { return this.error; diff --git a/lib/public/views/Error/index.js b/lib/public/views/Error/index.js index 12d8843fe9..44d86f7888 100644 --- a/lib/public/views/Error/index.js +++ b/lib/public/views/Error/index.js @@ -10,7 +10,8 @@ * granted to it by virtue of its status as an Intergovernmental Organization * or submit itself to any jurisdiction. */ -import { h, iconHome } from '/js/src/index.js'; +import { frontLink } from '../../components/common/navigation/frontLink.js'; +import { h } from '/js/src/index.js'; /** * Error page component that dynamically displays error details based on the model @@ -29,13 +30,10 @@ export const ErrorPage = (model) => { h('h2', 'Oops! Something went wrong.'), h('h3', `${code} - ${codeDescription}`), h('.f5', message), - h('button.btn.btn-primary', { - onclick: () => { - model.router.go('?page=home'); - } }, [ - iconHome(), - ' Go to Home Page', - ]), + frontLink( + h('nav-link', ['Go to Home Page']), + 'home', + ), ]), ]); }; diff --git a/test/public/error/error.test.js b/test/public/error/error.test.js index 5d9bd35e52..bb8fce41cc 100644 --- a/test/public/error/error.test.js +++ b/test/public/error/error.test.js @@ -23,11 +23,6 @@ module.exports = () => { before(async () => { [page, browser] = await defaultBefore(page, browser); - await page.setViewport({ - width: 700, - height: 720, - deviceScaleFactor: 1, - }); await resetDatabaseContent(); }); @@ -47,15 +42,11 @@ module.exports = () => { }); it('shows the error message', async () => { - await goToPage(page, 'error'); - const errorTitle = await page.$eval('h2', (el) => el.innerText); expect(errorTitle).to.equal('Oops! Something went wrong.'); }); it ('shows the default text', async () => { - await goToPage(page, 'error'); - const errorCode = await page.$eval('h3', (el) => el.innerText); expect(errorCode).to.equal('Unknown Error - Something unexpected happened.'); });