Skip to content

Commit

Permalink
Release UAT (#711)
Browse files Browse the repository at this point in the history
Co-authored-by: OraldoDoci <[email protected]>
  • Loading branch information
loremedda and OraldoDoci authored Apr 8, 2024
1 parent 7ce0b56 commit fb28546
Show file tree
Hide file tree
Showing 6 changed files with 328 additions and 27 deletions.
9 changes: 3 additions & 6 deletions src/components/DashboardHeader.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
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';
import { resolvePathVariables } from '@pagopa/selfcare-common-frontend/utils/routes-utils';
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';
Expand All @@ -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 & {
Expand Down Expand Up @@ -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,
})
);
Expand Down
2 changes: 1 addition & 1 deletion src/model/Party.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export type Party = {
urlLogo?: string;
fiscalCode?: string;
registeredOffice: string;
zipCode: string;
zipCode?: string;
typology: string;
institutionType?: string;
recipientCode?: string;
Expand Down
12 changes: 1 addition & 11 deletions src/pages/dashboard/Dashboard.tsx
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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 ? (
<Grid
container
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,73 @@ import { mockedParties } from '../../../../../services/__mocks__/partyService';
import { renderWithProviders } from '../../../../../utils/test-utils';
import PartyDetail from '../components/PartyDetail';

test('geotaxonomies should not be visible for AS', () => {
test('Test: Insurance company party cannot see the geotaxonomies', () => {
const mockedInsuranceCompany = mockedParties[18];

renderWithProviders(<PartyDetail party={mockedInsuranceCompany} />);

expect(screen.queryByText('Area geografica')).not.toBeInTheDocument();
});

test('Test: Party with taxCode and zipCode and without vatNumber', () => {
renderWithProviders(<PartyDetail party={mockedParties[22]} />);

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(<PartyDetail party={mockedParties[23]} />);

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(<PartyDetail party={mockedParties[24]} />);

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(<PartyDetail party={mockedParties[25]} />);

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(<PartyDetail party={mockedParties[26]} />);

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(<PartyDetail party={mockedParties[27]} />);

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(<PartyDetail party={mockedParties[13]} />);

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');
});
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,8 @@ export default function PartyDetail({ party }: Props) {
</Grid>
</>
) : undefined}
{(isInstitutionTypePA && !isTaxCodeEquals2Piva) || !isInstitutionTypePA ? (
{(isInstitutionTypePA && !isTaxCodeEquals2Piva && party.fiscalCode) ||
!isInstitutionTypePA ? (
<>
{/* fiscalCode */}
<Grid item xs={2}>
Expand Down Expand Up @@ -376,7 +377,7 @@ export default function PartyDetail({ party }: Props) {
)}

{/* fiscalCode */}
{isInstitutionTypePA && isTaxCodeEquals2Piva && (
{isInstitutionTypePA && isTaxCodeEquals2Piva && party.fiscalCode && (
<>
<Grid item xs={2}>
<Typography variant="body2" sx={{ ...labelStyles }}>
Expand Down Expand Up @@ -407,7 +408,7 @@ export default function PartyDetail({ party }: Props) {
)}
<>
{/* vatNumber */}
{!isTaxCodeEquals2Piva && (
{!isTaxCodeEquals2Piva && lastPartyVatNumber && (
<>
<Grid item xs={2}>
<Typography variant="body2" sx={{ ...labelStyles }}>
Expand Down Expand Up @@ -472,7 +473,9 @@ export default function PartyDetail({ party }: Props) {
arrow={true}
>
<Typography sx={{ ...infoStyles, maxWidth: '100% !important' }} className="ShowDots">
{party.registeredOffice + ' - ' + party.zipCode}
{party.zipCode
? party.registeredOffice + ' - ' + party.zipCode
: party.registeredOffice}
</Typography>
</Tooltip>
</Grid>
Expand Down
Loading

0 comments on commit fb28546

Please sign in to comment.