Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding a PageNotFound Component. #33

Merged
merged 2 commits into from
Jan 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/app/app.routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,12 @@ export const routes: Routes = [
(m) => m.ConfirmTotpComponent,
),
},
{
path: '**',
loadComponent: () =>
import('../app/portal/features/page-not-found/page-not-found.component').then(
(m) => m.PageNotFoundComponent,
),
title: 'GHGA | Page not found',
},
];
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<h1>Page not found</h1>
<p class="text-justify">
Sorry, we can't seem to find the page you're looking for. If you think it should
exist, please tell us (<a
class="mt-10"
target="_blank"
rel="noreferrer noopener"
href="https://www.ghga.de/about-us/contact"
><mat-icon inline="true" class="align-middle">email</mat-icon></a
>).
</p>
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/**
* Test the home page component
* @copyright The GHGA Authors
* @license Apache-2.0
*/

import { ComponentFixture, TestBed } from '@angular/core/testing';

import { PageNotFoundComponent } from './page-not-found.component';

describe('PageNotFoundComponent', () => {
let component: PageNotFoundComponent;
let fixture: ComponentFixture<PageNotFoundComponent>;

beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [PageNotFoundComponent],
providers: [],
}).compileComponents();

fixture = TestBed.createComponent(PageNotFoundComponent);
component = fixture.componentInstance;
await fixture.whenStable();
});

it('should create', () => {
expect(component).toBeTruthy();
});
SilverLinings89 marked this conversation as resolved.
Show resolved Hide resolved

it('should render the correct content in the <h1> tag', () => {
const compiled = fixture.nativeElement as HTMLElement;
const h1 = compiled.querySelector('h1');
expect(h1?.textContent).toBe('Page not found');
});

it('should contain the correct description text', () => {
const compiled = fixture.nativeElement as HTMLElement;
const p = compiled.querySelector('p');
expect(p?.textContent).toContain(
"Sorry, we can't seem to find the page you're looking for",
);
});
});
18 changes: 18 additions & 0 deletions src/app/portal/features/page-not-found/page-not-found.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/**
* PageNotFound component
* @copyright The GHGA Authors
* @license Apache-2.0
*/

import { Component } from '@angular/core';
import { MatIcon } from '@angular/material/icon';

/**
* This is the PageNotFound Component. It gets displayed if the router cannot resolve a route.
*/
@Component({
selector: 'app-page-not-found',
imports: [MatIcon],
templateUrl: './page-not-found.component.html',
})
export class PageNotFoundComponent {}