From 9eaaf8fc228752629b8986d846414f77ea64a51e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Rialland?= Date: Wed, 30 Nov 2022 20:00:58 +0100 Subject: [PATCH] Update cypress to v12 prerelease --- .github/workflows/deploy.yaml | 2 + site/cypress.config.ts | 2 +- .../integration/mon-entreprise/covid19.ts | 2 +- .../mon-entreprise/demande-mobilité.ts | 4 +- .../mon-entreprise/english/prerender.ts | 1 + .../integration/mon-entreprise/landing.ts | 4 +- .../mon-entreprise/localisation-field.js | 4 +- .../mon-entreprise/partage-simulation.js | 4 +- .../mon-entreprise/persistence-simulation.js | 10 +-- .../mon-entreprise/simulateur-ae.ts | 2 +- .../mon-entreprise/simulateur-dividendes.js | 4 +- .../mon-entreprise/simulateur-salarie.ts | 81 +++++++++---------- site/cypress/support/simulateur.js | 2 +- site/package.json | 2 +- yarn.lock | 10 +-- 15 files changed, 65 insertions(+), 69 deletions(-) diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml index bc206b98c..d646ff298 100644 --- a/.github/workflows/deploy.yaml +++ b/.github/workflows/deploy.yaml @@ -280,6 +280,8 @@ jobs: - name: Test e2e mon-entreprise on preview (site=${{ matrix.site }}, browser=${{ matrix.browser}}, viewport=${{ matrix.viewport }}) uses: cypress-io/github-action@v4 with: + # Hack to use local node version, issue : https://github.com/cypress-io/github-action/issues/489#issuecomment-1021379037 + command-prefix: '--' install: false working-directory: site record: true diff --git a/site/cypress.config.ts b/site/cypress.config.ts index 80aa63600..16eec0c75 100644 --- a/site/cypress.config.ts +++ b/site/cypress.config.ts @@ -15,7 +15,7 @@ export default defineConfig({ retries: { // Configure retry attempts for `cypress run` // Default is 0 - runMode: 2, + runMode: 3, // Configure retry attempts for `cypress open` // Default is 0 openMode: 0, diff --git a/site/cypress/integration/mon-entreprise/covid19.ts b/site/cypress/integration/mon-entreprise/covid19.ts index fba52758b..313b5be08 100644 --- a/site/cypress/integration/mon-entreprise/covid19.ts +++ b/site/cypress/integration/mon-entreprise/covid19.ts @@ -1,6 +1,6 @@ import { fr } from '../../support/utils' -describe('Page covid-19', function () { +describe('Page covid-19', { testIsolation: 'off' }, function () { if (!fr) { return } diff --git a/site/cypress/integration/mon-entreprise/demande-mobilité.ts b/site/cypress/integration/mon-entreprise/demande-mobilité.ts index 9d50433c2..75991af4c 100644 --- a/site/cypress/integration/mon-entreprise/demande-mobilité.ts +++ b/site/cypress/integration/mon-entreprise/demande-mobilité.ts @@ -77,7 +77,9 @@ describe(`Formulaire demande mobilité (${ .focused() cy.contains('65100').type('{enter}').focused().tab().type('{downarrow}') - cy.focused().tab().type('Brest').wait('@communes') + cy.focused().tab().type('Brest') + + cy.wait('@communes') cy.contains('29200') .type('{enter}') diff --git a/site/cypress/integration/mon-entreprise/english/prerender.ts b/site/cypress/integration/mon-entreprise/english/prerender.ts index fe2dbb949..7690178a5 100644 --- a/site/cypress/integration/mon-entreprise/english/prerender.ts +++ b/site/cypress/integration/mon-entreprise/english/prerender.ts @@ -115,6 +115,7 @@ describe('Test prerender', function () { cy.visit(path || '/', { script: false }) .get('#loading', { timeout: 200 }) .should('not.exist') + test(cy) }) }) diff --git a/site/cypress/integration/mon-entreprise/landing.ts b/site/cypress/integration/mon-entreprise/landing.ts index 9dd1319be..307a52a2d 100644 --- a/site/cypress/integration/mon-entreprise/landing.ts +++ b/site/cypress/integration/mon-entreprise/landing.ts @@ -45,9 +45,7 @@ describe('Landing page', function () { cy.get(searchInputPath).should('have.attr', 'placeholder') cy.get(searchInputPath).invoke('attr', 'type').should('equal', 'search') - cy.get(searchInputPath).focus().type('noima') - - cy.wait('@entreprises') + cy.get(searchInputPath).focus().type('noima').wait('@entreprises') cy.get(searchResultsPath).children().should('have.length', 6) cy.get(searchResultsPath).children().first().click() diff --git a/site/cypress/integration/mon-entreprise/localisation-field.js b/site/cypress/integration/mon-entreprise/localisation-field.js index a5f6aafad..2471e26d7 100644 --- a/site/cypress/integration/mon-entreprise/localisation-field.js +++ b/site/cypress/integration/mon-entreprise/localisation-field.js @@ -4,11 +4,9 @@ describe('Champs localisation (simulateur salarié)', function () { if (!fr) { return } - before(function () { - return cy.visit(encodeURI('/simulateurs/salaire-brut-net')) - }) it('should not crash when selecting localisation', function () { + cy.visit(encodeURI('/simulateurs/salaire-brut-net')) cy.contains('SMIC').click() cy.contains('button', 'Commune').click() cy.contains('Commune ou code postal') diff --git a/site/cypress/integration/mon-entreprise/partage-simulation.js b/site/cypress/integration/mon-entreprise/partage-simulation.js index 8de4fbef5..ae8c177c8 100644 --- a/site/cypress/integration/mon-entreprise/partage-simulation.js +++ b/site/cypress/integration/mon-entreprise/partage-simulation.js @@ -13,15 +13,17 @@ describe('Partage (simulateur salarié)', function () { if (!fr) { return } + it('should set input value from URL', function () { cy.visit(urlWithState) - cy.get(brutInputSelector) + cy.get(brutInputSelector, { timeout: 30 * 1000 }) .invoke('val') .should('match', /1[\s]539[\s]€/) cy.contains('Modifier mes réponses').click() cy.contains('CDD') }) + it('should set URL from input value', function () { cy.visit(simulatorUrl) cy.get(brutInputSelector).first().type('{selectall}1539') diff --git a/site/cypress/integration/mon-entreprise/persistence-simulation.js b/site/cypress/integration/mon-entreprise/persistence-simulation.js index 9c9bffb09..9b6884f5f 100644 --- a/site/cypress/integration/mon-entreprise/persistence-simulation.js +++ b/site/cypress/integration/mon-entreprise/persistence-simulation.js @@ -1,17 +1,13 @@ const inputSelector = 'div[id="simulator-legend"] input' const fr = Cypress.env('language') === 'fr' + describe('Persistence (simulateur salarié)', function () { if (!fr) { return } - before(function () { - return cy.visit(encodeURI('/simulateurs/salaire-brut-net')) - }) - beforeEach(function () { - cy.clearLocalStorage() - }) it('should persist the current simulation (persistSimulation)', function () { + cy.visit(encodeURI('/simulateurs/salaire-brut-net')) cy.get(inputSelector).first().type('{selectall}42') cy.contains('button', 'Passer').click() cy.contains('button', 'Passer').click() @@ -23,11 +19,13 @@ describe('Persistence (simulateur salarié)', function () { ) ).to.be.not.null }) + cy.visit('/simulateurs/auto-entrepreneur') cy.get(inputSelector).first().type('{selectall}007') cy.contains('button', 'Passer').click() cy.contains('button', 'Passer').click() cy.contains('button', 'Passer').click() + cy.visit(encodeURI('/simulateurs/salaire-brut-net')) cy.contains('Retrouver ma simulation').click() cy.get(inputSelector).first().invoke('val').should('match', /42/) diff --git a/site/cypress/integration/mon-entreprise/simulateur-ae.ts b/site/cypress/integration/mon-entreprise/simulateur-ae.ts index 88484fd8b..99a4f9be7 100644 --- a/site/cypress/integration/mon-entreprise/simulateur-ae.ts +++ b/site/cypress/integration/mon-entreprise/simulateur-ae.ts @@ -1,6 +1,6 @@ import { fr } from '../../support/utils' -describe('Simulateur auto-entrepreneur', function () { +describe('Simulateur auto-entrepreneur', { testIsolation: 'off' }, function () { if (!fr) { return } diff --git a/site/cypress/integration/mon-entreprise/simulateur-dividendes.js b/site/cypress/integration/mon-entreprise/simulateur-dividendes.js index d719a43f4..093f402a5 100644 --- a/site/cypress/integration/mon-entreprise/simulateur-dividendes.js +++ b/site/cypress/integration/mon-entreprise/simulateur-dividendes.js @@ -5,11 +5,9 @@ describe('Simulateur dividendes', function () { if (!fr) { return } - before(function () { - return cy.visit('/simulateurs/dividendes') - }) it('should show by default the PFU calculation at 12.8 / 17.2', function () { + cy.visit('/simulateurs/dividendes') cy.get(inputSelector).first().type('{selectall}5000') cy.contains(/[cC]otisations\s+17,2\s*%/) cy.contains(/[Ii]mpôt\s+12,8\s*%/) diff --git a/site/cypress/integration/mon-entreprise/simulateur-salarie.ts b/site/cypress/integration/mon-entreprise/simulateur-salarie.ts index 135bccaee..3121cab35 100644 --- a/site/cypress/integration/mon-entreprise/simulateur-salarie.ts +++ b/site/cypress/integration/mon-entreprise/simulateur-salarie.ts @@ -1,57 +1,54 @@ import { fr } from '../../support/utils' -describe('Simulateur salarié', function () { +describe('Simulateur salarié : part time contract', function () { if (!fr) { return } - before(function () { - return cy.visit(encodeURI('/simulateurs/salaire-brut-net')) + beforeEach(function () { + cy.visit(encodeURI('/simulateurs/salaire-brut-net')) + cy.get('button').contains('SMIC').click() + cy.contains('Modifier mes réponses').click() + cy.get('div[role="dialog"]') + .eq(0) + .contains('Temps partiel') + .next() + .find('button') + .click() + + cy.get('div[role="dialog"]').eq(1).contains('Fermer') + cy.get('div[role="dialog"]').eq(1).contains('Oui').click() + cy.get('div[role="dialog"]').eq(1).contains('Continuer').click() + cy.get('div[role="dialog"]').eq(0).contains('Fermer').click() }) - describe('part time contract', function () { - before(function () { - cy.get('button').contains('SMIC').click() - cy.contains('Modifier mes réponses').click() - cy.get('div[role="dialog"]') - .contains('Temps partiel') - .next() - .find('button') - .click() - - cy.get('div[role="dialog"]').contains('Oui').click() - cy.get('div[role="dialog"]').contains('Continuer').click() - cy.get('div[role="dialog"]').contains('Fermer').click() + it('should permit selecting the smic before part-time contrat', function () { + cy.get('#salariécontratsalairebrut').should(($input) => { + const val = $input + .val() + .toString() + .replace(/[\s,.€]/g, '') + expect(parseInt(val)).to.be.above(1300).and.to.be.below(1600) }) + }) - it('should permit selecting the smic before part-time contrat', function () { - cy.get('#salariécontratsalairebrut').should(($input) => { - const val = $input - .val() - .toString() - .replace(/[\s,.€]/g, '') - expect(parseInt(val)).to.be.above(1300).and.to.be.below(1600) - }) - }) + it('should permit customizing the number of worked hours and clear the input value', function () { + cy.contains('Modifier mes réponses').click() - it('should permit customizing the number of worked hours and clear the input value', function () { - cy.contains('Modifier mes réponses').click() + cy.get('div[role="dialog"]') + .contains('Heures par semaine') + .next() + .find('button') + .click() + cy.focused().type('25') + cy.contains('Fermer').click() - cy.get('div[role="dialog"]') - .contains('Heures par semaine') - .next() - .find('button') - .click() - cy.focused().type('25') - cy.contains('Fermer').click() - - cy.get('#salariérémunérationnetpayéaprèsimpôt').should(($input) => { - const val = $input - .val() - .toString() - .replace(/[\s,.€]/g, '') - expect(parseInt(val)).to.be.below(1000) - }) + cy.get('#salariérémunérationnetpayéaprèsimpôt').should(($input) => { + const val = $input + .val() + .toString() + .replace(/[\s,.€]/g, '') + expect(parseInt(val)).to.be.below(1000) }) }) }) diff --git a/site/cypress/support/simulateur.js b/site/cypress/support/simulateur.js index 4268e2097..9c7f5c4d6 100644 --- a/site/cypress/support/simulateur.js +++ b/site/cypress/support/simulateur.js @@ -4,7 +4,7 @@ const chargeInputSelector = 'input[id="entreprisecharges"]' const fr = Cypress.env('language') === 'fr' export const runSimulateurTest = (simulateur) => { - describe(`Simulateur ${simulateur}`, function () { + describe(`Simulateur ${simulateur}`, { testIsolation: 'off' }, function () { before(function () { return cy.visit( encodeURI(`/${fr ? 'simulateurs' : 'calculators'}/${simulateur}`) diff --git a/site/package.json b/site/package.json index 60d9716c8..68a06fc5c 100644 --- a/site/package.json +++ b/site/package.json @@ -126,7 +126,7 @@ "@types/styled-components": "^5.1.26", "@vitejs/plugin-legacy": "^2.3.1", "@vitejs/plugin-react": "^2.2.0", - "cypress": "^11.2.0", + "cypress": "https://cdn.cypress.io/beta/npm/12.0.0/linux-arm64/release/12.0.0-e8898d2f6b65a11f36ceb2dd32ce7f1d87b103bc/cypress.tgz", "cypress-plugin-tab": "^1.0.5", "cypress-wait-until": "^1.7.2", "dotenv": "^16.0.3", diff --git a/yarn.lock b/yarn.lock index 41898214a..8243a87d7 100644 --- a/yarn.lock +++ b/yarn.lock @@ -12876,9 +12876,9 @@ __metadata: languageName: node linkType: hard -"cypress@npm:^11.2.0": - version: 11.2.0 - resolution: "cypress@npm:11.2.0" +"cypress@https://cdn.cypress.io/beta/npm/12.0.0/linux-arm64/release/12.0.0-e8898d2f6b65a11f36ceb2dd32ce7f1d87b103bc/cypress.tgz": + version: 12.0.0 + resolution: "cypress@https://cdn.cypress.io/beta/npm/12.0.0/linux-arm64/release/12.0.0-e8898d2f6b65a11f36ceb2dd32ce7f1d87b103bc/cypress.tgz" dependencies: "@cypress/request": ^2.88.10 "@cypress/xvfb": ^1.2.4 @@ -12924,7 +12924,7 @@ __metadata: yauzl: ^2.10.0 bin: cypress: bin/cypress - checksum: e13649fb4b62a3c9dff7cc571f4e01dba009d8179b05c4f885c5ceb4ed76b78a7323fec491d992da35527708b54e596bfc9edb1d702f788317889f794d8c1e76 + checksum: d6e0d5c3325e915406981a487caf4413fbf84a92991e570378d4d911b19d8b0bde71a7fb5c8f0417e236c3e5c4f6077e6ec14e056646d38771a5607ac4096436 languageName: node linkType: hard @@ -25933,7 +25933,7 @@ __metadata: "@vitejs/plugin-legacy": ^2.3.1 "@vitejs/plugin-react": ^2.2.0 algoliasearch: ^4.14.2 - cypress: ^11.2.0 + cypress: "https://cdn.cypress.io/beta/npm/12.0.0/linux-arm64/release/12.0.0-e8898d2f6b65a11f36ceb2dd32ce7f1d87b103bc/cypress.tgz" cypress-plugin-tab: ^1.0.5 cypress-wait-until: ^1.7.2 dotenv: ^16.0.3