Skip to content

Commit

Permalink
Revert "Revert "chore(candidate): cypress tests -> work in progress""
Browse files Browse the repository at this point in the history
This reverts commit 5ecc182.
  • Loading branch information
agarbe committed Sep 9, 2024
1 parent 5ecc182 commit aab7e1e
Show file tree
Hide file tree
Showing 51 changed files with 3,000 additions and 7 deletions.
16 changes: 16 additions & 0 deletions packages/reva-candidate/cypress.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { defineConfig } from "cypress";

export default defineConfig({
experimentalStudio: true,
viewportWidth: 490,
viewportHeight: 844,
e2e: {
// We've imported your old cypress plugins here.
// You may want to clean this up later by importing these.
setupNodeEvents(on, config) {
// eslint-disable-next-line @typescript-eslint/no-var-requires
return require("./cypress/plugins/index.js")(on, config);
},
baseUrl: "http://localhost:3004/candidat/",
},
});
41 changes: 41 additions & 0 deletions packages/reva-candidate/cypress/e2e/certificate-list.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { stubMutation, stubQuery } from "../utils/graphql";

context("Certificate list", () => {
beforeEach(() => {
cy.intercept("POST", "/api/graphql", (req) => {
stubQuery(req, "getDepartments", "departments.json");
stubMutation(req, "candidate_login", "candidate1.json");
stubQuery(req, "getReferential", "referential.json");
stubQuery(req, "Certifications", "certifications.json");
stubQuery(req, "activeFeaturesForConnectedUser", "features.json");
stubMutation(
req,
"candidacy_updateCertification",
"updated-candidacy1.json",
);
});

cy.login();
cy.wait("@candidate_login");
cy.wait("@getReferential");
cy.wait("@activeFeaturesForConnectedUser");
});

it("should show only 2 certifications", function () {
cy.get('[data-test="project-home-select-certification"]').click();
cy.get("[name='select_department']").select("2");
cy.wait("@Certifications");

cy.get('[data-test="results"]').children("li").should("have.length", 2);

cy.get('[data-test="results"]')
.children("li")
.eq(0)
.should("have.text", "34691Titre 1");

cy.get('[data-test="results"]')
.children("li")
.eq(1)
.should("have.text", "34692Titre 2");
});
});
48 changes: 48 additions & 0 deletions packages/reva-candidate/cypress/e2e/certificates.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import { stubMutation, stubQuery } from "../utils/graphql";

context("Certificates", () => {
beforeEach(() => {
cy.intercept("POST", "/api/graphql", (req) => {
stubQuery(req, "getDepartments", "departments.json");
stubMutation(req, "candidate_login", "candidate1.json");
stubQuery(req, "getReferential", "referential.json");
stubQuery(req, "activeFeaturesForConnectedUser", "features.json");
stubQuery(req, "Certifications", "certifications.json");
stubMutation(
req,
"candidacy_updateCertification",
"updated-candidacy1.json",
);
});

cy.login();

cy.wait("@candidate_login");
cy.wait("@getReferential");
cy.wait("@activeFeaturesForConnectedUser");

cy.get('[data-test="project-home-select-certification"]').click();
cy.get("[name='select_department']").select("2");
cy.wait("@Certifications");
});

it("display information about the selected certificate", function () {
cy.get('[data-test="certification-select-c2"]').click();
cy.get('[data-test="certification-label"]').should("contain", "Titre 2");
cy.get('[data-test="certification-code-rncp"]').should("contain", "34692");
cy.get('[data-test="certification-more-info-link"]').should(
"have.attr",
"href",
"https://www.francecompetences.fr/recherche/rncp/34692/",
);
});

it("select department and submit certificate via summary", function () {
cy.get('[data-test="certification-select-c2"]').click();
cy.get('[data-test="submit-certification-button"]').click();
cy.wait("@candidacy_updateCertification");

cy.get('[data-test="project-home-ready"]');
cy.get('[data-test="certification-label"]').should("contain", "Titre 2");
});
});
59 changes: 59 additions & 0 deletions packages/reva-candidate/cypress/e2e/contact.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import { stubMutation, stubQuery } from "../utils/graphql";

const firstname1 = "John";
const firstname2 = "John 2";

const lastname1 = "Doe";
const lastname2 = "Doe 2";

const email1 = "[email protected]";
const email2 = "[email protected]";

