Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix : rules ridet #256

Merged
merged 1 commit into from
Nov 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ describe('candidature coordinateur', () => {
const etapeInformationsDeStructure = within(formulaire).getByRole('group', { name: 'Vos informations de structure' });
expect(etapeInformationsDeStructure).toHaveAttribute('id', 'informations-de-structure');

const siretOuRidet = within(etapeInformationsDeStructure).getByLabelText('SIRET / RIDET * Format attendu : SIRET (12345678901234) ou RIDET (123456789)');
const siretOuRidet = within(etapeInformationsDeStructure).getByLabelText('SIRET / RIDET * Format attendu : SIRET (12345678901234) ou RIDET (1234567)');
expect(siretOuRidet).toHaveAttribute('id', 'siret');
expect(siretOuRidet).toHaveAttribute('pattern', '^(?:[0-9]{6,10}|[0-9]{14})$');
expect(siretOuRidet).toHaveAttribute('pattern', '^(?:[0-9]{7}|[0-9]{14})$');
expect(siretOuRidet).toBeRequired();

const denomination = within(etapeInformationsDeStructure).getByLabelText('Dénomination *');
Expand Down Expand Up @@ -269,7 +269,7 @@ describe('candidature coordinateur', () => {
});

render(<CandidatureCoordinateur />);
const siret = screen.getByLabelText('SIRET / RIDET * Format attendu : SIRET (12345678901234) ou RIDET (123456789)');
const siret = screen.getByLabelText('SIRET / RIDET * Format attendu : SIRET (12345678901234) ou RIDET (1234567)');
fireEvent.change(siret, { target: { value: '12345678901234' } });
const denomination = screen.getByLabelText('Dénomination *');
fireEvent.change(denomination, { target: { value: 'Entreprise' } });
Expand Down Expand Up @@ -328,7 +328,7 @@ describe('candidature coordinateur', () => {
vi.spyOn(ReactRouterDom, 'useNavigate').mockReturnValue(mockNavigate);

render(<CandidatureCoordinateur />);
const siret = screen.getByLabelText('SIRET / RIDET * Format attendu : SIRET (12345678901234) ou RIDET (123456789)');
const siret = screen.getByLabelText('SIRET / RIDET * Format attendu : SIRET (12345678901234) ou RIDET (1234567)');
fireEvent.change(siret, { target: { value: '12345678901234' } });
const denomination = screen.getByLabelText('Dénomination *');
fireEvent.change(denomination, { target: { value: 'Entreprise' } });
Expand Down Expand Up @@ -604,7 +604,7 @@ describe('candidature coordinateur', () => {
});

render(<CandidatureCoordinateur />);
const siret = screen.getByLabelText('SIRET / RIDET * Format attendu : SIRET (12345678901234) ou RIDET (123456789)');
const siret = screen.getByLabelText('SIRET / RIDET * Format attendu : SIRET (12345678901234) ou RIDET (1234567)');
fireEvent.change(siret, { target: { value: '12345678901234' } });
const denomination = screen.getByLabelText('Dénomination *');
fireEvent.change(denomination, { target: { value: 'Entreprise' } });
Expand Down Expand Up @@ -653,7 +653,7 @@ describe('candidature coordinateur', () => {
it.each([
{
description: 'un SIRET/RIDET',
selector: 'SIRET / RIDET * Format attendu : SIRET (12345678901234) ou RIDET (123456789)',
selector: 'SIRET / RIDET * Format attendu : SIRET (12345678901234) ou RIDET (1234567)',
message: 'Veuillez renseigner le SIRET/RIDET'
},
{
Expand Down
2 changes: 1 addition & 1 deletion src/views/candidature-coordinateur/CompanyFinder.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export default function CompanyFinder() {
id="siret"
onChange={debounce(event => search(event.target.value))}
placeholder="N° SIRET / RIDET"
pattern="^(?:[0-9]{6,10}|[0-9]{14})$"
pattern="^(?:[0-9]{7}|[0-9]{14})$"
maxlength="14"
/>
{entreprise}
Expand Down
22 changes: 11 additions & 11 deletions src/views/candidature-structure/CandidatureStructure.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ describe('candidature structure', () => {
const etapeInformationsDeStructure = within(formulaire).getByRole('group', { name: 'Vos informations de structure' });
expect(etapeInformationsDeStructure).toHaveAttribute('id', 'informations-de-structure');

const siretOuRidet = within(etapeInformationsDeStructure).getByLabelText('SIRET / RIDET * Format attendu : SIRET (12345678901234) ou RIDET (123456789)');
expect(siretOuRidet).toHaveAttribute('pattern', '^(?:[0-9]{6,10}|[0-9]{14})$');
const siretOuRidet = within(etapeInformationsDeStructure).getByLabelText('SIRET / RIDET * Format attendu : SIRET (12345678901234) ou RIDET (1234567)');
expect(siretOuRidet).toHaveAttribute('pattern', '^(?:[0-9]{7}|[0-9]{14})$');
expect(siretOuRidet).toHaveAttribute('id', 'siret');
expect(siretOuRidet).toBeRequired();

Expand Down Expand Up @@ -246,7 +246,7 @@ describe('candidature structure', () => {
render(<CandidatureStructure />);

// WHEN
const siretInput = screen.getByLabelText('SIRET / RIDET * Format attendu : SIRET (12345678901234) ou RIDET (123456789)');
const siretInput = screen.getByLabelText('SIRET / RIDET * Format attendu : SIRET (12345678901234) ou RIDET (1234567)');
fireEvent.change(siretInput, { target: { value: '13002603200016' } });

// THEN
Expand Down Expand Up @@ -275,7 +275,7 @@ describe('candidature structure', () => {
render(<CandidatureStructure />);

// WHEN
const ridetInput = screen.getByLabelText('SIRET / RIDET * Format attendu : SIRET (12345678901234) ou RIDET (123456789)');
const ridetInput = screen.getByLabelText('SIRET / RIDET * Format attendu : SIRET (12345678901234) ou RIDET (1234567)');
fireEvent.change(ridetInput, { target: { value: '1071539' } });

// THEN
Expand All @@ -285,12 +285,12 @@ describe('candidature structure', () => {
});
});

it('quand je renseigne ni un siret (14 chiffres) ni un ridet (6 ou 7 chiffres) alors les champs sont vidés', async () => {
it('quand je renseigne ni un siret (14 chiffres) ni un ridet (7 chiffres) alors les champs sont vidés', async () => {
// GIVEN
render(<CandidatureStructure />);

// WHEN
const siretInput = screen.getByLabelText('SIRET / RIDET * Format attendu : SIRET (12345678901234) ou RIDET (123456789)');
const siretInput = screen.getByLabelText('SIRET / RIDET * Format attendu : SIRET (12345678901234) ou RIDET (1234567)');
fireEvent.change(siretInput, { target: { value: '1300260320001' } });

// THEN
Expand All @@ -315,7 +315,7 @@ describe('candidature structure', () => {
render(<CandidatureStructure />);

// WHEN
const siretInput = screen.getByLabelText('SIRET / RIDET * Format attendu : SIRET (12345678901234) ou RIDET (123456789)');
const siretInput = screen.getByLabelText('SIRET / RIDET * Format attendu : SIRET (12345678901234) ou RIDET (1234567)');
fireEvent.change(siretInput, { target: { value: '13002603200016' } });

// THEN
Expand Down Expand Up @@ -357,7 +357,7 @@ describe('candidature structure', () => {
});

render(<CandidatureStructure />);
const siret = screen.getByLabelText('SIRET / RIDET * Format attendu : SIRET (12345678901234) ou RIDET (123456789)');
const siret = screen.getByLabelText('SIRET / RIDET * Format attendu : SIRET (12345678901234) ou RIDET (1234567)');
fireEvent.change(siret, { target: { value: '12345678901234' } });
const denomination = screen.getByLabelText('Dénomination *');
fireEvent.change(denomination, { target: { value: 'Entreprise' } });
Expand Down Expand Up @@ -416,7 +416,7 @@ describe('candidature structure', () => {
vi.spyOn(ReactRouterDom, 'useNavigate').mockReturnValue(mockNavigate);

render(<CandidatureStructure />);
const siret = screen.getByLabelText('SIRET / RIDET * Format attendu : SIRET (12345678901234) ou RIDET (123456789)');
const siret = screen.getByLabelText('SIRET / RIDET * Format attendu : SIRET (12345678901234) ou RIDET (1234567)');
fireEvent.change(siret, { target: { value: '12345678901234' } });
const denomination = screen.getByLabelText('Dénomination *');
fireEvent.change(denomination, { target: { value: 'Entreprise' } });
Expand Down Expand Up @@ -693,7 +693,7 @@ describe('candidature structure', () => {
});

render(<CandidatureStructure />);
const siret = screen.getByLabelText('SIRET / RIDET * Format attendu : SIRET (12345678901234) ou RIDET (123456789)');
const siret = screen.getByLabelText('SIRET / RIDET * Format attendu : SIRET (12345678901234) ou RIDET (1234567)');
fireEvent.change(siret, { target: { value: '12345678901234' } });
const denomination = screen.getByLabelText('Dénomination *');
fireEvent.change(denomination, { target: { value: 'Entreprise' } });
Expand Down Expand Up @@ -742,7 +742,7 @@ describe('candidature structure', () => {
it.each([
{
description: 'un SIRET/RIDET',
selector: 'SIRET / RIDET * Format attendu : SIRET (12345678901234) ou RIDET (123456789)',
selector: 'SIRET / RIDET * Format attendu : SIRET (12345678901234) ou RIDET (1234567)',
message: 'Veuillez renseigner le SIRET/RIDET'
},
{
Expand Down
4 changes: 2 additions & 2 deletions src/views/candidature-structure/CompanyFinder.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ export default function CompanyFinder({ onSearch, errors }) {
<Input
id="siret"
onChange={event => handleSearch(event.target.value)}
pattern="^(?:[0-9]{6,10}|[0-9]{14})$"
pattern="^(?:[0-9]{7}|[0-9]{14})$"
maxlength="14"
error={errors.siret}
>
SIRET / RIDET <span className="cc-obligatoire">*</span> <span className="fr-hint-text">Format attendu : SIRET (12345678901234) ou RIDET (123456789)</span>
SIRET / RIDET <span className="cc-obligatoire">*</span> <span className="fr-hint-text">Format attendu : SIRET (12345678901234) ou RIDET (1234567)</span>
</Input>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import RadioGroup from '../../components/commun/RadioGroup';
import { checkValidity } from '../../shared/checkValidity';

const TAILLE_SIRET = 14;
const TAILLE_RIDET = [6, 7];
const TAILLE_RIDET = [7];
const TAILLES_POSSIBLES = [...TAILLE_RIDET, TAILLE_SIRET];

const options = [
Expand Down
4 changes: 2 additions & 2 deletions src/views/candidature-structure/useEntrepriseFinder.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useState } from 'react';

const TAILLE_SIRET = 14;
const TAILLE_RIDET = [6, 7];
const TAILLE_RIDET = [7];
const TAILLES_POSSIBLES = [...TAILLE_RIDET, TAILLE_SIRET];

export const useEntrepriseFinder = (setGeoLocation, setCodeCommune) => {
Expand Down Expand Up @@ -48,7 +48,7 @@ export const useEntrepriseFinder = (setGeoLocation, setCodeCommune) => {
setError(null);
setAddressSuggestions([]);
if (!isValidSiretOrRidet(siretOrRidet)) {
setError('Veuillez entrer un RIDET (6 ou 7 chiffres) ou un SIRET (14 chiffres) valide.');
setError('Veuillez entrer un RIDET (7 chiffres) ou un SIRET (14 chiffres) valide.');
return;
}
setLoading(true);
Expand Down