Skip to content

Commit

Permalink
test(candidate): add e2e tests in candidacy-banner for caducite inval…
Browse files Browse the repository at this point in the history
…idated
  • Loading branch information
ThomasDos committed Dec 13, 2024
1 parent 57737ef commit 0e1be57
Showing 1 changed file with 173 additions and 0 deletions.
173 changes: 173 additions & 0 deletions packages/reva-candidate/cypress/e2e/candidacy-banner.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,43 @@ context("Candidacy Banner Display Logic", () => {
cy.get('[data-test="actualisation-banner"]').should("not.exist");
cy.get('[data-test="welcome-banner"]').should("not.exist");
});

it("should display confirmed contestation banner when candidacy has both invalidated and confirmed contestations", () => {
cy.fixture("candidate1.json").then((candidate) => {
candidate.data.candidate_getCandidateWithCandidacy.candidacy.isCaduque = true;
candidate.data.candidate_getCandidateWithCandidacy.candidacy.candidacyContestationsCaducite =
[
{
certificationAuthorityContestationDecision:
"CADUCITE_INVALIDATED",
contestationSentAt: new Date().getTime(),
},
{
certificationAuthorityContestationDecision: "CADUCITE_CONFIRMED",
contestationSentAt: new Date().getTime(),
},
];

cy.intercept("POST", "/api/graphql", (req) => {
stubQuery(req, "candidate_getCandidateWithCandidacy", candidate);
});
});

cy.login();
cy.wait("@candidate_login");
cy.wait("@candidate_getCandidateWithCandidacy");
cy.wait("@activeFeaturesForConnectedUser");

cy.get('[data-test="contestation-caducite-confirmed-banner"]').should(
"exist",
);
cy.get('[data-test="pending-contestation-caducite-banner"]').should(
"not.exist",
);
cy.get('[data-test="caduque-banner"]').should("not.exist");
cy.get('[data-test="actualisation-banner"]').should("not.exist");
cy.get('[data-test="welcome-banner"]').should("not.exist");
});
});

