From 6327651cd3f235b4c4478c1dfe4a51fd8ececdc0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Soulas?= Date: Mon, 2 Sep 2024 11:30:07 +0200 Subject: [PATCH] chore(test): refactor directories --- .../e2e/{ => candidacies}/candidacies.cy.ts | 16 +++-- .../funding.cy.ts} | 60 ++++++++++--------- .../summary.cy.ts} | 16 +++-- .../admin-info.json} | 0 .../silent-check-sso.html} | 0 .../status-iframe.html} | 0 .../{auth-step1.html => auth/step1.html} | 0 .../{auth-token.json => auth/token.json} | 0 .../{ => candidacies}/candidacies.json | 0 .../candidacy-count-by-status.json | 0 .../candidacy-drop-out-funding.json | 0 .../candidacy-drop-out-menu.json | 0 .../{ => candidacy}/candidacy-menu.json | 0 .../fixtures/{ => candidacy}/candidacy.json | 0 .../{ => features}/active-features.json | 3 +- .../admin.json} | 0 .../cypress/fixtures/visibility/organism.json | 59 ++++++++++++++++++ .../cypress/support/commands.ts | 8 +-- .../app/(aap)/agencies-settings-v3/page.tsx | 2 +- .../app/(aap)/agencies-settings/layout.tsx | 1 + 20 files changed, 120 insertions(+), 45 deletions(-) rename packages/reva-admin-react/cypress/e2e/{ => candidacies}/candidacies.cy.ts (77%) rename packages/reva-admin-react/cypress/e2e/{candidacy-funding.cy.ts => candidacy/funding.cy.ts} (58%) rename packages/reva-admin-react/cypress/e2e/{candidacy-summary.cy.ts => candidacy/summary.cy.ts} (87%) rename packages/reva-admin-react/cypress/fixtures/{account-admin.json => account/admin-info.json} (100%) rename packages/reva-admin-react/cypress/fixtures/{auth-silent-check-sso.html => auth/silent-check-sso.html} (100%) rename packages/reva-admin-react/cypress/fixtures/{auth-status-iframe.html => auth/status-iframe.html} (100%) rename packages/reva-admin-react/cypress/fixtures/{auth-step1.html => auth/step1.html} (100%) rename packages/reva-admin-react/cypress/fixtures/{auth-token.json => auth/token.json} (100%) rename packages/reva-admin-react/cypress/fixtures/{ => candidacies}/candidacies.json (100%) rename packages/reva-admin-react/cypress/fixtures/{ => candidacy}/candidacy-count-by-status.json (100%) rename packages/reva-admin-react/cypress/fixtures/{ => candidacy}/candidacy-drop-out-funding.json (100%) rename packages/reva-admin-react/cypress/fixtures/{ => candidacy}/candidacy-drop-out-menu.json (100%) rename packages/reva-admin-react/cypress/fixtures/{ => candidacy}/candidacy-menu.json (100%) rename packages/reva-admin-react/cypress/fixtures/{ => candidacy}/candidacy.json (100%) rename packages/reva-admin-react/cypress/fixtures/{ => features}/active-features.json (82%) rename packages/reva-admin-react/cypress/fixtures/{visibility-check-admin.json => visibility/admin.json} (100%) create mode 100644 packages/reva-admin-react/cypress/fixtures/visibility/organism.json diff --git a/packages/reva-admin-react/cypress/e2e/candidacies.cy.ts b/packages/reva-admin-react/cypress/e2e/candidacies/candidacies.cy.ts similarity index 77% rename from packages/reva-admin-react/cypress/e2e/candidacies.cy.ts rename to packages/reva-admin-react/cypress/e2e/candidacies/candidacies.cy.ts index 3b67eb06b..270cc10f2 100644 --- a/packages/reva-admin-react/cypress/e2e/candidacies.cy.ts +++ b/packages/reva-admin-react/cypress/e2e/candidacies/candidacies.cy.ts @@ -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"); diff --git a/packages/reva-admin-react/cypress/e2e/candidacy-funding.cy.ts b/packages/reva-admin-react/cypress/e2e/candidacy/funding.cy.ts similarity index 58% rename from packages/reva-admin-react/cypress/e2e/candidacy-funding.cy.ts rename to packages/reva-admin-react/cypress/e2e/candidacy/funding.cy.ts index 513d175c5..3517f259f 100644 --- a/packages/reva-admin-react/cypress/e2e/candidacy-funding.cy.ts +++ b/packages/reva-admin-react/cypress/e2e/candidacy/funding.cy.ts @@ -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"); } diff --git a/packages/reva-admin-react/cypress/e2e/candidacy-summary.cy.ts b/packages/reva-admin-react/cypress/e2e/candidacy/summary.cy.ts similarity index 87% rename from packages/reva-admin-react/cypress/e2e/candidacy-summary.cy.ts rename to packages/reva-admin-react/cypress/e2e/candidacy/summary.cy.ts index 51566d86f..5b638a94d 100644 --- a/packages/reva-admin-react/cypress/e2e/candidacy-summary.cy.ts +++ b/packages/reva-admin-react/cypress/e2e/candidacy/summary.cy.ts @@ -1,4 +1,4 @@ -import { stubQuery } from "../utils/graphql"; +import { stubQuery } from "../../utils/graphql"; function visitSummary({ feasibilityFormat, @@ -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", ); }); }); diff --git a/packages/reva-admin-react/cypress/fixtures/account-admin.json b/packages/reva-admin-react/cypress/fixtures/account/admin-info.json similarity index 100% rename from packages/reva-admin-react/cypress/fixtures/account-admin.json rename to packages/reva-admin-react/cypress/fixtures/account/admin-info.json diff --git a/packages/reva-admin-react/cypress/fixtures/auth-silent-check-sso.html b/packages/reva-admin-react/cypress/fixtures/auth/silent-check-sso.html similarity index 100% rename from packages/reva-admin-react/cypress/fixtures/auth-silent-check-sso.html rename to packages/reva-admin-react/cypress/fixtures/auth/silent-check-sso.html diff --git a/packages/reva-admin-react/cypress/fixtures/auth-status-iframe.html b/packages/reva-admin-react/cypress/fixtures/auth/status-iframe.html similarity index 100% rename from packages/reva-admin-react/cypress/fixtures/auth-status-iframe.html rename to packages/reva-admin-react/cypress/fixtures/auth/status-iframe.html diff --git a/packages/reva-admin-react/cypress/fixtures/auth-step1.html b/packages/reva-admin-react/cypress/fixtures/auth/step1.html similarity index 100% rename from packages/reva-admin-react/cypress/fixtures/auth-step1.html rename to packages/reva-admin-react/cypress/fixtures/auth/step1.html diff --git a/packages/reva-admin-react/cypress/fixtures/auth-token.json b/packages/reva-admin-react/cypress/fixtures/auth/token.json similarity index 100% rename from packages/reva-admin-react/cypress/fixtures/auth-token.json rename to packages/reva-admin-react/cypress/fixtures/auth/token.json diff --git a/packages/reva-admin-react/cypress/fixtures/candidacies.json b/packages/reva-admin-react/cypress/fixtures/candidacies/candidacies.json similarity index 100% rename from packages/reva-admin-react/cypress/fixtures/candidacies.json rename to packages/reva-admin-react/cypress/fixtures/candidacies/candidacies.json diff --git a/packages/reva-admin-react/cypress/fixtures/candidacy-count-by-status.json b/packages/reva-admin-react/cypress/fixtures/candidacy/candidacy-count-by-status.json similarity index 100% rename from packages/reva-admin-react/cypress/fixtures/candidacy-count-by-status.json rename to packages/reva-admin-react/cypress/fixtures/candidacy/candidacy-count-by-status.json diff --git a/packages/reva-admin-react/cypress/fixtures/candidacy-drop-out-funding.json b/packages/reva-admin-react/cypress/fixtures/candidacy/candidacy-drop-out-funding.json similarity index 100% rename from packages/reva-admin-react/cypress/fixtures/candidacy-drop-out-funding.json rename to packages/reva-admin-react/cypress/fixtures/candidacy/candidacy-drop-out-funding.json diff --git a/packages/reva-admin-react/cypress/fixtures/candidacy-drop-out-menu.json b/packages/reva-admin-react/cypress/fixtures/candidacy/candidacy-drop-out-menu.json similarity index 100% rename from packages/reva-admin-react/cypress/fixtures/candidacy-drop-out-menu.json rename to packages/reva-admin-react/cypress/fixtures/candidacy/candidacy-drop-out-menu.json diff --git a/packages/reva-admin-react/cypress/fixtures/candidacy-menu.json b/packages/reva-admin-react/cypress/fixtures/candidacy/candidacy-menu.json similarity index 100% rename from packages/reva-admin-react/cypress/fixtures/candidacy-menu.json rename to packages/reva-admin-react/cypress/fixtures/candidacy/candidacy-menu.json diff --git a/packages/reva-admin-react/cypress/fixtures/candidacy.json b/packages/reva-admin-react/cypress/fixtures/candidacy/candidacy.json similarity index 100% rename from packages/reva-admin-react/cypress/fixtures/candidacy.json rename to packages/reva-admin-react/cypress/fixtures/candidacy/candidacy.json diff --git a/packages/reva-admin-react/cypress/fixtures/active-features.json b/packages/reva-admin-react/cypress/fixtures/features/active-features.json similarity index 82% rename from packages/reva-admin-react/cypress/fixtures/active-features.json rename to packages/reva-admin-react/cypress/fixtures/features/active-features.json index 328df005a..52f89351b 100644 --- a/packages/reva-admin-react/cypress/fixtures/active-features.json +++ b/packages/reva-admin-react/cypress/fixtures/features/active-features.json @@ -4,7 +4,8 @@ "DF_DISPLAY_LOCAL_ACCOUNTS_OF_CERTIFICATION_AUTHORITY", "AFFICHAGE_TYPES_FINANCEMENT_CANDIDATURE", "IMPERSONATE", - "AAP_CGU" + "AAP_CGU", + "AAP_SETTINGS_V3" ] } } diff --git a/packages/reva-admin-react/cypress/fixtures/visibility-check-admin.json b/packages/reva-admin-react/cypress/fixtures/visibility/admin.json similarity index 100% rename from packages/reva-admin-react/cypress/fixtures/visibility-check-admin.json rename to packages/reva-admin-react/cypress/fixtures/visibility/admin.json diff --git a/packages/reva-admin-react/cypress/fixtures/visibility/organism.json b/packages/reva-admin-react/cypress/fixtures/visibility/organism.json new file mode 100644 index 000000000..7c361fd7b --- /dev/null +++ b/packages/reva-admin-react/cypress/fixtures/visibility/organism.json @@ -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": [] + } + } + } +} \ No newline at end of file diff --git a/packages/reva-admin-react/cypress/support/commands.ts b/packages/reva-admin-react/cypress/support/commands.ts index 39a393df5..02134db3a 100644 --- a/packages/reva-admin-react/cypress/support/commands.ts +++ b/packages/reva-admin-react/cypress/support/commands.ts @@ -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, { diff --git a/packages/reva-admin-react/src/app/(aap)/agencies-settings-v3/page.tsx b/packages/reva-admin-react/src/app/(aap)/agencies-settings-v3/page.tsx index da71fd54d..f46225769 100644 --- a/packages/reva-admin-react/src/app/(aap)/agencies-settings-v3/page.tsx +++ b/packages/reva-admin-react/src/app/(aap)/agencies-settings-v3/page.tsx @@ -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 diff --git a/packages/reva-admin-react/src/app/(aap)/agencies-settings/layout.tsx b/packages/reva-admin-react/src/app/(aap)/agencies-settings/layout.tsx index 605e1eca8..00d53b982 100644 --- a/packages/reva-admin-react/src/app/(aap)/agencies-settings/layout.tsx +++ b/packages/reva-admin-react/src/app/(aap)/agencies-settings/layout.tsx @@ -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 {