@lookiero/checkout 7.0.0 → 7.0.1
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.
- package/dist/src/infrastructure/ui/routing/CheckoutMiddleware.js +5 -1
- package/dist/src/version.d.ts +1 -1
- package/dist/src/version.js +1 -1
- package/package.json +1 -1
- package/src/infrastructure/ui/routing/CheckoutMiddleware.test.tsx +10 -0
- package/src/infrastructure/ui/routing/CheckoutMiddleware.tsx +7 -1
|
@@ -78,9 +78,13 @@ const CheckoutMiddleware = ({ customerId, onNotAccessible, loader = React.create
|
|
|
78
78
|
}
|
|
79
79
|
}
|
|
80
80
|
}, [basePath, checkout?.status, checkout?.items]);
|
|
81
|
-
if (
|
|
81
|
+
if (checkout === undefined) {
|
|
82
82
|
return loader;
|
|
83
83
|
}
|
|
84
|
+
if (checkout === null) {
|
|
85
|
+
onNotAccessible();
|
|
86
|
+
return null;
|
|
87
|
+
}
|
|
84
88
|
/* Prevent direct payment access */
|
|
85
89
|
if (checkoutPaymentRouteMatch && !checkoutShown.current) {
|
|
86
90
|
onNotAccessible();
|
package/dist/src/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "7.0.
|
|
1
|
+
export declare const VERSION = "7.0.1";
|
package/dist/src/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const VERSION = "7.0.
|
|
1
|
+
export const VERSION = "7.0.1";
|
package/package.json
CHANGED
|
@@ -140,6 +140,16 @@ describe("CheckoutMiddleware component", () => {
|
|
|
140
140
|
expect(mockStartCheckout).toHaveBeenCalled();
|
|
141
141
|
});
|
|
142
142
|
|
|
143
|
+
it("should call onNotAccessible when no checkout is found", async () => {
|
|
144
|
+
(useViewFirstAvailableCheckoutByCustomerId as jest.Mock).mockReturnValue([null, QueryStatus.SUCCESS]);
|
|
145
|
+
(useStartCheckout as jest.Mock).mockReturnValue([mockStartCheckout, CommandStatus.SUCCESS]);
|
|
146
|
+
|
|
147
|
+
const onNotAccessible = jest.fn();
|
|
148
|
+
renderCheckoutMiddleware({ path: Routes.HOME, onNotAccessible });
|
|
149
|
+
|
|
150
|
+
expect(onNotAccessible).toHaveBeenCalled();
|
|
151
|
+
});
|
|
152
|
+
|
|
143
153
|
it("payment route should not be directly accessible", async () => {
|
|
144
154
|
const checkoutMock = checkout({ items: [{ status: CheckoutItemStatus.INITIAL }] });
|
|
145
155
|
(useViewFirstAvailableCheckoutByCustomerId as jest.Mock).mockReturnValue([checkoutMock, QueryStatus.SUCCESS]);
|
|
@@ -117,10 +117,16 @@ const CheckoutMiddleware: FC<CheckoutMiddlewareProps> = ({
|
|
|
117
117
|
}
|
|
118
118
|
}, [basePath, checkout?.status, checkout?.items]);
|
|
119
119
|
|
|
120
|
-
if (
|
|
120
|
+
if (checkout === undefined) {
|
|
121
121
|
return loader;
|
|
122
122
|
}
|
|
123
123
|
|
|
124
|
+
if (checkout === null) {
|
|
125
|
+
onNotAccessible();
|
|
126
|
+
|
|
127
|
+
return null;
|
|
128
|
+
}
|
|
129
|
+
|
|
124
130
|
/* Prevent direct payment access */
|
|
125
131
|
if (checkoutPaymentRouteMatch && !checkoutShown.current) {
|
|
126
132
|
onNotAccessible();
|