richie-education 2.25.0-b2.dev91 → 2.25.0-b2.dev92
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.
|
@@ -900,7 +900,7 @@ describe.each([
|
|
|
900
900
|
});
|
|
901
901
|
});
|
|
902
902
|
|
|
903
|
-
it('should show an error if
|
|
903
|
+
it('should show an error if user does not accept the terms', async () => {
|
|
904
904
|
const product: Joanie.Product = ProductFactory().one();
|
|
905
905
|
const billingAddress: Joanie.Address = AddressFactory().one();
|
|
906
906
|
|
|
@@ -945,7 +945,7 @@ describe.each([
|
|
|
945
945
|
expect(screen.getByText('You must accept the terms.')).toBeInTheDocument();
|
|
946
946
|
});
|
|
947
947
|
|
|
948
|
-
it('should
|
|
948
|
+
it('should show a link to the platform terms and conditions', async () => {
|
|
949
949
|
const product: Joanie.Product = ProductFactory().one();
|
|
950
950
|
const billingAddress: Joanie.Address = AddressFactory().one();
|
|
951
951
|
|
|
@@ -977,66 +977,6 @@ describe.each([
|
|
|
977
977
|
expect($terms).toHaveAttribute('href', '/en/about/terms-and-conditions/');
|
|
978
978
|
});
|
|
979
979
|
|
|
980
|
-
it('should not show terms checkbox if the product does not have a contract definition', async () => {
|
|
981
|
-
const product: Joanie.Product = ProductFactory().one();
|
|
982
|
-
product.contract_definition = undefined;
|
|
983
|
-
const billingAddress: Joanie.Address = AddressFactory().one();
|
|
984
|
-
|
|
985
|
-
const { payment_info: paymentInfo, ...order } = OrderWithPaymentFactory().one();
|
|
986
|
-
|
|
987
|
-
const fetchOrderQueryParams =
|
|
988
|
-
product.type === ProductType.CREDENTIAL
|
|
989
|
-
? {
|
|
990
|
-
course_code: TEST_COURSE_CODE,
|
|
991
|
-
product_id: product.id,
|
|
992
|
-
state: ['pending', 'validated', 'submitted'],
|
|
993
|
-
}
|
|
994
|
-
: {
|
|
995
|
-
enrollment_id: TEST_ENROLLMENT_ID,
|
|
996
|
-
product_id: product.id,
|
|
997
|
-
state: ['pending', 'validated', 'submitted'],
|
|
998
|
-
};
|
|
999
|
-
|
|
1000
|
-
fetchMock
|
|
1001
|
-
.get(
|
|
1002
|
-
`https://joanie.test/api/v1.0/orders/?${queryString.stringify(fetchOrderQueryParams)}`,
|
|
1003
|
-
[],
|
|
1004
|
-
)
|
|
1005
|
-
.post('https://joanie.test/api/v1.0/orders/', order)
|
|
1006
|
-
.patch(`https://joanie.test/api/v1.0/orders/${order.id}/submit/`, {
|
|
1007
|
-
paymentInfo,
|
|
1008
|
-
});
|
|
1009
|
-
|
|
1010
|
-
render(
|
|
1011
|
-
<Wrapper client={createTestQueryClient({ user: true })} product={product}>
|
|
1012
|
-
<PaymentButton billingAddress={billingAddress} onSuccess={noop} />
|
|
1013
|
-
</Wrapper>,
|
|
1014
|
-
);
|
|
1015
|
-
|
|
1016
|
-
const $button = screen.getByRole('button', {
|
|
1017
|
-
name: `Pay ${formatPrice(product.price, product.price_currency)}`,
|
|
1018
|
-
}) as HTMLButtonElement;
|
|
1019
|
-
|
|
1020
|
-
// - As all information are provided, payment button should not be disabled.
|
|
1021
|
-
expect($button.disabled).toBe(false);
|
|
1022
|
-
|
|
1023
|
-
// - The terms checbkox is not rendered.
|
|
1024
|
-
expect(
|
|
1025
|
-
screen.queryByLabelText('By checking this box, you accept the General Terms of Sale'),
|
|
1026
|
-
).not.toBeInTheDocument();
|
|
1027
|
-
|
|
1028
|
-
// - User clicks on pay button
|
|
1029
|
-
await act(async () => {
|
|
1030
|
-
fireEvent.click($button);
|
|
1031
|
-
});
|
|
1032
|
-
|
|
1033
|
-
// - No errors.
|
|
1034
|
-
expect(screen.queryByText('You must accept the terms.')).not.toBeInTheDocument();
|
|
1035
|
-
|
|
1036
|
-
// - Payment interface should be displayed.
|
|
1037
|
-
screen.getByText('Payment interface component');
|
|
1038
|
-
});
|
|
1039
|
-
|
|
1040
980
|
if (productType === ProductType.CREDENTIAL) {
|
|
1041
981
|
it('should create an order with an order group', async () => {
|
|
1042
982
|
const product: Joanie.Product = ProductFactory().one();
|
|
@@ -114,12 +114,7 @@ const PaymentButton = ({ billingAddress, creditCard, onSuccess }: PaymentButtonP
|
|
|
114
114
|
});
|
|
115
115
|
|
|
116
116
|
const isReadyToPay = useMemo(() => {
|
|
117
|
-
return (
|
|
118
|
-
(course || enrollment) &&
|
|
119
|
-
product &&
|
|
120
|
-
billingAddress &&
|
|
121
|
-
(termsAccepted || !product.contract_definition)
|
|
122
|
-
);
|
|
117
|
+
return (course || enrollment) && product && billingAddress && termsAccepted;
|
|
123
118
|
}, [product, course, enrollment, billingAddress, termsAccepted]);
|
|
124
119
|
|
|
125
120
|
/**
|
|
@@ -201,10 +196,12 @@ const PaymentButton = ({ billingAddress, creditCard, onSuccess }: PaymentButtonP
|
|
|
201
196
|
? {
|
|
202
197
|
product_id: product.id,
|
|
203
198
|
enrollment_id: enrollment!.id,
|
|
199
|
+
has_consent_to_terms: termsAccepted,
|
|
204
200
|
}
|
|
205
201
|
: {
|
|
206
202
|
product_id: product.id,
|
|
207
203
|
course_code: course!.code,
|
|
204
|
+
has_consent_to_terms: termsAccepted,
|
|
208
205
|
...(orderGroup ? { order_group_id: orderGroup.id } : {}),
|
|
209
206
|
};
|
|
210
207
|
|
|
@@ -284,7 +281,7 @@ const PaymentButton = ({ billingAddress, creditCard, onSuccess }: PaymentButtonP
|
|
|
284
281
|
|
|
285
282
|
return (
|
|
286
283
|
<div className="payment-button" data-testid={order && 'payment-button-order-loaded'}>
|
|
287
|
-
{
|
|
284
|
+
{renderTermsCheckbox()}
|
|
288
285
|
<Button
|
|
289
286
|
disabled={state === ComponentStates.LOADING}
|
|
290
287
|
onClick={createOrder}
|
package/js/types/Joanie.ts
CHANGED
|
@@ -376,6 +376,7 @@ export interface AddressCreationPayload extends Omit<Address, 'id' | 'is_main'>
|
|
|
376
376
|
interface AbstractOrderProductCreationPayload {
|
|
377
377
|
product_id: Product['id'];
|
|
378
378
|
order_group_id?: OrderGroup['id'];
|
|
379
|
+
has_consent_to_terms: boolean;
|
|
379
380
|
}
|
|
380
381
|
|
|
381
382
|
interface OrderCertificateCreationPayload extends AbstractOrderProductCreationPayload {
|