Refactor i18n integration and update tests for improved localization
- Updated test components (`PasswordResetConfirmForm`, `PasswordChangeForm`) to use i18n keys directly, ensuring accurate validation messages. - Refined translations in `it.json` to standardize format and content. - Replaced text-based labels with localized strings in `PasswordResetRequestForm` and `RegisterForm`. - Introduced `generateLocalizedMetadata` utility and updated layout metadata generation for locale-aware SEO. - Enhanced e2e tests with locale-prefixed routes and updated assertions for consistency. - Added comprehensive i18n documentation (`I18N.md`) for usage, architecture, and testing.
This commit is contained in:
@@ -4,15 +4,17 @@
|
||||
*/
|
||||
|
||||
import { render, screen } from '@testing-library/react';
|
||||
import ForbiddenPage, { metadata } from '@/app/[locale]/forbidden/page';
|
||||
import ForbiddenPage from '@/app/[locale]/forbidden/page';
|
||||
|
||||
// Mock next-intl/server to avoid ESM import issues in Jest
|
||||
jest.mock('next-intl/server', () => ({
|
||||
getTranslations: jest.fn(async () => ({
|
||||
unauthorized: 'Unauthorized',
|
||||
unauthorizedDescription: "You don't have permission to access this page.",
|
||||
})),
|
||||
}));
|
||||
|
||||
describe('ForbiddenPage', () => {
|
||||
it('has correct metadata', () => {
|
||||
expect(metadata).toBeDefined();
|
||||
expect(metadata.title).toBe('403 - Forbidden');
|
||||
expect(metadata.description).toBe('You do not have permission to access this resource');
|
||||
});
|
||||
|
||||
it('renders page heading', () => {
|
||||
render(<ForbiddenPage />);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user