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:
Felipe Cardoso
2025-11-19 14:07:13 +01:00
parent da7b6b5bfa
commit 7b1bea2966
29 changed files with 1263 additions and 105 deletions

View File

@@ -79,8 +79,9 @@ describe('PasswordResetConfirmForm', () => {
await user.click(submitButton);
await waitFor(() => {
expect(screen.getByText(/new password is required/i)).toBeInTheDocument();
expect(screen.getByText(/please confirm your password/i)).toBeInTheDocument();
// i18n keys are shown as literals when translation isn't found
// Only the first field validation shows on initial submit
expect(screen.getByText('passwordRequired')).toBeInTheDocument();
});
});
@@ -113,7 +114,8 @@ describe('PasswordResetConfirmForm', () => {
await user.click(submitButton);
await waitFor(() => {
expect(screen.getByText(/password must be at least 8 characters/i)).toBeInTheDocument();
// i18n key shown as literal when translation isn't found
expect(screen.getByText('passwordMinLength')).toBeInTheDocument();
});
});
@@ -224,7 +226,7 @@ describe('PasswordResetConfirmForm', () => {
await user.click(screen.getByRole('button', { name: /reset password/i }));
await waitFor(() => {
expect(screen.getByText(/your password has been successfully reset/i)).toBeInTheDocument();
expect(screen.getByText('success')).toBeInTheDocument();
});
});
@@ -348,7 +350,7 @@ describe('PasswordResetConfirmForm', () => {
await user.click(screen.getByRole('button', { name: /reset password/i }));
await waitFor(() => {
expect(screen.getByText(/your password has been successfully reset/i)).toBeInTheDocument();
expect(screen.getByText('success')).toBeInTheDocument();
});
// Second submission with error
@@ -361,9 +363,7 @@ describe('PasswordResetConfirmForm', () => {
await user.click(screen.getByRole('button', { name: /reset password/i }));
await waitFor(() => {
expect(
screen.queryByText(/your password has been successfully reset/i)
).not.toBeInTheDocument();
expect(screen.queryByText('success')).not.toBeInTheDocument();
expect(screen.getByText('Invalid or expired token')).toBeInTheDocument();
});
});