fix(integration-tests): Use asymmetric matcher for arrays in tests (#1992)
This commit is contained in:
@@ -331,12 +331,15 @@ describe("/admin/discounts", () => {
|
||||
})
|
||||
expect(response.status).toEqual(200)
|
||||
expect(response.data.count).toEqual(1)
|
||||
expect(response.data.discounts).toEqual([
|
||||
expect.objectContaining({
|
||||
id: "fixed-discount",
|
||||
code: "fixed100",
|
||||
}),
|
||||
])
|
||||
expect(response.data.discounts).toHaveLength(1)
|
||||
expect(response.data.discounts).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
id: "fixed-discount",
|
||||
code: "fixed100",
|
||||
}),
|
||||
])
|
||||
)
|
||||
})
|
||||
|
||||
it("fails when listing invalid discount types", async () => {
|
||||
@@ -394,12 +397,15 @@ describe("/admin/discounts", () => {
|
||||
})
|
||||
expect(response.status).toEqual(200)
|
||||
expect(response.data.count).toEqual(1)
|
||||
expect(response.data.discounts).toEqual([
|
||||
expect.objectContaining({
|
||||
id: "dynamic-discount",
|
||||
code: "Dyn100",
|
||||
}),
|
||||
])
|
||||
expect(response.data.discounts).toHaveLength(1)
|
||||
expect(response.data.discounts).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
id: "dynamic-discount",
|
||||
code: "Dyn100",
|
||||
})
|
||||
])
|
||||
)
|
||||
})
|
||||
|
||||
it("lists disabled discounts ", async () => {
|
||||
@@ -416,12 +422,15 @@ describe("/admin/discounts", () => {
|
||||
})
|
||||
expect(response.status).toEqual(200)
|
||||
expect(response.data.count).toEqual(1)
|
||||
expect(response.data.discounts).toEqual([
|
||||
expect.objectContaining({
|
||||
id: "disabled-discount",
|
||||
code: "Dis100",
|
||||
}),
|
||||
])
|
||||
expect(response.data.discounts).toHaveLength(1)
|
||||
expect(response.data.discounts).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
id: "disabled-discount",
|
||||
code: "Dis100",
|
||||
}),
|
||||
])
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -614,16 +623,19 @@ describe("/admin/discounts", () => {
|
||||
})
|
||||
|
||||
expect(response.status).toEqual(200)
|
||||
expect(response.data.discount.rule.conditions).toEqual([
|
||||
expect.objectContaining({
|
||||
type: "products",
|
||||
operator: "in",
|
||||
}),
|
||||
expect.objectContaining({
|
||||
type: "product_types",
|
||||
operator: "not_in",
|
||||
}),
|
||||
])
|
||||
expect(response.data.discount.rule.conditions).toHaveLength(2)
|
||||
expect(response.data.discount.rule.conditions).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
type: "products",
|
||||
operator: "in",
|
||||
}),
|
||||
expect.objectContaining({
|
||||
type: "product_types",
|
||||
operator: "not_in",
|
||||
}),
|
||||
])
|
||||
)
|
||||
|
||||
const createdRule = response.data.discount.rule
|
||||
const condsToUpdate = createdRule.conditions[0]
|
||||
|
||||
@@ -673,11 +673,14 @@ describe("/admin/orders", () => {
|
||||
)
|
||||
|
||||
expect(status).toEqual(200)
|
||||
expect(updateData.order.claims[0].shipping_methods).toEqual([
|
||||
expect.objectContaining({
|
||||
id: "test-method",
|
||||
}),
|
||||
])
|
||||
expect(updateData.order.claims[0].shipping_methods).toHaveLength(1)
|
||||
expect(updateData.order.claims[0].shipping_methods).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
id: "test-method",
|
||||
}),
|
||||
])
|
||||
)
|
||||
})
|
||||
|
||||
it("updates claim items", async () => {
|
||||
@@ -827,19 +830,21 @@ describe("/admin/orders", () => {
|
||||
claim = updateData.order.claims[0]
|
||||
|
||||
expect(claim.claim_items.length).toEqual(1)
|
||||
expect(claim.claim_items).toEqual([
|
||||
expect.objectContaining({
|
||||
id: claim.claim_items[0].id,
|
||||
reason: "production_failure",
|
||||
note: "Something new",
|
||||
images: [],
|
||||
// tags: expect.arrayContaining([
|
||||
// expect.objectContaining({ value: "completely" }),
|
||||
// expect.objectContaining({ value: "new" }),
|
||||
// expect.objectContaining({ value: "tags" }),
|
||||
// ]),
|
||||
}),
|
||||
])
|
||||
expect(claim.claim_items).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
id: claim.claim_items[0].id,
|
||||
reason: "production_failure",
|
||||
note: "Something new",
|
||||
images: [],
|
||||
// tags: expect.arrayContaining([
|
||||
// expect.objectContaining({ value: "completely" }),
|
||||
// expect.objectContaining({ value: "new" }),
|
||||
// expect.objectContaining({ value: "tags" }),
|
||||
// ]),
|
||||
}),
|
||||
])
|
||||
)
|
||||
})
|
||||
|
||||
it("fulfills a claim", async () => {
|
||||
@@ -892,27 +897,34 @@ describe("/admin/orders", () => {
|
||||
}
|
||||
)
|
||||
expect(fulRes.status).toEqual(200)
|
||||
expect(fulRes.data.order.claims).toEqual([
|
||||
expect.objectContaining({
|
||||
id: cid,
|
||||
order_id: "test-order",
|
||||
fulfillment_status: "fulfilled",
|
||||
}),
|
||||
])
|
||||
expect(fulRes.data.order.claims).toHaveLength(1)
|
||||
expect(fulRes.data.order.claims).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
id: cid,
|
||||
order_id: "test-order",
|
||||
fulfillment_status: "fulfilled",
|
||||
}),
|
||||
])
|
||||
)
|
||||
|
||||
const fid = fulRes.data.order.claims[0].fulfillments[0].id
|
||||
const iid = fulRes.data.order.claims[0].additional_items[0].id
|
||||
expect(fulRes.data.order.claims[0].fulfillments).toEqual([
|
||||
expect.objectContaining({
|
||||
items: [
|
||||
{
|
||||
fulfillment_id: fid,
|
||||
item_id: iid,
|
||||
quantity: 1,
|
||||
},
|
||||
],
|
||||
}),
|
||||
])
|
||||
|
||||
expect(fulRes.data.order.claims[0].fulfillments).toHaveLength(1)
|
||||
expect(fulRes.data.order.claims[0].fulfillments).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
items: [
|
||||
{
|
||||
fulfillment_id: fid,
|
||||
item_id: iid,
|
||||
quantity: 1,
|
||||
},
|
||||
],
|
||||
}),
|
||||
])
|
||||
)
|
||||
})
|
||||
|
||||
it("creates a claim on a claim additional item", async () => {
|
||||
@@ -1318,14 +1330,17 @@ describe("/admin/orders", () => {
|
||||
expect(response.status).toEqual(200)
|
||||
|
||||
expect(response.data.order.returns[0].refund_amount).toEqual(7200)
|
||||
expect(response.data.order.returns[0].items).toEqual([
|
||||
expect.objectContaining({
|
||||
item_id: "test-item",
|
||||
quantity: 1,
|
||||
reason_id: rrId,
|
||||
note: "TOO SMALL",
|
||||
}),
|
||||
])
|
||||
expect(response.data.order.returns[0].items).toHaveLength(1)
|
||||
expect(response.data.order.returns[0].items).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
item_id: "test-item",
|
||||
quantity: 1,
|
||||
reason_id: rrId,
|
||||
note: "TOO SMALL",
|
||||
}),
|
||||
])
|
||||
)
|
||||
})
|
||||
|
||||
it("increases inventory_quantity when return is received", async () => {
|
||||
@@ -1420,28 +1435,31 @@ describe("/admin/orders", () => {
|
||||
})
|
||||
|
||||
expect(response.status).toEqual(200)
|
||||
expect(response.data.orders).toEqual([
|
||||
expect.objectContaining({
|
||||
id: "test-order",
|
||||
}),
|
||||
expect(response.data.orders).toHaveLength(6)
|
||||
expect(response.data.orders).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
id: "test-order",
|
||||
}),
|
||||
|
||||
expect.objectContaining({
|
||||
id: "test-order-w-c",
|
||||
}),
|
||||
expect.objectContaining({
|
||||
id: "test-order-w-c",
|
||||
}),
|
||||
|
||||
expect.objectContaining({
|
||||
id: "test-order-w-s",
|
||||
}),
|
||||
expect.objectContaining({
|
||||
id: "test-order-w-f",
|
||||
}),
|
||||
expect.objectContaining({
|
||||
id: "test-order-w-r",
|
||||
}),
|
||||
expect.objectContaining({
|
||||
id: "discount-order",
|
||||
}),
|
||||
])
|
||||
expect.objectContaining({
|
||||
id: "test-order-w-s",
|
||||
}),
|
||||
expect.objectContaining({
|
||||
id: "test-order-w-f",
|
||||
}),
|
||||
expect.objectContaining({
|
||||
id: "test-order-w-r",
|
||||
}),
|
||||
expect.objectContaining({
|
||||
id: "discount-order",
|
||||
}),
|
||||
])
|
||||
)
|
||||
})
|
||||
|
||||
it("lists all orders with a fulfillment status = fulfilled and payment status = captured", async () => {
|
||||
@@ -1459,14 +1477,17 @@ describe("/admin/orders", () => {
|
||||
.catch((err) => console.log(err))
|
||||
|
||||
expect(response.status).toEqual(200)
|
||||
expect(response.data.orders).toEqual([
|
||||
expect.objectContaining({
|
||||
id: "test-order",
|
||||
}),
|
||||
expect.objectContaining({
|
||||
id: "discount-order",
|
||||
}),
|
||||
])
|
||||
expect(response.data.orders).toHaveLength(2)
|
||||
expect(response.data.orders).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
id: "test-order",
|
||||
}),
|
||||
expect.objectContaining({
|
||||
id: "discount-order",
|
||||
}),
|
||||
])
|
||||
)
|
||||
})
|
||||
|
||||
it("fails to lists all orders with an invalid status", async () => {
|
||||
@@ -1502,12 +1523,15 @@ describe("/admin/orders", () => {
|
||||
|
||||
expect(response.status).toEqual(200)
|
||||
expect(response.data.count).toEqual(1)
|
||||
expect(response.data.orders).toEqual([
|
||||
expect.objectContaining({
|
||||
id: "test-order",
|
||||
email: "test@email.com",
|
||||
}),
|
||||
])
|
||||
expect(response.data.orders).toHaveLength(1)
|
||||
expect(response.data.orders).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
id: "test-order",
|
||||
email: "test@email.com",
|
||||
}),
|
||||
])
|
||||
)
|
||||
})
|
||||
|
||||
it("list all orders with matching shipping_address first name", async () => {
|
||||
@@ -1546,27 +1570,30 @@ describe("/admin/orders", () => {
|
||||
)
|
||||
|
||||
expect(response.status).toEqual(200)
|
||||
expect(response.data.orders).toEqual([
|
||||
expect.objectContaining({
|
||||
id: "test-order",
|
||||
}),
|
||||
expect.objectContaining({
|
||||
id: "test-order-w-c",
|
||||
}),
|
||||
expect(response.data.orders).toHaveLength(6)
|
||||
expect(response.data.orders).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
id: "test-order",
|
||||
}),
|
||||
expect.objectContaining({
|
||||
id: "test-order-w-c",
|
||||
}),
|
||||
|
||||
expect.objectContaining({
|
||||
id: "test-order-w-s",
|
||||
}),
|
||||
expect.objectContaining({
|
||||
id: "test-order-w-f",
|
||||
}),
|
||||
expect.objectContaining({
|
||||
id: "test-order-w-r",
|
||||
}),
|
||||
expect.objectContaining({
|
||||
id: "discount-order",
|
||||
}),
|
||||
])
|
||||
expect.objectContaining({
|
||||
id: "test-order-w-s",
|
||||
}),
|
||||
expect.objectContaining({
|
||||
id: "test-order-w-f",
|
||||
}),
|
||||
expect.objectContaining({
|
||||
id: "test-order-w-r",
|
||||
}),
|
||||
expect.objectContaining({
|
||||
id: "discount-order",
|
||||
}),
|
||||
])
|
||||
)
|
||||
})
|
||||
|
||||
it("successfully lists no orders with greater than", async () => {
|
||||
@@ -1598,27 +1625,30 @@ describe("/admin/orders", () => {
|
||||
)
|
||||
|
||||
expect(response.status).toEqual(200)
|
||||
expect(response.data.orders).toEqual([
|
||||
expect.objectContaining({
|
||||
id: "test-order",
|
||||
}),
|
||||
expect.objectContaining({
|
||||
id: "test-order-w-c",
|
||||
}),
|
||||
expect(response.data.orders).toHaveLength(6)
|
||||
expect(response.data.orders).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
id: "test-order",
|
||||
}),
|
||||
expect.objectContaining({
|
||||
id: "test-order-w-c",
|
||||
}),
|
||||
|
||||
expect.objectContaining({
|
||||
id: "test-order-w-s",
|
||||
}),
|
||||
expect.objectContaining({
|
||||
id: "test-order-w-f",
|
||||
}),
|
||||
expect.objectContaining({
|
||||
id: "test-order-w-r",
|
||||
}),
|
||||
expect.objectContaining({
|
||||
id: "discount-order",
|
||||
}),
|
||||
])
|
||||
expect.objectContaining({
|
||||
id: "test-order-w-s",
|
||||
}),
|
||||
expect.objectContaining({
|
||||
id: "test-order-w-f",
|
||||
}),
|
||||
expect.objectContaining({
|
||||
id: "test-order-w-r",
|
||||
}),
|
||||
expect.objectContaining({
|
||||
id: "discount-order",
|
||||
}),
|
||||
])
|
||||
)
|
||||
})
|
||||
|
||||
it("successfully lists no orders with less than", async () => {
|
||||
@@ -1650,27 +1680,30 @@ describe("/admin/orders", () => {
|
||||
)
|
||||
|
||||
expect(response.status).toEqual(200)
|
||||
expect(response.data.orders).toEqual([
|
||||
expect.objectContaining({
|
||||
id: "test-order",
|
||||
}),
|
||||
expect.objectContaining({
|
||||
id: "test-order-w-c",
|
||||
}),
|
||||
expect(response.data.orders).toHaveLength(6)
|
||||
expect(response.data.orders).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
id: "test-order",
|
||||
}),
|
||||
expect.objectContaining({
|
||||
id: "test-order-w-c",
|
||||
}),
|
||||
|
||||
expect.objectContaining({
|
||||
id: "test-order-w-s",
|
||||
}),
|
||||
expect.objectContaining({
|
||||
id: "test-order-w-f",
|
||||
}),
|
||||
expect.objectContaining({
|
||||
id: "test-order-w-r",
|
||||
}),
|
||||
expect.objectContaining({
|
||||
id: "discount-order",
|
||||
}),
|
||||
])
|
||||
expect.objectContaining({
|
||||
id: "test-order-w-s",
|
||||
}),
|
||||
expect.objectContaining({
|
||||
id: "test-order-w-f",
|
||||
}),
|
||||
expect.objectContaining({
|
||||
id: "test-order-w-r",
|
||||
}),
|
||||
expect.objectContaining({
|
||||
id: "discount-order",
|
||||
}),
|
||||
])
|
||||
)
|
||||
})
|
||||
|
||||
it.each([
|
||||
@@ -1864,11 +1897,14 @@ describe("/admin/orders", () => {
|
||||
const cart = response.data.cart
|
||||
const items = cart.items
|
||||
const [returnItem] = items.filter((i) => i.is_return)
|
||||
expect(returnItem.adjustments).toEqual([
|
||||
expect.objectContaining({
|
||||
amount: -800,
|
||||
}),
|
||||
])
|
||||
expect(returnItem.adjustments).toHaveLength(1)
|
||||
expect(returnItem.adjustments).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
amount: -800,
|
||||
}),
|
||||
])
|
||||
)
|
||||
expect(cart.total).toBe(7200)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -363,10 +363,13 @@ describe("/admin/price-lists", () => {
|
||||
|
||||
expect(response.status).toEqual(200)
|
||||
expect(response.data.price_lists.length).toEqual(2)
|
||||
expect(response.data.price_lists).toEqual([
|
||||
expect.objectContaining({ id: "test-list-cgroup-1" }),
|
||||
expect.objectContaining({ id: "test-list-cgroup-2" }),
|
||||
])
|
||||
expect(response.data.price_lists).toHaveLength(2)
|
||||
expect(response.data.price_lists).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({ id: "test-list-cgroup-1" }),
|
||||
expect.objectContaining({ id: "test-list-cgroup-2" }),
|
||||
])
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -1177,52 +1180,55 @@ describe("/admin/price-lists", () => {
|
||||
|
||||
expect(response.status).toEqual(200)
|
||||
expect(response.data.count).toEqual(2)
|
||||
expect(response.data.products).toEqual([
|
||||
expect.objectContaining({
|
||||
id: "test-prod-1",
|
||||
variants: [
|
||||
expect.objectContaining({
|
||||
id: "test-variant-1",
|
||||
prices: [
|
||||
expect.objectContaining({ currency_code: "usd", amount: 100 }),
|
||||
expect.objectContaining({
|
||||
currency_code: "usd",
|
||||
amount: 150,
|
||||
price_list_id: "test-list",
|
||||
}),
|
||||
],
|
||||
}),
|
||||
expect.objectContaining({
|
||||
id: "test-variant-2",
|
||||
prices: [
|
||||
expect.objectContaining({ currency_code: "usd", amount: 100 }),
|
||||
],
|
||||
}),
|
||||
],
|
||||
}),
|
||||
expect.objectContaining({
|
||||
id: "test-prod-2",
|
||||
variants: [
|
||||
expect.objectContaining({
|
||||
id: "test-variant-3",
|
||||
prices: [
|
||||
expect.objectContaining({ currency_code: "usd", amount: 100 }),
|
||||
],
|
||||
}),
|
||||
expect.objectContaining({
|
||||
id: "test-variant-4",
|
||||
prices: [
|
||||
expect.objectContaining({ currency_code: "usd", amount: 100 }),
|
||||
expect.objectContaining({
|
||||
currency_code: "usd",
|
||||
amount: 150,
|
||||
price_list_id: "test-list",
|
||||
}),
|
||||
],
|
||||
}),
|
||||
],
|
||||
}),
|
||||
])
|
||||
expect(response.data.products).toHaveLength(2)
|
||||
expect(response.data.products).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
id: "test-prod-1",
|
||||
variants: [
|
||||
expect.objectContaining({
|
||||
id: "test-variant-1",
|
||||
prices: [
|
||||
expect.objectContaining({ currency_code: "usd", amount: 100 }),
|
||||
expect.objectContaining({
|
||||
currency_code: "usd",
|
||||
amount: 150,
|
||||
price_list_id: "test-list",
|
||||
}),
|
||||
],
|
||||
}),
|
||||
expect.objectContaining({
|
||||
id: "test-variant-2",
|
||||
prices: [
|
||||
expect.objectContaining({ currency_code: "usd", amount: 100 }),
|
||||
],
|
||||
}),
|
||||
],
|
||||
}),
|
||||
expect.objectContaining({
|
||||
id: "test-prod-2",
|
||||
variants: [
|
||||
expect.objectContaining({
|
||||
id: "test-variant-3",
|
||||
prices: [
|
||||
expect.objectContaining({ currency_code: "usd", amount: 100 }),
|
||||
],
|
||||
}),
|
||||
expect.objectContaining({
|
||||
id: "test-variant-4",
|
||||
prices: [
|
||||
expect.objectContaining({ currency_code: "usd", amount: 100 }),
|
||||
expect.objectContaining({
|
||||
currency_code: "usd",
|
||||
amount: 150,
|
||||
price_list_id: "test-list",
|
||||
}),
|
||||
],
|
||||
}),
|
||||
],
|
||||
}),
|
||||
])
|
||||
)
|
||||
})
|
||||
|
||||
it("lists only product 2", async () => {
|
||||
@@ -1240,9 +1246,12 @@ describe("/admin/price-lists", () => {
|
||||
|
||||
expect(response.status).toEqual(200)
|
||||
expect(response.data.count).toEqual(1)
|
||||
expect(response.data.products).toEqual([
|
||||
expect.objectContaining({ id: "test-prod-2" }),
|
||||
])
|
||||
expect(response.data.products).toHaveLength(1)
|
||||
expect(response.data.products).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({ id: "test-prod-2" }),
|
||||
])
|
||||
)
|
||||
})
|
||||
|
||||
it("lists products using free text search", async () => {
|
||||
@@ -1260,12 +1269,15 @@ describe("/admin/price-lists", () => {
|
||||
|
||||
expect(response.status).toEqual(200)
|
||||
expect(response.data.count).toEqual(1)
|
||||
expect(response.data.products).toEqual([
|
||||
expect.objectContaining({
|
||||
id: "test-prod-1",
|
||||
title: "MedusaHeadphones",
|
||||
}),
|
||||
])
|
||||
expect(response.data.products).toHaveLength(1)
|
||||
expect(response.data.products).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
id: "test-prod-1",
|
||||
title: "MedusaHeadphones",
|
||||
}),
|
||||
])
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
@@ -165,16 +165,19 @@ describe("/admin/products", () => {
|
||||
})
|
||||
|
||||
expect(response.status).toEqual(200)
|
||||
expect(response.data.products).toEqual([
|
||||
expect.objectContaining({
|
||||
id: "test-product_filtering_1",
|
||||
status: "proposed",
|
||||
}),
|
||||
expect.objectContaining({
|
||||
id: "test-product_filtering_2",
|
||||
status: "published",
|
||||
}),
|
||||
])
|
||||
expect(response.data.products).toHaveLength(2)
|
||||
expect(response.data.products).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
id: "test-product_filtering_1",
|
||||
status: "proposed",
|
||||
}),
|
||||
expect.objectContaining({
|
||||
id: "test-product_filtering_2",
|
||||
status: "published",
|
||||
}),
|
||||
])
|
||||
)
|
||||
|
||||
for (const notExpect of notExpected) {
|
||||
expect(response.data.products).toEqual(
|
||||
@@ -204,16 +207,19 @@ describe("/admin/products", () => {
|
||||
})
|
||||
|
||||
expect(response.status).toEqual(200)
|
||||
expect(response.data.products).toEqual([
|
||||
expect.objectContaining({
|
||||
id: "test-product_filtering_1",
|
||||
status: "proposed",
|
||||
}),
|
||||
expect.objectContaining({
|
||||
id: "test-product_filtering_2",
|
||||
status: "published",
|
||||
}),
|
||||
])
|
||||
expect(response.data.products).toHaveLength(2)
|
||||
expect(response.data.products).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
id: "test-product_filtering_1",
|
||||
status: "proposed",
|
||||
}),
|
||||
expect.objectContaining({
|
||||
id: "test-product_filtering_2",
|
||||
status: "published",
|
||||
}),
|
||||
])
|
||||
)
|
||||
|
||||
for (const notExpect of notExpected) {
|
||||
expect(response.data.products).toEqual(
|
||||
@@ -237,11 +243,14 @@ describe("/admin/products", () => {
|
||||
|
||||
expect(response.status).toEqual(200)
|
||||
expect(response.data.count).toEqual(1)
|
||||
expect(response.data.products).toEqual([
|
||||
expect.objectContaining({
|
||||
id: "test-product_filtering_4",
|
||||
}),
|
||||
])
|
||||
expect(response.data.products).toHaveLength(1)
|
||||
expect(response.data.products).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
id: "test-product_filtering_4",
|
||||
}),
|
||||
])
|
||||
)
|
||||
})
|
||||
|
||||
it("returns a list of products with free text query and limit", async () => {
|
||||
@@ -322,11 +331,14 @@ describe("/admin/products", () => {
|
||||
})
|
||||
|
||||
expect(response.status).toEqual(200)
|
||||
expect(response.data.products).toEqual([
|
||||
expect.objectContaining({
|
||||
id: "test-product_filtering_4",
|
||||
}),
|
||||
])
|
||||
expect(response.data.products).toHaveLength(1)
|
||||
expect(response.data.products).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
id: "test-product_filtering_4",
|
||||
}),
|
||||
])
|
||||
)
|
||||
})
|
||||
|
||||
it("returns a list of products in collection", async () => {
|
||||
@@ -348,16 +360,19 @@ describe("/admin/products", () => {
|
||||
})
|
||||
|
||||
expect(response.status).toEqual(200)
|
||||
expect(response.data.products).toEqual([
|
||||
expect.objectContaining({
|
||||
id: "test-product_filtering_1",
|
||||
collection_id: "test-collection1",
|
||||
}),
|
||||
expect.objectContaining({
|
||||
id: "test-product_filtering_3",
|
||||
collection_id: "test-collection1",
|
||||
}),
|
||||
])
|
||||
expect(response.data.products).toHaveLength(2)
|
||||
expect(response.data.products).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
id: "test-product_filtering_1",
|
||||
collection_id: "test-collection1",
|
||||
}),
|
||||
expect.objectContaining({
|
||||
id: "test-product_filtering_3",
|
||||
collection_id: "test-collection1",
|
||||
}),
|
||||
])
|
||||
)
|
||||
|
||||
for (const notExpect of notExpected) {
|
||||
expect(response.data.products).toEqual(
|
||||
@@ -431,13 +446,16 @@ describe("/admin/products", () => {
|
||||
})
|
||||
|
||||
expect(response.status).toEqual(200)
|
||||
expect(response.data.products).toEqual([
|
||||
expect.objectContaining({
|
||||
id: "test-product_filtering_3",
|
||||
collection_id: "test-collection1",
|
||||
tags: [expect.objectContaining({ id: "tag4" })],
|
||||
}),
|
||||
])
|
||||
expect(response.data.products).toHaveLength(1)
|
||||
expect(response.data.products).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
id: "test-product_filtering_3",
|
||||
collection_id: "test-collection1",
|
||||
tags: [expect.objectContaining({ id: "tag4" })],
|
||||
}),
|
||||
])
|
||||
)
|
||||
|
||||
for (const notExpect of notExpectedCollections) {
|
||||
expect(response.data.products).toEqual(
|
||||
|
||||
@@ -162,17 +162,20 @@ describe("/admin/regions", () => {
|
||||
console.log(err)
|
||||
})
|
||||
|
||||
expect(response.data.regions).toEqual([
|
||||
expect.objectContaining({
|
||||
id: "test-region-updated-1",
|
||||
}),
|
||||
expect.objectContaining({
|
||||
id: "test-region",
|
||||
}),
|
||||
expect.objectContaining({
|
||||
id: "test-region-updated",
|
||||
}),
|
||||
])
|
||||
expect(response.data.regions).toHaveLength(3)
|
||||
expect(response.data.regions).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
id: "test-region-updated-1",
|
||||
}),
|
||||
expect.objectContaining({
|
||||
id: "test-region",
|
||||
}),
|
||||
expect.objectContaining({
|
||||
id: "test-region-updated",
|
||||
}),
|
||||
])
|
||||
)
|
||||
expect(response.status).toEqual(200)
|
||||
})
|
||||
|
||||
@@ -189,14 +192,17 @@ describe("/admin/regions", () => {
|
||||
console.log(err)
|
||||
})
|
||||
|
||||
expect(response.data.regions).toEqual([
|
||||
expect.objectContaining({
|
||||
id: "test-region",
|
||||
}),
|
||||
expect.objectContaining({
|
||||
id: "test-region-updated",
|
||||
}),
|
||||
])
|
||||
expect(response.data.regions).toHaveLength(2)
|
||||
expect(response.data.regions).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
id: "test-region",
|
||||
}),
|
||||
expect.objectContaining({
|
||||
id: "test-region-updated",
|
||||
}),
|
||||
])
|
||||
)
|
||||
expect(response.status).toEqual(200)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -355,20 +355,23 @@ describe("/admin/return-reasons", () => {
|
||||
|
||||
expect(nested_response.status).toEqual(200)
|
||||
|
||||
expect(nested_response.data.return_reasons).toEqual([
|
||||
expect.objectContaining({
|
||||
label: "Wrong size",
|
||||
description: "Use this if the size was too big",
|
||||
value: "wrong_size",
|
||||
return_reason_children: expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
label: "Too Big",
|
||||
description: "Use this if the size was too big",
|
||||
value: "too_big",
|
||||
}),
|
||||
]),
|
||||
}),
|
||||
])
|
||||
expect(nested_response.data.return_reasons).toHaveLength(1)
|
||||
expect(nested_response.data.return_reasons).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
label: "Wrong size",
|
||||
description: "Use this if the size was too big",
|
||||
value: "wrong_size",
|
||||
return_reason_children: expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
label: "Too Big",
|
||||
description: "Use this if the size was too big",
|
||||
value: "too_big",
|
||||
}),
|
||||
]),
|
||||
}),
|
||||
])
|
||||
)
|
||||
})
|
||||
|
||||
it("list return reasons", async () => {
|
||||
@@ -401,11 +404,14 @@ describe("/admin/return-reasons", () => {
|
||||
})
|
||||
|
||||
expect(response.status).toEqual(200)
|
||||
expect(response.data.return_reasons).toEqual([
|
||||
expect.objectContaining({
|
||||
value: "too_big",
|
||||
}),
|
||||
])
|
||||
expect(response.data.return_reasons).toHaveLength(1)
|
||||
expect(response.data.return_reasons).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
value: "too_big",
|
||||
}),
|
||||
])
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
@@ -832,11 +832,13 @@ describe("sales channels", () => {
|
||||
|
||||
expect(response.status).toEqual(200)
|
||||
expect(response.data.orders.length).toEqual(1)
|
||||
expect(response.data.orders).toEqual([
|
||||
expect.objectContaining({
|
||||
id: order.id,
|
||||
}),
|
||||
])
|
||||
expect(response.data.orders).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
id: order.id,
|
||||
}),
|
||||
])
|
||||
)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user