Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: LBAC-1704 tests end to end sur la recette #825

Merged
merged 19 commits into from
Nov 21, 2023
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions .github/workflows/cypress.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: CI

on:
alanlr marked this conversation as resolved.
Show resolved Hide resolved
workflow_call:
inputs:
cypress_host:
description: host name
type: string
required: true
secrets:
CODECOV_TOKEN:
description: Code coverrage token
required: true
SLACK_WEBHOOK:
description: Wehook slack
alanlr marked this conversation as resolved.
Show resolved Hide resolved
required: true
jobs:
concurrency:
group: "cypress-${{ github.workflow }}-${{ github.ref }}"
needs: ["deploy"]
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: ${{ inputs.environment }} == 'recette'
alanlr marked this conversation as resolved.
Show resolved Hide resolved
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 }}
13 changes: 13 additions & 0 deletions .github/workflows/deploy_preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -152,3 +152,16 @@ jobs:
comment_tag: deployment
mode: recreate
pr_number: ${{ github.event.issue.number }}

cypress:
if: (startsWith(github.event.comment.body, '🚀') || startsWith(github.event.comment.body, ':rocket:')) && github.event.issue.pull_request
alanlr marked this conversation as resolved.
Show resolved Hide resolved
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 }}
8 changes: 8 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,11 @@ jobs:
DEPLOY_PASS: ${{ secrets.DEPLOY_PASS }}
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
VAULT_PWD: ${{ secrets.VAULT_PWD }}

cypress:
uses: "./.github/workflows/cypress.yml"
inputs:
alanlr marked this conversation as resolved.
Show resolved Hide resolved
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/*
6 changes: 3 additions & 3 deletions cypress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ dotenv.config()
export default defineConfig({
viewportHeight: 768,
viewportWidth: 1366,
env: {
host: process.env.CYPRESS_HOST,
},
// env: {
// host: process.env.CYPRESS_HOST,
// },
alanlr marked this conversation as resolved.
Show resolved Hide resolved
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.

67 changes: 43 additions & 24 deletions cypress/e2e/ui/send-rdv-from-widget.cy.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,46 @@
describe("send-rdv-from-widget", () => {
it("tests send-rdv-from-widget", () => {
cy.viewport(1271, 721)
cy.visit("https://labonnealternance.apprentissage.beta.gouv.fr/recherche-apprentissage-formation")
cy.get("form > div > div.css-0 input").click()
cy.get("form > div > div.css-0 input").type("esth")
cy.get("#lang-switcher-item-0").click()
cy.get("div.css-iiltjv div.css-0 img").click()
cy.get("a:nth-of-type(1) div.css-17xle36").click()
cy.get("header a").click()
cy.get("form > input:nth-of-type(1)").click()
cy.get("form > input:nth-of-type(1)").type("John")
cy.get("form > input.css-jw8yg").click()
cy.get("form > input.css-jw8yg").type("Doe")
cy.get("div.css-0 > input").click()
cy.get("div.css-0 > input").type("0700000000")
cy.get("input[type='email']").click()
cy.get("input[type='email']").type("[email protected]")
cy.get("label:nth-of-type(2) > span.chakra-checkbox__control").click()
cy.get("label:nth-of-type(4) > span.chakra-checkbox__control").click()
cy.get("label:nth-of-type(11) > span.chakra-checkbox__control").click()
cy.get("input:nth-of-type(4)").click()
cy.get("input:nth-of-type(4)").type("horaires")
cy.get("button").click()
it("tests send-rdv-from-widget on " + Cypress.env("ui") + " --- " + Cypress.env("server"), () => {
cy.intercept("GET", Cypress.env("server") + "/api/v1/formations?*").as("submitTrainingCall")
cy.intercept("POST", Cypress.env("server") + "/api/appointment-request/validate").as("submitRdv")

cy.generateRandomEmail("test-auto-", "@nexistepas.fr", 10).then((randomEmail) => {
cy.viewport(1254, 704)
cy.visit(Cypress.env("ui") + "/recherche-apprentissage-formation?displayMap=false")
cy.get("#headerFormJobField-input").click()
cy.get("#headerFormJobField-input").type("esth")
cy.get("#headerFormJobField-item-0").click()
cy.get("#headerFormJobField-input").should("have.value", "Esthétique")
cy.get("[data-testid='widget-form'] button").click()

cy.wait("@submitTrainingCall").then(() => {
cy.get(".resultCard.training").first().click()
// eslint-disable-next-line cypress/unsafe-to-chain-command
cy.get("[data-testid='prdvButton']")
//.invoke("removeAttr", "target")
.click()
.then(() => {
// eslint-disable-next-line cypress/no-unnecessary-waiting
cy.wait(5000).then(() => {
cy.get("input[name='firstname']").click()
cy.get("input[name='firstname']").type("John")
cy.get("input[name='lastname']").click()
cy.get("input[name='lastname']").type("Doe")
cy.get("input[name='phone']").click()
cy.get("input[name='phone']").type("0700000000")
cy.get("input[type='email']").click()
cy.get("input[type='email']").type(randomEmail)
cy.get(".chakra-accordion__button").click()
cy.get("[data-testid='fieldset-reasons'] .chakra-collapse input:checkbox[id='reason-3']").click({ force: true })
cy.get("[data-testid='fieldset-reasons'] .chakra-collapse input:checkbox[id='reason-10']").click({ force: true })
cy.get("input[name='applicantMessageToCfa']").click()
cy.get("input[name='applicantMessageToCfa']").type("horaires")
cy.get("button[type='submit'][data-tracking-id='prendre-rdv-cfa']").click()
cy.wait("@submitRdv").then(() => {
cy.get("[data-testid='DemandeDeContactConfirmationTitle']")
})
})
})
})
})
})
})
//# recorderSourceMap=BCBDBEAEAEAEBFBGBHBIBJAJBKBLBMBNBOBPBQBRBSBTBUBVBWBXAXBYA
Loading