diff --git a/.github/workflows/pre-merge.yml b/.github/workflows/pre-merge.yml index 02944655a..69c27b2d2 100644 --- a/.github/workflows/pre-merge.yml +++ b/.github/workflows/pre-merge.yml @@ -20,6 +20,7 @@ env: IRON_SESSION_PWD: ${{ secrets.IRON_SESSION_PWD }} GRIST_API_KEY: ${{ secrets.GRIST_API_KEY }} UPDOWN_IO_API_KEY: ${{ secrets.UPDOWN_IO_API_KEY }} + jobs: dependencies: name: 'Install dependencies' @@ -94,6 +95,11 @@ jobs: needs: [dependencies] env: NEXT_PUBLIC_END2END_MOCKING: enabled + AGENTCONNECT_CLIENT_ID: ${{ secrets.AGENTCONNECT_CLIENT_ID }} + AGENTCONNECT_CLIENT_SECRET: ${{ secrets.AGENTCONNECT_CLIENT_SECRET }} + AGENTCONNECT_URL_DISCOVER: https://fca.integ01.dev-agentconnect.fr/api/v2/.well-known/openid-configuration + AGENTCONNECT_REDIRECT_URI: http://localhost:3000/api/auth/agent-connect/callback + AGENTCONNECT_POST_LOGOUT_REDIRECT_URI: http://localhost:3000/api/auth/agent-connect/logout-callback steps: - name: Checkout 🛎 uses: actions/checkout@v3 @@ -117,6 +123,14 @@ jobs: env: PORT: 3000 NEXT_PUBLIC_END2END_MOCKING: enabled + - name: Upload screenshots 📸 + uses: actions/upload-artifact@v4 + # add the line below to store screenshots only on failures + if: failure() + with: + name: cypress-screenshots + path: cypress/screenshots + if-no-files-found: ignore # 'warn' or 'error' are also available, defaults to `warn` typecheck: name: Type check diff --git a/cypress/e2e/espace-agent.cy.js b/cypress/e2e/espace-agent.cy.js new file mode 100644 index 000000000..561cc0fa1 --- /dev/null +++ b/cypress/e2e/espace-agent.cy.js @@ -0,0 +1,59 @@ +describe( + 'Espace agent', + { + pageLoadTimeout: 180000, // 3min because AgentConnect testing env is veeeery slow + testIsolation: false, // We need to share session cookies between tests + retries: { + runMode: 2, + }, + }, + () => { + before(() => { + cy.clearCookies(); + }); + it("Page d'accueil", () => { + cy.visit(`/`); + cy.contains('Espace agent').click(); + cy.contains('button', 'AgentConnect'); + }); + + it('Bouton agent connect sur les données protégées', () => { + cy.visit('/documents/487444697'); + cy.contains('Réservé aux agents publics'); + cy.contains('button', 'AgentConnect'); + }); + + it('Connexion', () => { + cy.visit(`/lp/agent-public`); + cy.contains('button', 'AgentConnect').click(); + cy.origin('fca.integ01.dev-agentconnect.fr', () => { + cy.get('input[type="email"]').clear().type('annuaire@yopmail.com'); + cy.contains('button', 'Se connecter').click(); + }); + cy.origin('app-sandbox.moncomptepro.beta.gouv.fr', () => { + cy.contains('Renseignez votre mot de passe'); + cy.get('input[type="password"]').type("?AWth'~v@m6~Lv%"); + cy.contains('button', 'S’identifier').click(); + }); + cy.location().should((loc) => { + expect(loc.pathname).to.eq('/'); + }); + cy.visit('/'); + cy.contains('annuaire@yopmail.com'); + }); + + it('Actes et statuts accessibles', () => { + cy.visit('/documents/487444697'); + cy.contains('Actes et statuts'); + cy.contains(/Cette entreprise possède [\d]+ document\(s\) au RNE/); + }); + + it('Bilans accessibles', () => { + cy.visit('/donnees-financieres/487444697'); + cy.contains('Bilans'); + cy.contains( + /Cette entreprise possède [\d]+ bilan\(s\) déposé\(s\) au RNE/ + ); + }); + } +); diff --git a/cypress/e2e/etat-administratif.cy.js b/cypress/e2e/etat-administratif.cy.js index 85b540e67..c0bbfc393 100644 --- a/cypress/e2e/etat-administratif.cy.js +++ b/cypress/e2e/etat-administratif.cy.js @@ -1,5 +1,4 @@ describe('Etat administratif', () => { - // pass failing test as Insee is very instable in CI it('Non diffusible', () => { cy.visit(`/entreprise/300025764`); cy.contains('information non-diffusible');