richie-education 3.3.2-dev32 → 3.3.2-dev34
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -143,7 +143,7 @@ const messages = defineMessages({
|
|
|
143
143
|
id: 'components.SaleTunnel.Information.cpf.description',
|
|
144
144
|
description: 'Explanatory text for the CPF payment option',
|
|
145
145
|
defaultMessage:
|
|
146
|
-
'
|
|
146
|
+
'Purchase your training course by using your Personal Training Account (CPF) on Mon Compte Formation.',
|
|
147
147
|
},
|
|
148
148
|
cpfButtonLabel: {
|
|
149
149
|
id: 'components.SaleTunnel.Information.cpf.buttonLabel',
|
|
@@ -236,7 +236,12 @@ export const SaleTunnelInformationSingular = () => {
|
|
|
236
236
|
</div>
|
|
237
237
|
)}
|
|
238
238
|
{paymentMode === PaymentMode.CPF ? (
|
|
239
|
-
<CpfPayment
|
|
239
|
+
<CpfPayment
|
|
240
|
+
deepLink={deepLink!}
|
|
241
|
+
discount={discount}
|
|
242
|
+
voucherError={voucherError}
|
|
243
|
+
setVoucherError={setVoucherError}
|
|
244
|
+
/>
|
|
240
245
|
) : (
|
|
241
246
|
<>
|
|
242
247
|
{needsPayment && (
|
|
@@ -499,7 +504,17 @@ const PaymentScheduleBlock = ({ schedule }: { schedule: PaymentSchedule }) => {
|
|
|
499
504
|
);
|
|
500
505
|
};
|
|
501
506
|
|
|
502
|
-
const CpfPayment = ({
|
|
507
|
+
const CpfPayment = ({
|
|
508
|
+
deepLink,
|
|
509
|
+
discount,
|
|
510
|
+
voucherError,
|
|
511
|
+
setVoucherError,
|
|
512
|
+
}: {
|
|
513
|
+
deepLink: string;
|
|
514
|
+
discount?: string;
|
|
515
|
+
voucherError: HttpError | null;
|
|
516
|
+
setVoucherError: (value: HttpError | null) => void;
|
|
517
|
+
}) => {
|
|
503
518
|
return (
|
|
504
519
|
<div className="sale-tunnel__cpf">
|
|
505
520
|
<p className="description mb-s">
|
|
@@ -514,6 +529,7 @@ const CpfPayment = ({ deepLink }: { deepLink: string }) => {
|
|
|
514
529
|
>
|
|
515
530
|
<FormattedMessage {...messages.cpfButtonLabel} />
|
|
516
531
|
</Button>
|
|
532
|
+
<Voucher discount={discount} voucherError={voucherError} setVoucherError={setVoucherError} />
|
|
517
533
|
</div>
|
|
518
534
|
);
|
|
519
535
|
};
|
|
@@ -110,9 +110,6 @@ const SubscriptionButton = ({ buildOrderPayload }: Props) => {
|
|
|
110
110
|
paymentMode,
|
|
111
111
|
} = useSaleTunnelContext();
|
|
112
112
|
|
|
113
|
-
if (paymentMode === PaymentMode.CPF) {
|
|
114
|
-
return null;
|
|
115
|
-
}
|
|
116
113
|
const { methods: orderMethods } = useOrders(undefined, { enabled: false });
|
|
117
114
|
const { methods: batchOrderMethods } = useBatchOrder();
|
|
118
115
|
const [state, setState] = useState<ComponentStates>(ComponentStates.IDLE);
|
|
@@ -138,12 +135,17 @@ const SubscriptionButton = ({ buildOrderPayload }: Props) => {
|
|
|
138
135
|
return;
|
|
139
136
|
}
|
|
140
137
|
|
|
141
|
-
if (!billingAddress && needsPayment) {
|
|
138
|
+
if (!billingAddress && needsPayment && paymentMode !== PaymentMode.CPF) {
|
|
142
139
|
handleError(SubscriptionErrorMessageId.ERROR_ADDRESS);
|
|
143
140
|
return;
|
|
144
141
|
}
|
|
145
142
|
|
|
146
|
-
if (
|
|
143
|
+
if (
|
|
144
|
+
!saleTunnelProps.isWithdrawable &&
|
|
145
|
+
!hasWaivedWithdrawalRight &&
|
|
146
|
+
needsPayment &&
|
|
147
|
+
paymentMode !== PaymentMode.CPF
|
|
148
|
+
) {
|
|
147
149
|
handleError(SubscriptionErrorMessageId.ERROR_WITHDRAWAL_RIGHT);
|
|
148
150
|
return;
|
|
149
151
|
}
|
|
@@ -166,7 +166,9 @@ describe('SaleTunnel / Credential', () => {
|
|
|
166
166
|
|
|
167
167
|
// - CPF description and redirect button should be visible.
|
|
168
168
|
expect(
|
|
169
|
-
screen.getByText(
|
|
169
|
+
screen.getByText(
|
|
170
|
+
/purchase your training course by using your Personal Training Account \(CPF\) on Mon Compte Formation/i,
|
|
171
|
+
),
|
|
170
172
|
).toBeInTheDocument();
|
|
171
173
|
const cpfButton = screen.getByRole('link', { name: /go to mon compte formation/i });
|
|
172
174
|
|
|
@@ -222,4 +224,51 @@ describe('SaleTunnel / Credential', () => {
|
|
|
222
224
|
// - Classic billing information section should be displayed.
|
|
223
225
|
expect(screen.getByText(/this information will be used for billing/i)).toBeInTheDocument();
|
|
224
226
|
});
|
|
227
|
+
|
|
228
|
+
it('should display voucher input and subscribe button in CPF mode', async () => {
|
|
229
|
+
const course = PacedCourseFactory().one();
|
|
230
|
+
const product = CredentialProductFactory().one();
|
|
231
|
+
const billingAddress: Joanie.Address = AddressFactory({ is_main: true }).one();
|
|
232
|
+
const deepLink = 'https://placeholder.com/course/1';
|
|
233
|
+
const orderQueryParameters = {
|
|
234
|
+
course_code: course.code,
|
|
235
|
+
product_id: product.id,
|
|
236
|
+
state: NOT_CANCELED_ORDER_STATES,
|
|
237
|
+
};
|
|
238
|
+
|
|
239
|
+
fetchMock
|
|
240
|
+
.get(
|
|
241
|
+
`https://joanie.endpoint/api/v1.0/orders/?${queryString.stringify(orderQueryParameters)}`,
|
|
242
|
+
[],
|
|
243
|
+
)
|
|
244
|
+
.get(
|
|
245
|
+
`https://joanie.endpoint/api/v1.0/courses/${course.code}/products/${product.id}/payment-plan/`,
|
|
246
|
+
[],
|
|
247
|
+
)
|
|
248
|
+
.get(
|
|
249
|
+
`https://joanie.endpoint/api/v1.0/courses/${course.code}/products/${product.id}/deep-link/`,
|
|
250
|
+
{ deep_link: deepLink },
|
|
251
|
+
)
|
|
252
|
+
.get('https://joanie.endpoint/api/v1.0/addresses/', [billingAddress], {
|
|
253
|
+
overwriteRoutes: true,
|
|
254
|
+
});
|
|
255
|
+
|
|
256
|
+
const user = userEvent.setup({ delay: null });
|
|
257
|
+
|
|
258
|
+
render(<Wrapper product={product} course={course} />, {
|
|
259
|
+
queryOptions: { client: createTestQueryClient({ user: richieUser }) },
|
|
260
|
+
});
|
|
261
|
+
|
|
262
|
+
await screen.findByRole('heading', { level: 3, name: /payment method/i });
|
|
263
|
+
|
|
264
|
+
// Switch to CPF mode
|
|
265
|
+
await user.click(screen.getByRole('radio', { name: /my training account \(cpf\)/i }));
|
|
266
|
+
|
|
267
|
+
// - Voucher input should be visible in CPF mode.
|
|
268
|
+
expect(screen.getByLabelText('Voucher code')).toBeInTheDocument();
|
|
269
|
+
expect(screen.getByRole('button', { name: 'Validate' })).toBeInTheDocument();
|
|
270
|
+
|
|
271
|
+
// - Subscribe button should be visible in CPF mode.
|
|
272
|
+
expect(screen.getByRole('button', { name: 'Subscribe' })).toBeInTheDocument();
|
|
273
|
+
});
|
|
225
274
|
});
|