Skip to content

Commit

Permalink
chore(test): refactor directories
Browse files Browse the repository at this point in the history
  • Loading branch information
cedricss committed Sep 2, 2024
1 parent 5d9688d commit 6327651
Show file tree
Hide file tree
Showing 20 changed files with 120 additions and 45 deletions.
Original file line number Diff line number Diff line change
@@ -1,21 +1,25 @@
import { stubQuery } from "../utils/graphql";
import { stubQuery } from "../../utils/graphql";

context("Candidacy", () => {
beforeEach(() => {
cy.intercept("POST", "/api/graphql", (req) => {
stubQuery(req, "activeFeaturesForConnectedUser", "active-features.json");
stubQuery(
req,
"activeFeaturesForConnectedUser",
"features/active-features.json",
);
stubQuery(
req,
"getOrganismForAAPVisibilityCheck",
"visibility-check-admin.json",
"visibility/admin.json",
);
stubQuery(req, "getAccountInfo", "account-admin.json");
stubQuery(req, "getAccountInfo", "account/admin-info.json");
stubQuery(
req,
"getCandidacyByStatusCount",
"candidacy-count-by-status.json",
"candidacy/candidacy-count-by-status.json",
);
stubQuery(req, "getCandidaciesByStatus", "candidacies.json");
stubQuery(req, "getCandidaciesByStatus", "candidacies/candidacies.json");
});

cy.aap("/candidacies");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,33 +1,39 @@
import { stubQuery } from "../utils/graphql";
import { stubQuery } from "../../utils/graphql";
import { sub } from "date-fns";

function visitFunding({ dropOutCreationDate }: { dropOutCreationDate?: Date }) {
cy.fixture("candidacy-drop-out-funding.json").then((candidacyDroppedOut) => {
if (dropOutCreationDate) {
candidacyDroppedOut.data.getCandidacyById.candidacyDropOut.createdAt =
dropOutCreationDate;
} else {
delete candidacyDroppedOut.data.getCandidacyById.candidacyDropOut;
}

cy.intercept("POST", "/api/graphql", (req) => {
stubQuery(req, "activeFeaturesForConnectedUser", "active-features.json");
stubQuery(
req,
"getOrganismForAAPVisibilityCheck",
"visibility-check-admin.json",
);
stubQuery(req, "getAccountInfo", "account-admin.json");

stubQuery(req, "getCandidacyByIdFunding", candidacyDroppedOut);

stubQuery(
req,
"getCandidacyMenuAndCandidateInfos",
"candidacy-drop-out-menu.json",
);
});
});
cy.fixture("candidacy/candidacy-drop-out-funding.json").then(
(candidacyDroppedOut) => {
if (dropOutCreationDate) {
candidacyDroppedOut.data.getCandidacyById.candidacyDropOut.createdAt =
dropOutCreationDate;
} else {
delete candidacyDroppedOut.data.getCandidacyById.candidacyDropOut;
}

cy.intercept("POST", "/api/graphql", (req) => {
stubQuery(
req,
"activeFeaturesForConnectedUser",
"features/active-features.json",
);
stubQuery(
req,
"getOrganismForAAPVisibilityCheck",
"visibility/admin.json",
);
stubQuery(req, "getAccountInfo", "account/admin-info.json");

stubQuery(req, "getCandidacyByIdFunding", candidacyDroppedOut);

stubQuery(
req,
"getCandidacyMenuAndCandidateInfos",
"candidacy/candidacy-drop-out-menu.json",
);
});
},
);

cy.aap("/candidacies/46206f6b-0a59-4478-9338-45e3a8d968e4/funding");
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { stubQuery } from "../utils/graphql";
import { stubQuery } from "../../utils/graphql";

function visitSummary({
feasibilityFormat,
Expand All @@ -7,25 +7,29 @@ function visitSummary({
feasibilityFormat: "DEMATERIALIZED" | "PDF";
financeModule: "hors_plateforme" | "unifvae";
}) {
cy.fixture("candidacy.json").then((candidacy) => {
cy.fixture("candidacy/candidacy.json").then((candidacy) => {
candidacy.data.getCandidacyById.feasibilityFormat = feasibilityFormat;
candidacy.data.getCandidacyById.financeModule = financeModule;

cy.intercept("POST", "/api/graphql", (req) => {
stubQuery(req, "activeFeaturesForConnectedUser", "active-features.json");
stubQuery(
req,
"activeFeaturesForConnectedUser",
"features/active-features.json",
);
stubQuery(
req,
"getOrganismForAAPVisibilityCheck",
"visibility-check-admin.json",
"visibility/admin.json",
);
stubQuery(req, "getAccountInfo", "account-admin.json");
stubQuery(req, "getAccountInfo", "account/admin-info.json");

stubQuery(req, "getCandidacySummaryById", candidacy);

stubQuery(
req,
"getCandidacyMenuAndCandidateInfos",
"candidacy-menu.json",
"candidacy/candidacy-menu.json",
);
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"DF_DISPLAY_LOCAL_ACCOUNTS_OF_CERTIFICATION_AUTHORITY",
"AFFICHAGE_TYPES_FINANCEMENT_CANDIDATURE",
"IMPERSONATE",
"AAP_CGU"
"AAP_CGU",
"AAP_SETTINGS_V3"
]
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
{
"data": {
"account_getAccountForConnectedUser": {
"organism": {
"id": "29994a9a-f166-48b9-974f-f3b3dbccda19",
"isOnSite": false,
"isRemote": true,
"fermePourAbsenceOuConges": true,
"managedDegrees": [
{
"id": "80c1b97a-b1ab-4a9e-b3d1-9a8fef24cc44"
},
{
"id": "719ad4cf-a0a6-4994-a38e-b9f5964dec1c"
},
{
"id": "d7885ad6-42ea-4070-83ab-fd9aa40b7e69"
},
{
"id": "4d18554a-868d-4262-9173-aee184854cfd"
},
{
"id": "badd478b-9411-4247-8df6-683b141509dd"
},
{
"id": "ca24022a-2533-4e30-90ab-d3898b9d7209"
},
{
"id": "b4f431ef-e325-4ce0-a61f-9ee9ed1ae90f"
},
{
"id": "54df34a5-3734-4e04-8796-01ef43acd1fc"
}
],
"domaines": [
{
"id": "4462f3ed-d605-4e08-bb87-b481d3c0b710"
},
{
"id": "24a5eeaa-82af-46f6-ad03-b5a6c5babf14"
},
{
"id": "f69101d2-2824-4093-9ac0-8f8631e5010a"
},
{
"id": "24ebe074-78fc-41c7-8b56-fec2446e6253"
},
{
"id": "43062959-9315-4c1b-82b6-fdb9af494b0c"
},
{
"id": "b4e5cde7-4e2e-46bb-bbee-b3b92f8b6e3b"
}
],
"conventionCollectives": []
}
}
}
}
8 changes: 4 additions & 4 deletions packages/reva-admin-react/cypress/support/commands.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
Cypress.Commands.add("aap", (url = "/") => {
cy.intercept("**/realms/reva/protocol/openid-connect/3p-cookies/step1.html", {
fixture: "auth-step1.html",
fixture: "auth/step1.html",
});

cy.intercept(
"**/realms/reva/protocol/openid-connect/login-status-iframe.html",
{
fixture: "auth-status-iframe.html",
fixture: "auth/status-iframe.html",
},
);

cy.intercept("GET", "**/admin2/silent-check-sso.html", {
fixture: "auth-silent-check-sso.html",
fixture: "auth/silent-check-sso.html",
});

cy.intercept("POST", "**/realms/reva/protocol/openid-connect/token", {
fixture: "auth-token.json",
fixture: "auth/token.json",
});

cy.visit(url, {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const AgenciesSettingsPage = () => {
const { isGestionnaireMaisonMereAAP } = useAuth();
const isGeneralInformationCompleted =
maisonMereAAP?.statutValidationInformationsJuridiquesMaisonMereAAP ===
"A_JOUR";
"A_JOUR" || "EN_ATTENTE_DE_VERIFICATION";
const isCollaboratorsEditable = isGeneralInformationCompleted;

const remoteAgency = organism?.isRemote
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { SideMenu, SideMenuProps } from "@codegouvfr/react-dsfr/SideMenu";
import { useQuery } from "@tanstack/react-query";
import { usePathname } from "next/navigation";
import { ReactNode } from "react";

const agenciesInfoForConnectedUserQuery = graphql(`
query getAgenciesInfoForConnectedUserV2 {
account_getAccountForConnectedUser {
Expand Down

0 comments on commit 6327651

Please sign in to comment.