From 890c0ec30528c808b8dfd9fe0d37b242ffc07fea Mon Sep 17 00:00:00 2001
From: Benjamin Bohec <bbohec.pro@gmail.com>
Date: Thu, 9 Jan 2025 14:45:52 +0100
Subject: [PATCH] front AgencyDtoWithoutEmails replaced by
 AgencyDtoForAgencyUsersAndAdmins

---
 .../agency/IcUserAgenciesToReview.tsx         | 120 +++++++++---------
 .../user-profile/AgenciesTablesSection.tsx    |   9 +-
 .../AdminGateway/SimulatedAdminGateway.ts     |  54 +++++---
 .../AgencyGateway/SimulatedAgencyGateway.ts   |  10 +-
 .../domain/admin/fetchUser/fetchUser.test.ts  |   5 +-
 .../admin/icUsersAdmin/icUsersAdmin.test.ts   |  13 +-
 .../createUserOnAgency.test.ts                |   3 +-
 .../agencies/fetch-agency/fetchAgency.test.ts |  16 ++-
 .../updateUserOnAgency.test.ts                |   3 +-
 .../inclusionConnected.test.ts                |  21 ++-
 10 files changed, 144 insertions(+), 110 deletions(-)

diff --git a/front/src/app/components/agency/IcUserAgenciesToReview.tsx b/front/src/app/components/agency/IcUserAgenciesToReview.tsx
index 03695ee234..3d1134484e 100644
--- a/front/src/app/components/agency/IcUserAgenciesToReview.tsx
+++ b/front/src/app/components/agency/IcUserAgenciesToReview.tsx
@@ -8,7 +8,7 @@ import { createPortal } from "react-dom";
 import { SubmitHandler, useForm } from "react-hook-form";
 import { useDispatch } from "react-redux";
 import {
-  AgencyDtoWithoutEmails,
+  AgencyDtoForAgencyUsersAndAdmins,
   AgencyId,
   AgencyRight,
   RejectIcUserRoleForAgencyParams,
@@ -32,77 +32,75 @@ type IcUserAgenciesToReviewModalProps = {
   mode: "register" | "reject";
 };
 
-function AgencyReviewForm({
+const AgencyReviewForm = ({
   agency,
   setSelectedAgency,
   selectedUser,
   setModalProps,
 }: {
-  agency: AgencyDtoWithoutEmails;
+  agency: AgencyDtoForAgencyUsersAndAdmins;
   selectedUser: User;
-  setSelectedAgency: (agency: AgencyDtoWithoutEmails) => void;
+  setSelectedAgency: (agency: AgencyDtoForAgencyUsersAndAdmins) => void;
   setModalProps: (modalProps: IcUserAgenciesToReviewModalProps) => void;
-}) {
-  return (
-    <div className={fr.cx("fr-col-4")}>
-      <div className={fr.cx("fr-card")}>
-        <div className={fr.cx("fr-card__body")}>
-          <div className={fr.cx("fr-card__content")}>
-            <h3 className={fr.cx("fr-card__title")}>{agency.name}</h3>
-            <p className={fr.cx("fr-card__desc")}>
-              {agency.address.streetNumberAndAddress} {agency.address.postcode}{" "}
-              {agency.address.city}
-            </p>
-            <p className={fr.cx("fr-card__desc")}>
-              <a
-                {...routes.adminAgencyDetail({ agencyId: agency.id }).link}
-                target="_blank"
-              >
-                Voir les détails de l'agence
-              </a>
-            </p>
-          </div>
-          <div className={fr.cx("fr-card__footer")}>
-            <ButtonsGroup
-              alignment="center"
-              inlineLayoutWhen="always"
-              buttonsSize="small"
-              buttons={[
-                {
-                  type: "button",
-                  priority: "primary",
-                  id: `${domElementIds.admin.agencyTab.registerIcUserToAgencyButton}-${agency.id}-${selectedUser.id}`,
-                  onClick: () => {
-                    setModalProps({
-                      title: "Rattacher cet utilisateur",
-                      mode: "register",
-                    });
-                    setSelectedAgency(agency);
-                    openIcUserRegistrationToAgencyModal();
-                  },
-                  children: "Valider",
+}) => (
+  <div className={fr.cx("fr-col-4")}>
+    <div className={fr.cx("fr-card")}>
+      <div className={fr.cx("fr-card__body")}>
+        <div className={fr.cx("fr-card__content")}>
+          <h3 className={fr.cx("fr-card__title")}>{agency.name}</h3>
+          <p className={fr.cx("fr-card__desc")}>
+            {agency.address.streetNumberAndAddress} {agency.address.postcode}{" "}
+            {agency.address.city}
+          </p>
+          <p className={fr.cx("fr-card__desc")}>
+            <a
+              {...routes.adminAgencyDetail({ agencyId: agency.id }).link}
+              target="_blank"
+            >
+              Voir les détails de l'agence
+            </a>
+          </p>
+        </div>
+        <div className={fr.cx("fr-card__footer")}>
+          <ButtonsGroup
+            alignment="center"
+            inlineLayoutWhen="always"
+            buttonsSize="small"
+            buttons={[
+              {
+                type: "button",
+                priority: "primary",
+                id: `${domElementIds.admin.agencyTab.registerIcUserToAgencyButton}-${agency.id}-${selectedUser.id}`,
+                onClick: () => {
+                  setModalProps({
+                    title: "Rattacher cet utilisateur",
+                    mode: "register",
+                  });
+                  setSelectedAgency(agency);
+                  openIcUserRegistrationToAgencyModal();
                 },
-                {
-                  type: "button",
-                  priority: "secondary",
-                  onClick: () => {
-                    setModalProps({
-                      title: "Refuser le rattachement",
-                      mode: "reject",
-                    });
-                    setSelectedAgency(agency);
-                    openIcUserRegistrationToAgencyModal();
-                  },
-                  children: "Refuser",
+                children: "Valider",
+              },
+              {
+                type: "button",
+                priority: "secondary",
+                onClick: () => {
+                  setModalProps({
+                    title: "Refuser le rattachement",
+                    mode: "reject",
+                  });
+                  setSelectedAgency(agency);
+                  openIcUserRegistrationToAgencyModal();
                 },
-              ]}
-            />
-          </div>
+                children: "Refuser",
+              },
+            ]}
+          />
         </div>
       </div>
     </div>
-  );
-}
+  </div>
+);
 
 export const IcUserAgenciesToReview = ({
   agenciesNeedingReviewForUser,
@@ -110,7 +108,7 @@ export const IcUserAgenciesToReview = ({
 }: IcUserAgenciesToReviewProps) => {
   const dispatch = useDispatch();
   const [selectedAgency, setSelectedAgency] =
-    useState<AgencyDtoWithoutEmails>();
+    useState<AgencyDtoForAgencyUsersAndAdmins>();
   const [modalProps, setModalProps] =
     useState<IcUserAgenciesToReviewModalProps | null>(null);
 
diff --git a/front/src/app/components/user-profile/AgenciesTablesSection.tsx b/front/src/app/components/user-profile/AgenciesTablesSection.tsx
index 8998bb1473..aa04a03315 100644
--- a/front/src/app/components/user-profile/AgenciesTablesSection.tsx
+++ b/front/src/app/components/user-profile/AgenciesTablesSection.tsx
@@ -219,12 +219,9 @@ const makeAgencyAdminEmails = ({
   agencyRight,
 }: { agencyRight: AgencyRight }): ReactNode => (
   <ul className={fr.cx("fr-raw-list")}>
-    {
-      // missing admin emails on agencyRight
-      ["fake@email.com", "fake2@email2.com"].map((admin) => (
-        <li>{admin}</li>
-      ))
-    }
+    {agencyRight.agency.admins.map((admin) => (
+      <li>{admin}</li>
+    ))}
   </ul>
 );
 
diff --git a/front/src/core-logic/adapters/AdminGateway/SimulatedAdminGateway.ts b/front/src/core-logic/adapters/AdminGateway/SimulatedAdminGateway.ts
index db620d6312..9a8e371340 100644
--- a/front/src/core-logic/adapters/AdminGateway/SimulatedAdminGateway.ts
+++ b/front/src/core-logic/adapters/AdminGateway/SimulatedAdminGateway.ts
@@ -17,32 +17,42 @@ import {
   UserInList,
   UserParamsForAgency,
   WithAgencyIdAndUserId,
+  toAgencyDtoForAgencyUsersAndAdmins,
 } from "shared";
 import { AdminGateway } from "src/core-logic/ports/AdminGateway";
 
-const simulatedAgencyDtos: AgencyRight[] = [
+const simulatedAgencyRights: AgencyRight[] = [
   {
     roles: ["to-review"],
-    agency: new AgencyDtoBuilder()
-      .withName("Agence de Bourg en Bresse")
-      .withId("fake-agency-id-1")
-      .build(),
+    agency: toAgencyDtoForAgencyUsersAndAdmins(
+      new AgencyDtoBuilder()
+        .withName("Agence de Bourg en Bresse")
+        .withId("fake-agency-id-1")
+        .build(),
+      [],
+    ),
     isNotifiedByEmail: true,
   },
   {
     roles: ["validator"],
-    agency: new AgencyDtoBuilder()
-      .withName("Mission locale qu'on ne devrait pas voir")
-      .withId("fake-agency-id-not-shown")
-      .build(),
+    agency: toAgencyDtoForAgencyUsersAndAdmins(
+      new AgencyDtoBuilder()
+        .withName("Mission locale qu'on ne devrait pas voir")
+        .withId("fake-agency-id-not-shown")
+        .build(),
+      [],
+    ),
     isNotifiedByEmail: true,
   },
   {
     roles: ["to-review"],
-    agency: new AgencyDtoBuilder()
-      .withName("CCI de Quimper")
-      .withId("fake-agency-id-3")
-      .build(),
+    agency: toAgencyDtoForAgencyUsersAndAdmins(
+      new AgencyDtoBuilder()
+        .withName("CCI de Quimper")
+        .withId("fake-agency-id-3")
+        .build(),
+      [],
+    ),
     isNotifiedByEmail: true,
   },
 ];
@@ -114,7 +124,7 @@ export class SimulatedAdminGateway implements AdminGateway {
         email: "jbon8745@wanadoo.fr",
         firstName: "Jean",
         lastName: "Bon",
-        agencyRights: simulatedAgencyDtos,
+        agencyRights: simulatedAgencyRights,
         dashboards: { agencies: {}, establishments: {} },
         externalId: "fake-user-external-id-1",
         createdAt: new Date().toISOString(),
@@ -137,10 +147,13 @@ export class SimulatedAdminGateway implements AdminGateway {
         agencyRights: [
           {
             roles: ["to-review"],
-            agency: new AgencyDtoBuilder()
-              .withName("Mission locale qui plante")
-              .withId("non-existing-agency-id")
-              .build(),
+            agency: toAgencyDtoForAgencyUsersAndAdmins(
+              new AgencyDtoBuilder()
+                .withName("Mission locale qui plante")
+                .withId("non-existing-agency-id")
+                .build(),
+              [],
+            ),
             isNotifiedByEmail: true,
           },
         ],
@@ -216,7 +229,10 @@ export class SimulatedAdminGateway implements AdminGateway {
       ...icUser,
       agencyRights: [
         {
-          agency: new AgencyDtoBuilder().build(),
+          agency: toAgencyDtoForAgencyUsersAndAdmins(
+            new AgencyDtoBuilder().build(),
+            [],
+          ),
           roles: ["validator"],
           isNotifiedByEmail: true,
         },
diff --git a/front/src/core-logic/adapters/AgencyGateway/SimulatedAgencyGateway.ts b/front/src/core-logic/adapters/AgencyGateway/SimulatedAgencyGateway.ts
index 72f137bcb3..dd12459359 100644
--- a/front/src/core-logic/adapters/AgencyGateway/SimulatedAgencyGateway.ts
+++ b/front/src/core-logic/adapters/AgencyGateway/SimulatedAgencyGateway.ts
@@ -16,6 +16,7 @@ import {
   WithAgencyId,
   WithAgencyIdAndUserId,
   errors,
+  toAgencyDtoForAgencyUsersAndAdmins,
   toAgencyPublicDisplayDto,
 } from "shared";
 import { AgencyGateway } from "src/core-logic/ports/AgencyGateway";
@@ -83,12 +84,15 @@ const simulatedUsers: InclusionConnectedUser[] = [
     lastName: "Bon",
     agencyRights: [
       {
-        agency: MISSION_LOCAL_AGENCY_ACTIVE,
+        agency: toAgencyDtoForAgencyUsersAndAdmins(
+          MISSION_LOCAL_AGENCY_ACTIVE,
+          [],
+        ),
         isNotifiedByEmail: true,
         roles: ["agency-admin"],
       },
       {
-        agency: PE_AGENCY_ACTIVE,
+        agency: toAgencyDtoForAgencyUsersAndAdmins(PE_AGENCY_ACTIVE, []),
         isNotifiedByEmail: true,
         roles: ["validator"],
       },
@@ -114,7 +118,7 @@ const simulatedUsers: InclusionConnectedUser[] = [
     lastName: "Jeplante",
     agencyRights: [
       {
-        agency: PE_AGENCY_ACTIVE,
+        agency: toAgencyDtoForAgencyUsersAndAdmins(PE_AGENCY_ACTIVE, []),
         isNotifiedByEmail: true,
         roles: ["agency-admin"],
       },
diff --git a/front/src/core-logic/domain/admin/fetchUser/fetchUser.test.ts b/front/src/core-logic/domain/admin/fetchUser/fetchUser.test.ts
index 8aa50899bf..4c198d5ab4 100644
--- a/front/src/core-logic/domain/admin/fetchUser/fetchUser.test.ts
+++ b/front/src/core-logic/domain/admin/fetchUser/fetchUser.test.ts
@@ -4,6 +4,7 @@ import {
   InclusionConnectedUser,
   InclusionConnectedUserBuilder,
   expectToEqual,
+  toAgencyDtoForAgencyUsersAndAdmins,
 } from "shared";
 import { adminPreloadedState } from "src/core-logic/domain/admin/adminPreloadedState";
 import { adminFetchUserSelectors } from "src/core-logic/domain/admin/fetchUser/fetchUser.selectors";
@@ -49,7 +50,7 @@ describe("Admin Users slice", () => {
     it("if this other user is in the state, update this user rights successfully", () => {
       const agency = new AgencyDtoBuilder().build();
       const agencyRight: AgencyRight = {
-        agency,
+        agency: toAgencyDtoForAgencyUsersAndAdmins(agency, []),
         roles: ["validator"],
         isNotifiedByEmail: false,
       };
@@ -102,7 +103,7 @@ describe("Admin Users slice", () => {
     it("if it is not user in state, do nothing", () => {
       const agency = new AgencyDtoBuilder().build();
       const agencyRight: AgencyRight = {
-        agency,
+        agency: toAgencyDtoForAgencyUsersAndAdmins(agency, []),
         roles: ["validator"],
         isNotifiedByEmail: false,
       };
diff --git a/front/src/core-logic/domain/admin/icUsersAdmin/icUsersAdmin.test.ts b/front/src/core-logic/domain/admin/icUsersAdmin/icUsersAdmin.test.ts
index ed6bb7f121..5a95a4aed5 100644
--- a/front/src/core-logic/domain/admin/icUsersAdmin/icUsersAdmin.test.ts
+++ b/front/src/core-logic/domain/admin/icUsersAdmin/icUsersAdmin.test.ts
@@ -10,6 +10,7 @@ import {
   UserParamsForAgency,
   errors,
   expectToEqual,
+  toAgencyDtoForAgencyUsersAndAdmins,
 } from "shared";
 import { adminPreloadedState } from "src/core-logic/domain/admin/adminPreloadedState";
 import { icUsersAdminSelectors } from "src/core-logic/domain/admin/icUsersAdmin/icUsersAdmin.selectors";
@@ -36,12 +37,12 @@ const agency3 = new AgencyDtoBuilder().withId("agency-3").build();
 const agency4 = new AgencyDtoBuilder().withId("agency-4").build();
 
 const agency1Right: AgencyRight = {
-  agency: agency1,
+  agency: toAgencyDtoForAgencyUsersAndAdmins(agency1, []),
   roles: ["to-review"],
   isNotifiedByEmail: true,
 };
 const agency2Right: AgencyRight = {
-  agency: agency2,
+  agency: toAgencyDtoForAgencyUsersAndAdmins(agency2, []),
   roles: ["validator"],
   isNotifiedByEmail: true,
 };
@@ -51,12 +52,12 @@ const user1AgencyRights: Record<AgencyId, AgencyRight> = {
 };
 
 const agency3Right: AgencyRight = {
-  agency: agency3,
+  agency: toAgencyDtoForAgencyUsersAndAdmins(agency3, []),
   roles: ["to-review"],
   isNotifiedByEmail: true,
 };
 const agency4Right: AgencyRight = {
-  agency: agency4,
+  agency: toAgencyDtoForAgencyUsersAndAdmins(agency4, []),
   roles: ["to-review"],
   isNotifiedByEmail: true,
 };
@@ -597,7 +598,7 @@ describe("Agency registration for authenticated users", () => {
         ...userToCreate,
         agencyRights: [
           {
-            agency: agency2,
+            agency: toAgencyDtoForAgencyUsersAndAdmins(agency2, []),
             roles: ["validator"],
             isNotifiedByEmail: false,
           },
@@ -612,7 +613,7 @@ describe("Agency registration for authenticated users", () => {
           ...icUser,
           agencyRights: {
             [agency2.id]: {
-              agency: agency2,
+              agency: toAgencyDtoForAgencyUsersAndAdmins(agency2, []),
               roles: ["validator"],
               isNotifiedByEmail: false,
             },
diff --git a/front/src/core-logic/domain/agencies/create-user-on-agency/createUserOnAgency.test.ts b/front/src/core-logic/domain/agencies/create-user-on-agency/createUserOnAgency.test.ts
index 5b3055b2c3..4c5bdc58db 100644
--- a/front/src/core-logic/domain/agencies/create-user-on-agency/createUserOnAgency.test.ts
+++ b/front/src/core-logic/domain/agencies/create-user-on-agency/createUserOnAgency.test.ts
@@ -3,6 +3,7 @@ import {
   InclusionConnectedUser,
   errors,
   expectToEqual,
+  toAgencyDtoForAgencyUsersAndAdmins,
 } from "shared";
 import { NormalizedInclusionConnectedUser } from "src/core-logic/domain/admin/icUsersAdmin/icUsersAdmin.slice";
 import { agenciesPreloadedState } from "src/core-logic/domain/agencies/agenciesPreloadedState";
@@ -65,7 +66,7 @@ describe("CreateUserOnAgency", () => {
       ...userToCreate,
       agencyRights: [
         {
-          agency: agencyDto,
+          agency: toAgencyDtoForAgencyUsersAndAdmins(agencyDto, []),
           roles: ["validator"],
           isNotifiedByEmail: false,
         },
diff --git a/front/src/core-logic/domain/agencies/fetch-agency/fetchAgency.test.ts b/front/src/core-logic/domain/agencies/fetch-agency/fetchAgency.test.ts
index 8a2237c950..48274301dd 100644
--- a/front/src/core-logic/domain/agencies/fetch-agency/fetchAgency.test.ts
+++ b/front/src/core-logic/domain/agencies/fetch-agency/fetchAgency.test.ts
@@ -5,6 +5,7 @@ import {
   AgencyRight,
   InclusionConnectedUser,
   expectToEqual,
+  toAgencyDtoForAgencyUsersAndAdmins,
 } from "shared";
 import {
   NormalizedIcUserById,
@@ -30,6 +31,7 @@ import {
 import { ReduxStore } from "src/core-logic/storeConfig/store";
 
 const agencyDto = new AgencyDtoBuilder().build();
+const agencyWithAdminEmails = toAgencyDtoForAgencyUsersAndAdmins(agencyDto, []);
 
 const user1: NormalizedInclusionConnectedUser = {
   id: "fake-user-id-1",
@@ -38,7 +40,7 @@ const user1: NormalizedInclusionConnectedUser = {
   lastName: "Bon",
   agencyRights: {
     [agencyDto.id]: {
-      agency: agencyDto,
+      agency: agencyWithAdminEmails,
       isNotifiedByEmail: true,
       roles: ["agency-admin"],
     },
@@ -55,7 +57,7 @@ const user2: NormalizedInclusionConnectedUser = {
   lastName: "Jeplante",
   agencyRights: {
     [agencyDto.id]: {
-      agency: agencyDto,
+      agency: agencyWithAdminEmails,
       isNotifiedByEmail: true,
       roles: ["agency-admin"],
     },
@@ -301,7 +303,7 @@ describe("fetchAgency", () => {
         });
 
         const agencyRight: AgencyRight = {
-          agency: agencyDto,
+          agency: agencyWithAdminEmails,
           roles: ["validator"],
           isNotifiedByEmail: false,
         };
@@ -346,7 +348,7 @@ describe("fetchAgency", () => {
               ...icUser,
               agencyRights: {
                 [agencyDto.id]: {
-                  agency: agencyDto,
+                  agency: agencyWithAdminEmails,
                   roles: ["validator"],
                   isNotifiedByEmail: false,
                 },
@@ -365,7 +367,7 @@ describe("fetchAgency", () => {
         expectFetchAgencyStateToMatch(fetchAgencyInitialState);
 
         const agencyRight: AgencyRight = {
-          agency: agencyDto,
+          agency: agencyWithAdminEmails,
           roles: ["validator"],
           isNotifiedByEmail: false,
         };
@@ -571,8 +573,8 @@ describe("fetchAgency", () => {
     );
   };
 
-  const feedWithFetchedAgency = (agencyDto: AgencyDto) => {
-    dependencies.agencyGateway.fetchedAgency$.next(agencyDto);
+  const feedWithFetchedAgency = (agency: AgencyDto) => {
+    dependencies.agencyGateway.fetchedAgency$.next(agency);
   };
   const feedWithFetchedAgencyUsers = (agencyUsers: NormalizedIcUserById) => {
     dependencies.agencyGateway.fetchedAgencyUsers$.next(
diff --git a/front/src/core-logic/domain/agencies/update-user-on-agency/updateUserOnAgency.test.ts b/front/src/core-logic/domain/agencies/update-user-on-agency/updateUserOnAgency.test.ts
index 90f5a39c08..692bbc8885 100644
--- a/front/src/core-logic/domain/agencies/update-user-on-agency/updateUserOnAgency.test.ts
+++ b/front/src/core-logic/domain/agencies/update-user-on-agency/updateUserOnAgency.test.ts
@@ -5,6 +5,7 @@ import {
   InclusionConnectedUserBuilder,
   UserParamsForAgency,
   expectToEqual,
+  toAgencyDtoForAgencyUsersAndAdmins,
 } from "shared";
 import { adminPreloadedState } from "src/core-logic/domain/admin/adminPreloadedState";
 import { NormalizedInclusionConnectedUser } from "src/core-logic/domain/admin/icUsersAdmin/icUsersAdmin.slice";
@@ -26,7 +27,7 @@ describe("UpdateUserOnAgency slice", () => {
   const agency = new AgencyDtoBuilder().build();
 
   const agencyRight: AgencyRight = {
-    agency,
+    agency: toAgencyDtoForAgencyUsersAndAdmins(agency, []),
     roles: ["validator"],
     isNotifiedByEmail: false,
   };
diff --git a/front/src/core-logic/domain/inclusionConnected/inclusionConnected.test.ts b/front/src/core-logic/domain/inclusionConnected/inclusionConnected.test.ts
index 6f8b76089b..0d3ed67741 100644
--- a/front/src/core-logic/domain/inclusionConnected/inclusionConnected.test.ts
+++ b/front/src/core-logic/domain/inclusionConnected/inclusionConnected.test.ts
@@ -9,6 +9,7 @@ import {
   expectArraysToEqualIgnoringOrder,
   expectToEqual,
   inclusionConnectTokenExpiredMessage,
+  toAgencyDtoForAgencyUsersAndAdmins,
 } from "shared";
 import { updateUserOnAgencySelectors } from "src/core-logic/domain/agencies/update-user-on-agency/updateUserOnAgency.selectors";
 import { updateUserOnAgencySlice } from "src/core-logic/domain/agencies/update-user-on-agency/updateUserOnAgency.slice";
@@ -41,7 +42,10 @@ describe("InclusionConnected", () => {
     agencyRights: [
       {
         roles: ["agency-admin"],
-        agency: new AgencyDtoBuilder().build(),
+        agency: toAgencyDtoForAgencyUsersAndAdmins(
+          new AgencyDtoBuilder().build(),
+          [],
+        ),
         isNotifiedByEmail: true,
       },
     ],
@@ -294,7 +298,10 @@ describe("InclusionConnected", () => {
       agencyRights: [
         {
           roles: ["agency-admin", "validator"],
-          agency: new AgencyDtoBuilder().build(),
+          agency: toAgencyDtoForAgencyUsersAndAdmins(
+            new AgencyDtoBuilder().build(),
+            [],
+          ),
           isNotifiedByEmail: true,
         },
       ],
@@ -324,7 +331,10 @@ describe("InclusionConnected", () => {
     it("if it is himself, update the user rights successfully", () => {
       const agency = new AgencyDtoBuilder().build();
       const agencyRight: AgencyRight = {
-        agency,
+        agency: toAgencyDtoForAgencyUsersAndAdmins(
+          new AgencyDtoBuilder().build(),
+          [],
+        ),
         roles: ["validator"],
         isNotifiedByEmail: false,
       };
@@ -376,7 +386,10 @@ describe("InclusionConnected", () => {
     it("if it is not himself, do nothing", () => {
       const agency = new AgencyDtoBuilder().build();
       const agencyRight: AgencyRight = {
-        agency,
+        agency: toAgencyDtoForAgencyUsersAndAdmins(
+          new AgencyDtoBuilder().build(),
+          [],
+        ),
         roles: ["validator"],
         isNotifiedByEmail: false,
       };