Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat/pn 13918: remove old version of payment data #1464

Merged
merged 26 commits into from
Feb 13, 2025
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
b350f2a
feat(PN-13918): remove useless component for payment method
SarahDonvito Feb 6, 2025
e920d0e
feat(PN-13918): turn flag is_payment_enabled to true
SarahDonvito Feb 7, 2025
ccc02e1
Merge branch 'feat/test-payments' of github.com:pagopa/pn-frontend in…
SarahDonvito Feb 7, 2025
b8e11f8
feat(PN-13918): fix tests
SarahDonvito Feb 10, 2025
69567d2
feat(PN-13918): remove comments
SarahDonvito Feb 10, 2025
b9e5593
feat(PN-13918): restore payment step
SarahDonvito Feb 11, 2025
ee016fc
feat(PN-13918): remove useless comment and import
SarahDonvito Feb 11, 2025
b6b8ceb
feat(PN-13918): restore is_payment_enable to false
SarahDonvito Feb 11, 2025
bd36ca1
feat(PN-13918): restore newNotification page
SarahDonvito Feb 11, 2025
66a8225
feat(PN-13918): remove useless console.log
SarahDonvito Feb 11, 2025
1b3f53c
feat(PN-13918): restore newNotification
SarahDonvito Feb 11, 2025
22c49cf
removed useless configuration
AndreaCimini90 Feb 11, 2025
0bf4b70
feat(PN-13918): restore commented code
SarahDonvito Feb 11, 2025
4bf83d8
Merge branch 'feat/PN-13918' of github.com:pagopa/pn-frontend into fe…
SarahDonvito Feb 11, 2025
90c8298
feat(PN-13918): remove payment box in recipient component
SarahDonvito Feb 11, 2025
51e6040
feat(PN-13918): remove only in test
SarahDonvito Feb 11, 2025
eb8d112
feat(PN-13918): remove useless mock
SarahDonvito Feb 11, 2025
7003334
feat(PN-13918): remove paymentMode and creditorTaxId
SarahDonvito Feb 12, 2025
a592b54
feat(PN-13918): cr
SarahDonvito Feb 12, 2025
9c3646d
feat(PN-13918): remove useless mock
SarahDonvito Feb 12, 2025
4a8a6f6
feat(PN-13918): fix recipient tests
SarahDonvito Feb 12, 2025
0a23325
feat(PN-13918): fix PreliminaryInformations test
SarahDonvito Feb 12, 2025
33bd412
feat(PN-13918): remove useless mock
SarahDonvito Feb 12, 2025
cadf4a3
fix(PN-13918): fix test
SarahDonvito Feb 12, 2025
9c5e4ac
fixed tests
AndreaCimini90 Feb 13, 2025
41d716f
restored check in tests
AndreaCimini90 Feb 13, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion packages/pn-data-viz/src/setupTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ beforeAll(() => {
SELFCARE_URL_FE_LOGIN: 'https://test.selfcare.pagopa.it/auth/login',
SELFCARE_BASE_URL: 'https://test.selfcare.pagopa.it',
SELFCARE_SEND_PROD_ID: 'prod-pn-test',
IS_PAYMENT_ENABLED: false,
MIXPANEL_TOKEN: 'DUMMY',
IS_MANUAL_SEND_ENABLED: true,
});
Expand Down
20 changes: 20 additions & 0 deletions packages/pn-pa-webapp/src/__mocks__/NewNotification.mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,26 @@ export const newNotification: NewNotification = {
additionalAbstract: '',
};

export const newNotificationWithoutPayment: NewNotification = {
abstract: '',
paProtocolNumber: '12345678910',
subject: 'Multone esagerato',
recipients: newNotificationRecipients,
documents: newNotificationDocuments,
payment: {},
physicalCommunicationType: PhysicalCommunicationType.REGISTERED_LETTER_890,
paymentMode: PaymentModel.NOTHING,
group: newNotificationGroups[2].id,
taxonomyCode: '010801N',
notificationFeePolicy: NotificationFeePolicy.FLAT_RATE,
senderDenomination: userResponse.organization.name,
senderTaxId: userResponse.organization.fiscal_code,
lang: 'it',
additionalLang: '',
additionalSubject: '',
additionalAbstract: '',
};

export const newNotificationEmpty: NewNotification = {
paProtocolNumber: '',
subject: '',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -286,9 +286,9 @@ const PaymentMethods: React.FC<Props> = ({
dispatch(setPaymentDocuments({ paymentDocuments: formatPaymentDocuments() }));
},
}));

