Add tests for i18n metadata utilities and improve locale-based metadata generation

- Introduced comprehensive unit tests for `generateLocalizedMetadata` and `generatePageMetadata` utilities.
- Enhanced `siteConfig` validation assertions for structure and localization support.
- Updated metadata generation to handle empty paths, canonical URLs, language alternates, and Open Graph data consistently.
- Annotated server-side middleware with istanbul ignore for coverage clarity.
This commit is contained in:
Felipe Cardoso
2025-11-19 14:23:06 +01:00
parent 7b1bea2966
commit 3ec589293c
3 changed files with 353 additions and 3 deletions

View File

@@ -62,9 +62,9 @@ export async function generateLocalizedMetadata(
alternates: {
canonical: url,
languages: {
en: `/${path}`,
it: `/it${path}`,
'x-default': `/${path}`,
en: path || '/',
it: `/it${path || '/'}`,
'x-default': path || '/',
},
},
openGraph: {

View File

@@ -16,6 +16,7 @@
import { getRequestConfig } from 'next-intl/server';
import { routing } from '@/lib/i18n/routing';
/* istanbul ignore next - Server-side middleware configuration covered by e2e tests */
export default getRequestConfig(async ({ locale }) => {
// Validate that the incoming `locale` parameter is valid
// Type assertion: we know locale will be a string from the URL parameter