From fb2854695d17e202460819c7c648a423af35a5dd Mon Sep 17 00:00:00 2001 From: loremedda <98110186+loremedda@users.noreply.github.com> Date: Mon, 8 Apr 2024 11:17:19 +0200 Subject: [PATCH] Release UAT (#711) Co-authored-by: OraldoDoci <117348307+OraldoDoci@users.noreply.github.com> --- src/components/DashboardHeader.tsx | 9 +- src/model/Party.tsx | 2 +- src/pages/dashboard/Dashboard.tsx | 12 +- .../partyCard/__tests__/PartyDetail.test.tsx | 65 ++++- .../partyCard/components/PartyDetail.tsx | 11 +- src/services/__mocks__/partyService.ts | 256 +++++++++++++++++- 6 files changed, 328 insertions(+), 27 deletions(-) diff --git a/src/components/DashboardHeader.tsx b/src/components/DashboardHeader.tsx index 2dc94983..07706613 100644 --- a/src/components/DashboardHeader.tsx +++ b/src/components/DashboardHeader.tsx @@ -1,5 +1,6 @@ import { PartySwitchItem } from '@pagopa/mui-italia/dist/components/PartySwitch'; import { Header } from '@pagopa/selfcare-common-frontend'; +import i18n from '@pagopa/selfcare-common-frontend/locale/locale-utils'; import { User } from '@pagopa/selfcare-common-frontend/model/User'; import { trackEvent } from '@pagopa/selfcare-common-frontend/services/analyticsService'; import { roleLabels } from '@pagopa/selfcare-common-frontend/utils/constants'; @@ -7,7 +8,6 @@ import { resolvePathVariables } from '@pagopa/selfcare-common-frontend/utils/rou import { useEffect, useMemo, useRef, useState } from 'react'; import { Trans, useTranslation } from 'react-i18next'; import { useHistory } from 'react-router-dom'; -import i18n from '@pagopa/selfcare-common-frontend/locale/locale-utils'; import withParties, { WithPartiesProps } from '../decorators/withParties'; import { useTokenExchange } from '../hooks/useTokenExchange'; import { Party } from '../model/Party'; @@ -16,7 +16,7 @@ import GenericEnvProductModal from '../pages/dashboardOverview/components/active import SessionModalInteropProduct from '../pages/dashboardOverview/components/activeProductsSection/components/SessionModalInteropProduct'; import { useAppSelector } from '../redux/hooks'; import { partiesSelectors } from '../redux/slices/partiesSlice'; -import ROUTES, { DASHBOARD_ROUTES } from '../routes'; +import ROUTES from '../routes'; import { ENV } from './../utils/env'; type Props = WithPartiesProps & { @@ -166,11 +166,8 @@ const DashboardHeader = ({ onExit, loggedUser, parties }: Props) => { party_id: selectedParty.id, }); onExit(() => { - const redirectRoute = party?.delegation - ? DASHBOARD_ROUTES.TECHPARTNER.path - : ROUTES.PARTY_DASHBOARD.path; history.push( - resolvePathVariables(redirectRoute, { + resolvePathVariables(ROUTES.PARTY_DASHBOARD.path, { partyId: selectedParty.id, }) ); diff --git a/src/model/Party.tsx b/src/model/Party.tsx index 1324a02e..96c74fef 100644 --- a/src/model/Party.tsx +++ b/src/model/Party.tsx @@ -20,7 +20,7 @@ export type Party = { urlLogo?: string; fiscalCode?: string; registeredOffice: string; - zipCode: string; + zipCode?: string; typology: string; institutionType?: string; recipientCode?: string; diff --git a/src/pages/dashboard/Dashboard.tsx b/src/pages/dashboard/Dashboard.tsx index 8e7a7159..35995254 100644 --- a/src/pages/dashboard/Dashboard.tsx +++ b/src/pages/dashboard/Dashboard.tsx @@ -1,10 +1,9 @@ import { Box, Grid, useTheme } from '@mui/material'; -import { useEffect, useMemo } from 'react'; +import { useMemo } from 'react'; import { useTranslation } from 'react-i18next'; import { useStore } from 'react-redux'; import { Route, Switch, matchPath, useHistory } from 'react-router'; import { useLocation } from 'react-router-dom'; -import { resolvePathVariables } from '@pagopa/selfcare-common-frontend/utils/routes-utils'; import withProductRolesMap from '../../decorators/withProductsRolesMap'; import withSelectedParty from '../../decorators/withSelectedParty'; import withSelectedProduct from '../../decorators/withSelectedPartyProduct'; @@ -139,15 +138,6 @@ const Dashboard = () => { strict: false, }); - useEffect(() => { - if (party) { - const redirectPath = party.delegation - ? DASHBOARD_ROUTES.TECHPARTNER.path - : DASHBOARD_ROUTES.OVERVIEW.path; - history.push(resolvePathVariables(redirectPath, { partyId: party?.partyId ?? '' })); - } - }, [party?.partyId]); - return party && products ? ( { +test('Test: Insurance company party cannot see the geotaxonomies', () => { const mockedInsuranceCompany = mockedParties[18]; renderWithProviders(); expect(screen.queryByText('Area geografica')).not.toBeInTheDocument(); }); + +test('Test: Party with taxCode and zipCode and without vatNumber', () => { + renderWithProviders(); + + expect(screen.queryByText('Partita IVA')).not.toBeInTheDocument(); + expect(screen.queryByText('Codice Fiscale')).not.toBeInTheDocument(); + expect(screen.queryByText('Codice Fiscale / P.IVA')).not.toBeInTheDocument(); + expect(mockedParties[22].registeredOffice).toBe('Via Roma, 10'); +}); + +test('Test: Party with vatNumber and without fiscalCode and zipCode', () => { + renderWithProviders(); + + expect(screen.queryByText('Partita IVA')).toBeInTheDocument(); + expect(screen.queryByText('Codice Fiscale')).not.toBeInTheDocument(); + expect(screen.queryByText('Codice Fiscale / P.IVA')).not.toBeInTheDocument(); + expect(mockedParties[23].registeredOffice).toBe('Via Garibaldi, 10'); +}); + +test('Test: Party with fiscalCode and without vatNumber and zipCode', () => { + renderWithProviders(); + + expect(screen.queryByText('Partita IVA')).not.toBeInTheDocument(); + expect(screen.queryByText('Codice Fiscale')).toBeInTheDocument(); + expect(screen.queryByText('Codice Fiscale / P.IVA')).not.toBeInTheDocument(); + expect(mockedParties[24].registeredOffice).toBe('Corso Vittorio Emanuele, 1'); +}); + +test('Test: Party with zipCode and without fiscalCode and vatNumber', () => { + renderWithProviders(); + + expect(screen.queryByText('Partita IVA')).not.toBeInTheDocument(); + expect(screen.queryByText('Codice Fiscale')).not.toBeInTheDocument(); + expect(screen.queryByText('Codice Fiscale / P.IVA')).not.toBeInTheDocument(); + expect(mockedParties[25].zipCode).toBe('38100'); +}); + +test('Test: Party with different vatNumber and fiscalCode without zipCode', () => { + renderWithProviders(); + + expect(screen.queryByText('Partita IVA')).toBeInTheDocument(); + expect(screen.queryByText('Codice Fiscale')).toBeInTheDocument(); + expect(screen.queryByText('Codice Fiscale / P.IVA')).not.toBeInTheDocument(); + expect(mockedParties[26].registeredOffice).toBe('Via Etnea, 100'); +}); + +test('Test: Party with zipCode and different fiscalCode and vatNumber', () => { + renderWithProviders(); + + expect(screen.queryByText('Partita IVA')).toBeInTheDocument(); + expect(screen.queryByText('Codice Fiscale')).toBeInTheDocument(); + expect(screen.queryByText('Codice Fiscale / P.IVA')).not.toBeInTheDocument(); + expect(mockedParties[27].zipCode).toBe('74100'); +}); + +test('Test: Party with zipCode and equal fiscalCode and vatNumber', () => { + renderWithProviders(); + + expect(screen.queryByText('Partita IVA')).not.toBeInTheDocument(); + expect(screen.queryByText('Codice Fiscale')).not.toBeInTheDocument(); + expect(screen.queryByText('Codice Fiscale / P.IVA')).toBeInTheDocument(); + expect(mockedParties[13].zipCode).toBe('20121'); +}); diff --git a/src/pages/dashboardOverview/components/partyCard/components/PartyDetail.tsx b/src/pages/dashboardOverview/components/partyCard/components/PartyDetail.tsx index 32d3f8d9..6694ae28 100644 --- a/src/pages/dashboardOverview/components/partyCard/components/PartyDetail.tsx +++ b/src/pages/dashboardOverview/components/partyCard/components/PartyDetail.tsx @@ -322,7 +322,8 @@ export default function PartyDetail({ party }: Props) { ) : undefined} - {(isInstitutionTypePA && !isTaxCodeEquals2Piva) || !isInstitutionTypePA ? ( + {(isInstitutionTypePA && !isTaxCodeEquals2Piva && party.fiscalCode) || + !isInstitutionTypePA ? ( <> {/* fiscalCode */} @@ -376,7 +377,7 @@ export default function PartyDetail({ party }: Props) { )} {/* fiscalCode */} - {isInstitutionTypePA && isTaxCodeEquals2Piva && ( + {isInstitutionTypePA && isTaxCodeEquals2Piva && party.fiscalCode && ( <> @@ -407,7 +408,7 @@ export default function PartyDetail({ party }: Props) { )} <> {/* vatNumber */} - {!isTaxCodeEquals2Piva && ( + {!isTaxCodeEquals2Piva && lastPartyVatNumber && ( <> @@ -472,7 +473,9 @@ export default function PartyDetail({ party }: Props) { arrow={true} > - {party.registeredOffice + ' - ' + party.zipCode} + {party.zipCode + ? party.registeredOffice + ' - ' + party.zipCode + : party.registeredOffice} diff --git a/src/services/__mocks__/partyService.ts b/src/services/__mocks__/partyService.ts index 51aaf24f..25e0eead 100644 --- a/src/services/__mocks__/partyService.ts +++ b/src/services/__mocks__/partyService.ts @@ -112,6 +112,42 @@ export const mockedBaseParties: Array = [ status: 'ACTIVE', userRole: 'ADMIN', }, + { + partyId: '46', + description: 'Comune di Alberobello', + status: 'ACTIVE', + userRole: 'ADMIN', + }, + { + partyId: '47', + description: 'Comune di Novara', + status: 'ACTIVE', + userRole: 'ADMIN', + }, + { + partyId: '48', + description: 'Comune di Salerno', + status: 'ACTIVE', + userRole: 'ADMIN', + }, + { + partyId: '49', + description: 'Comune di Trento', + status: 'ACTIVE', + userRole: 'ADMIN', + }, + { + partyId: '50', + description: 'Comune di Catania', + status: 'ACTIVE', + userRole: 'ADMIN', + }, + { + partyId: '51', + description: 'Comune di Taranto', + status: 'ACTIVE', + userRole: 'ADMIN', + }, { partyId: '5dbec5e1-4262-4d00-a493-916e6171856a', description: 'Asea Azienda Speciale', @@ -155,7 +191,6 @@ export const mockedParties: Array = [ institutionType: 'PA', recipientCode: 'CGDAS23A', geographicTaxonomies: undefined, - vatNumber: '111111111141', supportEmail: '', products: [ { @@ -816,7 +851,7 @@ export const mockedParties: Array = [ { code: '456723', desc: 'Carugate - Comune' }, { code: '665543', desc: 'Cernusco sul Naviglio - Comune' }, ], // Use case with three taxonomy - vatNumber: '34434356575', + vatNumber: '76859430212', supportEmail: '', products: [ // Use case with two delegable products @@ -826,7 +861,7 @@ export const mockedParties: Array = [ productOnBoardingStatus: ProductOnBoardingStatusEnum.ACTIVE, userRole: 'ADMIN', billing: { - vatNumber: '81001510528', + vatNumber: '76859430212', recipientCode: 'BBGG34D', publicServices: true, }, @@ -861,7 +896,7 @@ export const mockedParties: Array = [ productOnBoardingStatus: ProductOnBoardingStatusEnum.REJECTED, userRole: 'ADMIN', billing: { - vatNumber: '81001510528', + vatNumber: '76859430212', recipientCode: 'DDFFRT', publicServices: true, }, @@ -1260,6 +1295,219 @@ export const mockedParties: Array = [ }, ], }, + // Use case without vatNumber, taxCode and zipCode + { + description: 'Comune di Alberobello', + urlLogo: 'image', + partyId: '46', + digitalAddress: 'comune.Alberobello@pec.it', + category: 'Comuni e loro Consorzi e Associazioni', + registeredOffice: 'Via Roma, 10', + typology: 'Pubblica Amministrazione', + externalId: 'externalId4', + originId: 'originId4', + origin: 'IPA', + institutionType: 'PA', + recipientCode: 'PTSCMA44D', + geographicTaxonomies: [{ code: '5454732', desc: 'Alberobello - Comune' }], + supportEmail: 'support@comune.Alberobello.it', + products: [ + { + productId: 'prod-pagopa', + authorized: true, + productOnBoardingStatus: ProductOnBoardingStatusEnum.PENDING, + userRole: 'ADMIN', + billing: { + recipientCode: 'POIUYTRE', + publicServices: true, + }, + }, + { + productId: 'prod-pn', + authorized: true, + productOnBoardingStatus: ProductOnBoardingStatusEnum.ACTIVE, + userRole: 'ADMIN', + billing: { + recipientCode: 'pppp', + publicServices: true, + }, + }, + ], + delegation: false, + status: undefined, + userRole: undefined, + }, + // Use case with vatNumber and without fiscalCode and zipCode + { + description: 'Comune di Novara', + urlLogo: 'image', + partyId: '47', + digitalAddress: 'comune.novara@pec.it', + category: 'Comuni e loro Consorzi e Associazioni', + registeredOffice: 'Via Garibaldi, 10', + typology: 'Pubblica Amministrazione', + externalId: 'extId47', + originId: 'originId47', + origin: 'IPA', + institutionType: 'PA', + recipientCode: 'NOVCMA47Z', + geographicTaxonomies: [{ code: '4545554', desc: 'Novara - Comune' }], + vatNumber: '12345678901', + supportEmail: 'support@comune.novara.it', + products: [ + { + productId: 'prod-pagopa', + authorized: true, + productOnBoardingStatus: ProductOnBoardingStatusEnum.ACTIVE, + userRole: 'ADMIN', + billing: { + vatNumber: '98765432101', + recipientCode: 'NOVCMA47Z', + publicServices: true, + }, + }, + ], + delegation: false, + status: undefined, + userRole: undefined, + }, + // Use case with fiscalCode and without vatNumber and zipCode + { + description: 'Comune di Salerno', + urlLogo: 'image', + partyId: '48', + digitalAddress: 'comune.salerno@pec.it', + category: 'Comuni e loro Consorzi e Associazioni', + registeredOffice: 'Corso Vittorio Emanuele, 1', + typology: 'Pubblica Amministrazione', + externalId: 'extId48', + originId: 'originId48', + origin: 'IPA', + institutionType: 'PA', + recipientCode: 'SLRNCM48Y', + geographicTaxonomies: [{ code: '863413', desc: 'Salerno - Comune' }], + fiscalCode: '98765432101', + supportEmail: 'support@comune.salerno.it', + products: [ + { + productId: 'prod-pagopa', + authorized: true, + productOnBoardingStatus: ProductOnBoardingStatusEnum.PENDING, + userRole: 'ADMIN', + billing: { + recipientCode: 'SLRNCM48Y', + publicServices: true, + }, + }, + ], + delegation: false, + status: undefined, + userRole: undefined, + }, + // Use case with zipCode and without fiscalCode and vatNumber + { + description: 'Comune di Trento', + urlLogo: 'image', + partyId: '49', + digitalAddress: 'comune.trento@pec.it', + category: 'Comuni e loro Consorzi e Associazioni', + registeredOffice: 'Piazza Duomo, 1', + typology: 'Pubblica Amministrazione', + externalId: 'extId49', + originId: 'originId49', + origin: 'IPA', + institutionType: 'PA', + recipientCode: 'TRNTCM49X', + geographicTaxonomies: [{ code: '9944123', desc: 'Trento - Comune' }], + zipCode: '38100', + supportEmail: 'support@comune.trento.it', + products: [ + { + productId: 'prod-pagopa', + authorized: true, + productOnBoardingStatus: ProductOnBoardingStatusEnum.PENDING, + userRole: 'ADMIN', + billing: { + recipientCode: 'TRNTCM49X', + publicServices: true, + }, + }, + ], + delegation: false, + status: undefined, + userRole: undefined, + }, + // Use case with different vatNumber and fiscalCode without zipCode + { + description: 'Comune di Catania', + urlLogo: 'image', + partyId: '50', + digitalAddress: 'comune.catania@pec.it', + category: 'Comuni e loro Consorzi e Associazioni', + registeredOffice: 'Via Etnea, 100', + typology: 'Pubblica Amministrazione', + externalId: 'extId50', + originId: 'originId50', + origin: 'IPA', + institutionType: 'PA', + recipientCode: 'CTNCMA50W', + geographicTaxonomies: [{ code: '441234', desc: 'Catania - Comune' }], + vatNumber: '11223344556', + fiscalCode: '65432109876', + supportEmail: 'support@comune.catania.it', + products: [ + { + productId: 'prod-pagopa', + authorized: true, + productOnBoardingStatus: ProductOnBoardingStatusEnum.ACTIVE, + userRole: 'ADMIN', + billing: { + vatNumber: '11223344556', + recipientCode: 'CTNCMA50W', + publicServices: true, + }, + }, + ], + delegation: false, + status: undefined, + userRole: undefined, + }, + // Use case with all data + { + description: 'Comune di Taranto', + urlLogo: 'image', + partyId: '51', + digitalAddress: 'comune.taranto@pec.it', + category: 'Comuni e loro Consorzi e Associazioni', + registeredOffice: 'Via Garibaldi, 10', + typology: 'Pubblica Amministrazione', + externalId: 'extId51', + originId: 'originId51', + origin: 'IPA', + institutionType: 'PA', + recipientCode: 'TRNTMA51T', + geographicTaxonomies: [{ code: '4400001', desc: 'Taranto - Comune' }], + vatNumber: '98765432109', + fiscalCode: '12345678901', + zipCode: '74100', + supportEmail: 'support@comune.taranto.it', + products: [ + { + productId: 'prod-pagopa', + authorized: true, + productOnBoardingStatus: ProductOnBoardingStatusEnum.ACTIVE, + userRole: 'ADMIN', + billing: { + vatNumber: '98765432109', + recipientCode: 'TRNTMA51T', + publicServices: true, + }, + }, + ], + delegation: false, + status: 'ACTIVE', + userRole: 'ADMIN', + }, ]; export const mockedGeotaxonomies: Array = [