const phone1 = "06 01 02 03 04";
const phone2 = "06 01 02 03 05";

context("Candidate account", () => {
it("update all account information", function () {
cy.intercept("POST", "/api/graphql", (req) => {
stubMutation(req, "candidate_login", "candidate1.json");
stubQuery(req, "getReferential", "referential.json");
stubQuery(req, "getDepartments", "departments.json");
stubQuery(req, "activeFeaturesForConnectedUser", "features.json");
stubQuery(req, "update_contact", "contact.json");
});
cy.login();
cy.wait("@candidate_login");
cy.wait("@getReferential");

cy.get('[data-test="project-home-update-contact"]').click();

cy.get("[name=firstname]").should("have.value", firstname1);
cy.get("[name=lastname]").should("have.value", lastname1);
cy.get("[name=phone]").should("have.value", phone1);
cy.get("[name=email]").should("have.value", email1);

cy.get("[name=firstname]").type(`{selectAll}${firstname2}`);
cy.get("[name=lastname]").type(`{selectAll}${lastname2}`);
cy.get("[name=phone]").type(`{selectAll}${phone2}`);
cy.get("[name=email]").type(`{selectAll}${email2}`);

cy.get('[data-test="project-contact-save"]').click();
cy.get(
'[title="Fermer"][aria-controls="project-home-modal-email"]',
).click();
cy.wait("@update_contact");

cy.get('[data-test="project-home-fullname"]').contains(
`${firstname2} ${lastname2}`,
);
cy.get('[data-test="project-home-contact-phone"]').contains(phone2);
cy.get('[data-test="project-home-contact-email"]').contains(email2);

cy.get('[data-test="project-home-update-contact"]').click();

cy.get("[name=firstname]").should("have.value", firstname2);
cy.get("[name=lastname]").should("have.value", lastname2);
cy.get("[name=phone]").should("have.value", phone2);
cy.get("[name=email]").should("have.value", email2);
});
});
64 changes: 64 additions & 0 deletions packages/reva-candidate/cypress/e2e/dropped-out.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import { stubMutation, stubQuery } from "../utils/graphql";

const firstname = "John";
const lastname = "Doe";
const email = "[email protected]";
const supportEmail = "[email protected]";

context("Dropped out", () => {
it("log on a dropped-out project", function () {
cy.intercept("POST", "/api/graphql", (req) => {
stubQuery(req, "getDepartments", "departments.json");
stubMutation(req, "candidate_login", "candidate2-dropped-out.json");
stubQuery(req, "getReferential", "referential.json");
stubQuery(req, "activeFeaturesForConnectedUser", "features.json");
});
cy.login();

cy.wait("@candidate_login");
cy.wait("@getReferential");
cy.wait("@activeFeaturesForConnectedUser");

cy.get('[data-test="home-project-dropped-out"]');
});

it("dropped-out project page should display candidate info", function () {
cy.intercept("POST", "/api/graphql", (req) => {
stubQuery(req, "getDepartments", "departments.json");
stubMutation(req, "candidate_login", "candidate2-dropped-out.json");
stubQuery(req, "getReferential", "referential.json");
stubQuery(req, "activeFeaturesForConnectedUser", "features.json");
});
cy.login();
cy.wait("@candidate_login");
cy.wait("@getReferential");
cy.wait("@activeFeaturesForConnectedUser");

cy.get('[data-test="home-dropped-out-name"').should(
"have.text",
`Bonjour ${firstname} ${lastname},`,
);
cy.get('[data-test="home-dropped-out-email"').should(
"have.text",
`Email: ${email}`,
);
});

it("dropped-out project page should display support email", function () {
cy.intercept("POST", "/api/graphql", (req) => {
stubQuery(req, "getDepartments", "departments.json");
stubMutation(req, "candidate_login", "candidate2-dropped-out.json");
stubQuery(req, "getReferential", "referential.json");
stubQuery(req, "activeFeaturesForConnectedUser", "features.json");
});
cy.login();
cy.wait("@candidate_login");
cy.wait("@getReferential");
cy.wait("@activeFeaturesForConnectedUser");

cy.get('[data-test="home-dropped-out-support-email"').should(
"have.text",
`${supportEmail}`,
);
});
});
72 changes: 72 additions & 0 deletions packages/reva-candidate/cypress/e2e/experiences.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
const experienceTitle1 = "Experience 1";
const experienceTitle2 = "Experience 2";

