fix(medusa): Support fields param in list-variants (#5053)

* fix(medusa): Support fields param in list-variants

* Create cuddly-pigs-tease.md

* address pr comments
This commit is contained in:
Oli Juhl
2023-09-15 09:08:04 +02:00
committed by GitHub
parent edf90eecb4
commit dc94f053d3
4 changed files with 60 additions and 40 deletions
@@ -379,5 +379,38 @@ describe("/store/variants", () => {
],
})
})
it("should list variants with id using fields param", async () => {
const api = useApi()
const response = await api
.get("/store/variants?fields=id&expand=&limit=1")
.catch((err) => console.log(err))
expect(response.data).toEqual({
variants: [
{
id: expect.any(String),
created_at: expect.any(String),
// tax rates, prices, and calculated prices are added regardless of fields and expand
calculated_price: null,
calculated_price_incl_tax: null,
calculated_tax: null,
original_price: null,
original_price_incl_tax: null,
original_tax: null,
tax_rates: null,
prices: expect.arrayContaining([
expect.objectContaining({
id: expect.any(String),
variant_id: expect.any(String),
created_at: expect.any(String),
updated_at: expect.any(String),
}),
]),
},
],
})
})
})
})