Skip to content

Commit

Permalink
fix(admin): it is no longer possible to validate a certification whit…
Browse files Browse the repository at this point in the history
…hout having filled its additional information
  • Loading branch information
agarbe committed Dec 24, 2024
1 parent 9b6a90b commit 1faf619
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ import certificationBPBoucher from "./fixtures/certification-bp-boucher.json";
function interceptCertification({
withPrerequisites,
withDescription,
withadditionalInfo,
withStatus,
}: {
withPrerequisites?: boolean;
withDescription?: boolean;
withadditionalInfo?: boolean;
withStatus?: CertificationStatus;
}) {
cy.intercept("POST", "/api/graphql", (req) => {
Expand Down Expand Up @@ -54,6 +56,9 @@ function interceptCertification({
juryPlace: null,
}
: {})(),
additionalInfo: withadditionalInfo
? { linkToReferential: "https://www.google.fr" }
: undefined,
status:
withStatus || certificationBPBoucher.data.getCertification.status,
},
Expand Down Expand Up @@ -201,7 +206,7 @@ context("when i access the update certification page ", () => {

context("validate certification", () => {
it("validate button should be disable if description has not been complete", function () {
interceptCertification({});
interceptCertification({ withadditionalInfo: true });

cy.admin(
"/responsable-certifications/certifications/bf78b4d6-f6ac-4c8f-9e6b-d6c6ae9e891b",
Expand All @@ -220,8 +225,11 @@ context("when i access the update certification page ", () => {
.should("be.disabled");
});

it("validate button should be enable if description has been complete", function () {
interceptCertification({ withDescription: true });
it("validate button should be enable if description and additional information sections are complete", function () {
interceptCertification({
withDescription: true,
withadditionalInfo: true,
});

cy.admin(
"/responsable-certifications/certifications/bf78b4d6-f6ac-4c8f-9e6b-d6c6ae9e891b",
Expand All @@ -243,6 +251,7 @@ context("when i access the update certification page ", () => {
it.skip("validate button should not be visible if certification has been validate", function () {
interceptCertification({
withDescription: true,
withadditionalInfo: true,
withStatus: "VALIDE_PAR_CERTIFICATEUR",
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,9 @@ const PageContent = ({
certification.availableAt &&
certification.expiresAt;

const canValidateCertification =
isDescriptionComplete && certification.additionalInfo;

return (
<div data-test="certification-registry-manager-update-certification-page">
<h1>
Expand Down Expand Up @@ -297,7 +300,7 @@ const PageContent = ({
<div className="flex gap-x-2 ml-auto">
<Button
type="button"
disabled={!isDescriptionComplete}
disabled={!canValidateCertification}
onClick={modal.open}
>
Valider cette certification
Expand Down

0 comments on commit 1faf619

Please sign in to comment.