return (
<form onSubmit={formik.handleSubmit}>
<form onSubmit={formik.handleSubmit} data-testid="paymentMethodForm">
<NewNotificationCard
noPaper
isContinueDisabled={!formik.isValid}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import { LangCode } from '@pagopa/mui-italia';
import {
NewNotification,
NewNotificationLangOther,
PaymentModel,
} from '../../models/NewNotification';
import { GroupStatus } from '../../models/user';
import { useAppDispatch, useAppSelector } from '../../redux/hooks';
Expand Down Expand Up @@ -87,7 +86,6 @@ const PreliminaryInformations = ({ notification, onConfirm }: Props) => {
group: notification.group ?? '',
taxonomyCode: notification.taxonomyCode || '',
physicalCommunicationType: notification.physicalCommunicationType || '',
paymentMode: notification.paymentMode || (IS_PAYMENT_ENABLED ? '' : PaymentModel.NOTHING),
lang: notification.lang || (additionalLang ? NewNotificationLangOther : 'it'),
additionalLang: notification.additionalLang || additionalLang || '',
additionalSubject: notification.additionalSubject || '',
Expand All @@ -111,7 +109,6 @@ const PreliminaryInformations = ({ notification, onConfirm }: Props) => {
.max(1024, tc('too-long-field-error', { maxLength: 1024 }))
.matches(dataRegex.noSpaceAtEdges, tc('no-spaces-at-edges')),
physicalCommunicationType: yup.string().required(),
paymentMode: yup.string().required(),
group: hasGroups ? yup.string().required() : yup.string(),
taxonomyCode: yup
.string()
Expand Down Expand Up @@ -312,41 +309,6 @@ const PreliminaryInformations = ({ notification, onConfirm }: Props) => {
))}
</CustomDropdown>
</FormBox>

{IS_PAYMENT_ENABLED && (
<FormControl margin="normal" fullWidth>
<FormLabel id="payment-method-label">
<Typography fontWeight={600} fontSize={'16px'}>
{`${t('payment-method')}*`}
</Typography>
</FormLabel>
<RadioGroup
aria-labelledby="payment-method-label"
name="paymentMode"
value={formik.values.paymentMode}
onChange={handleChange}
>
<FormControlLabel
value={PaymentModel.PAGO_PA_NOTICE}
control={<Radio />}
label={t('pagopa-notice')}
data-testid="paymentMethodRadio"
/>
<FormControlLabel
value={PaymentModel.F24}
control={<Radio />}
label={t('f24')}
data-testid="paymentMethodRadio"
/>
<FormControlLabel
value={PaymentModel.NOTHING}
control={<Radio />}
label={t('nothing')}
data-testid="paymentMethodRadio"
/>
</RadioGroup>
</FormControl>
)}
</NewNotificationCard>
</form>
</ApiErrorWrapper>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ import PhysicalAddress from './PhysicalAddress';
const singleRecipient = {
recipientType: RecipientType.PF,
taxId: '',
creditorTaxId: '',
noticeCode: '',
firstName: '',
lastName: '',
type: DigitalDomicileType.PEC,
Expand Down Expand Up @@ -89,8 +87,7 @@ const Recipient: React.FC<Props> = ({
}
: { recipients: [{ ...singleRecipient, idx: 0, id: 'recipient.0' }] };

const buildRecipientValidationObject = () => {
const validationObject = {
const buildRecipientValidationObject = () => ({
recipientType: yup.string(),
// validazione sulla denominazione (firstName + " " + lastName per PF, firstName per PG)
// la lunghezza non può superare i 80 caratteri
Expand Down Expand Up @@ -160,24 +157,7 @@ const Recipient: React.FC<Props> = ({
municipality: requiredStringFieldValidation(tc, 256),
province: requiredStringFieldValidation(tc, 256),
foreignState: requiredStringFieldValidation(tc),
};

if (paymentMode !== PaymentModel.NOTHING) {
return {
...validationObject,
creditorTaxId: yup
.string()
.required(tc('required-field'))
.matches(dataRegex.pIva, t('fiscal-code-error')),
noticeCode: yup
.string()
.matches(dataRegex.noticeCode, t('notice-code-error'))
.required(tc('required-field')),
};
}

return validationObject;
};
});

const validationSchema = yup.object({
recipients: yup
Expand Down Expand Up @@ -464,33 +444,6 @@ const Recipient: React.FC<Props> = ({
/>
</Grid>
</Grid>

{paymentMode !== PaymentModel.NOTHING && (
<Grid container columnSpacing={1} rowSpacing={2} marginTop={4}>
<Grid item xs={12} lg={6}>
<FormTextField
keyName={`recipients[${index}].creditorTaxId`}
label={`${t('creditor-fiscal-code')}*`}
values={values}
touched={touched}
errors={errors}
setFieldValue={setFieldValue}
handleBlur={handleBlur}
/>
</Grid>
<Grid item xs={12} lg={6}>
<FormTextField
keyName={`recipients[${index}].noticeCode`}
label={`${t('notice-code')}*`}
values={values}
touched={touched}
errors={errors}
setFieldValue={setFieldValue}
handleBlur={handleBlur}
/>
</Grid>
</Grid>
)}
</FormBox>
{values.recipients.length < 5 && values.recipients.length - 1 === index && (
<Stack mt={2} direction="row" justifyContent="space-between">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ vi.mock('../../../services/configuration.service', async () => {

const populateForm = async (
form: HTMLFormElement,
hasPayment: boolean,
organizationName: string = userResponse.organization.name
) => {
await testInput(form, 'paProtocolNumber', newNotification.paProtocolNumber);
Expand All @@ -84,10 +83,6 @@ const populateForm = async (
1,
true
);

if (hasPayment) {
await testRadio(form, 'paymentMethodRadio', ['pagopa-notice', 'f24', 'nothing'], 1, true);
}
};

describe('PreliminaryInformations component with payment enabled', async () => {
Expand Down Expand Up @@ -142,7 +137,6 @@ describe('PreliminaryInformations component with payment enabled', async () => {
testFormElements(form, 'taxonomyCode', 'taxonomy-id*');
testFormElements(form, 'senderDenomination', 'sender-name*');
testRadio(form, 'comunicationTypeRadio', ['registered-letter-890', 'simple-registered-letter']);
testRadio(form, 'paymentMethodRadio', ['pagopa-notice', 'f24', 'nothing']);
const button = within(form).getByTestId('step-submit');
expect(button).toBeDisabled();
});
Expand Down Expand Up @@ -195,7 +189,7 @@ describe('PreliminaryInformations component with payment enabled', async () => {
const form = result.getByTestId('preliminaryInformationsForm') as HTMLFormElement;
const button = within(form).getByTestId('step-submit');
expect(button).toBeDisabled();
await populateForm(form, true);
await populateForm(form);
expect(button).toBeEnabled();
fireEvent.click(button);
await waitFor(() => {
Expand All @@ -211,15 +205,15 @@ describe('PreliminaryInformations component with payment enabled', async () => {
documents: [],
recipients: [],
physicalCommunicationType: PhysicalCommunicationType.AR_REGISTERED_LETTER,
paymentMode: PaymentModel.F24,
paymentMode: PaymentModel.NOTHING,
senderDenomination: newNotification.senderDenomination,
lang: 'it',
additionalAbstract: '',
additionalLang: '',
additionalSubject: '',
});
});
expect(confirmHandlerMk).toBeCalledTimes(1);
expect(confirmHandlerMk).toHaveBeenCalledTimes(1);
});

it('fills form with invalid values', async () => {
Expand All @@ -242,7 +236,7 @@ describe('PreliminaryInformations component with payment enabled', async () => {
);
});
const form = result.getByTestId('preliminaryInformationsForm') as HTMLFormElement;
await populateForm(form, true);
await populateForm(form);
// set invalid values
// paProtocolNumber
await testInput(form, 'paProtocolNumber', '');
Expand Down Expand Up @@ -321,10 +315,6 @@ describe('PreliminaryInformations component with payment enabled', async () => {
`input[name="physicalCommunicationType"][value="${newNotification.physicalCommunicationType}"]`
);
expect(physicalCommunicationType).toBeChecked();
const paymentMode = form.querySelector(
`input[name="paymentMode"][value="${newNotification.paymentMode}"]`
);
expect(paymentMode).toBeChecked();
});

it('errors on api call', async () => {
Expand Down Expand Up @@ -397,8 +387,6 @@ describe('PreliminaryInformations Component with payment disabled', async () =>
});
expect(result.container).toHaveTextContent(/title/i);
const form = result.getByTestId('preliminaryInformationsForm') as HTMLFormElement;
const paymentMethodRadio = within(form).queryAllByTestId('paymentMethodRadio');
expect(paymentMethodRadio).toHaveLength(0);
const button = within(form).getByTestId('step-submit');
expect(button).toBeDisabled();
});
Expand All @@ -425,7 +413,7 @@ describe('PreliminaryInformations Component with payment disabled', async () =>
const form = result.getByTestId('preliminaryInformationsForm') as HTMLFormElement;
const button = within(form).getByTestId('step-submit');
expect(button).toBeDisabled();
await populateForm(form, false);
await populateForm(form);
expect(button).toBeEnabled();
fireEvent.click(button);
await waitFor(() => {
Expand All @@ -449,7 +437,7 @@ describe('PreliminaryInformations Component with payment disabled', async () =>
additionalSubject: '',
});
});
expect(confirmHandlerMk).toBeCalledTimes(1);
expect(confirmHandlerMk).toHaveBeenCalledTimes(1);
});

it('set senderDenomination longer than 80 characters', async () => {
Expand Down
Loading