feat(medusa): Add ProductVariantInventoryService (#2883)

* add mw feature flag

* add services

* add types

* add module interfaces

* add interface export

* add models for mw

* to be ammended

* remove featureflag

* use correct count

* update cart completion strategy

* swap service conversion

* update return service

* update order service

* update claim service

* add exception to claim item

* update cart service

* add indicies

* add changeset

* nullable changes in store

* store model update

* fix unit tests

* remove old inventory service

* format integration test

* update snapshots

* remove old inventory service tests

* update snapshots

* remove old code

* option updates

* naming

* add jsdoc to pv inventory service

* rename class variables

* pr feedback

* rename option to context

* if(variant_id) instead of if(typeof varia...)

* update tests

* add jsdoc

* go for custom

* update code for readability
This commit is contained in:
Philip Korsholm
2022-12-30 11:30:04 +01:00
committed by GitHub
parent eda26f6e81
commit b9680b641f
42 changed files with 1514 additions and 761 deletions

View File

@@ -25,6 +25,7 @@ Object {
},
],
"default_currency_code": "usd",
"default_location_id": null,
"id": Any<String>,
"invite_link_template": null,
"metadata": null,
@@ -59,6 +60,7 @@ Object {
"symbol_native": "¥",
},
"default_currency_code": "jpy",
"default_location_id": null,
"id": Any<String>,
"invite_link_template": null,
"metadata": null,
@@ -93,6 +95,7 @@ Object {
"symbol_native": "kr",
},
"default_currency_code": "dkk",
"default_location_id": null,
"id": Any<String>,
"invite_link_template": null,
"metadata": null,
@@ -121,6 +124,7 @@ Object {
"symbol_native": "$",
},
"default_currency_code": "usd",
"default_location_id": null,
"feature_flags": Any<Array>,
"fulfillment_providers": Array [
Object {

View File

@@ -157,6 +157,7 @@ Object {
"return_id": StringMatching /\\^ret_\\*/,
},
],
"location_id": null,
"metadata": null,
"no_notification": true,
"order_id": null,
@@ -333,6 +334,7 @@ Object {
"return_id": StringMatching /\\^ret_\\*/,
},
],
"location_id": null,
"metadata": null,
"no_notification": true,
"order_id": null,

View File

@@ -1055,9 +1055,13 @@ describe("/store/carts", () => {
regions: ["test-region"],
}
const cartId = "discount-cart"
const cartId = "discount-cart"
const discount = await simpleDiscountFactory(dbConnection, discountData, 100)
const discount = await simpleDiscountFactory(
dbConnection,
discountData,
100
)
const discountCart = await simpleCartFactory(
dbConnection,
{
@@ -1088,14 +1092,10 @@ describe("/store/carts", () => {
const api = useApi()
let response = await api
.post(
`/store/carts/${cartId}/line-items`,
{
quantity: 1,
variant_id: "test-variant-quantity",
},
)
let response = await api.post(`/store/carts/${cartId}/line-items`, {
quantity: 1,
variant_id: "test-variant-quantity",
})
expect(response.data.cart.items.length).toEqual(1)
expect(response.data.cart.items).toEqual(
@@ -1111,13 +1111,9 @@ describe("/store/carts", () => {
])
)
response = await api
.post(
`/store/carts/${cartId}`,
{
discounts: [],
},
)
response = await api.post(`/store/carts/${cartId}`, {
discounts: [],
})
expect(response.data.cart.items.length).toEqual(1)
expect(response.data.cart.items[0].adjustments).toHaveLength(0)
@@ -2201,7 +2197,11 @@ describe("/store/carts", () => {
it("removes line item adjustments upon discount deletion", async () => {
const cartId = "discount-cart"
const discount = await simpleDiscountFactory(dbConnection, discountData, 100)
const discount = await simpleDiscountFactory(
dbConnection,
discountData,
100
)
const discountCart = await simpleCartFactory(
dbConnection,
{
@@ -2232,14 +2232,10 @@ describe("/store/carts", () => {
const api = useApi()
let response = await api
.post(
`/store/carts/${cartId}/line-items`,
{
quantity: 1,
variant_id: "test-variant-quantity",
},
)
let response = await api.post(`/store/carts/${cartId}/line-items`, {
quantity: 1,
variant_id: "test-variant-quantity",
})
expect(response.data.cart.items.length).toEqual(1)
expect(response.data.cart.items).toEqual(
@@ -2255,8 +2251,9 @@ describe("/store/carts", () => {
])
)
response = await api
.delete(`/store/carts/${cartId}/discounts/${discountData.code}`)
response = await api.delete(
`/store/carts/${cartId}/discounts/${discountData.code}`
)
expect(response.data.cart.items.length).toEqual(1)
expect(response.data.cart.items[0].adjustments).toHaveLength(0)