fix(medusa): Price selection strategy bug with customer groups without customers (#4578)
* change up condition for joining price lists * add changeset * naming * update tests
This commit is contained in:
@@ -1299,9 +1299,11 @@ describe("/admin/price-lists", () => {
|
||||
|
||||
expect(response.status).toBe(200)
|
||||
expect(response.data).toEqual({
|
||||
ids: product1.variants.map((variant, i) => {
|
||||
return getCustomPriceIdFromVariant(variant.id, i)
|
||||
}),
|
||||
ids: expect.arrayContaining(
|
||||
product1.variants.map((variant, i) => {
|
||||
return getCustomPriceIdFromVariant(variant.id, i)
|
||||
})
|
||||
),
|
||||
object: "money-amount",
|
||||
deleted: true,
|
||||
})
|
||||
|
||||
@@ -262,6 +262,12 @@ describe("/admin/products", () => {
|
||||
product_id: productData.id,
|
||||
sku: `test-product_filtering_by_variant_id-${i}`,
|
||||
title: `test-product_filtering_by_variant_id-${i}`,
|
||||
options: [
|
||||
{
|
||||
option_id: "test-product_filtering_by_variant_id-option",
|
||||
value: `Large-${i}`,
|
||||
},
|
||||
],
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,16 @@ const { useDb, initDb } = require("../../../environment-helpers/use-db")
|
||||
|
||||
const adminSeeder = require("../../../helpers/admin-seeder")
|
||||
const promotionsSeeder = require("../../../helpers/price-selection-seeder")
|
||||
const {
|
||||
Product,
|
||||
ShippingProfileType,
|
||||
ShippingProfile,
|
||||
ProductOption,
|
||||
CustomerGroup,
|
||||
PriceList,
|
||||
ProductVariant,
|
||||
Customer,
|
||||
} = require("@medusajs/medusa")
|
||||
|
||||
jest.setTimeout(30000)
|
||||
|
||||
@@ -449,6 +459,55 @@ describe("Promotions", () => {
|
||||
)
|
||||
})
|
||||
|
||||
it("should only join price lists with customer groups for the customer, not empty groups", async () => {
|
||||
const api = useApi()
|
||||
|
||||
const authResponse = await api.post("/store/auth", {
|
||||
email: "test5@email-pl.com",
|
||||
password: "test",
|
||||
})
|
||||
|
||||
const [authCookie] = authResponse.headers["set-cookie"][0].split(";")
|
||||
|
||||
const res = await api
|
||||
.get("/store/products/test-product-pl?cart_id=test-cart", {
|
||||
headers: {
|
||||
Cookie: authCookie,
|
||||
},
|
||||
})
|
||||
.catch((error) => console.log(error))
|
||||
|
||||
const variant = res.data.product.variants[0]
|
||||
|
||||
expect(variant.prices.length).toEqual(2)
|
||||
|
||||
expect(variant).toEqual(
|
||||
expect.objectContaining({
|
||||
id: "test-variant-pl",
|
||||
calculated_price: 110,
|
||||
})
|
||||
)
|
||||
|
||||
expect(variant.prices.length).toEqual(2)
|
||||
expect(variant.prices).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
id: "test-price1120",
|
||||
region_id: "test-region",
|
||||
currency_code: "usd",
|
||||
amount: 120,
|
||||
}),
|
||||
expect.objectContaining({
|
||||
id: "test-price2120",
|
||||
region_id: "test-region",
|
||||
currency_code: "usd",
|
||||
price_list_id: "pl_current_pl",
|
||||
amount: 110,
|
||||
}),
|
||||
])
|
||||
)
|
||||
})
|
||||
|
||||
it("fetches product with groups and quantities in money amounts with login", async () => {
|
||||
const api = useApi()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user