const experienceDescription1 = "Description 1";
const experienceDescription2 = "Description 2";

import { stubMutation, stubQuery } from "../utils/graphql";

context("Experiences", () => {
it("add and edit an experience", function () {
cy.intercept("POST", "/api/graphql", (req) => {
stubQuery(req, "getDepartments", "departments.json");
stubMutation(
req,
"candidate_login",
"candidate1-certification-and-goals-selected.json",
);
stubQuery(req, "getReferential", "referential.json");
stubQuery(req, "add_experience", "added-experience1.json");
stubQuery(req, "update_experience", "updated-experience2.json");
stubQuery(req, "activeFeaturesForConnectedUser", "features.json");
});
cy.login();
cy.wait("@candidate_login");
cy.wait("@getReferential");
cy.wait("@activeFeaturesForConnectedUser");

cy.get('[data-test="timeline-add-experience"]').click();
cy.get("[name='title']").type(experienceTitle1);
cy.get("[name='startedAt']").type("2019-01-31");
cy.get("[name='duration']").select("betweenOneAndThreeYears");
cy.get("textarea[name='description']").type(experienceDescription1);

cy.get('[data-test="project-experience-add"]').click();
cy.wait("@add_experience");

cy.get('[data-test="timeline-experiences-list"] > li')
.eq(0)
.within(() => {
cy.get('[data-test="timeline-experience-title"]').should(
"have.text",
experienceTitle1,
);
cy.get('[data-test="timeline-experience-duration"]').should(
"have.text",
"Entre 1 et 3 ans",
);
});

cy.get('[data-test="timeline-experiences-list"] > li').eq(0).click();
cy.get("[name='startedAt']").type("2017-03-31");
cy.get("[name='title']").type(`{selectAll}${experienceTitle2}`);
cy.get("[name='duration']").select("moreThanFiveYears");
cy.get("textarea[name='description']").type(
`{selectAll}${experienceDescription2}`,
);
cy.get('[data-test="project-experience-save"]').click();

cy.get('[data-test="timeline-experiences-list"] > li')
.eq(0)
.within(() => {
cy.get('[data-test="timeline-experience-title"]').should(
"have.text",
experienceTitle2,
);
cy.get('[data-test="timeline-experience-duration"]').should(
"have.text",
"Plus de 5 ans",
);
});
});
});
24 changes: 24 additions & 0 deletions packages/reva-candidate/cypress/e2e/funding-request-sent.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { stubMutation, stubQuery } from "../utils/graphql";

context("Funding Request Sent", () => {
describe("Testing correct screen", () => {
it("display all fields", () => {
cy.intercept("POST", "/api/graphql", (req) => {
stubQuery(req, "getDepartments", "departments.json");
stubMutation(
req,
"candidate_login",
"candidate2-funding-request-sent.json",
);
stubQuery(req, "getReferential", "referential.json");
stubQuery(req, "activeFeaturesForConnectedUser", "features.json");
});
cy.login();
cy.wait("@candidate_login");
cy.wait("@getReferential");
cy.wait("@activeFeaturesForConnectedUser");

cy.get('[data-test="view-training-program-button"]').should("exist");
});
});
});
32 changes: 32 additions & 0 deletions packages/reva-candidate/cypress/e2e/login.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { stubQuery } from "../utils/graphql";

const email = "[email protected]";

context("Login", () => {
it("submit email", function () {
cy.intercept("POST", "/api/graphql", (req) => {
stubQuery(req, "getDepartments", "departments.json");
stubQuery(req, "candidate_askForLogin", "login.json");
});

cy.login();

cy.get('[data-test="login-home"] #email').type(email);

cy.get('[data-test="login-home-submit"]').click();
cy.wait("@candidate_askForLogin");

cy.get('[data-test="login-confirmation"]');
});

it("access login page from registration page", function () {
cy.intercept("POST", "/api/graphql", (req) => {
stubQuery(req, "getDepartments", "departments.json");
stubQuery(req, "activeFeaturesForConnectedUser", "features.json");
});

cy.visit("/registration");
cy.get('[data-test="navigate-to-login"]').click();
cy.get('[data-test="login-home"]');
});
});
Loading

0 comments on commit aab7e1e

Please sign in to comment.