Skip to content

Commit

Permalink
feat: LBAC-1704 tests end to end sur la recette (#825)
Browse files Browse the repository at this point in the history
* feat: suppression inutilisé

* feat: gitignore here

* feat: gitignore

* feat: env passé par yarn params

* feat: ajout dans la ci recette

* feat: tests ok

* feat: test pas encore ok

* feat: cleaning

* feat: essai workflow preview

* feat: syntax

* feat: correct e2e action

* feat: test prdv ok

* Update .github/workflows/cypress.yml

Co-authored-by: Moroine Bentefrit <[email protected]>

* feat: ajustements

* Update .github/workflows/cypress.yml

Co-authored-by: Moroine Bentefrit <[email protected]>

* fix: irrelevant here

* feat: suppression vieux poc et mise en commentaire temp

---------

Co-authored-by: Moroine Bentefrit <[email protected]>
  • Loading branch information
alanlr and moroine authored Nov 21, 2023
1 parent 1d1b7b0 commit 268ffff
Show file tree
Hide file tree
Showing 16 changed files with 229 additions and 302 deletions.
67 changes: 67 additions & 0 deletions .github/workflows/cypress.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: CI

on:
workflow_dispatch:
inputs:
cypress_host:
description: host name
type: string
required: true
secrets:
CODECOV_TOKEN:
description: Code coverrage token
required: true
SLACK_WEBHOOK:
description: Webhook slack
required: true
workflow_call:
inputs:
cypress_host:
description: host name
type: string
required: true
secrets:
CODECOV_TOKEN:
description: Code coverrage token
required: true
SLACK_WEBHOOK:
description: Webhook slack
required: true
jobs:
concurrency:
group: "cypress-${{ github.workflow }}-${{ github.ref }}"
runs-on: ubuntu-latest
steps:
- name: Checkout project
uses: actions/checkout@v4

- uses: actions/setup-node@v3
with:
node-version: 20

- uses: actions/cache@v3
with:
path: |
**/node_modules
.yarn/install-state.gz
.yarn/cache
key: yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: yarn-

- name: Install dependencies
run: yarn install

- name: Run cypress e2e tests
run: yarn e2e:headless --env ui=${{inputs.cypress_host}},server=${{inputs.cypress_host}}

- name: Notify failure on Slack
uses: ravsamhq/notify-slack-action@v2
if: ${{ failure() }} && ${{ inputs.environment }} == 'recette'
with:
status: ${{ job.status }}
notification_title: "Les tests e2e ne sont pas passés : ${{ inputs.app_version }} en ${{ inputs.environment }}"
message_format: "{emoji} *[${{ inputs.environment }}]* *{workflow}* {status_message} in <{repo_url}|{branch}> on <{commit_url}|{commit_sha}>. You can get error logs using `.bin/mna-lba deploy:log:decrypt ${{ github.run_id }}`"
notify_when: "failure"
mention_groups: "!channel"
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }}
12 changes: 12 additions & 0 deletions .github/workflows/deploy_preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -152,3 +152,15 @@ jobs:
comment_tag: deployment
mode: recreate
pr_number: ${{ github.event.issue.number }}

# cypress:
# concurrency:
# group: ${{ github.workflow }}-${{ github.event.issue.id }}-cypress
# cancel-in-progress: true
# needs: ["deploy_preview"]
# uses: "./.github/workflows/cypress.yml"
# inputs:
# cypress_host: "https://${{ github.event.issue.number }}.labonnealternance-preview.apprentissage.beta.gouv.fr"
# secrets:
# CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
# SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
15 changes: 0 additions & 15 deletions .github/workflows/end-to-end-testing.yml

This file was deleted.

9 changes: 9 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,12 @@ jobs:
DEPLOY_PASS: ${{ secrets.DEPLOY_PASS }}
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
VAULT_PWD: ${{ secrets.VAULT_PWD }}

# cypress:
# needs: ["deploy"]
# uses: "./.github/workflows/cypress.yml"
# inputs:
# cypress_host: "https://labonnealternance-recette.apprentissage.beta.gouv.fr"
# secrets:
# CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
# SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -166,3 +166,5 @@ SEED_PASSPHRASE.txt
seed.gz

cypress.env.json

