Skip to content

Commit

Permalink
Merge pull request #986 from etalab/964-e2e-connexion-egtn
Browse files Browse the repository at this point in the history
Test end to end connection agent
  • Loading branch information
johangirod authored Apr 9, 2024
2 parents 12ddafb + 2e92b79 commit 1450eb0
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 1 deletion.
14 changes: 14 additions & 0 deletions .github/workflows/pre-merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
59 changes: 59 additions & 0 deletions cypress/e2e/espace-agent.cy.js
Original file line number Diff line number Diff line change
@@ -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('[email protected]');
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('[email protected]');
});

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/
);
});
}
);
1 change: 0 additions & 1 deletion cypress/e2e/etat-administratif.cy.js
Original file line number Diff line number Diff line change
@@ -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');
Expand Down

0 comments on commit 1450eb0

Please sign in to comment.