feat(medusa): Cart and totals computational optimizations (#2475)
This commit is contained in:
committed by
GitHub
parent
755ba90c05
commit
d2b1848e52
@@ -1866,25 +1866,28 @@ describe("/admin/products", () => {
|
||||
|
||||
expect(res.status).toEqual(200)
|
||||
|
||||
expect(insertedVariant.prices).toEqual([
|
||||
expect.objectContaining({
|
||||
currency_code: "usd",
|
||||
amount: 100,
|
||||
min_quantity: null,
|
||||
max_quantity: null,
|
||||
variant_id: insertedVariant.id,
|
||||
region_id: null,
|
||||
}),
|
||||
expect.objectContaining({
|
||||
currency_code: "usd",
|
||||
amount: 200,
|
||||
min_quantity: null,
|
||||
max_quantity: null,
|
||||
price_list_id: null,
|
||||
variant_id: insertedVariant.id,
|
||||
region_id: "test-region",
|
||||
}),
|
||||
])
|
||||
expect(insertedVariant.prices).toHaveLength(2)
|
||||
expect(insertedVariant.prices).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
currency_code: "usd",
|
||||
amount: 100,
|
||||
min_quantity: null,
|
||||
max_quantity: null,
|
||||
variant_id: insertedVariant.id,
|
||||
region_id: null,
|
||||
}),
|
||||
expect.objectContaining({
|
||||
currency_code: "usd",
|
||||
amount: 200,
|
||||
min_quantity: null,
|
||||
max_quantity: null,
|
||||
price_list_id: null,
|
||||
variant_id: insertedVariant.id,
|
||||
region_id: "test-region",
|
||||
}),
|
||||
])
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
@@ -66,7 +66,9 @@ describe("/store/carts", () => {
|
||||
tax_rate: 0,
|
||||
})
|
||||
await manager.query(
|
||||
`UPDATE "country" SET region_id='region' WHERE iso_2 = 'us'`
|
||||
`UPDATE "country"
|
||||
SET region_id='region'
|
||||
WHERE iso_2 = 'us'`
|
||||
)
|
||||
})
|
||||
|
||||
@@ -88,9 +90,12 @@ describe("/store/carts", () => {
|
||||
const api = useApi()
|
||||
|
||||
await dbConnection.manager.query(
|
||||
`UPDATE "country" SET region_id=null WHERE iso_2 = 'us'`
|
||||
`UPDATE "country"
|
||||
SET region_id=null
|
||||
WHERE iso_2 = 'us'`
|
||||
)
|
||||
await dbConnection.manager.query(`DELETE from region`)
|
||||
await dbConnection.manager.query(`DELETE
|
||||
from region`)
|
||||
|
||||
try {
|
||||
await api.post("/store/carts")
|
||||
@@ -1679,7 +1684,9 @@ describe("/store/carts", () => {
|
||||
const manager = dbConnection.manager
|
||||
const api = useApi()
|
||||
await manager.query(
|
||||
`UPDATE "cart" SET completed_at=current_timestamp WHERE id = 'test-cart-2'`
|
||||
`UPDATE "cart"
|
||||
SET completed_at=current_timestamp
|
||||
WHERE id = 'test-cart-2'`
|
||||
)
|
||||
try {
|
||||
await api.post(`/store/carts/test-cart-2/complete-cart`)
|
||||
@@ -1982,7 +1989,8 @@ describe("/store/carts", () => {
|
||||
try {
|
||||
await cartSeeder(dbConnection)
|
||||
await dbConnection.manager.query(
|
||||
`INSERT INTO "cart_discounts" (cart_id, discount_id) VALUES ('test-cart', 'free-shipping')`
|
||||
`INSERT INTO "cart_discounts" (cart_id, discount_id)
|
||||
VALUES ('test-cart', 'free-shipping')`
|
||||
)
|
||||
} catch (err) {
|
||||
console.log(err)
|
||||
|
||||
Reference in New Issue
Block a user