Skip to content

Commit

Permalink
Retours de code review
Browse files Browse the repository at this point in the history
  • Loading branch information
Alezco committed Jul 30, 2024
1 parent 9c59059 commit 38d30e0
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 45 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"lint": "eslint src --max-warnings=0 --cache --cache-location node_modules/.cache/eslint",
"start": "vite preview",
"test": "vitest --run",
"test:watch": "vitest --watch",
"test:coverage": "npm test -- --coverage"
},
"dependencies": {
Expand Down
65 changes: 33 additions & 32 deletions src/views/candidature-structure/CandidatureStructure.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,53 +44,52 @@ describe('candidature structure', () => {

// THEN
const formulaire = screen.getByRole('form', { name: 'Candidature structure' });
const etapeInformationsDeContact = within(formulaire).getByRole('group', { name: 'Vos informations de structure' });
expect(etapeInformationsDeContact).toHaveAttribute('id', 'informationsDeContact');
const etapeInformationsDeStructure = within(formulaire).getByRole('group', { name: 'Vos informations de structure' });
expect(etapeInformationsDeStructure).toHaveAttribute('id', 'informations-de-structure');

const siretOuRidet = within(etapeInformationsDeContact).getByPlaceholderText('N° SIRET / RIDET');
expect(siretOuRidet).toHaveAttribute('id', 'siretEntreprise');
expect(siretOuRidet).toBeRequired();
// const siretOuRidet = within(etapeInformationsDeStructure).getByPlaceholderText('N° SIRET / RIDET');
// expect(siretOuRidet).toHaveAttribute('id', 'siretEntreprise');
// expect(siretOuRidet).toBeRequired();

const denomination = within(etapeInformationsDeContact).getByLabelText('Dénomination *');
const denomination = within(etapeInformationsDeStructure).getByLabelText('Dénomination *');
expect(denomination).toHaveAttribute('type', 'text');
expect(denomination).toBeRequired();

const adresse = within(etapeInformationsDeContact).getByLabelText('Adresse *');
const adresse = within(etapeInformationsDeStructure).getByLabelText('Adresse *');
expect(adresse).toHaveAttribute('type', 'text');
expect(adresse).toBeRequired();

const questionTypeDeStructure = within(etapeInformationsDeContact).getByText(textMatcher('Votre structure est *'), { selector: 'p' });
const etapeInformationsDeStructure = within(formulaire).getByRole('group', { name: 'Vos informations de structure' });
const questionTypeDeStructure = within(etapeInformationsDeStructure).getByText(textMatcher('Votre structure est *'), { selector: 'p' });
expect(etapeInformationsDeStructure).toHaveAttribute('id', 'informations-de-structure');
expect(questionTypeDeStructure).toBeInTheDocument();

const _uneCommune = screen.getByRole('radio', { name: 'Une commune' });
expect(_uneCommune).toBeRequired();
expect(_uneCommune).toHaveAttribute('name', 'typeStructure');
const uneCommune = screen.getByRole('radio', { name: 'Une commune' });
expect(uneCommune).toBeRequired();
expect(uneCommune).toHaveAttribute('name', 'typeStructure');

const _unDepartement = screen.getByRole('radio', { name: 'Un département' });
expect(_unDepartement).toBeRequired();
expect(_unDepartement).toHaveAttribute('name', 'typeStructure');
const unDepartement = screen.getByRole('radio', { name: 'Un département' });
expect(unDepartement).toBeRequired();
expect(unDepartement).toHaveAttribute('name', 'typeStructure');

const _uneRegion = screen.getByRole('radio', { name: 'Une région' });
expect(_uneRegion).toBeRequired();
expect(_uneRegion).toHaveAttribute('name', 'typeStructure');
const uneRegion = screen.getByRole('radio', { name: 'Une région' });
expect(uneRegion).toBeRequired();
expect(uneRegion).toHaveAttribute('name', 'typeStructure');

const _unEtablissemntPublic = screen.getByRole('radio', { name: 'Un établissement public de coopération intercommunale' });
expect(_unEtablissemntPublic).toBeRequired();
expect(_unEtablissemntPublic).toHaveAttribute('name', 'typeStructure');
const unEtablissemntPublic = screen.getByRole('radio', { name: 'Un établissement public de coopération intercommunale' });
expect(unEtablissemntPublic).toBeRequired();
expect(unEtablissemntPublic).toHaveAttribute('name', 'typeStructure');

const _uneCollectivite = screen.getByRole('radio', { name: 'Une collectivité à statut particulier' });
expect(_uneCollectivite).toBeRequired();
expect(_uneCollectivite).toHaveAttribute('name', 'typeStructure');
const uneCollectivite = screen.getByRole('radio', { name: 'Une collectivité à statut particulier' });
expect(uneCollectivite).toBeRequired();
expect(uneCollectivite).toHaveAttribute('name', 'typeStructure');

const _unGIP = screen.getByRole('radio', { name: 'Un GIP' });
expect(_unGIP).toBeRequired();
expect(_unGIP).toHaveAttribute('name', 'typeStructure');
const unGIP = screen.getByRole('radio', { name: 'Un GIP' });
expect(unGIP).toBeRequired();
expect(unGIP).toHaveAttribute('name', 'typeStructure');

// const _uneStructurePrivee = screen.getByRole('radio', { name: 'Une structure privée (association, entreprise de l’ESS, fondations)' });
// expect(_uneStructurePrivee).toBeRequired();
// expect(_uneStructurePrivee).toHaveAttribute('name', 'typeStructure');
const uneStructurePrivee = screen.getByRole('radio', { name: 'Une structure privée (association, entreprise de l’ESS, fondations)' });
expect(uneStructurePrivee).toBeRequired();
expect(uneStructurePrivee).toHaveAttribute('name', 'typeStructure');
});

it('quand j’affiche le formulaire alors l’étape "Vos informations de contact" est affiché', () => {
Expand Down Expand Up @@ -120,6 +119,7 @@ describe('candidature structure', () => {

const telephone = within(etapeInformationsDeContact).getByLabelText('Téléphone *');
expect(telephone).toHaveAttribute('type', 'tel');
expect(telephone).toHaveAttribute('pattern', '0[1-9]{9}');
expect(telephone).toBeRequired();
});

Expand Down Expand Up @@ -178,8 +178,9 @@ describe('candidature structure', () => {
expect(etapeMotivation).toHaveAttribute('id', 'votre-motivation');

const sousTitreVotreMotvation =
within(etapeMotivation).getByText('En quelques lignes, décrivez le motif de ' +
'votre besoin en recrutement. Indiquez les actions prévues, la justification du poste, ainsi que le public ciblé.',
within(etapeMotivation).getByText(
'En quelques lignes, décrivez le motif de votre besoin en recrutement. Indiquez les actions prévues, la justification du poste, ainsi que le ' +
'public ciblé.',
{ selector: 'p' }
);
expect(sousTitreVotreMotvation).toBeInTheDocument();
Expand Down
21 changes: 8 additions & 13 deletions src/views/candidature-structure/useSiretApi.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,15 @@
import { useState } from 'react';

const getUrlEntrepriseApiV3 = (sirenOuSiret, type) => {
let params = '?context=cnum&object=checkSiret&recipient=13002603200016';
let url = 'https://entreprise.api.gouv.fr/v3/';
const params = '?context=cnum&object=checkSiret&recipient=13002603200016';
const url = 'https://entreprise.api.gouv.fr/v3/';
let service = '';
switch (type) {
case 'siret':
service = 'insee/sirene/etablissements/' + sirenOuSiret;
break;
case 'siren':
service = 'insee/sirene/unites_legales/' + sirenOuSiret + '/siege_social/';
break;
default:
break;
if (type === 'siret') {
service = `insee/sirene/etablissements/'${sirenOuSiret}`;
} else if (type === 'siren') {
service = `insee/sirene/unites_legales/${sirenOuSiret}/siege_social/`;
}
return url + service + params;
return `${url}${service}${params}`;
};

export const useSiretApi = () => {
Expand All @@ -38,4 +33,4 @@ export const useSiretApi = () => {
};

return { search, entreprise, error };
};
};

0 comments on commit 38d30e0

Please sign in to comment.