Skip to content

Commit df32557

Browse files
Better coverage on router
1 parent 9a781ba commit df32557

File tree

1 file changed

+58
-0
lines changed

1 file changed

+58
-0
lines changed

src/app/app.routes.spec.ts

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,3 +216,61 @@ describe('Route Configuration Integrity', () => {
216216
});
217217

218218
});
219+
220+
describe('Route SEO Data Integrity', () => {
221+
// --- SETUP VARIABLES ---
222+
const publicLayoutRoute = ROUTES.find(r => r.path === '');
223+
const publicRoutes = publicLayoutRoute?.children || [];
224+
225+
const errorLayoutRoute = publicRoutes.find(r => r.path === 'error');
226+
const errorRoutes = errorLayoutRoute?.children || [];
227+
228+
it('should contain valid and EXACT SEO metadata for public views', () => {
229+
// --- ARRANGE ---
230+
const expectedPublicSeo = [
231+
{ path: 'home', titleKey: 'META.PAGES.HOME.TITLE', descriptionKey: 'META.PAGES.HOME.DESCRIPTION' },
232+
{ path: 'login', titleKey: 'META.PAGES.LOGIN.TITLE', descriptionKey: 'META.PAGES.LOGIN.DESCRIPTION' },
233+
{ path: 'contact', titleKey: 'META.PAGES.CONTACT.TITLE', descriptionKey: 'META.PAGES.CONTACT.DESCRIPTION' }
234+
];
235+
236+
// --- ACT & ASSERT ---
237+
expectedPublicSeo.forEach(expected => {
238+
const route = publicRoutes.find(r => r.path === expected.path);
239+
240+
expect(route).toBeDefined();
241+
expect(route?.data?.['seo']).toBeDefined();
242+
243+
expect(route?.data?.['seo']?.titleKey).toBe(expected.titleKey);
244+
expect(route?.data?.['seo']?.descriptionKey).toBe(expected.descriptionKey);
245+
});
246+
});
247+
248+
it('should contain valid and EXACT SEO metadata (including robots) for error views', () => {
249+
// --- ARRANGE ---
250+
const expectedErrorSeo = [
251+
{ path: 'unauthorized-error', titleKey: 'META.PAGES.ERROR.401.TITLE', descriptionKey: 'META.PAGES.ERROR.401.DESCRIPTION' },
252+
{ path: 'unfound-error', titleKey: 'META.PAGES.ERROR.404.TITLE', descriptionKey: 'META.PAGES.ERROR.404.DESCRIPTION' },
253+
{ path: 'server-error', titleKey: 'META.PAGES.ERROR.500.TITLE', descriptionKey: 'META.PAGES.ERROR.500.DESCRIPTION' },
254+
{ path: 'generic-error', titleKey: 'META.PAGES.ERROR.GENERIC.TITLE', descriptionKey: 'META.PAGES.ERROR.GENERIC.DESCRIPTION' },
255+
{ path: 'unknown-error', titleKey: 'META.PAGES.ERROR.UNKNOWN.TITLE', descriptionKey: 'META.PAGES.ERROR.UNKNOWN.DESCRIPTION' }
256+
];
257+
258+
// --- ACT & ASSERT ---
259+
expectedErrorSeo.forEach(expected => {
260+
const route = errorRoutes.find(r => r.path === expected.path);
261+
262+
expect(route).toBeDefined();
263+
expect(route?.data?.['seo']).toBeDefined();
264+
265+
expect(route?.data?.['seo']?.titleKey).toBe(expected.titleKey);
266+
expect(route?.data?.['seo']?.descriptionKey).toBe(expected.descriptionKey);
267+
268+
expect(route?.data?.['seo']?.robots).toBe('noindex, nofollow');
269+
});
270+
});
271+
272+
it('should have a global "noindex, nofollow" on the parent error layout route', () => {
273+
// --- ACT & ASSERT ---
274+
expect(errorLayoutRoute?.data?.['seo']?.robots).toBe('noindex, nofollow');
275+
});
276+
});

0 commit comments

Comments
 (0)