From 46e059bec400930dfdaa821103cd6b01733edde2 Mon Sep 17 00:00:00 2001 From: Johan Girod Date: Tue, 25 Jan 2022 14:18:16 +0100 Subject: [PATCH] =?UTF-8?q?Ajoute=20des=20tests=20E2E=20sur=20les=20versio?= =?UTF-8?q?ns=20anglaises=20des=20simulateurs=20auto-entrepreneur=20et=20s?= =?UTF-8?q?alari=C3=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../english/simulateurs/auto-entrepreneur.js | 3 +++ .../english/simulateurs/salarié.js | 4 ++++ .../simulateurs-generic/auto-entrepreneur.js | 3 --- .../simulateurs-generic/salarié.js | 3 --- site/cypress/support/simulateur.js | 22 ++++++++++--------- 5 files changed, 19 insertions(+), 16 deletions(-) create mode 100644 site/cypress/integration/mon-entreprise/english/simulateurs/auto-entrepreneur.js create mode 100644 site/cypress/integration/mon-entreprise/english/simulateurs/salarié.js delete mode 100644 site/cypress/integration/mon-entreprise/simulateurs-generic/auto-entrepreneur.js delete mode 100644 site/cypress/integration/mon-entreprise/simulateurs-generic/salarié.js diff --git a/site/cypress/integration/mon-entreprise/english/simulateurs/auto-entrepreneur.js b/site/cypress/integration/mon-entreprise/english/simulateurs/auto-entrepreneur.js new file mode 100644 index 000000000..cc8920f47 --- /dev/null +++ b/site/cypress/integration/mon-entreprise/english/simulateurs/auto-entrepreneur.js @@ -0,0 +1,3 @@ +import { runSimulateurTest } from '../../../../support/simulateur' + +runSimulateurTest('auto-entrepreneur') diff --git a/site/cypress/integration/mon-entreprise/english/simulateurs/salarié.js b/site/cypress/integration/mon-entreprise/english/simulateurs/salarié.js new file mode 100644 index 000000000..e791b9fc6 --- /dev/null +++ b/site/cypress/integration/mon-entreprise/english/simulateurs/salarié.js @@ -0,0 +1,4 @@ +import { runSimulateurTest } from '../../../../support/simulateur' +const fr = Cypress.env('language') === 'fr' + +runSimulateurTest(fr ? 'salaire-brut-net' : 'salary') diff --git a/site/cypress/integration/mon-entreprise/simulateurs-generic/auto-entrepreneur.js b/site/cypress/integration/mon-entreprise/simulateurs-generic/auto-entrepreneur.js deleted file mode 100644 index a0650b464..000000000 --- a/site/cypress/integration/mon-entreprise/simulateurs-generic/auto-entrepreneur.js +++ /dev/null @@ -1,3 +0,0 @@ -import { runSimulateurTest } from '../../../support/simulateur' - -runSimulateurTest('auto-entrepreneur') diff --git a/site/cypress/integration/mon-entreprise/simulateurs-generic/salarié.js b/site/cypress/integration/mon-entreprise/simulateurs-generic/salarié.js deleted file mode 100644 index ea222411d..000000000 --- a/site/cypress/integration/mon-entreprise/simulateurs-generic/salarié.js +++ /dev/null @@ -1,3 +0,0 @@ -import { runSimulateurTest } from '../../../support/simulateur' - -runSimulateurTest('salarié') diff --git a/site/cypress/support/simulateur.js b/site/cypress/support/simulateur.js index 0d40d4182..6ea97cfe5 100644 --- a/site/cypress/support/simulateur.js +++ b/site/cypress/support/simulateur.js @@ -5,16 +5,18 @@ const chargeInputSelector = const fr = Cypress.env('language') === 'fr' export const runSimulateurTest = (simulateur) => { - if (!fr) return - describe(`Simulateur ${simulateur}`, () => { - before(() => cy.visit(encodeURI(`/simulateurs/${simulateur}`))) + before(() => + cy.visit( + encodeURI(`/${fr ? 'simulateurs' : 'calculators'}/${simulateur}`) + ) + ) it('should not crash', function () { cy.get(inputSelector) }) it('should display a result when entering a value in any of the currency input', () => { - cy.contains('Annuel').click() + cy.contains(fr ? 'Annuel' : 'Yearly').click() if (['indépendant', 'profession-liberale'].includes(simulateur)) { cy.get(chargeInputSelector).type(1000) } @@ -32,31 +34,31 @@ export const runSimulateurTest = (simulateur) => { expect(val).to.match(/[1-9][\d]{3,6}$/) }) }) - cy.contains('Cotisations') + cy.contains(fr ? 'Cotisations' : 'contributions') }) }) it('should allow to change period', function () { - cy.contains('Annuel').click() + cy.contains(fr ? 'Annuel' : 'Yearly').click() cy.get(inputSelector).first().type('{selectall}12000') if (['indépendant', 'profession-liberale'].includes(simulateur)) { cy.get(chargeInputSelector).type('{selectall}6000') } cy.get(inputSelector).eq(1).invoke('val').should('not.be.empty') - cy.contains('Mensuel').click() + cy.contains(fr ? 'Mensuel' : 'Monthly').click() cy.get(inputSelector) .first() .invoke('val') - .should('match', /1[\s]000/) + .should('match', /1[\s,]000/) if (['indépendant', 'profession-liberale'].includes(simulateur)) { cy.get(chargeInputSelector).first().invoke('val').should('match', /500/) } - cy.contains('Annuel').click() + cy.contains(fr ? 'Annuel' : 'Yearly').click() }) it('should allow to navigate to a documentation page', function () { cy.get(inputSelector).first().type('{selectall}2000') - cy.contains('Cotisations').click() + cy.contains(fr ? 'Cotisations' : /(c|C)ontributions/).click() cy.location().should((loc) => { expect(loc.pathname).to.match(/\/documentation\/.*\/cotisations/) })