fix: Update is_giftcard type when filtering products (#1427)

* transform is_giftcard parameter and default to false

* add test for non gift_cards

* make default optional
This commit is contained in:
Philip Korsholm
2022-04-25 14:55:33 +02:00
committed by GitHub
parent 7a1e394b9d
commit f7386bf4b3
3 changed files with 52 additions and 6 deletions
@@ -509,6 +509,50 @@ describe("/admin/products", () => {
])
})
it("returns a list of products not containing a giftcard in list", async () => {
const api = useApi()
const payload = {
title: "Test Giftcard",
is_giftcard: true,
description: "test-giftcard-description",
options: [{ title: "Denominations" }],
variants: [
{
title: "Test variant",
prices: [{ currency_code: "usd", amount: 100 }],
options: [{ value: "100" }],
},
],
}
await api
.post("/admin/products", payload, {
headers: {
Authorization: "Bearer test_token",
},
})
.catch((err) => {
console.log(err)
})
const response = await api
.get("/admin/products?is_giftcard=false", {
headers: {
Authorization: "Bearer test_token",
},
})
.catch((err) => {
console.log(err)
})
expect(response.data.products).toEqual(
expect.not.arrayContaining([
expect.objectContaining({ is_giftcard: true }),
])
)
})
it("returns a list of products with child entities", async () => {
const api = useApi()