Skip to content

Commit

Permalink
feat(admin): added some tests to the update certification bloc page
Browse files Browse the repository at this point in the history
  • Loading branch information
agarbe committed Nov 13, 2024
1 parent dc14642 commit a7f6517
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"data": {
"referential_updateCertificationCompetenceBloc": {
"id": "008a6fab-55ad-4412-ab17-56bc4b8e2fd0"
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { stubQuery } from "../../../utils/graphql";
import { stubMutation, stubQuery } from "../../../utils/graphql";
import certificationCBBPBoucher1 from "./fixtures/certification-competence-bloc-bp-boucher-1.json";
import updateCertificationBlocMutationResponse from "./fixtures/update-competence-bloc-bp-boucher-mutation-response.json";

function interceptCertificationCompetenceBloc() {
cy.intercept("POST", "/api/graphql", (req) => {
Expand All @@ -21,6 +22,16 @@ function interceptCertificationCompetenceBloc() {
});
}

function interceptUpdateCertificationCompetenceBlocMutation() {
cy.intercept("POST", "/api/graphql", (req) => {
stubMutation(
req,
"updateCertificationCompetenceBlocForUpdateCertificationCompetenceBlocPage",
updateCertificationBlocMutationResponse,
);
});
}

context("when i access the update certification page ", () => {
it("display the page with a correct title", function () {
interceptCertificationCompetenceBloc();
Expand All @@ -39,4 +50,36 @@ context("when i access the update certification page ", () => {
"RNCP37310BC01 - Préparation, présentation, décoration et vente en boucherie",
);
});

it("dont let me submit the form if no edit has been made", function () {
interceptCertificationCompetenceBloc();
cy.admin(
"http://localhost:3003/admin2/certifications-v2/bf78b4d6-f6ac-4c8f-9e6b-d6c6ae9e891b/bloc-competence/008a6fab-55ad-4412-ab17-56bc4b8e2fd0/",
);
cy.wait("@activeFeaturesForConnectedUser");
cy.wait("@getMaisonMereCGUQuery");
cy.wait("@getCompetenceBlocForUpdateCompetenceBlocPage");

cy.get("button").contains("Enregistrer").should("be.disabled");
});

it("let me update a competence bloc and submit the form", function () {
interceptCertificationCompetenceBloc();
interceptUpdateCertificationCompetenceBlocMutation();
cy.admin(
"http://localhost:3003/admin2/certifications-v2/bf78b4d6-f6ac-4c8f-9e6b-d6c6ae9e891b/bloc-competence/008a6fab-55ad-4412-ab17-56bc4b8e2fd0/",
);
cy.wait("@activeFeaturesForConnectedUser");
cy.wait("@getMaisonMereCGUQuery");
cy.wait("@getCompetenceBlocForUpdateCompetenceBlocPage");

cy.get('[data-test="competence-bloc-label-input"] input')
.clear()
.type("updated competence bloc label");

cy.get("button").contains("Enregistrer").click();
cy.wait(
"@updateCertificationCompetenceBlocForUpdateCertificationCompetenceBlocPage",
);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export const CompetenceBlocForm = ({
return (
<form onSubmit={handleFormSubmit} className={`${className}`}>
<Input
data-test="competence-bloc-label-input"
label="Intitulé du bloc de compétences"
state={errors.label ? "error" : "default"}
stateRelatedMessage={errors.label?.message?.toString()}
Expand Down

0 comments on commit a7f6517

Please sign in to comment.