describe("Pending Contestation Caducite Banner", () => {
Expand Down Expand Up @@ -87,6 +124,40 @@ context("Candidacy Banner Display Logic", () => {
cy.get('[data-test="welcome-banner"]').should("not.exist");
});

it("should display pending contestation banner when candidacy has both invalidated and pending contestations", () => {
cy.fixture("candidate1.json").then((candidate) => {
candidate.data.candidate_getCandidateWithCandidacy.candidacy.isCaduque = true;
candidate.data.candidate_getCandidateWithCandidacy.candidacy.candidacyContestationsCaducite =
[
{
certificationAuthorityContestationDecision:
"CADUCITE_INVALIDATED",
contestationSentAt: new Date().getTime(),
},
{
certificationAuthorityContestationDecision: "DECISION_PENDING",
contestationSentAt: new Date().getTime(),
},
];

cy.intercept("POST", "/api/graphql", (req) => {
stubQuery(req, "candidate_getCandidateWithCandidacy", candidate);
});
});

cy.login();
cy.wait("@candidate_login");
cy.wait("@candidate_getCandidateWithCandidacy");
cy.wait("@activeFeaturesForConnectedUser");

cy.get('[data-test="pending-contestation-caducite-banner"]').should(
"exist",
);
cy.get('[data-test="caduque-banner"]').should("not.exist");
cy.get('[data-test="actualisation-banner"]').should("not.exist");
cy.get('[data-test="welcome-banner"]').should("not.exist");
});

it("should display the correct contestation sent date", () => {
const contestationDate = new Date(2023, 0, 15).getTime();

Expand Down Expand Up @@ -146,6 +217,41 @@ context("Candidacy Banner Display Logic", () => {
cy.get('[data-test="welcome-banner"]').should("not.exist");
});

it(`should display caduque banner when candidacy has invalidated contestation with ${status} status`, () => {
cy.fixture("candidate1.json").then((candidate) => {
candidate.data.candidate_getCandidateWithCandidacy.candidacy.isCaduque = true;
candidate.data.candidate_getCandidateWithCandidacy.candidacy.lastActivityDate =
subMonths(new Date(), 6).getTime();
candidate.data.candidate_getCandidateWithCandidacy.candidacy.status =
status;
candidate.data.candidate_getCandidateWithCandidacy.candidacy.feasibility =
{
decision: ADMISSIBLE_DECISION,
};
candidate.data.candidate_getCandidateWithCandidacy.candidacy.candidacyContestationsCaducite =
[
{
certificationAuthorityContestationDecision:
"CADUCITE_INVALIDATED",
contestationSentAt: new Date().getTime(),
},
];

cy.intercept("POST", "/api/graphql", (req) => {
stubQuery(req, "candidate_getCandidateWithCandidacy", candidate);
});
});

cy.login();
cy.wait("@candidate_login");
cy.wait("@candidate_getCandidateWithCandidacy");
cy.wait("@activeFeaturesForConnectedUser");

cy.get('[data-test="caduque-banner"]').should("exist");
cy.get('[data-test="actualisation-banner"]').should("not.exist");
cy.get('[data-test="welcome-banner"]').should("not.exist");
});

it(`should redirect to contestation page when clicking contest button`, () => {
cy.fixture("candidate1.json").then((candidate) => {
candidate.data.candidate_getCandidateWithCandidacy.candidacy.isCaduque = true;
Expand Down Expand Up @@ -225,6 +331,45 @@ context("Candidacy Banner Display Logic", () => {
cy.get('[data-test="welcome-banner"]').should("exist");
}
});

it(`should ${shouldShowBanner ? "display" : "hide"} actualisation banner when candidacy has invalidated contestation and ${name}`, () => {
cy.fixture("candidate1.json").then((candidate) => {
candidate.data.candidate_getCandidateWithCandidacy.candidacy.lastActivityDate =
lastActivityDate();
candidate.data.candidate_getCandidateWithCandidacy.candidacy.status =
VALID_STATUSES[0];
candidate.data.candidate_getCandidateWithCandidacy.candidacy.feasibility =
{
decision: ADMISSIBLE_DECISION,
};
candidate.data.candidate_getCandidateWithCandidacy.candidacy.isCaduque = false;
candidate.data.candidate_getCandidateWithCandidacy.candidacy.candidacyContestationsCaducite =
[
{
certificationAuthorityContestationDecision:
"CADUCITE_INVALIDATED",
contestationSentAt: new Date().getTime(),
},
];

cy.intercept("POST", "/api/graphql", (req) => {
stubQuery(req, "candidate_getCandidateWithCandidacy", candidate);
});
});

cy.login();
cy.wait("@candidate_login");
cy.wait("@candidate_getCandidateWithCandidacy");
cy.wait("@activeFeaturesForConnectedUser");

if (shouldShowBanner) {
cy.get('[data-test="actualisation-banner"]').should("exist");
cy.get('[data-test="welcome-banner"]').should("not.exist");
} else {
cy.get('[data-test="actualisation-banner"]').should("not.exist");
cy.get('[data-test="welcome-banner"]').should("exist");
}
});
},
);

Expand Down Expand Up @@ -298,6 +443,34 @@ context("Candidacy Banner Display Logic", () => {
cy.get('[data-test="actualisation-banner"]').should("not.exist");
cy.get('[data-test="caduque-banner"]').should("not.exist");
});

it(`should display welcome banner when candidacy has invalidated contestation and ${name}`, () => {
cy.fixture("candidate1.json").then((candidate) => {
candidate.data.candidate_getCandidateWithCandidacy.candidacy = {
...candidate.data.candidate_getCandidateWithCandidacy.candidacy,
...candidacy,
candidacyContestationsCaducite: [
{
certificationAuthorityContestationDecision:
"CADUCITE_INVALIDATED",
contestationSentAt: new Date().getTime(),
},
],
};
cy.intercept("POST", "/api/graphql", (req) => {
stubQuery(req, "candidate_getCandidateWithCandidacy", candidate);
});
});

cy.login();
cy.wait("@candidate_login");
cy.wait("@candidate_getCandidateWithCandidacy");
cy.wait("@activeFeaturesForConnectedUser");

cy.get('[data-test="welcome-banner"]').should("exist");
cy.get('[data-test="actualisation-banner"]').should("not.exist");
cy.get('[data-test="caduque-banner"]').should("not.exist");
});
});
});

Expand Down

0 comments on commit 0e1be57

Please sign in to comment.