Ajoute des tests E2E sur les versions anglaises des simulateurs auto-entrepreneur et salarié

pull/1939/head
Johan Girod 2022-01-25 14:18:16 +01:00
parent b89aaad87e
commit 46e059bec4
5 changed files with 19 additions and 16 deletions

View File

@ -0,0 +1,3 @@
import { runSimulateurTest } from '../../../../support/simulateur'
runSimulateurTest('auto-entrepreneur')

View File

@ -0,0 +1,4 @@
import { runSimulateurTest } from '../../../../support/simulateur'
const fr = Cypress.env('language') === 'fr'
runSimulateurTest(fr ? 'salaire-brut-net' : 'salary')

View File

@ -1,3 +0,0 @@
import { runSimulateurTest } from '../../../support/simulateur'
runSimulateurTest('auto-entrepreneur')

View File

@ -1,3 +0,0 @@
import { runSimulateurTest } from '../../../support/simulateur'
runSimulateurTest('salarié')

View File

@ -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/)
})