richie-education 2.25.0-b2.dev118 → 2.25.0-b2.dev120
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.
|
@@ -367,10 +367,13 @@ describe.each([
|
|
|
367
367
|
// - Route to create order should have been called
|
|
368
368
|
nbApiCalls += 1; // order post create (invalidate queries)
|
|
369
369
|
nbApiCalls += 1; // useProductOrder call (invalidate from create)
|
|
370
|
-
nbApiCalls += 1; // order submit
|
|
370
|
+
nbApiCalls += 1; // order submit (invalidate queries)
|
|
371
|
+
nbApiCalls += 1; // useProductOrder call (invalidate from submit)
|
|
371
372
|
|
|
372
373
|
await waitFor(() => expect(fetchMock.calls()).toHaveLength(nbApiCalls));
|
|
373
|
-
expect(fetchMock.lastUrl()).toBe(
|
|
374
|
+
expect(fetchMock.lastUrl()).toBe(
|
|
375
|
+
`https://joanie.test/api/v1.0/orders/?${queryString.stringify(fetchOrderQueryParams)}`,
|
|
376
|
+
);
|
|
374
377
|
|
|
375
378
|
// - Spinner should be displayed
|
|
376
379
|
screen.getByText('Payment in progress');
|
|
@@ -482,10 +485,13 @@ describe.each([
|
|
|
482
485
|
// - Route to create order should have been called
|
|
483
486
|
nbApiCalls += 1; // order post create (invalidate queries)
|
|
484
487
|
nbApiCalls += 1; // useProductOrder call (invalidate from create)
|
|
485
|
-
nbApiCalls += 1; // order submit
|
|
488
|
+
nbApiCalls += 1; // order submit (invalidate queries)
|
|
489
|
+
nbApiCalls += 1; // useProductOrder call (invalidate from submit)
|
|
486
490
|
|
|
487
491
|
await waitFor(() => expect(fetchMock.calls()).toHaveLength(nbApiCalls));
|
|
488
|
-
expect(fetchMock.lastUrl()).toBe(
|
|
492
|
+
expect(fetchMock.lastUrl()).toBe(
|
|
493
|
+
`https://joanie.test/api/v1.0/orders/?${queryString.stringify(fetchOrderQueryParams)}`,
|
|
494
|
+
);
|
|
489
495
|
|
|
490
496
|
// - Spinner should be displayed
|
|
491
497
|
screen.getByText('Payment in progress');
|
|
@@ -534,9 +540,13 @@ describe.each([
|
|
|
534
540
|
screen.getByText('Payment interface component');
|
|
535
541
|
|
|
536
542
|
// - Now we make sure the order is not created again and just submitted.
|
|
537
|
-
nbApiCalls += 1; //
|
|
543
|
+
nbApiCalls += 1; // order submit (invalidate queries)
|
|
544
|
+
nbApiCalls += 1; // useProductOrder call (invalidate from submit)
|
|
545
|
+
|
|
538
546
|
await waitFor(() => expect(fetchMock.calls()).toHaveLength(nbApiCalls));
|
|
539
|
-
expect(fetchMock.lastUrl()).toBe(
|
|
547
|
+
expect(fetchMock.lastUrl()).toBe(
|
|
548
|
+
`https://joanie.test/api/v1.0/orders/?${queryString.stringify(fetchOrderQueryParams)}`,
|
|
549
|
+
);
|
|
540
550
|
});
|
|
541
551
|
|
|
542
552
|
it('should render a payment button and not call the order creation route', async () => {
|
|
@@ -627,6 +637,7 @@ describe.each([
|
|
|
627
637
|
// - Route to submit an existing order
|
|
628
638
|
// - Furthermore, as payment succeeded immediately, order should have been refetched
|
|
629
639
|
nbApiCalls += 1; // order submit
|
|
640
|
+
nbApiCalls += 1; // useProductOrder call (invalidate from submit)
|
|
630
641
|
nbApiCalls += 1; // order get on id
|
|
631
642
|
expect(fetchMock.calls()).toHaveLength(nbApiCalls);
|
|
632
643
|
|
|
@@ -758,6 +769,7 @@ describe.each([
|
|
|
758
769
|
// - Furthermore, as payment succeeded immediately, order should have been refetched
|
|
759
770
|
const onClickApiCalls = fetchMock.calls().splice(nbApiCalls);
|
|
760
771
|
nbApiCalls += 1; // order submit
|
|
772
|
+
nbApiCalls += 1; // refetch order (submit invalidate)
|
|
761
773
|
nbApiCalls += 1; // fetch validated order
|
|
762
774
|
expect(fetchMock.calls()).toHaveLength(nbApiCalls);
|
|
763
775
|
|
|
@@ -766,8 +778,10 @@ describe.each([
|
|
|
766
778
|
billing_address: ObjectHelper.omit(billingAddress, 'id', 'is_main'),
|
|
767
779
|
credit_card_id: creditCard.id,
|
|
768
780
|
});
|
|
769
|
-
|
|
770
|
-
|
|
781
|
+
expect(onClickApiCalls[1][0]).toBe(
|
|
782
|
+
`https://joanie.test/api/v1.0/orders/?${queryString.stringify(fetchOrderQueryParams)}`,
|
|
783
|
+
);
|
|
784
|
+
expect(onClickApiCalls[2][0]).toBe(`https://joanie.test/api/v1.0/orders/${order.id}/`);
|
|
771
785
|
|
|
772
786
|
// - Spinner should be displayed
|
|
773
787
|
screen.getByText('Payment in progress');
|
|
@@ -869,12 +883,12 @@ describe.each([
|
|
|
869
883
|
nbApiCalls += 1; // order post create (invalidate queries)
|
|
870
884
|
nbApiCalls += 1; // refetch useProductOrder
|
|
871
885
|
nbApiCalls += 1; // order submit
|
|
886
|
+
nbApiCalls += 1; // refetch useProductOrder
|
|
872
887
|
expect(fetchMock.calls()).toHaveLength(nbApiCalls);
|
|
873
888
|
|
|
874
|
-
expect(fetchMock.lastUrl()).toBe(
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
});
|
|
889
|
+
expect(fetchMock.lastUrl()).toBe(
|
|
890
|
+
`https://joanie.test/api/v1.0/orders/?${queryString.stringify(fetchOrderQueryParams)}`,
|
|
891
|
+
);
|
|
878
892
|
|
|
879
893
|
// - Spinner should be displayed and payment button should be disabled
|
|
880
894
|
screen.getByText('Payment in progress');
|
|
@@ -141,6 +141,7 @@ const SaleTunnel = ({
|
|
|
141
141
|
return {
|
|
142
142
|
product: product as CredentialProduct,
|
|
143
143
|
order,
|
|
144
|
+
orderGroup,
|
|
144
145
|
key,
|
|
145
146
|
course: course!,
|
|
146
147
|
enrollment: undefined,
|
|
@@ -149,6 +150,7 @@ const SaleTunnel = ({
|
|
|
149
150
|
return {
|
|
150
151
|
product: product as CertificateProduct,
|
|
151
152
|
order,
|
|
153
|
+
orderGroup,
|
|
152
154
|
key,
|
|
153
155
|
course: undefined,
|
|
154
156
|
enrollment: enrollment!,
|
|
@@ -156,18 +158,6 @@ const SaleTunnel = ({
|
|
|
156
158
|
}
|
|
157
159
|
}, [product, order]);
|
|
158
160
|
|
|
159
|
-
useMemo(
|
|
160
|
-
() => ({
|
|
161
|
-
product,
|
|
162
|
-
order,
|
|
163
|
-
key,
|
|
164
|
-
course,
|
|
165
|
-
enrollment,
|
|
166
|
-
orderGroup,
|
|
167
|
-
}),
|
|
168
|
-
[product, order, key, course, enrollment, orderGroup],
|
|
169
|
-
);
|
|
170
|
-
|
|
171
161
|
/**
|
|
172
162
|
* correctly handle keyboard/screen reader users navigation on step change.
|
|
173
163
|
* Without this, since elements are removed from the DOM from step to step,
|
package/js/hooks/useOrders.ts
CHANGED
|
@@ -79,7 +79,12 @@ const useOrdersBase =
|
|
|
79
79
|
custom.methods.invalidate();
|
|
80
80
|
},
|
|
81
81
|
});
|
|
82
|
-
const submitHandler = useSessionMutation({
|
|
82
|
+
const submitHandler = useSessionMutation({
|
|
83
|
+
mutationFn: useJoanieApi().user.orders.submit,
|
|
84
|
+
onSuccess: () => {
|
|
85
|
+
custom.methods.invalidate();
|
|
86
|
+
},
|
|
87
|
+
});
|
|
83
88
|
return {
|
|
84
89
|
...custom,
|
|
85
90
|
methods: {
|