diff --git a/mon-entreprise/cypress/integration/external/external-integrations.js b/mon-entreprise/cypress/integration/external/external-integrations.js index c43e06c2e..11d636d0f 100644 --- a/mon-entreprise/cypress/integration/external/external-integrations.js +++ b/mon-entreprise/cypress/integration/external/external-integrations.js @@ -1,22 +1,18 @@ -describe('Pole emploi', function() { - it('should display an iframe of the simulateur', function() { - cy.on('uncaught:exception', err => { +describe('Pole emploi', function () { + it('should display an iframe of the simulateur', function () { + cy.on('uncaught:exception', (err) => { return !err.message.contains('Unexpected token <') }) cy.visit('https://entreprise.pole-emploi.fr/cout-salarie/') - cy.get('#simulateurEmbauche') - .iframe() - .contains('Salaire net') + cy.get('#simulateurEmbauche').iframe().contains('Salaire net') }) }) -describe('URSSAF', function() { - it('should display an iframe of the simulateur', function() { +describe('URSSAF', function () { + it('should display an iframe of the simulateur', function () { cy.visit( 'https://www.urssaf.fr/portail/home/utile-et-pratique/estimateur-de-cotisations-2019.html' ) - cy.get('#simulateurEmbauche') - .iframe() - .contains('Salaire net') + cy.get('#simulateurEmbauche').iframe().contains('Salaire net') }) }) diff --git a/mon-entreprise/cypress/integration/mon-entreprise/covid19.js b/mon-entreprise/cypress/integration/mon-entreprise/covid19.js index b96750bc8..489af713e 100644 --- a/mon-entreprise/cypress/integration/mon-entreprise/covid19.js +++ b/mon-entreprise/cypress/integration/mon-entreprise/covid19.js @@ -1,15 +1,12 @@ const fr = Cypress.env('language') === 'fr' const testText = (selector, text) => - cy.get(`[data-test-id=${selector}]`).should($span => { - const displayedText = $span - .text() - .trim() - .replace(/[\s]/g, ' ') + cy.get(`[data-test-id=${selector}]`).should(($span) => { + const displayedText = $span.text().trim().replace(/[\s]/g, ' ') console.log(displayedText, text) expect(displayedText).to.eq(text) }) -describe('Page covid-19', function() { +describe('Page covid-19', function () { if (!fr) { return } diff --git a/mon-entreprise/cypress/integration/mon-entreprise/demande-mobilité.js b/mon-entreprise/cypress/integration/mon-entreprise/demande-mobilité.js index 54d4b3919..a46b56469 100644 --- a/mon-entreprise/cypress/integration/mon-entreprise/demande-mobilité.js +++ b/mon-entreprise/cypress/integration/mon-entreprise/demande-mobilité.js @@ -1,6 +1,6 @@ const fr = Cypress.env('language') === 'fr' -describe('Formulaire demande mobilité', function() { +describe('Formulaire demande mobilité', function () { if (!fr) { return } @@ -49,11 +49,7 @@ describe('Formulaire demande mobilité', function() { .wait(1500) cy.contains('29240').click() cy.contains('Organisme Urssaf').click() - cy.focused() - .type('Bretagne') - .tab() - .tab() - .type('Boulangerie') + cy.focused().type('Bretagne').tab().tab().type('Boulangerie') }) it('should allow to complete "votre demande" section', () => { cy.contains('Oui').click() @@ -66,9 +62,7 @@ describe('Formulaire demande mobilité', function() { cy.get("input[name='demande . date de fin connue'][value='oui']") .next() .click() - cy.get('label[for="détachement . pays"]') - .wait(1500) - .click() + cy.get('label[for="détachement . pays"]').wait(1500).click() cy.focused() .select('Irlande') .tab() @@ -78,9 +72,7 @@ describe('Formulaire demande mobilité', function() { .tab() .tab() .type('Fabrications de gateaux bretons') - cy.get("input[name='détachement . base fixe'][value='non']") - .next() - .click() + cy.get("input[name='détachement . base fixe'][value='non']").next().click() cy.get( "input[name='commentaires additionnels . commentaires'][value='non']" ) diff --git a/mon-entreprise/cypress/integration/mon-entreprise/gérer.js b/mon-entreprise/cypress/integration/mon-entreprise/gérer.js index f117c35d2..b1ef26464 100644 --- a/mon-entreprise/cypress/integration/mon-entreprise/gérer.js +++ b/mon-entreprise/cypress/integration/mon-entreprise/gérer.js @@ -1,27 +1,23 @@ -describe('Manage page test', function() { +describe('Manage page test', function () { const fr = Cypress.env('language') === 'fr' beforeEach(() => { cy.visit(fr ? '/gérer' : '/manage') }) - it('should not crash', function() { + it('should not crash', function () { cy.contains(fr ? 'Gérer mon activité' : 'Manage my business') }) - it('should allow to retrieve company and show link corresponding to the legal status', function() { + it('should allow to retrieve company and show link corresponding to the legal status', function () { cy.get('button.cta').click() - cy.get('input') - .first() - .type('menoz') + cy.get('input').first().type('menoz') cy.contains('834364291').click() cy.contains(fr ? 'simulateur SASU' : 'simulator for SASU').click() - cy.location().should(loc => { + cy.location().should((loc) => { expect(loc.pathname).to.match(fr ? /dirigeant-sasu$/ : /sasu-chairman$/) }) }) - it('should allow auto entrepreneur to access the corresponding income simulator', function() { + it('should allow auto entrepreneur to access the corresponding income simulator', function () { cy.get('button.cta').click() - cy.get('input') - .first() - .type('gwenael girod') + cy.get('input').first().type('gwenael girod') cy.contains('MONSIEUR').click() // ask if auto-entrepreneur cy.contains( @@ -31,11 +27,11 @@ describe('Manage page test', function() { cy.contains( fr ? 'simulateur auto-entrepreneur' : 'simulator for auto-entrepreneur' ).click() - cy.location().should(loc => { + cy.location().should((loc) => { expect(loc.pathname).to.match(/auto-entrepreneur$/) }) }) - it('should be able to navigate to the hiring simulator', function() { + it('should be able to navigate to the hiring simulator', function () { cy.contains(fr ? 'une embauche' : 'hiring').click() cy.contains(fr ? 'salarié' : 'employee') }) diff --git a/mon-entreprise/cypress/integration/mon-entreprise/iframe.js b/mon-entreprise/cypress/integration/mon-entreprise/iframe.js index 621f7a239..86b694f5e 100644 --- a/mon-entreprise/cypress/integration/mon-entreprise/iframe.js +++ b/mon-entreprise/cypress/integration/mon-entreprise/iframe.js @@ -1,13 +1,11 @@ -describe('Iframe integration test', function() { +describe('Iframe integration test', function () { if (Cypress.env('language') !== 'fr') { return } - it('should display an iframe of the simulateur', function() { + it('should display an iframe of the simulateur', function () { cy.visit('/dev/integration-test') cy.contains('Visualiser').click() cy.wait(1000) - cy.get('#simulateurEmbauche') - .iframe() - .contains('Salaire net') + cy.get('#simulateurEmbauche').iframe().contains('Salaire net') }) }) diff --git a/mon-entreprise/cypress/integration/mon-entreprise/landing.js b/mon-entreprise/cypress/integration/mon-entreprise/landing.js index 7eaa1e5c8..aeec373db 100644 --- a/mon-entreprise/cypress/integration/mon-entreprise/landing.js +++ b/mon-entreprise/cypress/integration/mon-entreprise/landing.js @@ -1,15 +1,15 @@ -describe('Landing test', function() { +describe('Landing test', function () { const fr = Cypress.env('language') === 'fr' - it('should not crash', function() { + it('should not crash', function () { cy.visit('/') cy.get('img[alt="logo mon-entreprise.fr"]').should('be.visible') }) - it('should display urssaf and marianne logo', function() { + it('should display urssaf and marianne logo', function () { cy.visit('/') cy.get('img[alt="logo urssaf"]').should('be.visible') cy.get('img[alt="logo marianne"]').should('be.visible') }) - it('should display actionnable items', function() { + it('should display actionnable items', function () { cy.visit('/') cy.contains(fr ? 'Créer une entreprise' : 'Create a company') cy.contains(fr ? 'Gérer mon activité' : 'Manage my business') diff --git a/mon-entreprise/cypress/integration/mon-entreprise/navigation.js b/mon-entreprise/cypress/integration/mon-entreprise/navigation.js index 6367e2a35..190e93034 100644 --- a/mon-entreprise/cypress/integration/mon-entreprise/navigation.js +++ b/mon-entreprise/cypress/integration/mon-entreprise/navigation.js @@ -1,4 +1,4 @@ -describe('Navigation', function() { +describe('Navigation', function () { const fr = Cypress.env('language') === 'fr' it('should enable switching site language', () => { cy.visit(fr ? '/créer/auto-entrepreneur' : '/create/auto-entrepreneur') diff --git a/mon-entreprise/cypress/integration/mon-entreprise/simulateurs.js b/mon-entreprise/cypress/integration/mon-entreprise/simulateurs.js index b150507d2..af06dcb61 100644 --- a/mon-entreprise/cypress/integration/mon-entreprise/simulateurs.js +++ b/mon-entreprise/cypress/integration/mon-entreprise/simulateurs.js @@ -1,7 +1,7 @@ const fr = Cypress.env('language') === 'fr' const inputSelector = 'input.currencyInput__input:not([name$="charges"])' const chargeInputSelector = 'input.currencyInput__input[name$="charges"]' -describe('Simulateurs', function() { +describe('Simulateurs', function () { if (!fr) { return } @@ -14,11 +14,11 @@ describe('Simulateurs', function() { 'profession-liberale/medecin', 'profession-liberale/sage-femme', 'profession-liberale/auxiliaire-medical', - 'profession-liberale/chirurgien-dentiste' - ].forEach(simulateur => + 'profession-liberale/chirurgien-dentiste', + ].forEach((simulateur) => describe(simulateur, () => { before(() => cy.visit(`/simulateurs/${simulateur}`)) - it('should not crash', function() { + it('should not crash', function () { cy.get(inputSelector) }) @@ -41,12 +41,10 @@ describe('Simulateurs', function() { }) }) - it('should allow to change period', function() { + it('should allow to change period', function () { cy.contains('€/an').click() cy.wait(200) - cy.get(inputSelector) - .first() - .type('{selectall}12000') + cy.get(inputSelector).first().type('{selectall}12000') if (['indépendant', 'dirigeant-sasu'].includes(simulateur)) { cy.get(chargeInputSelector).type('{selectall}6000') } @@ -57,59 +55,50 @@ describe('Simulateurs', function() { .invoke('val') .should('match', /1[\s]000/) if (['indépendant', 'dirigeant-sasu'].includes(simulateur)) { - cy.get(chargeInputSelector) - .first() - .invoke('val') - .should('be', '500') + cy.get(chargeInputSelector).first().invoke('val').should('be', '500') } cy.contains('€/an').click() }) - it('should allow to navigate to a documentation page', function() { - cy.get(inputSelector) - .first() - .type('{selectall}2000') + it('should allow to navigate to a documentation page', function () { + cy.get(inputSelector).first().type('{selectall}2000') cy.wait(700) cy.contains('Cotisations').click() - cy.location().should(loc => { + cy.location().should((loc) => { expect(loc.pathname).to.match(/\/documentation\/.*\/cotisations/) }) }) - it('should allow to go back to the simulation', function() { + it('should allow to go back to the simulation', function () { cy.contains('← ').click() - cy.get(inputSelector) - .first() - .invoke('val') - .should('be', '2 000') + cy.get(inputSelector).first().invoke('val').should('be', '2 000') }) - - if (simulateur === 'auto-entrepreneur') { - it('should allow to enter the date of creation', () => { - cy.get(inputSelector) - .first() - .type('{selectall}50000') - cy.contains('Passer').click() - cy.contains('Passer').click() - cy.contains('Début 2020').click() - cy.contains('ACRE') - }) - it('should not have negative value', () => { - cy.contains('€/mois').click() - cy.wait(100) - cy.get(inputSelector) - .first() - .type('{selectall}5000') - cy.wait(800) - cy.get(inputSelector).each($input => { - const val = +$input.val().replace(/[\s,.]/g, '') - expect(val).not.to.be.below(4000) - }) - }) - } }) ) }) +describe('Simulateur auto-entrepreneur', () => { + if (!fr) { + return + } + before(() => cy.visit('/simulateurs/auto-entrepreneur')) + + it('should allow to enter the date of creation', () => { + cy.get(inputSelector).first().type('{selectall}50000') + cy.contains('Passer').click() + cy.contains('Début 2020').click() + cy.contains('ACRE') + }) + it('should not have negative value', () => { + cy.contains('€/mois').click() + cy.wait(100) + cy.get(inputSelector).first().type('{selectall}5000') + cy.wait(800) + cy.get(inputSelector).each(($input) => { + const val = +$input.val().replace(/[\s,.]/g, '') + expect(val).not.to.be.below(4000) + }) + }) +}) describe('Simulateur salarié', () => { if (!fr) { @@ -117,22 +106,8 @@ describe('Simulateur salarié', () => { } before(() => cy.visit('/simulateurs/salarié')) - it('should ask for CDD motif directly after CDD is selected', function() { - cy.get(inputSelector) - .eq(1) - .type('{selectall}3000') - cy.wait(1000) - cy.get('.step') - .find('input[value="\'CDD\'"]') - .click({ force: true }) - cy.contains('Suivant').click() - cy.contains('Motifs classiques') - }) - - it('should save the current simulation', function() { - cy.get(inputSelector) - .first() - .type('{selectall}2137') + it('should save the current simulation', function () { + cy.get(inputSelector).first().type('{selectall}2137') cy.contains('Passer').click() cy.contains('Passer').click() cy.contains('Passer').click() @@ -145,32 +120,28 @@ describe('Simulateur salarié', () => { .should('match', /2[\s]137/) }) - it('should not crash when selecting localisation', function() { + it('should not crash when selecting localisation', function () { cy.contains('Commune').click() cy.get('fieldset input[type="search"]').type('Steenvoorde') cy.contains('Steenvoorde (59114)').click() cy.contains('Suivant').click() cy.contains('Voir ma situation').click() - cy.contains('Steenvoorde (59114)') + cy.contains('Steenvoorde') }) describe('part time contract', () => { before(() => { cy.visit('/simulateurs/salarié') cy.get('input[name$="brut de base"]').click() - cy.get('button') - .contains('SMIC') - .click() + cy.get('button').contains('SMIC').click() cy.contains('Voir ma situation').click() cy.contains('Temps partiel').click() - cy.get('input[value="oui"]') - .parent() - .click() + cy.get('input[value="oui"]').parent().click() cy.wait(100) }) it('should permit selecting the smic before part-time contrat', () => { - cy.get('input[name$="brut de base"]').should($input => { + cy.get('input[name$="brut de base"]').should(($input) => { expect(+$input.val().replace(/[\s,.]/g, '')) .to.be.above(1300) .and.to.be.below(1500) @@ -180,11 +151,12 @@ describe('Simulateur salarié', () => { it('should permit customizing the number of worked hours and clear the input value', () => { cy.contains('Suivant').click() cy.get('fieldset input[type="text"]').type(25) - cy.get('input[name$="net après impôt"]').should($input => { + cy.get('input[name$="net après impôt"]').should(($input) => { expect(+$input.val().replace(/[\s,.]/g, '')).to.be.below(1000) }) + cy.get('fieldset input[type="text"]').clear() - cy.get('input[name$="net après impôt"]').should($input => { + cy.get('input[name$="net après impôt"]').should(($input) => { expect(+$input.val().replace(/[\s,.]/g, '')).to.be.above(1000) }) }) diff --git a/mon-entreprise/cypress/integration/mon-entreprise/status.js b/mon-entreprise/cypress/integration/mon-entreprise/status.js index 654f4d03a..e08703de9 100644 --- a/mon-entreprise/cypress/integration/mon-entreprise/status.js +++ b/mon-entreprise/cypress/integration/mon-entreprise/status.js @@ -1,18 +1,18 @@ -describe('Status guide', function() { +describe('Status guide', function () { const fr = Cypress.env('language') === 'fr' beforeEach(() => { cy.visit(fr ? '/créer' : '/create') cy.get('.cta').click() }) - it('should allow to go back clicking on the previous answers', function() { + it('should allow to go back clicking on the previous answers', function () { cy.get('.ui__.answer-group') .contains(fr ? 'Seul' : 'Alone') .click() cy.contains(fr ? 'Un seul associé' : 'Only one partner').click() cy.contains(fr ? 'Seul ou à plusieurs' : 'Number of partners') }) - it('should guide thought the SASU status', function() { + it('should guide thought the SASU status', function () { cy.get('.ui__.answer-group') .contains(fr ? 'Seul' : 'Alone') .click() @@ -21,9 +21,7 @@ describe('Status guide', function() { .click() // The click fails randomly and unexplicablly on CI cy.wait(200) - cy.get('.answer-group button') - .contains('Assimilé') - .click() + cy.get('.answer-group button').contains('Assimilé').click() cy.contains(fr ? 'Créer une SASU' : 'Create a SASU').click() cy.url().should('match', /\/SASU$/) }) diff --git a/mon-entreprise/cypress/integration/publi.codes/index.js b/mon-entreprise/cypress/integration/publi.codes/index.js index 77838d296..4c7642bcf 100644 --- a/mon-entreprise/cypress/integration/publi.codes/index.js +++ b/mon-entreprise/cypress/integration/publi.codes/index.js @@ -1,12 +1,12 @@ -describe('Navigation', function() { - it('landing should not crash', function() { +describe('Navigation', function () { + it('landing should not crash', function () { cy.visit('/') }) - it('liste des mécanismes should not crash', function() { + it('liste des mécanismes should not crash', function () { cy.contains('Liste des mécanismes').click() cy.contains('barème') }) - it('bac à sable should work', function() { + it('bac à sable should work', function () { cy.contains('Bac à sable').click() cy.wait(5000) cy.contains('Dépenses primeur') diff --git a/mon-entreprise/cypress/support/commands.js b/mon-entreprise/cypress/support/commands.js index d2e62b78c..e25527a4f 100644 --- a/mon-entreprise/cypress/support/commands.js +++ b/mon-entreprise/cypress/support/commands.js @@ -23,8 +23,8 @@ // // -- This is will overwrite an existing command -- // Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... }) -Cypress.Commands.add('iframe', { prevSubject: 'element' }, $iframe => { - return new Cypress.Promise(resolve => { +Cypress.Commands.add('iframe', { prevSubject: 'element' }, ($iframe) => { + return new Cypress.Promise((resolve) => { setTimeout(() => resolve($iframe.contents().find('body')), 6000) }) }) diff --git a/mon-entreprise/source/Provider.tsx b/mon-entreprise/source/Provider.tsx index b947da513..caa03c1d9 100644 --- a/mon-entreprise/source/Provider.tsx +++ b/mon-entreprise/source/Provider.tsx @@ -29,11 +29,11 @@ if ( window.addEventListener('load', () => { navigator.serviceWorker .register('/sw.js') - .then(registration => { + .then((registration) => { // eslint-disable-next-line no-console console.log('SW registered: ', registration) }) - .catch(registrationError => { + .catch((registrationError) => { // eslint-disable-next-line no-console console.log('SW registration failed: ', registrationError) }) @@ -61,12 +61,12 @@ export default function Provider({ initialStore, onStoreCreated, children, - sitePaths = {} as SitePaths + sitePaths = {} as SitePaths, }: ProviderProps) { const history = useMemo( () => createBrowserHistory({ - basename: process.env.NODE_ENV === 'production' ? '' : basename + basename: process.env.NODE_ENV === 'production' ? '' : basename, }), [] ) @@ -82,7 +82,7 @@ export default function Provider({ // Allows us to painlessly do route transition in action creators thunk.withExtraArgument({ history, - sitePaths + sitePaths, }), ...(reduxMiddlewares ?? []) ) diff --git a/mon-entreprise/source/Tracker.ts b/mon-entreprise/source/Tracker.ts index 8201c40cd..868f12593 100644 --- a/mon-entreprise/source/Tracker.ts +++ b/mon-entreprise/source/Tracker.ts @@ -29,7 +29,7 @@ export default class Tracker { previousPath: string | undefined constructor( - pushFunction: PushType = args => { + pushFunction: PushType = (args) => { // There is an issue with the way Safari handle cookies in iframe, cf. // https://gist.github.com/iansltx/18caf551baaa60b79206. We could probably // do better but for now we don't track action of iOs Safari user in @@ -45,7 +45,7 @@ export default class Tracker { } connectToHistory(history: History) { - this.unlistenFromHistory = history.listen(loc => { + this.unlistenFromHistory = history.listen((loc) => { this.track(loc) }) diff --git a/mon-entreprise/source/actions/actions.ts b/mon-entreprise/source/actions/actions.ts index 4fda1d8c3..f460c9149 100644 --- a/mon-entreprise/source/actions/actions.ts +++ b/mon-entreprise/source/actions/actions.ts @@ -57,34 +57,34 @@ type UpdateTargetUnitAction = ReturnType export const resetSimulation = () => ({ - type: 'RESET_SIMULATION' + type: 'RESET_SIMULATION', } as const) export const goToQuestion = (question: DottedName) => ({ type: 'STEP_ACTION', name: 'unfold', - step: question + step: question, } as const) export const validateStepWithValue = ( dottedName: DottedName, value: unknown -): ThunkResult => dispatch => { +): ThunkResult => (dispatch) => { if (value !== undefined) { dispatch(updateSituation(dottedName, value)) } dispatch({ type: 'STEP_ACTION', name: 'fold', - step: dottedName + step: dottedName, }) } export const setSituationBranch = (id: number) => ({ type: 'SET_SITUATION_BRANCH', - id + id, } as const) export const setSimulationConfig = ( @@ -99,19 +99,19 @@ export const setSimulationConfig = ( type: 'SET_SIMULATION', url, useCompanyDetails, - config + config, }) } export const setActiveTarget = (targetName: DottedName) => ({ type: 'SET_ACTIVE_TARGET_INPUT', - name: targetName + name: targetName, } as const) -export const deletePreviousSimulation = (): ThunkResult => dispatch => { +export const deletePreviousSimulation = (): ThunkResult => (dispatch) => { dispatch({ - type: 'DELETE_PREVIOUS_SIMULATION' + type: 'DELETE_PREVIOUS_SIMULATION', }) deletePersistedSimulation() } @@ -120,13 +120,13 @@ export const updateSituation = (fieldName: DottedName, value: unknown) => ({ type: 'UPDATE_SITUATION', fieldName, - value + value, } as const) export const updateUnit = (targetUnit: string) => ({ type: 'UPDATE_TARGET_UNIT', - targetUnit + targetUnit, } as const) export const goBackToSimulation = (): ThunkResult => ( @@ -140,7 +140,7 @@ export const goBackToSimulation = (): ThunkResult => ( export function loadPreviousSimulation() { return { - type: 'LOAD_PREVIOUS_SIMULATION' + type: 'LOAD_PREVIOUS_SIMULATION', } as const } @@ -151,5 +151,5 @@ export function hideNotification(id: string) { export const explainVariable = (variableName: DottedName | null = null) => ({ type: 'EXPLAIN_VARIABLE', - variableName + variableName, } as const) diff --git a/mon-entreprise/source/actions/companyCreationChecklistActions.ts b/mon-entreprise/source/actions/companyCreationChecklistActions.ts index 4fc5c8b25..a204227b1 100644 --- a/mon-entreprise/source/actions/companyCreationChecklistActions.ts +++ b/mon-entreprise/source/actions/companyCreationChecklistActions.ts @@ -18,12 +18,12 @@ export const initializeCompanyCreationChecklist = ( ({ type: 'INITIALIZE_COMPANY_CREATION_CHECKLIST', checklistItems, - statusName + statusName, } as const) export const checkCompanyCreationItem = (name: string, checked: boolean) => ({ type: 'CHECK_COMPANY_CREATION_ITEM', name, - checked + checked, } as const) diff --git a/mon-entreprise/source/actions/companyStatusActions.ts b/mon-entreprise/source/actions/companyStatusActions.ts index 043cf8d6e..2018e0dc0 100644 --- a/mon-entreprise/source/actions/companyStatusActions.ts +++ b/mon-entreprise/source/actions/companyStatusActions.ts @@ -51,7 +51,7 @@ export const isSoleProprietorship = thenGoToNextQuestion( (isSoleProprietorship?: boolean) => ({ type: 'COMPANY_IS_SOLE_PROPRIETORSHIP', - isSoleProprietorship + isSoleProprietorship, } as const) ) @@ -61,7 +61,7 @@ export const defineDirectorStatus = thenGoToNextQuestion( (status: DirectorStatus) => ({ type: 'DEFINE_DIRECTOR_STATUS', - status + status, } as const) ) @@ -69,7 +69,7 @@ export const companyHasMultipleAssociates = thenGoToNextQuestion( (multipleAssociates?: boolean) => ({ type: 'COMPANY_HAS_MULTIPLE_ASSOCIATES', - multipleAssociates + multipleAssociates, } as const) ) @@ -77,7 +77,7 @@ export const isAutoentrepreneur = thenGoToNextQuestion( (autoEntrepreneur?: boolean) => ({ type: 'COMPANY_IS_MICROENTERPRISE', - autoEntrepreneur + autoEntrepreneur, } as const) ) @@ -85,7 +85,7 @@ export const directorIsInAMinority = thenGoToNextQuestion( (minorityDirector?: boolean) => ({ type: 'SPECIFY_DIRECTORS_SHARE', - minorityDirector + minorityDirector, } as const) ) @@ -95,7 +95,7 @@ export const goToCompanyStatusChoice = (): ThunkResult => ( { history, sitePaths } ) => { dispatch({ - type: 'RESET_COMPANY_STATUS_CHOICE' + type: 'RESET_COMPANY_STATUS_CHOICE', } as const) history.push(sitePaths.créer.index) } @@ -107,12 +107,12 @@ export const resetCompanyStatusChoice = (from: string): ThunkResult => ( const answeredQuestion = Object.keys( getState().inFranceApp.companyLegalStatus ) - const answersToReset = dropWhile(a => a !== from, answeredQuestion) + const answersToReset = dropWhile((a) => a !== from, answeredQuestion) if (!answersToReset.length) { return } dispatch({ type: 'RESET_COMPANY_STATUS_CHOICE', - answersToReset + answersToReset, } as const) } diff --git a/mon-entreprise/source/actions/existingCompanyActions.ts b/mon-entreprise/source/actions/existingCompanyActions.ts index 8eeefe4b7..8b15c4ee9 100644 --- a/mon-entreprise/source/actions/existingCompanyActions.ts +++ b/mon-entreprise/source/actions/existingCompanyActions.ts @@ -1,10 +1,10 @@ import { ApiCommuneJson } from 'Components/conversation/select/SelectCommune' import { fetchCompanyDetails } from '../api/sirene' -const fetchCommuneDetails = function(codeCommune: string) { +const fetchCommuneDetails = function (codeCommune: string) { return fetch( `https://geo.api.gouv.fr/communes/${codeCommune}?fields=departement,region` - ).then(response => { + ).then((response) => { return response.json() }) } @@ -32,27 +32,27 @@ export const setEntreprise = (siren: string) => async ( ) => { dispatch({ type: 'EXISTING_COMPANY::SET_SIREN', - siren + siren, } as ActionExistingCompany) const companyDetails = await fetchCompanyDetails(siren) dispatch({ type: 'EXISTING_COMPANY::SET_DETAILS', catégorieJuridique: companyDetails.categorie_juridique, - dateDeCréation: companyDetails.date_creation + dateDeCréation: companyDetails.date_creation, }) const communeDetails: ApiCommuneJson = await fetchCommuneDetails( companyDetails.etablissement_siege.code_commune ) dispatch({ type: 'EXISTING_COMPANY::ADD_COMMUNE_DETAILS', - details: communeDetails + details: communeDetails, } as ActionExistingCompany) } export const specifyIfAutoEntrepreneur = (isAutoEntrepreneur: boolean) => ({ type: 'EXISTING_COMPANY::SPECIFY_AUTO_ENTREPRENEUR', - isAutoEntrepreneur + isAutoEntrepreneur, } as const) export const specifyIfDirigeantMajoritaire = ( @@ -60,10 +60,10 @@ export const specifyIfDirigeantMajoritaire = ( ) => ({ type: 'EXISTING_COMPANY::SPECIFY_DIRIGEANT_MAJORITAIRE', - isDirigeantMajoritaire + isDirigeantMajoritaire, } as const) export const resetEntreprise = () => ({ - type: 'EXISTING_COMPANY::RESET' + type: 'EXISTING_COMPANY::RESET', } as const) diff --git a/mon-entreprise/source/actions/hiringChecklistAction.ts b/mon-entreprise/source/actions/hiringChecklistAction.ts index 0a45d6011..7acfbbbd7 100644 --- a/mon-entreprise/source/actions/hiringChecklistAction.ts +++ b/mon-entreprise/source/actions/hiringChecklistAction.ts @@ -8,12 +8,12 @@ type CheckHiringItemAction = ReturnType export const initializeHiringChecklist = (checklistItems: Array) => ({ type: 'INITIALIZE_HIRING_CHECKLIST', - checklistItems + checklistItems, } as const) export const checkHiringItem = (name: string, checked: boolean) => ({ type: 'CHECK_HIRING_ITEM', name, - checked + checked, } as const) diff --git a/mon-entreprise/source/api/sirene.ts b/mon-entreprise/source/api/sirene.ts index 48decfdb9..f87127acf 100644 --- a/mon-entreprise/source/api/sirene.ts +++ b/mon-entreprise/source/api/sirene.ts @@ -59,7 +59,7 @@ async function searchFullText( ) .map(({ l1_normalisee, siren }) => ({ denomination: l1_normalisee, - siren + siren, })) if (!etablissements.length) { return null diff --git a/mon-entreprise/source/components/Banner.tsx b/mon-entreprise/source/components/Banner.tsx index 74ea425f4..a4179b306 100644 --- a/mon-entreprise/source/components/Banner.tsx +++ b/mon-entreprise/source/components/Banner.tsx @@ -14,7 +14,7 @@ type BannerProps = { export default function Banner({ children, hidden: hiddenProp = false, - icon + icon, }: BannerProps) { const hiddenState = useSelector(firstStepCompletedSelector) const hidden = hiddenProp || hiddenState diff --git a/mon-entreprise/source/components/BarChart.tsx b/mon-entreprise/source/components/BarChart.tsx index 707194a51..308694138 100644 --- a/mon-entreprise/source/components/BarChart.tsx +++ b/mon-entreprise/source/components/BarChart.tsx @@ -29,7 +29,7 @@ function ChartItemBar({ style, numberToPlot, unit }: ChartItemBarProps) { {formatValue(numberToPlot, { displayedUnit: unit, precision: 0, - language + language, })} @@ -59,10 +59,10 @@ export default function BarChartBranch({ icon, maximum, description, - unit + unit, }: BarChartBranchProps) { const [intersectionRef, brancheInViewport] = useDisplayOnIntersecting({ - threshold: 0.5 + threshold: 0.5, }) const { color } = useContext(ThemeColorsContext) const numberToPlot = brancheInViewport ? value : 0 @@ -70,8 +70,8 @@ export default function BarChartBranch({ config: ANIMATION_SPRING, to: { flex: numberToPlot / maximum, - opacity: numberToPlot ? 1 : 0 - } + opacity: numberToPlot ? 1 : 0, + }, }) as { flex: number; opacity: number } // TODO: problème avec les types de react-spring ? return ( @@ -90,7 +90,7 @@ export default function BarChartBranch({ mount(component).find('input') +let getInput = (component) => mount(component).find('input') describe('CurrencyInput', () => { it('should render an input', () => { expect(getInput()).to.have.length(1) @@ -76,19 +76,9 @@ describe('CurrencyInput', () => { it('should change the position of the currency symbol depending on the language', () => { const inputFr = shallow() - expect( - inputFr - .children() - .last() - .text() - ).to.includes('€') + expect(inputFr.children().last().text()).to.includes('€') const inputEn = shallow() - expect( - inputEn - .children() - .first() - .text() - ).to.includes('€') + expect(inputEn.children().first().text()).to.includes('€') }) it('should debounce onChange call', () => { @@ -155,22 +145,22 @@ describe('CurrencyInput', () => { mount() .find('input') .simulate('change', { - target: { value: '-', focus: () => {} } + target: { value: '-', focus: () => {} }, }) mount() .find('input') .simulate('change', { - target: { value: ',', focus: () => {} } + target: { value: ',', focus: () => {} }, }) mount() .find('input') .simulate('change', { - target: { value: ',5', focus: () => {} } + target: { value: ',5', focus: () => {} }, }) mount() .find('input') .simulate('change', { - target: { value: '8,', focus: () => {} } + target: { value: '8,', focus: () => {} }, }) expect(onChange).not.to.have.been.called }) diff --git a/mon-entreprise/source/components/CurrencyInput/CurrencyInput.tsx b/mon-entreprise/source/components/CurrencyInput/CurrencyInput.tsx index 92b3c62cb..e469f99be 100644 --- a/mon-entreprise/source/components/CurrencyInput/CurrencyInput.tsx +++ b/mon-entreprise/source/components/CurrencyInput/CurrencyInput.tsx @@ -53,7 +53,7 @@ export default function CurrencyInput({ event.persist() event.target = { ...event.target, - value: nextValue.current + value: nextValue.current, } nextValue.current = '' onChangeDebounced?.(event) @@ -62,7 +62,7 @@ export default function CurrencyInput({ const { isCurrencyPrefixed, thousandSeparator, - decimalSeparator + decimalSeparator, } = currencyFormat(language) // Autogrow the input const valueLength = currentValue.toString().length diff --git a/mon-entreprise/source/components/Distribution.tsx b/mon-entreprise/source/components/Distribution.tsx index 3144d8f6e..54a9cceee 100644 --- a/mon-entreprise/source/components/Distribution.tsx +++ b/mon-entreprise/source/components/Distribution.tsx @@ -18,11 +18,11 @@ export default function Distribution() { ).map(([section, cotisations]) => [ section, cotisations - .map(c => engine.evaluate({ valeur: c, unité: targetUnit })) + .map((c) => engine.evaluate({ valeur: c, unité: targetUnit })) .reduce( (acc, evaluation) => acc + ((evaluation?.nodeValue as number) || 0), 0 - ) + ), ]) as Array<[DottedName, number]>) .filter(([, value]) => value > 0) .sort(([, a], [, b]) => b - a) @@ -55,7 +55,7 @@ export function DistributionBranch({ dottedName, value, icon, - maximum + maximum, }: DistributionBranchProps) { const rules = useContext(EngineContext).getParsedRules() const branche = rules[dottedName] diff --git a/mon-entreprise/source/components/EngineValue.tsx b/mon-entreprise/source/components/EngineValue.tsx index abc839804..571a4a795 100644 --- a/mon-entreprise/source/components/EngineValue.tsx +++ b/mon-entreprise/source/components/EngineValue.tsx @@ -1,4 +1,4 @@ -import Engine, { EvaluatedNode, formatValue } from 'publicodes' +import Engine, { formatValue } from 'publicodes' import React, { useContext } from 'react' import { useTranslation } from 'react-i18next' import { DottedName } from 'Rules' @@ -32,12 +32,12 @@ export default function Value({ const isRule = expression in e.getParsedRules() const evaluation = e.evaluate({ valeur: expression, - ...(unit && { unité: unit }) + ...(unit && { unité: unit }), }) const value = formatValue(evaluation, { displayedUnit, language, - precision + precision, }) if (isRule && linkToRule) { return ( @@ -55,7 +55,9 @@ type ConditionProps = { } export function Condition({ expression, children }: ConditionProps) { const engine = useContext(EngineContext) - if (!coerceArray(expression).every(expr => engine.evaluate(expr).nodeValue)) { + if ( + !coerceArray(expression).every((expr) => engine.evaluate(expr).nodeValue) + ) { return null } return <>{children} diff --git a/mon-entreprise/source/components/Feedback/FeedbackForm.tsx b/mon-entreprise/source/components/Feedback/FeedbackForm.tsx index dedb37745..b0c0bc9fd 100644 --- a/mon-entreprise/source/components/Feedback/FeedbackForm.tsx +++ b/mon-entreprise/source/components/Feedback/FeedbackForm.tsx @@ -39,23 +39,23 @@ export default function FeedbackForm({ onEnd, onCancel }: Props) { tag: 'textarea', placeholder: 'Your Message...', defaultValue: '', - rows: 7 + rows: 7, }, { display: 'Nom', name: 'name', tag: 'input', type: 'text', - defaultValue: '-' + defaultValue: '-', }, { display: 'Email (pour recevoir notre réponse)', name: 'email', tag: 'input', type: 'email', - placeholder: 'Your Email' - } - ] + placeholder: 'Your Email', + }, + ], }) } script.src = 'https://mon-entreprise.zammad.com/assets/form/form.js' diff --git a/mon-entreprise/source/components/Feedback/PageFeedback.tsx b/mon-entreprise/source/components/Feedback/PageFeedback.tsx index c98cc692d..381f0496b 100644 --- a/mon-entreprise/source/components/Feedback/PageFeedback.tsx +++ b/mon-entreprise/source/components/Feedback/PageFeedback.tsx @@ -30,7 +30,7 @@ const feedbackAlreadyGiven = (feedback: [string, string]) => { export default function PageFeedback({ customMessage, - customEventName + customEventName, }: PageFeedbackProps) { const location = useLocation() const tracker = useContext(TrackerContext) @@ -39,8 +39,8 @@ export default function PageFeedback({ showThanks: false, feedbackAlreadyGiven: feedbackAlreadyGiven([ customEventName || 'rate page usefulness', - location.pathname - ]) + location.pathname, + ]), }) const handleFeedback = useCallback(({ useful }: { useful: boolean }) => { @@ -48,19 +48,19 @@ export default function PageFeedback({ 'trackEvent', 'Feedback', useful ? 'positive rating' : 'negative rating', - location.pathname + location.pathname, ]) const feedback = [ customEventName || 'rate page usefulness', location.pathname, - useful ? 10 : 0.1 + useful ? 10 : 0.1, ] as [string, string, number] tracker.push(['trackEvent', 'Feedback', ...feedback]) saveFeedbackOccurrenceInLocalStorage(feedback) setState({ showThanks: useful, feedbackAlreadyGiven: true, - showForm: !useful + showForm: !useful, }) }, []) diff --git a/mon-entreprise/source/components/FindCompany.tsx b/mon-entreprise/source/components/FindCompany.tsx index be2d3e469..d999f0747 100644 --- a/mon-entreprise/source/components/FindCompany.tsx +++ b/mon-entreprise/source/components/FindCompany.tsx @@ -7,14 +7,15 @@ import { Etablissement, searchDenominationOrSiren } from '../api/sirene' import { debounce } from '../utils' export default function Search() { - const [searchResults, setSearchResults] = useState | null>() + const [ + searchResults, + setSearchResults, + ] = useState | null>() const [isLoading, setLoadingState] = useState(false) const handleSearch = useCallback( - function(value) { - searchDenominationOrSiren(value).then(results => { + function (value) { + searchDenominationOrSiren(value).then((results) => { setLoadingState(false) setSearchResults(results) }) @@ -22,7 +23,7 @@ export default function Search() { [setSearchResults, setLoadingState] ) const debouncedHandleSearch = useMemo(() => debounce(300, handleSearch), [ - handleSearch + handleSearch, ]) const dispatch = useDispatch() return ( @@ -58,7 +59,7 @@ export default function Search() { border-color: var(--color); } `} - onChange={e => { + onChange={(e) => { if (e.target.value.length < 2) { setSearchResults(undefined) return diff --git a/mon-entreprise/source/components/LangSwitcher.tsx b/mon-entreprise/source/components/LangSwitcher.tsx index e3aa08d50..c090901c5 100644 --- a/mon-entreprise/source/components/LangSwitcher.tsx +++ b/mon-entreprise/source/components/LangSwitcher.tsx @@ -3,7 +3,7 @@ import { useTranslation } from 'react-i18next' const languageCodeToEmoji = { en: '🇬🇧', - fr: '🇫🇷' + fr: '🇫🇷', } export default function LangSwitcher({ className }: { className: string }) { diff --git a/mon-entreprise/source/components/MoreInfosOnUs.tsx b/mon-entreprise/source/components/MoreInfosOnUs.tsx index 869342ace..2472bad18 100644 --- a/mon-entreprise/source/components/MoreInfosOnUs.tsx +++ b/mon-entreprise/source/components/MoreInfosOnUs.tsx @@ -65,7 +65,7 @@ export default function MoreInfosOnUs() { style={{ width: '3rem', height: '3rem', - margin: 0 + margin: 0, }} > diff --git a/mon-entreprise/source/components/NewsletterRegister.tsx b/mon-entreprise/source/components/NewsletterRegister.tsx index ba1d7a06e..b22510b13 100644 --- a/mon-entreprise/source/components/NewsletterRegister.tsx +++ b/mon-entreprise/source/components/NewsletterRegister.tsx @@ -10,7 +10,7 @@ import * as animate from 'Components/ui/animate' const formInfos = { method: 'post', action: - 'https://b713d5c4.sibforms.com/serve/MUIEAEJui5ynU5AtcKQfxhATKzruDK8yC3YO4M56ltHV6LXHnZPESWHRjwK6Dtp3GgPqu49TljpGSa4Iy-BbaqLArDYDt5mEYtvOkrPD2b5siSNsthqi9kDz8wbljxKSDRbOQztsjyp3InDR1EUrTZJvyAk9YEkXtANb5upeHfN2VTF2m6lRiyOMF9B5VfD6jWGyxJaSNR8gsVQo?isAjax=1' + 'https://b713d5c4.sibforms.com/serve/MUIEAEJui5ynU5AtcKQfxhATKzruDK8yC3YO4M56ltHV6LXHnZPESWHRjwK6Dtp3GgPqu49TljpGSa4Iy-BbaqLArDYDt5mEYtvOkrPD2b5siSNsthqi9kDz8wbljxKSDRbOQztsjyp3InDR1EUrTZJvyAk9YEkXtANb5upeHfN2VTF2m6lRiyOMF9B5VfD6jWGyxJaSNR8gsVQo?isAjax=1', } export default function NewsletterRegister() { @@ -30,7 +30,7 @@ export default function NewsletterRegister() { } fetch(formInfos.action, { method: formInfos.method, - body: new FormData(formElement.current) + body: new FormData(formElement.current), }).then(() => { tracker.push(['trackEvent', 'Newsletter', 'registered']) setUserIsRegistered(true) diff --git a/mon-entreprise/source/components/Notifications.tsx b/mon-entreprise/source/components/Notifications.tsx index 71a321536..17e249d9b 100644 --- a/mon-entreprise/source/components/Notifications.tsx +++ b/mon-entreprise/source/components/Notifications.tsx @@ -3,7 +3,7 @@ import animate from 'Components/ui/animate' import { useInversionFail, EngineContext, - useEngine + useEngine, } from 'Components/utils/EngineContext' import { useContext } from 'react' import emoji from 'react-easy-emoji' @@ -30,8 +30,8 @@ export function getNotifications(engine: Engine) { (rule: ASTNode & { nodeKind: 'rule' }) => rule.rawNode['type'] === 'notification' ) - .map(node => evaluateRule(engine, node.dottedName)) - .filter(node => !!node.nodeValue) + .map((node) => evaluateRule(engine, node.dottedName)) + .filter((node) => !!node.nodeValue) } export default function Notifications() { const { t } = useTranslation() @@ -52,8 +52,8 @@ export default function Notifications() { 'Le montant saisi abouti à un résultat impossible. Cela est dû à un effet de seuil dans le calcul des cotisations.\n\nNous vous invitons à réessayer en modifiant légèrement le montant renseigné (quelques euros de plus par exemple).' ), type: 'notification', - sévérité: 'avertissement' - } + sévérité: 'avertissement', + }, ] : ((getNotifications(engine) as any) as Array) if (!messages?.length) return null diff --git a/mon-entreprise/source/components/Overlay.tsx b/mon-entreprise/source/components/Overlay.tsx index 680b15151..d0d283ddd 100644 --- a/mon-entreprise/source/components/Overlay.tsx +++ b/mon-entreprise/source/components/Overlay.tsx @@ -49,7 +49,7 @@ export default function Overlay({
) - .map(cotisation => cotisation.dottedName) + .map((cotisation) => cotisation.dottedName) .filter(Boolean) .map( - dottedName => + (dottedName) => dottedName.replace(/ . (salarié|employeur)$/, '') as DottedName ) .reduce((acc, cotisation: DottedName) => { const sectionName = getSection(parsedRules[cotisation]) return { ...acc, - [sectionName]: (acc[sectionName] ?? new Set()).add(cotisation) + [sectionName]: (acc[sectionName] ?? new Set()).add(cotisation), } }, {} as Record>) return Object.entries(cotisations) @@ -131,7 +131,7 @@ export default function PaySlip() {
- {cotisations.map(cotisation => ( + {cotisations.map((cotisation) => ( ))} @@ -179,7 +179,10 @@ export default function PaySlip() { ) } -function findReferenceInNode(dottedName: DottedName, node: EvaluatedNode) { +function findReferenceInNode( + dottedName: DottedName, + node: EvaluatedNode +): EvaluatedNode | null { return reduceAST<(EvaluatedNode & { nodeKind: 'reference' }) | null>( (acc, node) => { if ( diff --git a/mon-entreprise/source/components/PaySlipSections.tsx b/mon-entreprise/source/components/PaySlipSections.tsx index 3a28ea94e..d72f38768 100644 --- a/mon-entreprise/source/components/PaySlipSections.tsx +++ b/mon-entreprise/source/components/PaySlipSections.tsx @@ -35,7 +35,7 @@ export const SalaireNetSection = () => { diff --git a/mon-entreprise/source/components/PercentageField.tsx b/mon-entreprise/source/components/PercentageField.tsx index acb6cbe4a..bbade0a39 100644 --- a/mon-entreprise/source/components/PercentageField.tsx +++ b/mon-entreprise/source/components/PercentageField.tsx @@ -14,7 +14,7 @@ type PercentageFieldProps = InputCommonProps & { export default function PercentageField({ onChange, value, - debounce = 0 + debounce = 0, }: PercentageFieldProps) { const [localValue, setLocalValue] = useState(value) const debouncedOnChange = useCallback( @@ -27,7 +27,7 @@ export default function PercentageField({
{ + onChange={(e) => { const value = e.target.value setLocalValue(value) debouncedOnChange(value) @@ -42,7 +42,7 @@ export default function PercentageField({ {formatValue(localValue, { language, - displayedUnit: '%' + displayedUnit: '%', })}
diff --git a/mon-entreprise/source/components/PeriodSwitch.tsx b/mon-entreprise/source/components/PeriodSwitch.tsx index f0fc5291b..d19771a92 100644 --- a/mon-entreprise/source/components/PeriodSwitch.tsx +++ b/mon-entreprise/source/components/PeriodSwitch.tsx @@ -12,7 +12,7 @@ export default function PeriodSwitch() { return ( - {units.map(unit => ( + {units.map((unit) => (