From dd60436799645ec73ad684abcfb21bf0e8d39b84 Mon Sep 17 00:00:00 2001 From: OraldoDoci <117348307+OraldoDoci@users.noreply.github.com> Date: Tue, 29 Oct 2024 15:31:55 +0100 Subject: [PATCH] SELC-5823 add check if delegation is present in getInstituions list --- .../TechPartnersTable.tsx | 10 ++++--- .../__tests__/DashboardTablePT.test.tsx | 26 ++++++++++++++++--- src/services/__mocks__/partyService.ts | 4 +-- 3 files changed, 32 insertions(+), 8 deletions(-) diff --git a/src/pages/dashboardTechnologyPartnerPage/TechPartnersTable.tsx b/src/pages/dashboardTechnologyPartnerPage/TechPartnersTable.tsx index 3593f4e4..e804ef67 100644 --- a/src/pages/dashboardTechnologyPartnerPage/TechPartnersTable.tsx +++ b/src/pages/dashboardTechnologyPartnerPage/TechPartnersTable.tsx @@ -50,6 +50,8 @@ export default function TechPartnersTable({ delegationsWithoutDuplicates }: Read const [currentPage, setCurrentPage] = useState(1); const [totalPages, setTotalPages] = useState(Math.ceil(tableData.length / itemsPerPage)); const products = useAppSelector(partiesSelectors.selectPartySelectedProducts); + const parties = useAppSelector(partiesSelectors.selectPartiesList); + const partyIdsSet = parties ? new Set(parties.map((party) => party.partyId)) : new Set(); useEffect(() => { setTotalPages(Math.ceil(tableData.length / itemsPerPage)); @@ -210,9 +212,7 @@ export default function TechPartnersTable({ delegationsWithoutDuplicates }: Read {getSortedData(tableData) .slice((currentPage - 1) * itemsPerPage, currentPage * itemsPerPage) .map((item, _index) => { - const isClickable = - (item.productId === 'prod-io' || item.productId === 'prod-pagopa') && - item.type === 'EA'; + const isClickable = item.type === 'EA' && partyIdsSet.has(item.institutionId); return ( <> @@ -223,6 +223,10 @@ export default function TechPartnersTable({ delegationsWithoutDuplicates }: Read { history.push( resolvePathVariables(ROUTES.PARTY_DASHBOARD.path, { diff --git a/src/pages/dashboardTechnologyPartnerPage/__tests__/DashboardTablePT.test.tsx b/src/pages/dashboardTechnologyPartnerPage/__tests__/DashboardTablePT.test.tsx index cdd3fda7..2aeb6cc4 100644 --- a/src/pages/dashboardTechnologyPartnerPage/__tests__/DashboardTablePT.test.tsx +++ b/src/pages/dashboardTechnologyPartnerPage/__tests__/DashboardTablePT.test.tsx @@ -13,15 +13,25 @@ import TechPartnersTable from '../TechPartnersTable'; const mockedDelegation: DelegationWithPagination = { delegations: [ { - brokerId: '123', + brokerId: '111', brokerName: 'Broker 1', - id: '456', - institutionId: '789', + id: '1', + institutionId: '1111', institutionName: 'Institution 1', institutionRootName: 'Root Institution', productId: '7890', type: TypeEnum.AOO, }, + { + brokerId: '222', + brokerName: 'Broker EA', + id: '2', + institutionId: 'institutionId0', + institutionName: 'Institution EA', + institutionRootName: 'Root Institution', + productId: '7890', + type: TypeEnum.EA, + }, ], pageInfo: { pageSize: 0, @@ -80,3 +90,13 @@ test('test input field change and filter on click and search by name', async () expect(removeFiltersButton).toBeEnabled(); fireEvent.click(removeFiltersButton); }); + +test('delegation of type EA should be clikable for same institution is present on instituionList', async () => { + renderDashboardTablePT(); + + const delegationOfTypeEA = await screen.findByText('Institution EA'); + + expect(delegationOfTypeEA).toBeInTheDocument(); + + fireEvent.click(delegationOfTypeEA); +}); diff --git a/src/services/__mocks__/partyService.ts b/src/services/__mocks__/partyService.ts index 9d8176e2..1e9fb3ba 100644 --- a/src/services/__mocks__/partyService.ts +++ b/src/services/__mocks__/partyService.ts @@ -42,7 +42,7 @@ export const mockedBaseParties: Array = [ userRole: 'ADMIN', }, { - partyId: '6', + partyId: 'institutionId0', description: 'Scuola Media Oswald Von Wolkenstein di Bressa', status: 'ACTIVE', userRole: 'ADMIN', @@ -601,7 +601,7 @@ export const mockedParties: Array = [ { description: 'Scuola Media Oswald Von Wolkenstein di Bressa', urlLogo: 'image', - partyId: '6', + partyId: 'institutionId0', digitalAddress: 'comune.bressanone@pec.it', fiscalCode: '111122211111', category: 'Comuni e loro Consorzi e Associazioni',