assets/*
3 changes: 0 additions & 3 deletions cypress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@ dotenv.config()
export default defineConfig({
viewportHeight: 768,
viewportWidth: 1366,
env: {
host: process.env.CYPRESS_HOST,
},
e2e: {
video: false,
},
Expand Down
2 changes: 2 additions & 0 deletions cypress/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/screenshots/*
/videos/*
37 changes: 0 additions & 37 deletions cypress/e2e/ui/send-job-application-mjsbal.cy.js

This file was deleted.

45 changes: 0 additions & 45 deletions cypress/e2e/ui/send-job-application-modified.cy.js

This file was deleted.

76 changes: 42 additions & 34 deletions cypress/e2e/ui/send-job-application.cy.js
Original file line number Diff line number Diff line change
@@ -1,37 +1,45 @@
describe("send-job-application", () => {
it("tests send-job-application", () => {
cy.viewport(1254, 704)
cy.visit("https://labonnealternance-recette.apprentissage.beta.gouv.fr/")
cy.get("form > div > div.css-0 input").click()
cy.get("form > div > div.css-0 input").type("ress")
cy.get("#lang-switcher-item-0").click()
cy.get("div.css-1kw2fa0 div.containerIdentity").click()
cy.get("div.css-1kw2fa0 input").click()
cy.get("div.css-1kw2fa0 input").type("pari")
cy.get("#lang-switcher-item-0 > strong").click()
cy.get("div.css-6st093 div:nth-of-type(3) select").click()
cy.get("div.css-6st093 div:nth-of-type(3) select").type("60")
cy.get("div.css-uos98o img").click()
cy.get("div.css-gmd149 button:nth-of-type(2)").click()
cy.get("#matcha648adcb8258b0842bb1afcc1 > div").click()
cy.get("[data-testid='CandidatureSpontanee'] button").click()
cy.get("[data-testid='lastName']").click()
cy.get("[data-testid='lastName']").type("Doe")
cy.get("[data-testid='firstName']").click()
cy.get("[data-testid='firstName']").type("John")
cy.get("[data-testid='email']").click()
cy.get("[data-testid='email']").type("[email protected]")
cy.get("[data-testid='phone']").click()
cy.get("[data-testid='phone']").type("0700000000")
cy.get("[data-testid='message']").click()
cy.get("[data-testid='message']").rightclick()
cy.get("[data-testid='message']").type(
"Madame, Monsieur,\nEtant actuellement à la recherche d’un emploi, je me permets de vous proposer ma candidature au poste de (emploi).\n\nEn effet, mon profil correspond à la description recherchée sur l’offre d’emploi (préciser où l’annonce a été vue). (Si le candidat possède peu d’expérience professionnelle) Ma formation en (préciser la formation) m'a permis d'acquérir de nombreuses compétences parmi celles que vous recherchez. Je possède tous les atouts qui me permettront de réussir dans le rôle que vous voudrez bien me confier. Motivation, rigueur et écoute sont les maîtres mots de mon comportement professionnel.(Si le candidat possède une expérience significative dans le poste à pourvoir). Mon expérience en tant que (emploi) m’a permis d’acquérir toutes les connaissances nécessaires à la bonne exécution des tâches du poste à pourvoir. Régulièrement confronté aux aléas du métier, je suis capable de répondre aux imprévus en toute autonomie. Intégrer votre entreprise représente pour moi un réel enjeu d’avenir dans lequel mon travail et mon honnêteté pourront s’exprimer pleinement.\n\nRestant à votre disposition pour toute information complémentaire, je suis disponible pour vous rencontrer lors d’un entretien à votre convenance\n\nVeuillez agréer, Madame, Monsieur, l’expression de mes sincères salutations."
)
cy.get("p.css-1egmowt").click()
cy.get("[data-testid='fileDropzone']").type("C:\\fakepath\\CV - John Doe.pdf")
cy.get("[data-testid='candidature-not-sent']").click()
cy.get("p.css-x9fc5p").click()
it("tests send-job-application on " + Cypress.env("ui") + " --- " + Cypress.env("server"), () => {
cy.on("uncaught:exception", () => {
return false
})

cy.intercept("GET", Cypress.env("server") + "/api/v1/jobs?*").as("submitJobCall")
cy.intercept("POST", Cypress.env("server") + "/api/v1/application").as("submitApplication")

cy.generateRandomEmail("test-auto-", "@nexistepas.fr", 10).then((randomEmail) => {
cy.viewport(1254, 704)
cy.visit(Cypress.env("ui") + "?displayMap=false")
cy.get("#headerFormJobField-input").click()
cy.get("#headerFormJobField-input").type("gestion inf")
cy.get("#headerFormJobField-item-0").click()
cy.get("#headerFormJobField-input").should("have.value", "Gestion de projets informatiques")
cy.get("#headerFormPlaceField-input").click()
cy.get("#headerFormPlaceField-input").type("lill")
cy.get("#headerFormPlaceField-item-0").click()
cy.get("[data-testid='widget-form'] select[data-testid='locationRadius']").select("60")
cy.get("[data-testid='widget-form'] button").click()

cy.wait("@submitJobCall").then(() => {
cy.get(".resultCard.matcha").first().click()
cy.get("[data-testid='CandidatureSpontanee'] button").click()
cy.get("[data-testid='lastName']").click()
cy.get("[data-testid='lastName']").type("Doe")
cy.get("[data-testid='firstName']").click()
cy.get("[data-testid='firstName']").type("John")
cy.get("[data-testid='email']").click()
cy.get("[data-testid='email']").type(randomEmail)
cy.get("[data-testid='phone']").click()
cy.get("[data-testid='phone']").type("0700000000")
cy.get("[data-testid='message']").click()
cy.get("[data-testid='message']").type("Madame, Monsieur,\nEtant actuellement à la recherche d’un emploi, ...")
cy.get("[data-testid='fileDropzone']").selectFile("cypress/fixtures/CV - John Doe.docx", { action: "drag-drop" })
cy.get("[data-testid='candidature-not-sent']").click()

cy.wait("@submitApplication").then(() => {
cy.get("[data-testid='CandidatureSpontaneeWorked']")
})
})
})
})
})
//# recorderSourceMap=BCBDBEBFBGBHBIBJBKBLBMBNBOAOBPBQAQAQBRARBSBTBUBVBWBXBYBZBaBbBcBdBeBfAfB
46 changes: 0 additions & 46 deletions cypress/e2e/ui/send-rdv-from-widget-modified.cy.js

This file was deleted.

Loading

0 comments on commit 268ffff

Please sign in to comment.