✅ Split Cypress simulateur tests & some improvements
* modularize generic simulateurs tests * split salarié * improve perf (mostly: remove cy.wait calls) * ignore downloads folderpull/1596/head
parent
6c619a257b
commit
6faf98964a
|
@ -3,3 +3,4 @@ source/data/*
|
|||
!source/data/versement-transport.json
|
||||
cypress/videos
|
||||
cypress/screenshots
|
||||
cypress/downloads
|
||||
|
|
|
@ -5,7 +5,6 @@ describe('Iframe integration test', 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')
|
||||
})
|
||||
})
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
const fr = Cypress.env('language') === 'fr'
|
||||
const inputSelector = 'input.currencyInput__input:not([name$="charges"])'
|
||||
|
||||
describe('Champs localisation (simulateur salarié)', () => {
|
||||
if (!fr) {
|
||||
return
|
||||
}
|
||||
before(() => cy.visit(encodeURI('/simulateurs/salarié')))
|
||||
|
||||
it('should not crash when selecting localisation', function () {
|
||||
cy.get(inputSelector).first().type('{selectall}42')
|
||||
cy.contains('Commune').click({ force: true })
|
||||
cy.get('fieldset input[type="search"]').type('Steenvoorde')
|
||||
cy.contains('Steenvoorde (59114)').click({ force: true })
|
||||
cy.contains('Suivant').click({ force: true })
|
||||
cy.contains('Voir mes paramètres').click({ force: true })
|
||||
cy.contains('Steenvoorde')
|
||||
})
|
||||
})
|
|
@ -0,0 +1,35 @@
|
|||
const fr = Cypress.env('language') === 'fr'
|
||||
|
||||
describe('Partage (simulateur salarié)', () => {
|
||||
const brutInputSelector =
|
||||
'input.currencyInput__input[name="contrat salarié . rémunération . brut de base"]'
|
||||
const simulatorUrl = '/simulateurs/salaire-brut-net'
|
||||
const searchParams = new URLSearchParams({
|
||||
'contrat salarié': "'CDD'",
|
||||
'salaire-brut': '1539€/mois',
|
||||
})
|
||||
searchParams.set('utm_source', 'sharing')
|
||||
|
||||
const urlWithState = `${simulatorUrl}?${searchParams.toString()}`
|
||||
if (!fr) {
|
||||
return
|
||||
}
|
||||
it('should set input value from URL', function () {
|
||||
cy.visit(urlWithState)
|
||||
cy.get(brutInputSelector).first().invoke('val').should('eq', '1 539')
|
||||
|
||||
cy.contains('Voir mes paramètres').click()
|
||||
cy.get('span.answerContent').first().contains('CDD')
|
||||
})
|
||||
it('should set URL from input value', function () {
|
||||
cy.visit(simulatorUrl)
|
||||
cy.get(brutInputSelector).first().type('{selectall}1539')
|
||||
cy.contains('De quel type de contrat').should('be.visible')
|
||||
cy.get('.step').contains('CDD').should('be.visible').click()
|
||||
cy.get('button').contains('Suivant').should('be.visible')
|
||||
cy.contains('Générer un lien').click()
|
||||
cy.get('.shareableLink')
|
||||
.invoke('val')
|
||||
.should('eq', Cypress.config().baseUrl + urlWithState)
|
||||
})
|
||||
})
|
|
@ -0,0 +1,34 @@
|
|||
const fr = Cypress.env('language') === 'fr'
|
||||
const inputSelector = 'input.currencyInput__input:not([name$="charges"])'
|
||||
|
||||
describe('Persistence (simulateur salarié)', () => {
|
||||
if (!fr) {
|
||||
return
|
||||
}
|
||||
before(() => cy.visit(encodeURI('/simulateurs/salarié')))
|
||||
beforeEach(() => {
|
||||
cy.clearLocalStorage()
|
||||
})
|
||||
|
||||
it('should persist the current simulation (persistSimulation)', function () {
|
||||
cy.get(inputSelector).first().type('{selectall}42')
|
||||
cy.contains('Passer').click()
|
||||
cy.contains('Passer').click()
|
||||
cy.contains('Passer').click()
|
||||
cy.get('body').should(() => {
|
||||
expect(
|
||||
window.localStorage.getItem(
|
||||
'mon-entreprise::persisted-simulation::v5::/simulateurs/salaire-brut-net'
|
||||
)
|
||||
).to.be.not.null
|
||||
})
|
||||
cy.visit('/simulateurs/auto-entrepreneur')
|
||||
cy.get(inputSelector).first().type('{selectall}007')
|
||||
cy.contains('Passer').click()
|
||||
cy.contains('Passer').click()
|
||||
cy.contains('Passer').click()
|
||||
cy.visit(encodeURI('/simulateurs/salarié'))
|
||||
cy.contains('Retrouver ma simulation').click()
|
||||
cy.get(inputSelector).first().invoke('val').should('match', /42/)
|
||||
})
|
||||
})
|
|
@ -0,0 +1,28 @@
|
|||
const fr = Cypress.env('language') === 'fr'
|
||||
const inputSelector = 'input.currencyInput__input:not([name$="charges"])'
|
||||
|
||||
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('Passer').click()
|
||||
cy.contains('Début 2021').click()
|
||||
cy.contains('ACRE')
|
||||
})
|
||||
it('should not have negative value', () => {
|
||||
cy.contains('Mensuel').click()
|
||||
cy.wait(100)
|
||||
cy.get(inputSelector).first().type('{selectall}5000')
|
||||
cy.get(inputSelector).each(($input) => {
|
||||
cy.wrap($input).should(($i) => {
|
||||
const val = +$i.val().replace(/[\s,.]/g, '')
|
||||
expect(val).not.to.be.below(4000)
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
|
@ -0,0 +1,41 @@
|
|||
const fr = Cypress.env('language') === 'fr'
|
||||
|
||||
describe('Simulateur salarié', () => {
|
||||
if (!fr) {
|
||||
return
|
||||
}
|
||||
before(() => cy.visit(encodeURI('/simulateurs/salarié')))
|
||||
|
||||
describe('part time contract', () => {
|
||||
before(() => {
|
||||
cy.visit(encodeURI('/simulateurs/salarié'))
|
||||
cy.get('input[name$="brut de base"]').click()
|
||||
cy.get('button').contains('SMIC').click()
|
||||
cy.contains('Voir mes paramètres').click()
|
||||
cy.contains('Temps partiel').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) => {
|
||||
expect(+$input.val().replace(/[\s,.]/g, ''))
|
||||
.to.be.above(1300)
|
||||
.and.to.be.below(1500)
|
||||
})
|
||||
})
|
||||
|
||||
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) => {
|
||||
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) => {
|
||||
expect(+$input.val().replace(/[\s,.]/g, '')).to.be.above(1000)
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
|
@ -0,0 +1,3 @@
|
|||
import { runSimulateurTest } from '../../../support/simulateur'
|
||||
|
||||
runSimulateurTest('auto-entrepreneur')
|
|
@ -0,0 +1,3 @@
|
|||
import { runSimulateurTest } from '../../../support/simulateur'
|
||||
|
||||
runSimulateurTest('dirigeant-sasu')
|
|
@ -0,0 +1,3 @@
|
|||
import { runSimulateurTest } from '../../../support/simulateur'
|
||||
|
||||
runSimulateurTest('indépendant')
|
|
@ -0,0 +1,3 @@
|
|||
import { runSimulateurTest } from '../../../support/simulateur'
|
||||
|
||||
runSimulateurTest('profession-liberale')
|
|
@ -0,0 +1,3 @@
|
|||
import { runSimulateurTest } from '../../../../support/simulateur'
|
||||
|
||||
runSimulateurTest('profession-liberale/auxiliaire-medical')
|
|
@ -0,0 +1,3 @@
|
|||
import { runSimulateurTest } from '../../../../support/simulateur'
|
||||
|
||||
runSimulateurTest('profession-liberale/chirurgien-dentiste')
|
|
@ -0,0 +1,3 @@
|
|||
import { runSimulateurTest } from '../../../../support/simulateur'
|
||||
|
||||
runSimulateurTest('profession-liberale/medecin')
|
|
@ -0,0 +1,3 @@
|
|||
import { runSimulateurTest } from '../../../../support/simulateur'
|
||||
|
||||
runSimulateurTest('profession-liberale/sage-femme')
|
|
@ -0,0 +1,3 @@
|
|||
import { runSimulateurTest } from '../../../support/simulateur'
|
||||
|
||||
runSimulateurTest('salarié')
|
|
@ -76,128 +76,3 @@ describe('Simulateurs', function () {
|
|||
})
|
||||
)
|
||||
})
|
||||
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('Passer').click()
|
||||
cy.contains('Début 2021').click()
|
||||
cy.contains('ACRE')
|
||||
})
|
||||
it('should not have negative value', () => {
|
||||
cy.contains('Mensuel').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é mode partagé', () => {
|
||||
const brutInputSelector =
|
||||
'input.currencyInput__input[name="contrat salarié . rémunération . brut de base"]'
|
||||
const simulatorUrl = '/simulateurs/salaire-brut-net'
|
||||
const searchParams = new URLSearchParams({
|
||||
'contrat salarié': "'CDD'",
|
||||
'salaire-brut': '1539€/mois',
|
||||
})
|
||||
searchParams.set('utm_source', 'sharing')
|
||||
|
||||
const urlWithState = `${simulatorUrl}?${searchParams.toString()}`
|
||||
if (!fr) {
|
||||
return
|
||||
}
|
||||
it('should set input value from URL', function () {
|
||||
cy.visit(urlWithState)
|
||||
cy.wait(800)
|
||||
cy.get(brutInputSelector).first().invoke('val').should('eq', '1 539')
|
||||
|
||||
cy.contains('Voir mes paramètres').click()
|
||||
cy.get('span.answerContent').first().contains('CDD')
|
||||
})
|
||||
it('should set URL from input value', function () {
|
||||
cy.visit(simulatorUrl)
|
||||
cy.get(brutInputSelector).first().type('{selectall}1539')
|
||||
cy.wait(1000)
|
||||
cy.get('.step').find('input[value="\'CDD\'"]').click({ force: true })
|
||||
cy.wait(1000)
|
||||
cy.contains('Générer un lien').click()
|
||||
cy.get('.shareableLink')
|
||||
.invoke('val')
|
||||
.should('eq', Cypress.config().baseUrl + urlWithState)
|
||||
})
|
||||
})
|
||||
|
||||
describe('Simulateur salarié', () => {
|
||||
if (!fr) {
|
||||
return
|
||||
}
|
||||
before(() => cy.visit(encodeURI('/simulateurs/salarié')))
|
||||
|
||||
it('should persist the current simulation (persistSimulation)', function () {
|
||||
cy.get(inputSelector).first().type('{selectall}42')
|
||||
cy.contains('Passer').click()
|
||||
cy.contains('Passer').click()
|
||||
cy.contains('Passer').click()
|
||||
cy.wait(1600)
|
||||
cy.visit('/simulateurs/auto-entrepreneur')
|
||||
cy.get(inputSelector).first().type('{selectall}007')
|
||||
cy.contains('Passer').click()
|
||||
cy.contains('Passer').click()
|
||||
cy.contains('Passer').click()
|
||||
cy.wait(1600)
|
||||
cy.visit(encodeURI('/simulateurs/salarié'))
|
||||
cy.contains('Retrouver ma simulation').click()
|
||||
cy.get(inputSelector).first().invoke('val').should('match', /42/)
|
||||
})
|
||||
|
||||
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 mes paramètres').click()
|
||||
cy.contains('Steenvoorde')
|
||||
})
|
||||
|
||||
describe('part time contract', () => {
|
||||
before(() => {
|
||||
cy.visit(encodeURI('/simulateurs/salarié'))
|
||||
cy.get('input[name$="brut de base"]').click()
|
||||
cy.get('button').contains('SMIC').click()
|
||||
cy.contains('Voir mes paramètres').click()
|
||||
cy.contains('Temps partiel').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) => {
|
||||
expect(+$input.val().replace(/[\s,.]/g, ''))
|
||||
.to.be.above(1300)
|
||||
.and.to.be.below(1500)
|
||||
})
|
||||
})
|
||||
|
||||
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) => {
|
||||
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) => {
|
||||
expect(+$input.val().replace(/[\s,.]/g, '')).to.be.above(1000)
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
|
@ -9,7 +9,6 @@ describe('Navigation', function () {
|
|||
})
|
||||
it('bac à sable should work', function () {
|
||||
cy.contains('Bac à sable').click()
|
||||
cy.wait(5000)
|
||||
cy.contains('Dépenses primeur')
|
||||
cy.contains('11,50')
|
||||
})
|
||||
|
|
|
@ -0,0 +1,68 @@
|
|||
const inputSelector = 'input.currencyInput__input:not([name$="charges"])'
|
||||
const chargeInputSelector = 'input.currencyInput__input[name$="charges"]'
|
||||
const fr = Cypress.env('language') === 'fr'
|
||||
|
||||
export const runSimulateurTest = (simulateur) => {
|
||||
if (!fr) return
|
||||
|
||||
describe(`Simulateur ${simulateur}`, () => {
|
||||
before(() => cy.visit(encodeURI(`/simulateurs/${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()
|
||||
if (['indépendant', 'profession-liberale'].includes(simulateur)) {
|
||||
cy.get(chargeInputSelector).type(1000)
|
||||
}
|
||||
cy.get(inputSelector).each(($testedInput) => {
|
||||
cy.wrap($testedInput)
|
||||
.type('{selectall}60111')
|
||||
.and(($i) =>
|
||||
expect($i.val().replace(/[\s,.]/g, '')).to.match(/[1-9][\d]{3,6}$/)
|
||||
)
|
||||
cy.get(inputSelector).each(($input) => {
|
||||
if ($testedInput.get(0) === $input.get(0)) return
|
||||
cy.wrap($input).and(($i) => {
|
||||
const val = $i.val().replace(/[\s,.]/g, '')
|
||||
expect(val).not.to.be.eq('60111')
|
||||
expect(val).to.match(/[1-9][\d]{3,6}$/)
|
||||
})
|
||||
})
|
||||
cy.contains('Cotisations')
|
||||
})
|
||||
})
|
||||
|
||||
it('should allow to change period', function () {
|
||||
cy.contains('Annuel').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.get(inputSelector)
|
||||
.first()
|
||||
.invoke('val')
|
||||
.should('match', /1[\s]000/)
|
||||
if (['indépendant', 'profession-liberale'].includes(simulateur)) {
|
||||
cy.get(chargeInputSelector).first().invoke('val').should('eq', '500')
|
||||
}
|
||||
cy.contains('Annuel').click()
|
||||
})
|
||||
|
||||
it('should allow to navigate to a documentation page', function () {
|
||||
cy.get(inputSelector).first().type('{selectall}2000')
|
||||
cy.contains('Cotisations').click()
|
||||
cy.location().should((loc) => {
|
||||
expect(loc.pathname).to.match(/\/documentation\/.*\/cotisations/)
|
||||
})
|
||||
})
|
||||
|
||||
it('should allow to go back to the simulation', function () {
|
||||
cy.contains('← ').click()
|
||||
cy.get(inputSelector).first().invoke('val').should('eq', '2 000')
|
||||
})
|
||||
})
|
||||
}
|
Loading…
Reference in New Issue