Files
Andrew Beveridge ☄️andClaude Opus 4.6 648a26d462 fix(i18n): locale-aware navigation for internal links (#662)
## Summary
- Replace `next/navigation` and `next/link` imports with
`@/i18n/routing` equivalents in 13 user-facing components and pages so
`router.push()` and `<Link>` automatically include the locale prefix
(`/es/`, `/de/`)
- Without this fix, users on Spanish/German routes were kicked back to
non-locale paths on every internal navigation click
- Admin navigation (`/admin`) correctly excluded from locale routing
(uses `next/link` / `window.location`)
- Fix Jest ESM transform for `next-intl` transitive deps and add global
`@/i18n/routing` mock

## Test plan
- [x] `next build` succeeds — all 3 locale directories generated
(`/en/`, `/es/`, `/de/`)
- [x] 39 Jest test suites / 707 tests pass
- [x] CodeRabbit review: clean, no findings
- [ ] Post-deploy: verify `/es/app` links navigate to `/es/` prefixed
routes
- [ ] Post-deploy: verify admin link from header goes to `/admin` (no
locale prefix)

<!-- @coderabbitai ignore -->

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-04 01:34:57 -04:00

49 lines
1.5 KiB
JavaScript

const nextJest = require('next/jest')
const createJestConfig = nextJest({
// Provide the path to your Next.js app to load next.config.js and .env files in your test environment
dir: './',
})
// Add any custom config to be passed to Jest
const customJestConfig = {
setupFilesAfterEnv: ['<rootDir>/jest.setup.js'],
testEnvironment: 'jest-environment-jsdom',
moduleNameMapper: {
'^@/(.*)$': '<rootDir>/$1',
'^nanoid$': '<rootDir>/node_modules/nanoid/index.cjs',
},
testMatch: [
'**/__tests__/**/*.test.[jt]s?(x)',
],
testPathIgnorePatterns: [
'/node_modules/',
'/e2e/', // E2E tests run via Playwright, not Jest
],
// Allow Jest to transform ESM packages (next-intl uses ESM exports)
transformIgnorePatterns: [
'/node_modules/(?!(next-intl|use-intl)/)',
],
collectCoverageFrom: [
'components/**/*.{js,jsx,ts,tsx}',
'lib/**/*.{js,jsx,ts,tsx}',
'app/**/*.{js,jsx,ts,tsx}',
'!**/*.d.ts',
'!**/node_modules/**',
'!**/.next/**',
'!**/out/**',
],
}
// createJestConfig is exported this way to ensure that next/jest can load the Next.js config which is async
// We must override transformIgnorePatterns AFTER next/jest generates its config,
// because next/jest's defaults would otherwise re-add next-intl to the ignore list.
module.exports = async () => {
const jestConfig = await createJestConfig(customJestConfig)()
jestConfig.transformIgnorePatterns = [
'/node_modules/(?!(next-intl|use-intl|@formatjs|intl-messageformat)/)',
]
return jestConfig
}