diff --git a/packages/reva-admin-react/cypress/e2e/certifications/update-certification-page/update-certification-page.cy.ts b/packages/reva-admin-react/cypress/e2e/certifications/update-certification-page/update-certification-page.cy.ts index ac34345c5..636312151 100644 --- a/packages/reva-admin-react/cypress/e2e/certifications/update-certification-page/update-certification-page.cy.ts +++ b/packages/reva-admin-react/cypress/e2e/certifications/update-certification-page/update-certification-page.cy.ts @@ -1,7 +1,9 @@ import { stubQuery } from "../../../utils/graphql"; import certificationBPBoucher from "./fixtures/certification-bp-boucher.json"; -function interceptCertification() { +function interceptCertification({ + withStructure, +}: { withStructure?: boolean } = {}) { cy.intercept("POST", "/api/graphql", (req) => { stubQuery( req, @@ -14,11 +16,16 @@ function interceptCertification() { "getMaisonMereCGUQuery", "account/gestionnaire-cgu-accepted.json", ); - stubQuery( - req, - "getCertificationForUpdateCertificationPage", - certificationBPBoucher, - ); + stubQuery(req, "getCertificationForUpdateCertificationPage", { + data: { + getCertification: { + ...certificationBPBoucher.data.getCertification, + certificationAuthorityStructure: withStructure + ? { id: "0ec61d50-a202-4222-95ff-d516b9cae503" } + : undefined, + }, + }, + }); }); } @@ -37,65 +44,115 @@ context("when i access the update certification page ", () => { .should("have.text", "BP Boucher"); }); - it("display the correct number of competence blocs and competences", function () { - interceptCertification(); - - cy.admin("/certifications-v2/bf78b4d6-f6ac-4c8f-9e6b-d6c6ae9e891b"); - cy.wait("@activeFeaturesForConnectedUser"); - cy.wait("@getOrganismForAAPVisibilityCheck"); - cy.wait("@getMaisonMereCGUQuery"); - cy.wait("@getCertificationForUpdateCertificationPage"); - - //2 competence blocs - cy.get( - '[data-test="update-certification-page"] [data-test="competence-blocs-list"] [data-test="competence-bloc"]', - ).should("have.length", 2); - - //4 competence for the first competence bloc - cy.get( - '[data-test="update-certification-page"] [data-test="competence-blocs-list"] [data-test="competence-bloc"]:first-child [data-test="competences-list"] > li', - ).should("have.length", 4); - - //2 competence for the second competence bloc - cy.get( - '[data-test="update-certification-page"] [data-test="competence-blocs-list"] [data-test="competence-bloc"]:nth-child(2) [data-test="competences-list"] > li', - ).should("have.length", 2); - }); - - it("let me click on the 'update competence bloc' button of the first competence bloc and leads me to its update page ", function () { - interceptCertification(); - - cy.admin("/certifications-v2/bf78b4d6-f6ac-4c8f-9e6b-d6c6ae9e891b"); - cy.wait("@activeFeaturesForConnectedUser"); - cy.wait("@getOrganismForAAPVisibilityCheck"); - cy.wait("@getMaisonMereCGUQuery"); - cy.wait("@getCertificationForUpdateCertificationPage"); - - cy.get( - '[data-test="update-certification-page"] [data-test="competence-blocs-list"] [data-test="competence-bloc"]:first-child [data-test="update-competence-bloc-button"]', - ).click(); - - cy.url().should( - "eq", - "http://localhost:3003/admin2/certifications-v2/bf78b4d6-f6ac-4c8f-9e6b-d6c6ae9e891b/bloc-competence/008a6fab-55ad-4412-ab17-56bc4b8e2fd0/", - ); + context("Competence blocs summary card", () => { + it("display the correct number of competence blocs and competences", function () { + interceptCertification(); + + cy.admin("/certifications-v2/bf78b4d6-f6ac-4c8f-9e6b-d6c6ae9e891b"); + cy.wait("@activeFeaturesForConnectedUser"); + cy.wait("@getOrganismForAAPVisibilityCheck"); + cy.wait("@getMaisonMereCGUQuery"); + cy.wait("@getCertificationForUpdateCertificationPage"); + + //2 competence blocs + cy.get( + '[data-test="update-certification-page"] [data-test="competence-blocs-list"] [data-test="competence-bloc"]', + ).should("have.length", 2); + + //4 competence for the first competence bloc + cy.get( + '[data-test="update-certification-page"] [data-test="competence-blocs-list"] [data-test="competence-bloc"]:first-child [data-test="competences-list"] > li', + ).should("have.length", 4); + + //2 competence for the second competence bloc + cy.get( + '[data-test="update-certification-page"] [data-test="competence-blocs-list"] [data-test="competence-bloc"]:nth-child(2) [data-test="competences-list"] > li', + ).should("have.length", 2); + }); + + it("let me click on the 'update competence bloc' button of the first competence bloc and leads me to its update page ", function () { + interceptCertification(); + + cy.admin("/certifications-v2/bf78b4d6-f6ac-4c8f-9e6b-d6c6ae9e891b"); + cy.wait("@activeFeaturesForConnectedUser"); + cy.wait("@getOrganismForAAPVisibilityCheck"); + cy.wait("@getMaisonMereCGUQuery"); + cy.wait("@getCertificationForUpdateCertificationPage"); + + cy.get( + '[data-test="update-certification-page"] [data-test="competence-blocs-list"] [data-test="competence-bloc"]:first-child [data-test="update-competence-bloc-button"]', + ).click(); + + cy.url().should( + "eq", + "http://localhost:3003/admin2/certifications-v2/bf78b4d6-f6ac-4c8f-9e6b-d6c6ae9e891b/bloc-competence/008a6fab-55ad-4412-ab17-56bc4b8e2fd0/", + ); + }); + + it("let me click on the 'add competence bloc' button and leads me to the create competence bloc page ", function () { + interceptCertification(); + + cy.admin("/certifications-v2/bf78b4d6-f6ac-4c8f-9e6b-d6c6ae9e891b"); + cy.wait("@activeFeaturesForConnectedUser"); + cy.wait("@getOrganismForAAPVisibilityCheck"); + cy.wait("@getMaisonMereCGUQuery"); + cy.wait("@getCertificationForUpdateCertificationPage"); + + cy.get( + '[data-test="competence-blocs-summary-card"] [data-test="action-button"] ', + ).click(); + cy.url().should( + "eq", + "http://localhost:3003/admin2/certifications-v2/bf78b4d6-f6ac-4c8f-9e6b-d6c6ae9e891b/bloc-competence/add/", + ); + }); }); - it("let me click on the 'add competence bloc' button and leads me to the create competence bloc page ", function () { - interceptCertification(); - - cy.admin("/certifications-v2/bf78b4d6-f6ac-4c8f-9e6b-d6c6ae9e891b"); - cy.wait("@activeFeaturesForConnectedUser"); - cy.wait("@getOrganismForAAPVisibilityCheck"); - cy.wait("@getMaisonMereCGUQuery"); - cy.wait("@getCertificationForUpdateCertificationPage"); - - cy.get( - '[data-test="update-certification-page"] [data-test="action-button"] ', - ).click(); - cy.url().should( - "eq", - "http://localhost:3003/admin2/certifications-v2/bf78b4d6-f6ac-4c8f-9e6b-d6c6ae9e891b/bloc-competence/add/", - ); + context("Structure summary card", () => { + it("display a 'to complete' badge on the certification structure summary card when the certification has no associated structure", function () { + interceptCertification(); + + cy.admin("/certifications-v2/bf78b4d6-f6ac-4c8f-9e6b-d6c6ae9e891b"); + cy.wait("@activeFeaturesForConnectedUser"); + cy.wait("@getOrganismForAAPVisibilityCheck"); + cy.wait("@getMaisonMereCGUQuery"); + cy.wait("@getCertificationForUpdateCertificationPage"); + + cy.get( + '[data-test="certification-structure-summary-card"] [data-test="to-complete-badge"]', + ).should("exist"); + }); + + it("display a 'completed' badge on the certification structure summary card when the certification has no associated structure", function () { + interceptCertification({ withStructure: true }); + + cy.admin("/certifications-v2/bf78b4d6-f6ac-4c8f-9e6b-d6c6ae9e891b"); + cy.wait("@activeFeaturesForConnectedUser"); + cy.wait("@getOrganismForAAPVisibilityCheck"); + cy.wait("@getMaisonMereCGUQuery"); + cy.wait("@getCertificationForUpdateCertificationPage"); + + cy.get( + '[data-test="certification-structure-summary-card"] [data-test="completed-badge"]', + ).should("exist"); + }); + + it("let me click on the 'completer' button and redirect me to the structure page", function () { + interceptCertification(); + + cy.admin("/certifications-v2/bf78b4d6-f6ac-4c8f-9e6b-d6c6ae9e891b"); + cy.wait("@activeFeaturesForConnectedUser"); + cy.wait("@getOrganismForAAPVisibilityCheck"); + cy.wait("@getMaisonMereCGUQuery"); + cy.wait("@getCertificationForUpdateCertificationPage"); + + cy.get( + '[data-test="certification-structure-summary-card"] [data-test="action-button"] ', + ).click(); + cy.url().should( + "eq", + "http://localhost:3003/admin2/certifications-v2/bf78b4d6-f6ac-4c8f-9e6b-d6c6ae9e891b/structure/", + ); + }); }); }); diff --git a/packages/reva-admin-react/src/app/(admin)/certifications-v2/[certificationId]/page.tsx b/packages/reva-admin-react/src/app/(admin)/certifications-v2/[certificationId]/page.tsx index 75c293ebc..10d9fc3be 100644 --- a/packages/reva-admin-react/src/app/(admin)/certifications-v2/[certificationId]/page.tsx +++ b/packages/reva-admin-react/src/app/(admin)/certifications-v2/[certificationId]/page.tsx @@ -32,6 +32,8 @@ const PageContent = ({ certification: CertificationForPage; }) => { const router = useRouter(); + const structureSummaryCardComplete = + !!certification.certificationAuthorityStructure; return (

{certification.label}

@@ -94,6 +96,7 @@ const PageContent = ({ +

Validation par le responsable des certifications

diff --git a/packages/reva-admin-react/src/app/(admin)/certifications-v2/[certificationId]/updateCertification.hook.ts b/packages/reva-admin-react/src/app/(admin)/certifications-v2/[certificationId]/updateCertification.hook.ts index 957291ca9..97795674a 100644 --- a/packages/reva-admin-react/src/app/(admin)/certifications-v2/[certificationId]/updateCertification.hook.ts +++ b/packages/reva-admin-react/src/app/(admin)/certifications-v2/[certificationId]/updateCertification.hook.ts @@ -39,6 +39,10 @@ const getCertificationQuery = graphql(` label } } + certificationAuthorityStructure { + id + label + } } } `);