Skip to content

Commit

Permalink
Merge branch 'develop' into feat/updated-json-view
Browse files Browse the repository at this point in the history
  • Loading branch information
kasperkristensen authored Jul 9, 2024
2 parents 1814fa0 + 566bbd5 commit 3aa725d
Show file tree
Hide file tree
Showing 54 changed files with 1,521 additions and 542 deletions.
85 changes: 78 additions & 7 deletions integration-tests/http/__tests__/product/store/product.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -771,7 +771,8 @@ medusaIntegrationTestRunner({
])
})

it("returns a list of products filtered by variant options", async () => {
// TODO: This test is flaky for some reason, reenable once that is resolved
it.skip("returns a list of products filtered by variant options", async () => {
const response = await api.get(
`/store/products?variants.options[option_id]=${product.options[1].id}&variants.options[value]=large`
)
Expand Down Expand Up @@ -1269,6 +1270,43 @@ medusaIntegrationTestRunner({
let euCart

beforeEach(async () => {
const store = (await api.get("/admin/stores", adminHeaders)).data
.stores[0]
if (store) {
await api.post(
`/admin/stores/${store.id}`,
{
supported_currencies: [
{
currency_code: "usd",
is_tax_inclusive: true,
is_default: true,
},
{ currency_code: "eur", is_tax_inclusive: false },
{ currency_code: "dkk", is_tax_inclusive: true },
],
},
adminHeaders
)
} else {
await api.post(
"/admin/stores",
{
name: "Test store",
supported_currencies: [
{
currency_code: "usd",
is_tax_inclusive: true,
is_default: true,
},
{ currency_code: "eur", is_tax_inclusive: false },
{ currency_code: "dkk", is_tax_inclusive: true },
],
},
adminHeaders
)
}

usRegion = (
await api.post(
"/admin/regions",
Expand Down Expand Up @@ -1344,6 +1382,14 @@ medusaIntegrationTestRunner({
)
).data.product

product2 = (
await api.post(
"/admin/products",
getProductFixture({ title: "test2", status: "published" }),
adminHeaders
)
).data.product

euCart = (await api.post("/store/carts", { region_id: euRegion.id }))
.data.cart

Expand Down Expand Up @@ -1394,7 +1440,7 @@ medusaIntegrationTestRunner({
)
).data.products

expect(products.length).toBe(1)
expect(products.length).toBe(2)
expect(products[0].variants[0].calculated_price).not.toHaveProperty(
"calculated_amount_with_tax"
)
Expand All @@ -1410,7 +1456,7 @@ medusaIntegrationTestRunner({
)
).data.products

expect(products.length).toBe(1)
expect(products.length).toBe(2)
expect(products[0].variants[0].calculated_price).not.toHaveProperty(
"calculated_amount_with_tax"
)
Expand All @@ -1426,7 +1472,7 @@ medusaIntegrationTestRunner({
)
).data.products

expect(products.length).toBe(1)
expect(products.length).toBe(2)
expect(products[0].variants).toEqual(
expect.arrayContaining([
expect.objectContaining({
Expand All @@ -1445,6 +1491,19 @@ medusaIntegrationTestRunner({
1
)
).toEqual("40.9")

expect(products[1].variants).toEqual(
expect.arrayContaining([
expect.objectContaining({
calculated_price: expect.objectContaining({
currency_code: "eur",
calculated_amount: 45,
calculated_amount_without_tax: 45,
calculated_amount_with_tax: 49.5,
}),
}),
])
)
})

it("should return prices with and without tax for a tax exclusive region when listing products", async () => {
Expand All @@ -1454,7 +1513,7 @@ medusaIntegrationTestRunner({
)
).data.products

expect(products.length).toBe(1)
expect(products.length).toBe(2)
expect(products[0].variants).toEqual(
expect.arrayContaining([
expect.objectContaining({
Expand All @@ -1467,6 +1526,18 @@ medusaIntegrationTestRunner({
}),
])
)
expect(products[1].variants).toEqual(
expect.arrayContaining([
expect.objectContaining({
calculated_price: expect.objectContaining({
currency_code: "dkk",
calculated_amount: 30,
calculated_amount_with_tax: 30,
calculated_amount_without_tax: 25,
}),
}),
])
)
})

it("should return prices with and without tax when the cart is available and a country is passed when listing products", async () => {
Expand All @@ -1476,7 +1547,7 @@ medusaIntegrationTestRunner({
)
).data.products

expect(products.length).toBe(1)
expect(products.length).toBe(2)
expect(products[0].variants).toEqual(
expect.arrayContaining([
expect.objectContaining({
Expand Down Expand Up @@ -1510,7 +1581,7 @@ medusaIntegrationTestRunner({
)
).data.products

expect(products.length).toBe(1)
expect(products.length).toBe(2)
expect(products[0].variants).toEqual(
expect.arrayContaining([
expect.objectContaining({
Expand Down
Loading

0 comments on commit 3aa725d

Please sign in to comment.