From 4dffe6f674212742f153479fb50923fc28953113 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Rialland?= Date: Tue, 21 Jun 2022 17:05:12 +0200 Subject: [PATCH] Wait search request in navigation test --- .../mon-entreprise/demande-mobilité.ts | 6 ++-- .../english/{navigation.js => navigation.ts} | 30 +++++++++++++++---- 2 files changed, 28 insertions(+), 8 deletions(-) rename site/cypress/integration/mon-entreprise/english/{navigation.js => navigation.ts} (81%) diff --git a/site/cypress/integration/mon-entreprise/demande-mobilité.ts b/site/cypress/integration/mon-entreprise/demande-mobilité.ts index f4b069138..9d50433c2 100644 --- a/site/cypress/integration/mon-entreprise/demande-mobilité.ts +++ b/site/cypress/integration/mon-entreprise/demande-mobilité.ts @@ -1,8 +1,5 @@ import { fr } from '../../support/utils' -const FIXTURES_FOLDER = 'cypress/fixtures' -const DEMANDE_MOBILITE_FIXTURES_FOLDER = `${FIXTURES_FOLDER}/demande-mobilité` - const writeFixtures = Cypress.env('record_http') !== undefined describe(`Formulaire demande mobilité (${ @@ -11,6 +8,9 @@ describe(`Formulaire demande mobilité (${ if (!fr) { return } + const FIXTURES_FOLDER = 'cypress/fixtures' + const DEMANDE_MOBILITE_FIXTURES_FOLDER = `${FIXTURES_FOLDER}/demande-mobilité` + let pendingRequests = new Set() let responses = {} const hostnamesToRecord = ['geo.api.gouv.fr'] diff --git a/site/cypress/integration/mon-entreprise/english/navigation.js b/site/cypress/integration/mon-entreprise/english/navigation.ts similarity index 81% rename from site/cypress/integration/mon-entreprise/english/navigation.js rename to site/cypress/integration/mon-entreprise/english/navigation.ts index df422d6ec..a30b989ca 100644 --- a/site/cypress/integration/mon-entreprise/english/navigation.js +++ b/site/cypress/integration/mon-entreprise/english/navigation.ts @@ -1,8 +1,5 @@ const fr = Cypress.env('language') === 'fr' -const FIXTURES_FOLDER = 'cypress/fixtures' -const GERER_FIXTURES_FOLDER = `${FIXTURES_FOLDER}/gérer` - const writeFixtures = Cypress.env('record_http') !== undefined describe('General navigation', function () { @@ -27,12 +24,16 @@ describe('General navigation', function () { describe(`Navigation to income simulator using company name (${ writeFixtures ? 'record mode' : 'stubbed mode' })`, function () { + const FIXTURES_FOLDER = 'cypress/fixtures' + const GERER_FIXTURES_FOLDER = `${FIXTURES_FOLDER}/gérer` + let pendingRequests = new Set() let responses = {} const hostnamesToRecord = [ 'api.recherche-entreprises.fabrique.social.gouv.fr', 'geo.api.gouv.fr', ] + beforeEach(function () { pendingRequests = new Set() responses = {} @@ -45,6 +46,7 @@ describe(`Navigation to income simulator using company name (${ cy.clearLocalStorage() // Try to avoid flaky tests cy.visit('/') }) + afterEach(function () { cy.writeInterceptResponses( pendingRequests, @@ -52,22 +54,40 @@ describe(`Navigation to income simulator using company name (${ GERER_FIXTURES_FOLDER ) }) + it('should allow to retrieve company and show link corresponding to the legal status', function () { + cy.intercept({ + method: 'GET', + hostname: 'api.recherche-entreprises.fabrique.social.gouv.fr', + url: '/api/v1/search*', + }).as('search') + cy.contains( fr ? 'Rechercher votre entreprise ' : 'Search for your company ' ).click() - cy.get('input').first().type('menoz') + + cy.get('input').first().type('menoz').wait('@search') + cy.contains('834364291').click() cy.contains('SAS(U)').click() cy.location().should((loc) => { expect(loc.pathname).to.match(/sasu$/) }) }) + it('should allow auto entrepreneur to access the corresponding income simulator', function () { + cy.intercept({ + method: 'GET', + hostname: 'api.recherche-entreprises.fabrique.social.gouv.fr', + url: '/api/v1/search*', + }).as('search') + cy.contains( fr ? 'Rechercher votre entreprise ' : 'Search for your company ' ).click() - cy.get('input').first().type('johan girod') + + cy.get('input').first().type('johan girod').wait('@search') + cy.contains('834825614').click() // ask if auto-entrepreneur cy.contains(