fix(medusa): cart now returns 404 when not found (#13622)
FIXES #10218 FIXES CORE-739
This commit is contained in:
1 parent
f970e1355a
commit
9d3c71fefd
3 files changed
+26
-5
No files matched your search
@@ -0,0 +1,6 @@
|
|||||||
|
---
|
||||||
|
"@medusajs/medusa": patch
|
||||||
|
"integration-tests-http": patch
|
||||||
|
---
|
||||||
|
|
||||||
|
fix(medusa): cart now returns 404 when not found
|
||||||
@@ -9,11 +9,7 @@ import {
|
|||||||
PromotionStatus,
|
PromotionStatus,
|
||||||
PromotionType,
|
PromotionType,
|
||||||
} from "@medusajs/utils"
|
} from "@medusajs/utils"
|
||||||
import {
|
import { createAdminUser, generatePublishableKey, generateStoreHeaders, } from "../../../../helpers/create-admin-user"
|
||||||
createAdminUser,
|
|
||||||
generatePublishableKey,
|
|
||||||
generateStoreHeaders,
|
|
||||||
} from "../../../../helpers/create-admin-user"
|
|
||||||
import { setupTaxStructure } from "../../../../modules/__tests__/fixtures"
|
import { setupTaxStructure } from "../../../../modules/__tests__/fixtures"
|
||||||
import { createAuthenticatedCustomer } from "../../../../modules/helpers/create-authenticated-customer"
|
import { createAuthenticatedCustomer } from "../../../../modules/helpers/create-authenticated-customer"
|
||||||
import { medusaTshirtProduct } from "../../../__fixtures__/product"
|
import { medusaTshirtProduct } from "../../../__fixtures__/product"
|
||||||
@@ -152,6 +148,17 @@ medusaIntegrationTestRunner({
|
|||||||
).data.promotion
|
).data.promotion
|
||||||
})
|
})
|
||||||
|
|
||||||
|
describe("GET /store/carts/[id]", () => {
|
||||||
|
it("should return 404 when trying to fetch a cart that does not exist", async () => {
|
||||||
|
const response = await api.get(
|
||||||
|
`/store/carts/fake`,
|
||||||
|
storeHeadersWithCustomer
|
||||||
|
).catch((e) => e)
|
||||||
|
|
||||||
|
expect(response.response.status).toEqual(404)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
describe("POST /store/carts", () => {
|
describe("POST /store/carts", () => {
|
||||||
it("should successfully create a cart", async () => {
|
it("should successfully create a cart", async () => {
|
||||||
const response = await api.post(
|
const response = await api.post(
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import { MedusaContainer } from "@medusajs/framework/types"
|
import { MedusaContainer } from "@medusajs/framework/types"
|
||||||
import {
|
import {
|
||||||
ContainerRegistrationKeys,
|
ContainerRegistrationKeys,
|
||||||
|
MedusaError,
|
||||||
remoteQueryObjectFromString,
|
remoteQueryObjectFromString,
|
||||||
} from "@medusajs/framework/utils"
|
} from "@medusajs/framework/utils"
|
||||||
|
|
||||||
@@ -18,5 +19,12 @@ export const refetchCart = async (
|
|||||||
|
|
||||||
const [cart] = await remoteQuery(queryObject)
|
const [cart] = await remoteQuery(queryObject)
|
||||||
|
|
||||||
|
if (!cart) {
|
||||||
|
throw new MedusaError(
|
||||||
|
MedusaError.Types.NOT_FOUND,
|
||||||
|
`Cart with id '${id}' not found`
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
return cart
|
return cart
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user