Ajoute des tests extensif pour tous les simulateurs

pull/640/head
Johan Girod 2019-10-22 14:25:06 +02:00
parent c40ae69660
commit f958e632d5
18 changed files with 205 additions and 141 deletions

View File

@ -1,15 +0,0 @@
# Redirects following architectural changes on the end of October 2018
/s%C3%A9curit%C3%A9-sociale /g%C3%A9rer 301
/d%C3%A9marches-embauche /g%C3%A9rer/embaucher 301
/s%C3%A9curit%C3%A9-sociale/s%C3%A9lection-du-r%C3%A9gime /simulateurs 301
/s%C3%A9curit%C3%A9-sociale/* /simulateurs/:splat 301
/entreprise/cr%C3%A9er-une-* /cr%C3%A9er/:splat 301
/entreprise/devenir-* /cr%C3%A9er/:splat 301
/entreprise* /cr%C3%A9er:splat 301
/social-security /manage 301
/social-security/assimilated-salaried /social-security/assimile-salarie 301
/social-security/* /simulators/:splat 301
/company/create-a-* /create/:splat 301
/company/become-* /create/:splat 301
/company* /create:splat 301

View File

@ -27,7 +27,7 @@ commands:
type: string
default: https://mon-entreprise.fr
steps:
- run: CYPRESS_baseUrl=<< parameters.base_url >> yarn run cypress run --record --key 21660df5-36a5-4c49-b23d-801799b0c759 --env language=<< parameters.language >> --config integrationFolder=cypress/integration/<< parameters.integration_folder >>
- run: CYPRESS_baseUrl=<< parameters.base_url >> yarn run cypress run --parallel --record --key 21660df5-36a5-4c49-b23d-801799b0c759 --env language=<< parameters.language >> --config integrationFolder=cypress/integration/<< parameters.integration_folder >>
jobs:
unit-test:
@ -46,6 +46,7 @@ jobs:
- image: cypress/base:8
environment:
TERM: xterm
parallelism: 2
steps:
- install
- run: yarn run compile-dev

View File

@ -6,4 +6,4 @@
},
"integrationFolder": "cypress/integration/mon-entreprise",
"chromeWebSecurity": false
}
}

View File

@ -1,4 +1,5 @@
globals:
cy: false
Cypress: false
expect: false
parser: esprima

View File

@ -0,0 +1,33 @@
describe('Manage page test', function () {
const fr = Cypress.env('language') === 'fr'
beforeEach(() => {
cy.visit(fr ? '/gérer' : '/manage')
})
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 () {
cy.get('button.cta').click()
cy.get('input').first().type('menoz')
cy.contains('834364291').click()
cy.contains('assimilé-salarié').click()
cy.location().should((loc) => {
expect(loc.pathname).to.match(fr ? /assimil%C3%A9-salari%C3%A9$/ : /assimile-salarie$/)
})
})
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.contains('MONSIEUR').click()
// ask if auto-entrepreneur
cy.contains(fr ? 'Êtes-vous auto-entrepreneur ?' : 'Are you auto-entrepreneur?')
cy.contains(fr ? 'Oui' : 'Yes').click()
cy.contains(fr ? 'simulateur auto-entrepreneur' : 'simulator for auto-entrepreneur').click()
cy.location().should((loc) => {
expect(loc.pathname).to.match(/auto-entrepreneur$/)
})
})
})

View File

@ -1,6 +1,11 @@
describe('Iframe integration test', function() {
it('should display an iframe of the simulateur', function() {
describe('Iframe integration test', function () {
if (Cypress.env('language') !== 'fr') {
return
}
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')

View File

@ -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')

View File

@ -1,17 +1,26 @@
describe('Navigation', function() {
describe('Navigation', function () {
const fr = Cypress.env('language') === 'fr'
it('should enable switching site language', () => {
cy.visit(
fr
? '/entreprise/devenir-auto-entrepreneur'
: '/company/become-auto-entrepreneur'
? '/créer/auto-entrepreneur'
: '/create/auto-entrepreneur'
)
cy.contains(fr ? 'Switch to English' : 'Passer en français').click()
cy.url().should(
'include',
fr
? '/company/become-auto-entrepreneur'
: '/entreprise/devenir-auto-entrepreneur'
? '/create/auto-entrepreneur'
: '/cr%C3%A9er/auto-entrepreneur'
)
})
it('should go back to home when clicking on logo', () => {
cy.visit('/documentation/contrat-salarié')
cy.get('img[alt^="logo mon-entreprise"]').click()
cy.url().should(
'be',
Cypress.baseUrl
)
})
})

View File

@ -1,46 +0,0 @@
const salaryInput = inputTitle => {
const inputContainer = cy
.contains(inputTitle)
.closest('.main')
.find('.targetInputOrValue')
inputContainer.click()
return inputContainer.find('input')
}
const fr = Cypress.env('language') === 'fr'
if (fr) {
beforeEach(() => {
cy.visit('/sécurité-sociale/salarié')
})
describe('Basic test', function() {
it('should display the simulateur after loading', function() {
cy.contains('Salaire net')
})
it('should display cotisation repartition when entering net salary', function() {
salaryInput('Salaire net').type('2000')
cy.get('.distribution-chart__container')
})
it('should allow to navigate to a documentation page', function() {
salaryInput('Salaire net').type('2000')
cy.contains('Total chargé').click()
cy.contains(
`C'est le total que l'employeur doit verser pour employer un salarié`
)
})
})
describe('Simulation saving test', function() {
it('should save the current simulation', function() {
salaryInput('Salaire net').type('471')
cy.wait(1000)
cy.contains('Passer').click()
cy.contains('Passer').click()
cy.contains('Passer').click()
// Wanted to use cypress.clock(), but can't because of piwik changing Date prototype (!)
cy.wait(1100)
cy.visit('/sécurité-sociale/salarié')
cy.contains('Retrouver ma simulation').click()
salaryInput('Salaire net').should('have.value', '471')
})
})
}

View File

@ -1,46 +1,69 @@
const salaryInput = inputTitle => {
const inputContainer = cy
.contains(inputTitle)
.closest('.main')
.find('.targetInputOrValue')
inputContainer.click()
return inputContainer.find('input')
}
describe('Simulateurs test', function() {
const fr = Cypress.env('language') === 'fr'
const fr = Cypress.env('language') === 'fr'
const inputSelector = 'input.currencyInput__input:not([name$="charges"])'
describe('Simulateurs', function () {
if (!fr) { return }
['indépendant', 'assimilé-salarié', 'auto-entrepreneur', 'salarié'].forEach(simulateur =>
describe(simulateur, () => {
before(() => cy.visit(`/simulateurs/${simulateur}`))
it('should not crash', function () {
cy.get(inputSelector)
})
it('should not crash', function() {
cy.visit(fr ? '/sécurité-sociale' : '/social-security')
cy.contains(
fr ? 'Que souhaitez-vous estimer ?' : 'What do you want to estimate?'
)
})
it('should display selection page', function() {
cy.visit(fr ? '/sécurité-sociale' : '/social-security')
cy.contains(fr ? 'Mon revenu' : 'My income').click()
cy.contains(
fr
? 'Quel régime souhaitez-vous explorer ?'
: 'Which social scheme would you like to explore?'
)
cy.contains('Indépendant').click({ force: true })
cy.contains(
fr
? 'Simulateur de revenus pour indépendants'
: 'Self-employed income simulator'
)
})
it('donne une estimation pour le revenu des indépendants', function() {
cy.visit(
fr ? '/sécurité-sociale/indépendant' : '/social-security/self-employed'
)
salaryInput(fr ? 'Rémunération totale' : 'Director total income').type(
100000,
{
force: true
}
)
cy.contains(fr ? 'Cotisations et contributions' : 'All contributions')
})
})
it('should display a result when entering a value in any of the currency input', () => {
cy.contains('année').click()
if (['indépendant', 'assimilé-salarié'].includes(simulateur)) {
cy.get('input.currencyInput__input[name$="charges"]').type(1000)
}
cy.get(inputSelector).each((testedInput, i) => {
cy.wrap(testedInput).type('{selectall}60000')
cy.wait(600)
cy.contains('Cotisations')
cy.get(inputSelector).each(($input, j) => {
const val = $input.val().replace(/[\s,.]/g, '')
if (i != j) {
expect(val).not.to.be.eq('60000')
}
expect(val).to.match(/[1-9][\d]*$/)
})
})
})
it.only('should allow to change period', function () {
cy.contains('année').click()
cy.get(inputSelector).first().type('{selectall}12000')
cy.wait(500)
cy.contains('mois').click()
cy.get(inputSelector).first().invoke('val').should('match', /1[\s]000/)
})
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) => {
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('be', '2000')
})
if (simulateur === 'salarié') {
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()
cy.wait(1000)
cy.visit('/simulateurs/salarié')
cy.contains('Retrouver ma simulation').click()
cy.get(inputSelector).first().invoke('val').should('match', /2[\s]137/)
})
}
})
)
})

View File

@ -1,27 +1,18 @@
describe('Status guide', function() {
describe('Status guide', function () {
const fr = Cypress.env('language') === 'fr'
beforeEach(() => {
cy.visit(fr ? '/entreprise' : '/company')
cy.get('a.ui__.button.plain').click()
cy.visit(fr ? '/créer' : '/create')
cy.get('.cta').click()
})
it('should allow to go back clicking on the previous button', function() {
cy.get('.ui__.answer-group')
.contains(fr ? 'Seul' : 'Alone')
.click()
cy.get('.ui__.answer-group')
.contains(fr ? 'Précédent' : 'Previous')
.click()
cy.contains(fr ? 'Seul ou à plusieurs' : 'Number of partners')
})
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()
@ -34,5 +25,6 @@ describe('Status guide', function() {
.contains('Assimilé')
.click()
cy.contains(fr ? 'Créer une SASU' : 'Create a SASU').click()
cy.url().should('match', /\/SASU$/)
})
})

View File

@ -25,6 +25,6 @@
// Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... })
Cypress.Commands.add('iframe', { prevSubject: 'element' }, $iframe => {
return new Cypress.Promise(resolve => {
setTimeout(() => resolve($iframe.contents().find('body')), 5000)
setTimeout(() => resolve($iframe.contents().find('body')), 6000)
})
})

View File

@ -1,3 +1,69 @@
# Redirects following architectural changes on the end of October 2018
[[redirects]]
from="/s%C3%A9curit%C3%A9-sociale"
to="/g%C3%A9rer"
status = 301
[[redirects]]
from="/d%C3%A9marches-embauche"
to="/g%C3%A9rer/embaucher"
status = 301
[[redirects]]
from="/s%C3%A9curit%C3%A9-sociale/s%C3%A9lection-du-r%C3%A9gime"
to="/simulateurs"
status = 301
[[redirects]]
from="/s%C3%A9curit%C3%A9-sociale/*"
to="/simulateurs/:splat"
status = 301
[[redirects]]
from="/entreprise/cr%C3%A9er-une-*"
to="/cr%C3%A9er/:splat"
status = 301
[[redirects]]
from="/entreprise/devenir-*"
to="/cr%C3%A9er/:splat"
status = 301
[[redirects]]
from="/entreprise*"
to="/cr%C3%A9er:splat"
status = 301
[[redirects]]
from="/social-security"
to="/manage"
status = 301
[[redirects]]
from="/social-security/assimilated-salaried"
to="/social-security/assimile-salarie"
status = 301
[[redirects]]
from="/social-security/*"
to="/simulators/:splat"
status = 301
[[redirects]]
from="/company/create-a-*"
to="/create/:splat"
status = 301
[[redirects]]
from="/company/become-*"
to="/create/:splat"
status = 301
[[redirects]]
from="/company*"
to="/create:splat"
status = 301
# SEO redirect
[[redirects]]

View File

@ -13,9 +13,6 @@ objectifs:
- entreprise . charges
- entreprise . chiffre d'affaires minimum
objectifs secondaires:
- contrat salarié . cotisations
questions:
à l'affiche:
ACRE: entreprise . ACRE

View File

@ -342,7 +342,7 @@ gérer:
<0>Access the official auto-entrepreneur website</0>
<1>You will be able to make your turnover declaration, pay your contributions, and more widely find all the information relating to the status of auto-entrepreneur</1>
entreprise:
auto: Are you an auto-entrepreneur?
auto: Are you auto-entrepreneur?
dirigeant: |
<0>Are you the majority director?</0>
<1>If you are a majority director or a member of a majority board of directors, you will not have the same social security system as if you are a minority.</1>

View File

@ -118,8 +118,6 @@ const App = compose(withSitePaths)(({ sitePaths }) => {
path={sitePaths.documentation.index}
component={Documentation}
/>
<Route path={sitePaths.privacy.index} component={PrivacyContent} />
<Route path={sitePaths.integration.index} component={Integration} />
<Route exact path="/dev/sitemap" component={Sitemap} />
<Route

View File

@ -39,7 +39,7 @@ export default function Header() {
<a
href="https://www.urssaf.fr"
target="_blank"
css={{
style={{
height: '4rem',
padding: '1rem'
}}

View File

@ -115,7 +115,7 @@ module.exports = {
outputDir: path.resolve('dist', 'prerender', 'mon-entreprise'),
routes: [
'/',
'/sécurité-sociale/salarié',
'/simulateurs/salarié',
'/iframes/simulateur-embauche'
],
indexPath: path.resolve('dist', 'mon-entreprise.html')