Files
twenty/packages/twenty-front/src/utils/__tests__/normalizeSearchText.test.ts
T
Félix Malfait b27a97f2c5 feat: enforce @/ alias for imports and fix all relative parent imports (#16787)
## Summary
This PR enforces the use of `@/` alias for imports instead of relative
parent imports (`../`).

## Changes

### ESLint Configuration
- Added `no-restricted-imports` pattern in `eslint.config.react.mjs` to
block `../*` imports with the message "Relative parent imports are not
allowed. Use @/ alias instead."
- Removed the non-working `import/no-relative-parent-imports` rule
(doesn't work properly in ESLint flat config)

### VS Code Settings
- Added `javascript.preferences.importModuleSpecifier: non-relative` to
`.vscode/settings.json` (TypeScript setting was already there)

### Code Fixes
- Fixed **941 relative parent imports** across **706 files** in
`packages/twenty-front`
- All `../` imports converted to use `@/` alias

## Why
- Consistent import style across the codebase
- Easier to move files without breaking imports
- Better IDE support for auto-imports
- Clearer understanding of where imports come from
2025-12-23 22:57:51 +01:00

71 lines
2.8 KiB
TypeScript

import { normalizeSearchText } from '~/utils/normalizeSearchText';
describe('normalizeSearchText', () => {
it('should handle basic ASCII text', () => {
expect(normalizeSearchText('Hello World')).toBe('hello world');
expect(normalizeSearchText('TEST')).toBe('test');
expect(normalizeSearchText('MixedCase123')).toBe('mixedcase123');
});
it('should remove accents from various languages', () => {
expect(normalizeSearchText('café')).toBe('cafe');
expect(normalizeSearchText('naïve')).toBe('naive');
expect(normalizeSearchText('résumé')).toBe('resume');
expect(normalizeSearchText('Zürich')).toBe('zurich');
expect(normalizeSearchText('Müller')).toBe('muller');
expect(normalizeSearchText('niño')).toBe('nino');
expect(normalizeSearchText('España')).toBe('espana');
expect(normalizeSearchText('São Paulo')).toBe('sao paulo');
expect(normalizeSearchText('João')).toBe('joao');
expect(normalizeSearchText('Åse')).toBe('ase');
expect(normalizeSearchText('Øyvind')).toBe('oyvind');
});
it('should handle Nordic and Germanic special characters', () => {
expect(normalizeSearchText('Øyvind')).toBe('oyvind');
expect(normalizeSearchText('Åse')).toBe('ase');
expect(normalizeSearchText('Æther')).toBe('aether');
expect(normalizeSearchText('Straße')).toBe('strasse');
expect(normalizeSearchText('Łódź')).toBe('lodz');
expect(normalizeSearchText('Œuvre')).toBe('oeuvre');
});
it('should handle mixed case with accents', () => {
expect(normalizeSearchText('CAFÉ')).toBe('cafe');
expect(normalizeSearchText('NaÏvE')).toBe('naive');
expect(normalizeSearchText('ZÜRICH')).toBe('zurich');
});
it('should handle null and undefined gracefully', () => {
expect(normalizeSearchText(null)).toBe('');
expect(normalizeSearchText(undefined)).toBe('');
});
it('should handle empty strings', () => {
expect(normalizeSearchText('')).toBe('');
expect(normalizeSearchText(' ')).toBe(' ');
});
it('should handle special characters and numbers', () => {
expect(normalizeSearchText('user@example.com')).toBe('user@example.com');
expect(normalizeSearchText('123-456-7890')).toBe('123-456-7890');
expect(normalizeSearchText('Café #1')).toBe('cafe #1');
});
it('should handle complex Unicode combinations', () => {
expect(normalizeSearchText('e\u0301')).toBe('e');
expect(normalizeSearchText('a\u0300\u0301')).toBe('a');
expect(normalizeSearchText('é')).toBe('e');
expect(normalizeSearchText('e\u0301')).toBe('e');
});
it('should be consistent for search matching', () => {
const searchTerm = 'cafe';
const names = ['Café', 'CAFE', 'cafe', 'Cafe'];
names.forEach((name) => {
expect(normalizeSearchText(name)).toContain(searchTerm);
});
});
});