Skip to content

Commit

Permalink
Merge branch 'develop' into docs/references-enhancement
Browse files Browse the repository at this point in the history
  • Loading branch information
shahednasser authored Dec 5, 2023
2 parents fb65430 + a418e6c commit e1b581d
Show file tree
Hide file tree
Showing 26 changed files with 2,561 additions and 90 deletions.
6 changes: 6 additions & 0 deletions .changeset/angry-eels-guess.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@medusajs/admin-ui": patch
"@medusajs/admin": patch
---

feat(admin): Add Korean language support
5 changes: 5 additions & 0 deletions .changeset/early-monkeys-rush.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"medusa-payment-klarna": minor
---

Add language support
6 changes: 6 additions & 0 deletions .changeset/grumpy-bees-laugh.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@medusajs/medusa": patch
"@medusajs/admin": patch
---

feat(medusa): add monorepo support command develop
5 changes: 5 additions & 0 deletions .changeset/heavy-moles-check.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@medusajs/medusa": minor
---

feat(medusa): Respond with order when cart is already completed
5 changes: 5 additions & 0 deletions .changeset/large-swans-rule.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"medusa-react": patch
---

fix(medusa-react): Allow setting maxRetries on MedusaProvider
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,6 @@ Object {
}
`;

exports[`/store/carts POST /store/carts/:id returns early, if cart is already completed 1`] = `
Object {
"code": "cart_incompatible_state",
"message": "Cart has already been completed",
"type": "not_allowed",
}
`;

exports[`/store/carts shipping address + region updates updates region only - single to multiple countries 1`] = `
Object {
"address_1": null,
Expand Down
59 changes: 44 additions & 15 deletions integration-tests/api/__tests__/store/cart/cart.js
Original file line number Diff line number Diff line change
Expand Up @@ -2234,24 +2234,27 @@ describe("/store/carts", () => {
expect(createdOrder.status).toEqual(200)
})

it("returns early, if cart is already completed", async () => {
const manager = dbConnection.manager
it("should return early, if cart is already completed", async () => {
const api = useApi()
await manager.query(
`UPDATE "cart"
SET completed_at=current_timestamp
WHERE id = 'test-cart-2'`

const completedCart = await api.post(
`/store/carts/test-cart-2/complete-cart`
)
try {
await api.post(`/store/carts/test-cart-2/complete-cart`)
} catch (error) {
expect(error.response.data).toMatchSnapshot({
type: "not_allowed",
message: "Cart has already been completed",
code: "cart_incompatible_state",

expect(completedCart.status).toEqual(200)

const alreadyCompletedCart = await api.post(
`/store/carts/test-cart-2/complete-cart`
)

expect(alreadyCompletedCart.data.data).toEqual(
expect.objectContaining({
cart_id: "test-cart-2",
id: expect.any(String),
})
expect(error.response.status).toEqual(409)
}
)
expect(alreadyCompletedCart.data.type).toEqual("order")
expect(alreadyCompletedCart.status).toEqual(200)
})

it("fails to complete cart with items inventory not/partially covered", async () => {
Expand Down Expand Up @@ -2354,6 +2357,32 @@ describe("/store/carts", () => {
expect(res.data.cart.completed_at).not.toBe(null)
})

it("should return the swap when cart is already completed", async () => {
const manager = dbConnection.manager
await manager.query(
"UPDATE swap SET cart_id='swap-cart' where id='test-swap'"
)

await manager.query("DELETE FROM payment where swap_id='test-swap'")

const api = useApi()

await api.post(`/store/carts/swap-cart/complete-cart`)

const alreadyCompletedCart = await api.post(
`/store/carts/swap-cart/complete-cart`
)

expect(alreadyCompletedCart.data.data).toEqual(
expect.objectContaining({
cart_id: "swap-cart",
id: expect.any(String),
})
)
expect(alreadyCompletedCart.data.type).toEqual("swap")
expect(alreadyCompletedCart.status).toEqual(200)
})

it("completes cart with a non-customer and for a customer with the same email created later the order doesn't show up", async () => {
const api = useApi()
const customerEmail = "test-email-for-non-existent-customer@test.com"
Expand Down
19 changes: 9 additions & 10 deletions integration-tests/api/__tests__/store/orders.js
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ describe("/store/carts", () => {
await db.teardown()
})

it("should fails on cart already completed", async () => {
it("should return an order on cart already completed", async () => {
const api = useApi()
const manager = dbConnection.manager

Expand Down Expand Up @@ -501,17 +501,16 @@ describe("/store/carts", () => {
})
)

const responseFail = await api
.post(`/store/carts/${cartId}/complete`)
.catch((err) => {
return err.response
})
const successRes = await api.post(`/store/carts/${cartId}/complete`)

expect(responseFail.status).toEqual(409)
expect(responseFail.data.code).toEqual("cart_incompatible_state")
expect(responseFail.data.message).toEqual(
"Cart has already been completed"
expect(successRes.status).toEqual(200)
expect(successRes.data.data).toEqual(
expect.objectContaining({
cart_id: cartId,
id: expect.any(String),
})
)
expect(successRes.data.type).toEqual("order")
})
})

Expand Down
Loading

0 comments on commit e1b581d

Please sign in to comment.