From 04b31783a46445da430a2a5f324ada67f2f427af Mon Sep 17 00:00:00 2001 From: Alexandre Garbe Date: Fri, 27 Dec 2024 16:57:46 +0100 Subject: [PATCH] feat(candidate): added some tests to candidate drop out decision page --- .../candidacy-dropout-decision.cy.ts | 64 +++++++++++++++++++ .../app/candidacy-dropout-decision/page.tsx | 1 + 2 files changed, 65 insertions(+) create mode 100644 packages/reva-candidate/cypress/e2e/candidacy-dropout/candidacy-dropout-decision.cy.ts diff --git a/packages/reva-candidate/cypress/e2e/candidacy-dropout/candidacy-dropout-decision.cy.ts b/packages/reva-candidate/cypress/e2e/candidacy-dropout/candidacy-dropout-decision.cy.ts new file mode 100644 index 000000000..5107e3555 --- /dev/null +++ b/packages/reva-candidate/cypress/e2e/candidacy-dropout/candidacy-dropout-decision.cy.ts @@ -0,0 +1,64 @@ +import { stubMutation, stubQuery } from "../../utils/graphql"; +import candidateDropOut from "./fixtures/candidate-dropped-out.json"; + +function interceptCandidacy() { + cy.intercept("POST", "/api/graphql", (req) => { + stubMutation(req, "candidate_login", "candidate_login.json"); + stubMutation( + req, + "updateCandidateCandidacyDropoutDecision", + candidateDropOut, + ); + stubQuery(req, "candidate_getCandidateWithCandidacy", { + data: { + candidate_getCandidateWithCandidacy: { + ...candidateDropOut.data.candidate_getCandidateWithCandidacy, + candidacy: { + ...candidateDropOut.data.candidate_getCandidateWithCandidacy + .candidacy, + candidacyDropOut: { + createdAt: "2021-09-01T00:00:00Z", + dropOutConfirmedByCandidate: true, + }, + }, + }, + }, + }); + stubQuery(req, "getCandidacyForDropOutDecisionPage", { + data: { + candidate_getCandidateWithCandidacy: { + candidacy: { + id: "c1", + }, + }, + }, + }); + stubQuery(req, "activeFeaturesForConnectedUser", "features.json"); + }); +} + +context("Candidacy dropout decision page", () => { + it("should let me access the page", function () { + interceptCandidacy(); + cy.login(); + cy.wait("@candidate_login"); + cy.wait("@candidate_getCandidateWithCandidacy"); + cy.wait("@activeFeaturesForConnectedUser"); + cy.visit("/candidacy-dropout-decision/"); + cy.wait("@getCandidacyForDropOutDecisionPage"); + cy.get('[data-test="candidacy-dropout-decision-page"]').should("exist"); + cy.get("h1").should("contain.text", "Abandon du parcours VAE"); + }); + it("should let me validate my drop out", function () { + interceptCandidacy(); + cy.login(); + cy.wait("@candidate_login"); + cy.wait("@candidate_getCandidateWithCandidacy"); + cy.wait("@activeFeaturesForConnectedUser"); + cy.visit("/candidacy-dropout-decision/"); + cy.wait("@getCandidacyForDropOutDecisionPage"); + cy.get(".drop-out-confirmation-radio-button~label").click(); + cy.get("button[type=submit]").click(); + cy.wait("@updateCandidateCandidacyDropoutDecision"); + }); +}); diff --git a/packages/reva-candidate/src/app/candidacy-dropout-decision/page.tsx b/packages/reva-candidate/src/app/candidacy-dropout-decision/page.tsx index 5db50d6da..586cfa992 100644 --- a/packages/reva-candidate/src/app/candidacy-dropout-decision/page.tsx +++ b/packages/reva-candidate/src/app/candidacy-dropout-decision/page.tsx @@ -63,6 +63,7 @@ export default function CandidacyDropOutDecisionPage() { hintText: "Ce choix est irréversible. Vous ne pourrez plus reprendre votre parcours.", nativeInputProps: { + className: "drop-out-confirmation-radio-button", value: "DROP_OUT_CONFIRMED", ...register("dropOutConfirmed"), },