fix(medusa): keep country_code when partially updating cart addresses (#2683)
**What** - Fixes a bug where `country_code` was dropped when partially updating a shipping or billing address on a cart.
This commit is contained in:
@@ -1642,6 +1642,44 @@ describe("/store/carts", () => {
|
||||
expect(response.status).toEqual(200)
|
||||
})
|
||||
|
||||
it("partially updates shipping and billing address while retaining the addresses country codes", async () => {
|
||||
const api = useApi()
|
||||
|
||||
// Partially update the shipping address
|
||||
await api
|
||||
.post("/store/carts/test-cart", {
|
||||
shipping_address: {
|
||||
last_name: "james",
|
||||
},
|
||||
})
|
||||
.catch((error) => console.log(error))
|
||||
|
||||
// Partially update the billing address
|
||||
const response = await api.post("/store/carts/test-cart", {
|
||||
billing_address: {
|
||||
first_name: "bruce",
|
||||
last_name: "banner",
|
||||
country_code: "us",
|
||||
},
|
||||
})
|
||||
|
||||
expect(response.status).toEqual(200)
|
||||
expect(response.data.cart).toEqual(
|
||||
expect.objectContaining({
|
||||
shipping_address: expect.objectContaining({
|
||||
first_name: "lebron",
|
||||
last_name: "james",
|
||||
country_code: "us",
|
||||
}),
|
||||
billing_address: expect.objectContaining({
|
||||
first_name: "bruce",
|
||||
last_name: "banner",
|
||||
country_code: "us",
|
||||
}),
|
||||
})
|
||||
)
|
||||
})
|
||||
|
||||
it("adds free shipping to cart then removes it again", async () => {
|
||||
const api = useApi()
|
||||
|
||||
|
||||
+2
-2
@@ -2415,7 +2415,7 @@ Object {
|
||||
"address_2": null,
|
||||
"city": "ville la something",
|
||||
"company": null,
|
||||
"country_code": null,
|
||||
"country_code": "us",
|
||||
"created_at": Any<Date>,
|
||||
"customer_id": null,
|
||||
"deleted_at": null,
|
||||
@@ -2476,4 +2476,4 @@ Object {
|
||||
"tracking_links": Array [],
|
||||
"tracking_number": "",
|
||||
}
|
||||
`;
|
||||
`;
|
||||
|
||||
Reference in New Issue
Block a user