fix(integration-tests): Use asymmetric matcher for arrays in tests (#1992)
This commit is contained in:
1 parent
73383cc466
commit
b3b69d7117
16 files changed
+935
-730
No files matched your search
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
Use asymetric matcher for arrays
|
||||||
@@ -331,12 +331,15 @@ describe("/admin/discounts", () => {
|
|||||||
})
|
})
|
||||||
expect(response.status).toEqual(200)
|
expect(response.status).toEqual(200)
|
||||||
expect(response.data.count).toEqual(1)
|
expect(response.data.count).toEqual(1)
|
||||||
expect(response.data.discounts).toEqual([
|
expect(response.data.discounts).toHaveLength(1)
|
||||||
expect.objectContaining({
|
expect(response.data.discounts).toEqual(
|
||||||
id: "fixed-discount",
|
expect.arrayContaining([
|
||||||
code: "fixed100",
|
expect.objectContaining({
|
||||||
}),
|
id: "fixed-discount",
|
||||||
])
|
code: "fixed100",
|
||||||
|
}),
|
||||||
|
])
|
||||||
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
it("fails when listing invalid discount types", async () => {
|
it("fails when listing invalid discount types", async () => {
|
||||||
@@ -394,12 +397,15 @@ describe("/admin/discounts", () => {
|
|||||||
})
|
})
|
||||||
expect(response.status).toEqual(200)
|
expect(response.status).toEqual(200)
|
||||||
expect(response.data.count).toEqual(1)
|
expect(response.data.count).toEqual(1)
|
||||||
expect(response.data.discounts).toEqual([
|
expect(response.data.discounts).toHaveLength(1)
|
||||||
expect.objectContaining({
|
expect(response.data.discounts).toEqual(
|
||||||
id: "dynamic-discount",
|
expect.arrayContaining([
|
||||||
code: "Dyn100",
|
expect.objectContaining({
|
||||||
}),
|
id: "dynamic-discount",
|
||||||
])
|
code: "Dyn100",
|
||||||
|
})
|
||||||
|
])
|
||||||
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
it("lists disabled discounts ", async () => {
|
it("lists disabled discounts ", async () => {
|
||||||
@@ -416,12 +422,15 @@ describe("/admin/discounts", () => {
|
|||||||
})
|
})
|
||||||
expect(response.status).toEqual(200)
|
expect(response.status).toEqual(200)
|
||||||
expect(response.data.count).toEqual(1)
|
expect(response.data.count).toEqual(1)
|
||||||
expect(response.data.discounts).toEqual([
|
expect(response.data.discounts).toHaveLength(1)
|
||||||
expect.objectContaining({
|
expect(response.data.discounts).toEqual(
|
||||||
id: "disabled-discount",
|
expect.arrayContaining([
|
||||||
code: "Dis100",
|
expect.objectContaining({
|
||||||
}),
|
id: "disabled-discount",
|
||||||
])
|
code: "Dis100",
|
||||||
|
}),
|
||||||
|
])
|
||||||
|
)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -614,16 +623,19 @@ describe("/admin/discounts", () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
expect(response.status).toEqual(200)
|
expect(response.status).toEqual(200)
|
||||||
expect(response.data.discount.rule.conditions).toEqual([
|
expect(response.data.discount.rule.conditions).toHaveLength(2)
|
||||||
expect.objectContaining({
|
expect(response.data.discount.rule.conditions).toEqual(
|
||||||
type: "products",
|
expect.arrayContaining([
|
||||||
operator: "in",
|
expect.objectContaining({
|
||||||
}),
|
type: "products",
|
||||||
expect.objectContaining({
|
operator: "in",
|
||||||
type: "product_types",
|
}),
|
||||||
operator: "not_in",
|
expect.objectContaining({
|
||||||
}),
|
type: "product_types",
|
||||||
])
|
operator: "not_in",
|
||||||
|
}),
|
||||||
|
])
|
||||||
|
)
|
||||||
|
|
||||||
const createdRule = response.data.discount.rule
|
const createdRule = response.data.discount.rule
|
||||||
const condsToUpdate = createdRule.conditions[0]
|
const condsToUpdate = createdRule.conditions[0]
|
||||||
|
|||||||
@@ -673,11 +673,14 @@ describe("/admin/orders", () => {
|
|||||||
)
|
)
|
||||||
|
|
||||||
expect(status).toEqual(200)
|
expect(status).toEqual(200)
|
||||||
expect(updateData.order.claims[0].shipping_methods).toEqual([
|
expect(updateData.order.claims[0].shipping_methods).toHaveLength(1)
|
||||||
expect.objectContaining({
|
expect(updateData.order.claims[0].shipping_methods).toEqual(
|
||||||
id: "test-method",
|
expect.arrayContaining([
|
||||||
}),
|
expect.objectContaining({
|
||||||
])
|
id: "test-method",
|
||||||
|
}),
|
||||||
|
])
|
||||||
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
it("updates claim items", async () => {
|
it("updates claim items", async () => {
|
||||||
@@ -827,19 +830,21 @@ describe("/admin/orders", () => {
|
|||||||
claim = updateData.order.claims[0]
|
claim = updateData.order.claims[0]
|
||||||
|
|
||||||
expect(claim.claim_items.length).toEqual(1)
|
expect(claim.claim_items.length).toEqual(1)
|
||||||
expect(claim.claim_items).toEqual([
|
expect(claim.claim_items).toEqual(
|
||||||
expect.objectContaining({
|
expect.arrayContaining([
|
||||||
id: claim.claim_items[0].id,
|
expect.objectContaining({
|
||||||
reason: "production_failure",
|
id: claim.claim_items[0].id,
|
||||||
note: "Something new",
|
reason: "production_failure",
|
||||||
images: [],
|
note: "Something new",
|
||||||
// tags: expect.arrayContaining([
|
images: [],
|
||||||
// expect.objectContaining({ value: "completely" }),
|
// tags: expect.arrayContaining([
|
||||||
// expect.objectContaining({ value: "new" }),
|
// expect.objectContaining({ value: "completely" }),
|
||||||
// expect.objectContaining({ value: "tags" }),
|
// expect.objectContaining({ value: "new" }),
|
||||||
// ]),
|
// expect.objectContaining({ value: "tags" }),
|
||||||
}),
|
// ]),
|
||||||
])
|
}),
|
||||||
|
])
|
||||||
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
it("fulfills a claim", async () => {
|
it("fulfills a claim", async () => {
|
||||||
@@ -892,27 +897,34 @@ describe("/admin/orders", () => {
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
expect(fulRes.status).toEqual(200)
|
expect(fulRes.status).toEqual(200)
|
||||||
expect(fulRes.data.order.claims).toEqual([
|
expect(fulRes.data.order.claims).toHaveLength(1)
|
||||||
expect.objectContaining({
|
expect(fulRes.data.order.claims).toEqual(
|
||||||
id: cid,
|
expect.arrayContaining([
|
||||||
order_id: "test-order",
|
expect.objectContaining({
|
||||||
fulfillment_status: "fulfilled",
|
id: cid,
|
||||||
}),
|
order_id: "test-order",
|
||||||
])
|
fulfillment_status: "fulfilled",
|
||||||
|
}),
|
||||||
|
])
|
||||||
|
)
|
||||||
|
|
||||||
const fid = fulRes.data.order.claims[0].fulfillments[0].id
|
const fid = fulRes.data.order.claims[0].fulfillments[0].id
|
||||||
const iid = fulRes.data.order.claims[0].additional_items[0].id
|
const iid = fulRes.data.order.claims[0].additional_items[0].id
|
||||||
expect(fulRes.data.order.claims[0].fulfillments).toEqual([
|
|
||||||
expect.objectContaining({
|
expect(fulRes.data.order.claims[0].fulfillments).toHaveLength(1)
|
||||||
items: [
|
expect(fulRes.data.order.claims[0].fulfillments).toEqual(
|
||||||
{
|
expect.arrayContaining([
|
||||||
fulfillment_id: fid,
|
expect.objectContaining({
|
||||||
item_id: iid,
|
items: [
|
||||||
quantity: 1,
|
{
|
||||||
},
|
fulfillment_id: fid,
|
||||||
],
|
item_id: iid,
|
||||||
}),
|
quantity: 1,
|
||||||
])
|
},
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
])
|
||||||
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
it("creates a claim on a claim additional item", async () => {
|
it("creates a claim on a claim additional item", async () => {
|
||||||
@@ -1318,14 +1330,17 @@ describe("/admin/orders", () => {
|
|||||||
expect(response.status).toEqual(200)
|
expect(response.status).toEqual(200)
|
||||||
|
|
||||||
expect(response.data.order.returns[0].refund_amount).toEqual(7200)
|
expect(response.data.order.returns[0].refund_amount).toEqual(7200)
|
||||||
expect(response.data.order.returns[0].items).toEqual([
|
expect(response.data.order.returns[0].items).toHaveLength(1)
|
||||||
expect.objectContaining({
|
expect(response.data.order.returns[0].items).toEqual(
|
||||||
item_id: "test-item",
|
expect.arrayContaining([
|
||||||
quantity: 1,
|
expect.objectContaining({
|
||||||
reason_id: rrId,
|
item_id: "test-item",
|
||||||
note: "TOO SMALL",
|
quantity: 1,
|
||||||
}),
|
reason_id: rrId,
|
||||||
])
|
note: "TOO SMALL",
|
||||||
|
}),
|
||||||
|
])
|
||||||
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
it("increases inventory_quantity when return is received", async () => {
|
it("increases inventory_quantity when return is received", async () => {
|
||||||
@@ -1420,28 +1435,31 @@ describe("/admin/orders", () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
expect(response.status).toEqual(200)
|
expect(response.status).toEqual(200)
|
||||||
expect(response.data.orders).toEqual([
|
expect(response.data.orders).toHaveLength(6)
|
||||||
expect.objectContaining({
|
expect(response.data.orders).toEqual(
|
||||||
id: "test-order",
|
expect.arrayContaining([
|
||||||
}),
|
expect.objectContaining({
|
||||||
|
id: "test-order",
|
||||||
|
}),
|
||||||
|
|
||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
id: "test-order-w-c",
|
id: "test-order-w-c",
|
||||||
}),
|
}),
|
||||||
|
|
||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
id: "test-order-w-s",
|
id: "test-order-w-s",
|
||||||
}),
|
}),
|
||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
id: "test-order-w-f",
|
id: "test-order-w-f",
|
||||||
}),
|
}),
|
||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
id: "test-order-w-r",
|
id: "test-order-w-r",
|
||||||
}),
|
}),
|
||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
id: "discount-order",
|
id: "discount-order",
|
||||||
}),
|
}),
|
||||||
])
|
])
|
||||||
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
it("lists all orders with a fulfillment status = fulfilled and payment status = captured", async () => {
|
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))
|
.catch((err) => console.log(err))
|
||||||
|
|
||||||
expect(response.status).toEqual(200)
|
expect(response.status).toEqual(200)
|
||||||
expect(response.data.orders).toEqual([
|
expect(response.data.orders).toHaveLength(2)
|
||||||
expect.objectContaining({
|
expect(response.data.orders).toEqual(
|
||||||
id: "test-order",
|
expect.arrayContaining([
|
||||||
}),
|
expect.objectContaining({
|
||||||
expect.objectContaining({
|
id: "test-order",
|
||||||
id: "discount-order",
|
}),
|
||||||
}),
|
expect.objectContaining({
|
||||||
])
|
id: "discount-order",
|
||||||
|
}),
|
||||||
|
])
|
||||||
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
it("fails to lists all orders with an invalid status", async () => {
|
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.status).toEqual(200)
|
||||||
expect(response.data.count).toEqual(1)
|
expect(response.data.count).toEqual(1)
|
||||||
expect(response.data.orders).toEqual([
|
expect(response.data.orders).toHaveLength(1)
|
||||||
expect.objectContaining({
|
expect(response.data.orders).toEqual(
|
||||||
id: "test-order",
|
expect.arrayContaining([
|
||||||
email: "test@email.com",
|
expect.objectContaining({
|
||||||
}),
|
id: "test-order",
|
||||||
])
|
email: "test@email.com",
|
||||||
|
}),
|
||||||
|
])
|
||||||
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
it("list all orders with matching shipping_address first name", async () => {
|
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.status).toEqual(200)
|
||||||
expect(response.data.orders).toEqual([
|
expect(response.data.orders).toHaveLength(6)
|
||||||
expect.objectContaining({
|
expect(response.data.orders).toEqual(
|
||||||
id: "test-order",
|
expect.arrayContaining([
|
||||||
}),
|
expect.objectContaining({
|
||||||
expect.objectContaining({
|
id: "test-order",
|
||||||
id: "test-order-w-c",
|
}),
|
||||||
}),
|
expect.objectContaining({
|
||||||
|
id: "test-order-w-c",
|
||||||
|
}),
|
||||||
|
|
||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
id: "test-order-w-s",
|
id: "test-order-w-s",
|
||||||
}),
|
}),
|
||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
id: "test-order-w-f",
|
id: "test-order-w-f",
|
||||||
}),
|
}),
|
||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
id: "test-order-w-r",
|
id: "test-order-w-r",
|
||||||
}),
|
}),
|
||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
id: "discount-order",
|
id: "discount-order",
|
||||||
}),
|
}),
|
||||||
])
|
])
|
||||||
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
it("successfully lists no orders with greater than", async () => {
|
it("successfully lists no orders with greater than", async () => {
|
||||||
@@ -1598,27 +1625,30 @@ describe("/admin/orders", () => {
|
|||||||
)
|
)
|
||||||
|
|
||||||
expect(response.status).toEqual(200)
|
expect(response.status).toEqual(200)
|
||||||
expect(response.data.orders).toEqual([
|
expect(response.data.orders).toHaveLength(6)
|
||||||
expect.objectContaining({
|
expect(response.data.orders).toEqual(
|
||||||
id: "test-order",
|
expect.arrayContaining([
|
||||||
}),
|
expect.objectContaining({
|
||||||
expect.objectContaining({
|
id: "test-order",
|
||||||
id: "test-order-w-c",
|
}),
|
||||||
}),
|
expect.objectContaining({
|
||||||
|
id: "test-order-w-c",
|
||||||
|
}),
|
||||||
|
|
||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
id: "test-order-w-s",
|
id: "test-order-w-s",
|
||||||
}),
|
}),
|
||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
id: "test-order-w-f",
|
id: "test-order-w-f",
|
||||||
}),
|
}),
|
||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
id: "test-order-w-r",
|
id: "test-order-w-r",
|
||||||
}),
|
}),
|
||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
id: "discount-order",
|
id: "discount-order",
|
||||||
}),
|
}),
|
||||||
])
|
])
|
||||||
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
it("successfully lists no orders with less than", async () => {
|
it("successfully lists no orders with less than", async () => {
|
||||||
@@ -1650,27 +1680,30 @@ describe("/admin/orders", () => {
|
|||||||
)
|
)
|
||||||
|
|
||||||
expect(response.status).toEqual(200)
|
expect(response.status).toEqual(200)
|
||||||
expect(response.data.orders).toEqual([
|
expect(response.data.orders).toHaveLength(6)
|
||||||
expect.objectContaining({
|
expect(response.data.orders).toEqual(
|
||||||
id: "test-order",
|
expect.arrayContaining([
|
||||||
}),
|
expect.objectContaining({
|
||||||
expect.objectContaining({
|
id: "test-order",
|
||||||
id: "test-order-w-c",
|
}),
|
||||||
}),
|
expect.objectContaining({
|
||||||
|
id: "test-order-w-c",
|
||||||
|
}),
|
||||||
|
|
||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
id: "test-order-w-s",
|
id: "test-order-w-s",
|
||||||
}),
|
}),
|
||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
id: "test-order-w-f",
|
id: "test-order-w-f",
|
||||||
}),
|
}),
|
||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
id: "test-order-w-r",
|
id: "test-order-w-r",
|
||||||
}),
|
}),
|
||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
id: "discount-order",
|
id: "discount-order",
|
||||||
}),
|
}),
|
||||||
])
|
])
|
||||||
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
it.each([
|
it.each([
|
||||||
@@ -1864,11 +1897,14 @@ describe("/admin/orders", () => {
|
|||||||
const cart = response.data.cart
|
const cart = response.data.cart
|
||||||
const items = cart.items
|
const items = cart.items
|
||||||
const [returnItem] = items.filter((i) => i.is_return)
|
const [returnItem] = items.filter((i) => i.is_return)
|
||||||
expect(returnItem.adjustments).toEqual([
|
expect(returnItem.adjustments).toHaveLength(1)
|
||||||
expect.objectContaining({
|
expect(returnItem.adjustments).toEqual(
|
||||||
amount: -800,
|
expect.arrayContaining([
|
||||||
}),
|
expect.objectContaining({
|
||||||
])
|
amount: -800,
|
||||||
|
}),
|
||||||
|
])
|
||||||
|
)
|
||||||
expect(cart.total).toBe(7200)
|
expect(cart.total).toBe(7200)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -363,10 +363,13 @@ describe("/admin/price-lists", () => {
|
|||||||
|
|
||||||
expect(response.status).toEqual(200)
|
expect(response.status).toEqual(200)
|
||||||
expect(response.data.price_lists.length).toEqual(2)
|
expect(response.data.price_lists.length).toEqual(2)
|
||||||
expect(response.data.price_lists).toEqual([
|
expect(response.data.price_lists).toHaveLength(2)
|
||||||
expect.objectContaining({ id: "test-list-cgroup-1" }),
|
expect(response.data.price_lists).toEqual(
|
||||||
expect.objectContaining({ id: "test-list-cgroup-2" }),
|
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.status).toEqual(200)
|
||||||
expect(response.data.count).toEqual(2)
|
expect(response.data.count).toEqual(2)
|
||||||
expect(response.data.products).toEqual([
|
expect(response.data.products).toHaveLength(2)
|
||||||
expect.objectContaining({
|
expect(response.data.products).toEqual(
|
||||||
id: "test-prod-1",
|
expect.arrayContaining([
|
||||||
variants: [
|
expect.objectContaining({
|
||||||
expect.objectContaining({
|
id: "test-prod-1",
|
||||||
id: "test-variant-1",
|
variants: [
|
||||||
prices: [
|
expect.objectContaining({
|
||||||
expect.objectContaining({ currency_code: "usd", amount: 100 }),
|
id: "test-variant-1",
|
||||||
expect.objectContaining({
|
prices: [
|
||||||
currency_code: "usd",
|
expect.objectContaining({ currency_code: "usd", amount: 100 }),
|
||||||
amount: 150,
|
expect.objectContaining({
|
||||||
price_list_id: "test-list",
|
currency_code: "usd",
|
||||||
}),
|
amount: 150,
|
||||||
],
|
price_list_id: "test-list",
|
||||||
}),
|
}),
|
||||||
expect.objectContaining({
|
],
|
||||||
id: "test-variant-2",
|
}),
|
||||||
prices: [
|
expect.objectContaining({
|
||||||
expect.objectContaining({ currency_code: "usd", amount: 100 }),
|
id: "test-variant-2",
|
||||||
],
|
prices: [
|
||||||
}),
|
expect.objectContaining({ currency_code: "usd", amount: 100 }),
|
||||||
],
|
],
|
||||||
}),
|
}),
|
||||||
expect.objectContaining({
|
],
|
||||||
id: "test-prod-2",
|
}),
|
||||||
variants: [
|
expect.objectContaining({
|
||||||
expect.objectContaining({
|
id: "test-prod-2",
|
||||||
id: "test-variant-3",
|
variants: [
|
||||||
prices: [
|
expect.objectContaining({
|
||||||
expect.objectContaining({ currency_code: "usd", amount: 100 }),
|
id: "test-variant-3",
|
||||||
],
|
prices: [
|
||||||
}),
|
expect.objectContaining({ currency_code: "usd", amount: 100 }),
|
||||||
expect.objectContaining({
|
],
|
||||||
id: "test-variant-4",
|
}),
|
||||||
prices: [
|
expect.objectContaining({
|
||||||
expect.objectContaining({ currency_code: "usd", amount: 100 }),
|
id: "test-variant-4",
|
||||||
expect.objectContaining({
|
prices: [
|
||||||
currency_code: "usd",
|
expect.objectContaining({ currency_code: "usd", amount: 100 }),
|
||||||
amount: 150,
|
expect.objectContaining({
|
||||||
price_list_id: "test-list",
|
currency_code: "usd",
|
||||||
}),
|
amount: 150,
|
||||||
],
|
price_list_id: "test-list",
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
}),
|
}),
|
||||||
])
|
],
|
||||||
|
}),
|
||||||
|
])
|
||||||
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
it("lists only product 2", async () => {
|
it("lists only product 2", async () => {
|
||||||
@@ -1240,9 +1246,12 @@ describe("/admin/price-lists", () => {
|
|||||||
|
|
||||||
expect(response.status).toEqual(200)
|
expect(response.status).toEqual(200)
|
||||||
expect(response.data.count).toEqual(1)
|
expect(response.data.count).toEqual(1)
|
||||||
expect(response.data.products).toEqual([
|
expect(response.data.products).toHaveLength(1)
|
||||||
expect.objectContaining({ id: "test-prod-2" }),
|
expect(response.data.products).toEqual(
|
||||||
])
|
expect.arrayContaining([
|
||||||
|
expect.objectContaining({ id: "test-prod-2" }),
|
||||||
|
])
|
||||||
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
it("lists products using free text search", async () => {
|
it("lists products using free text search", async () => {
|
||||||
@@ -1260,12 +1269,15 @@ describe("/admin/price-lists", () => {
|
|||||||
|
|
||||||
expect(response.status).toEqual(200)
|
expect(response.status).toEqual(200)
|
||||||
expect(response.data.count).toEqual(1)
|
expect(response.data.count).toEqual(1)
|
||||||
expect(response.data.products).toEqual([
|
expect(response.data.products).toHaveLength(1)
|
||||||
expect.objectContaining({
|
expect(response.data.products).toEqual(
|
||||||
id: "test-prod-1",
|
expect.arrayContaining([
|
||||||
title: "MedusaHeadphones",
|
expect.objectContaining({
|
||||||
}),
|
id: "test-prod-1",
|
||||||
])
|
title: "MedusaHeadphones",
|
||||||
|
}),
|
||||||
|
])
|
||||||
|
)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -165,16 +165,19 @@ describe("/admin/products", () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
expect(response.status).toEqual(200)
|
expect(response.status).toEqual(200)
|
||||||
expect(response.data.products).toEqual([
|
expect(response.data.products).toHaveLength(2)
|
||||||
expect.objectContaining({
|
expect(response.data.products).toEqual(
|
||||||
id: "test-product_filtering_1",
|
expect.arrayContaining([
|
||||||
status: "proposed",
|
expect.objectContaining({
|
||||||
}),
|
id: "test-product_filtering_1",
|
||||||
expect.objectContaining({
|
status: "proposed",
|
||||||
id: "test-product_filtering_2",
|
}),
|
||||||
status: "published",
|
expect.objectContaining({
|
||||||
}),
|
id: "test-product_filtering_2",
|
||||||
])
|
status: "published",
|
||||||
|
}),
|
||||||
|
])
|
||||||
|
)
|
||||||
|
|
||||||
for (const notExpect of notExpected) {
|
for (const notExpect of notExpected) {
|
||||||
expect(response.data.products).toEqual(
|
expect(response.data.products).toEqual(
|
||||||
@@ -204,16 +207,19 @@ describe("/admin/products", () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
expect(response.status).toEqual(200)
|
expect(response.status).toEqual(200)
|
||||||
expect(response.data.products).toEqual([
|
expect(response.data.products).toHaveLength(2)
|
||||||
expect.objectContaining({
|
expect(response.data.products).toEqual(
|
||||||
id: "test-product_filtering_1",
|
expect.arrayContaining([
|
||||||
status: "proposed",
|
expect.objectContaining({
|
||||||
}),
|
id: "test-product_filtering_1",
|
||||||
expect.objectContaining({
|
status: "proposed",
|
||||||
id: "test-product_filtering_2",
|
}),
|
||||||
status: "published",
|
expect.objectContaining({
|
||||||
}),
|
id: "test-product_filtering_2",
|
||||||
])
|
status: "published",
|
||||||
|
}),
|
||||||
|
])
|
||||||
|
)
|
||||||
|
|
||||||
for (const notExpect of notExpected) {
|
for (const notExpect of notExpected) {
|
||||||
expect(response.data.products).toEqual(
|
expect(response.data.products).toEqual(
|
||||||
@@ -237,11 +243,14 @@ describe("/admin/products", () => {
|
|||||||
|
|
||||||
expect(response.status).toEqual(200)
|
expect(response.status).toEqual(200)
|
||||||
expect(response.data.count).toEqual(1)
|
expect(response.data.count).toEqual(1)
|
||||||
expect(response.data.products).toEqual([
|
expect(response.data.products).toHaveLength(1)
|
||||||
expect.objectContaining({
|
expect(response.data.products).toEqual(
|
||||||
id: "test-product_filtering_4",
|
expect.arrayContaining([
|
||||||
}),
|
expect.objectContaining({
|
||||||
])
|
id: "test-product_filtering_4",
|
||||||
|
}),
|
||||||
|
])
|
||||||
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
it("returns a list of products with free text query and limit", async () => {
|
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.status).toEqual(200)
|
||||||
expect(response.data.products).toEqual([
|
expect(response.data.products).toHaveLength(1)
|
||||||
expect.objectContaining({
|
expect(response.data.products).toEqual(
|
||||||
id: "test-product_filtering_4",
|
expect.arrayContaining([
|
||||||
}),
|
expect.objectContaining({
|
||||||
])
|
id: "test-product_filtering_4",
|
||||||
|
}),
|
||||||
|
])
|
||||||
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
it("returns a list of products in collection", async () => {
|
it("returns a list of products in collection", async () => {
|
||||||
@@ -348,16 +360,19 @@ describe("/admin/products", () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
expect(response.status).toEqual(200)
|
expect(response.status).toEqual(200)
|
||||||
expect(response.data.products).toEqual([
|
expect(response.data.products).toHaveLength(2)
|
||||||
expect.objectContaining({
|
expect(response.data.products).toEqual(
|
||||||
id: "test-product_filtering_1",
|
expect.arrayContaining([
|
||||||
collection_id: "test-collection1",
|
expect.objectContaining({
|
||||||
}),
|
id: "test-product_filtering_1",
|
||||||
expect.objectContaining({
|
collection_id: "test-collection1",
|
||||||
id: "test-product_filtering_3",
|
}),
|
||||||
collection_id: "test-collection1",
|
expect.objectContaining({
|
||||||
}),
|
id: "test-product_filtering_3",
|
||||||
])
|
collection_id: "test-collection1",
|
||||||
|
}),
|
||||||
|
])
|
||||||
|
)
|
||||||
|
|
||||||
for (const notExpect of notExpected) {
|
for (const notExpect of notExpected) {
|
||||||
expect(response.data.products).toEqual(
|
expect(response.data.products).toEqual(
|
||||||
@@ -431,13 +446,16 @@ describe("/admin/products", () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
expect(response.status).toEqual(200)
|
expect(response.status).toEqual(200)
|
||||||
expect(response.data.products).toEqual([
|
expect(response.data.products).toHaveLength(1)
|
||||||
expect.objectContaining({
|
expect(response.data.products).toEqual(
|
||||||
id: "test-product_filtering_3",
|
expect.arrayContaining([
|
||||||
collection_id: "test-collection1",
|
expect.objectContaining({
|
||||||
tags: [expect.objectContaining({ id: "tag4" })],
|
id: "test-product_filtering_3",
|
||||||
}),
|
collection_id: "test-collection1",
|
||||||
])
|
tags: [expect.objectContaining({ id: "tag4" })],
|
||||||
|
}),
|
||||||
|
])
|
||||||
|
)
|
||||||
|
|
||||||
for (const notExpect of notExpectedCollections) {
|
for (const notExpect of notExpectedCollections) {
|
||||||
expect(response.data.products).toEqual(
|
expect(response.data.products).toEqual(
|
||||||
|
|||||||
@@ -162,17 +162,20 @@ describe("/admin/regions", () => {
|
|||||||
console.log(err)
|
console.log(err)
|
||||||
})
|
})
|
||||||
|
|
||||||
expect(response.data.regions).toEqual([
|
expect(response.data.regions).toHaveLength(3)
|
||||||
expect.objectContaining({
|
expect(response.data.regions).toEqual(
|
||||||
id: "test-region-updated-1",
|
expect.arrayContaining([
|
||||||
}),
|
expect.objectContaining({
|
||||||
expect.objectContaining({
|
id: "test-region-updated-1",
|
||||||
id: "test-region",
|
}),
|
||||||
}),
|
expect.objectContaining({
|
||||||
expect.objectContaining({
|
id: "test-region",
|
||||||
id: "test-region-updated",
|
}),
|
||||||
}),
|
expect.objectContaining({
|
||||||
])
|
id: "test-region-updated",
|
||||||
|
}),
|
||||||
|
])
|
||||||
|
)
|
||||||
expect(response.status).toEqual(200)
|
expect(response.status).toEqual(200)
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -189,14 +192,17 @@ describe("/admin/regions", () => {
|
|||||||
console.log(err)
|
console.log(err)
|
||||||
})
|
})
|
||||||
|
|
||||||
expect(response.data.regions).toEqual([
|
expect(response.data.regions).toHaveLength(2)
|
||||||
expect.objectContaining({
|
expect(response.data.regions).toEqual(
|
||||||
id: "test-region",
|
expect.arrayContaining([
|
||||||
}),
|
expect.objectContaining({
|
||||||
expect.objectContaining({
|
id: "test-region",
|
||||||
id: "test-region-updated",
|
}),
|
||||||
}),
|
expect.objectContaining({
|
||||||
])
|
id: "test-region-updated",
|
||||||
|
}),
|
||||||
|
])
|
||||||
|
)
|
||||||
expect(response.status).toEqual(200)
|
expect(response.status).toEqual(200)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -355,20 +355,23 @@ describe("/admin/return-reasons", () => {
|
|||||||
|
|
||||||
expect(nested_response.status).toEqual(200)
|
expect(nested_response.status).toEqual(200)
|
||||||
|
|
||||||
expect(nested_response.data.return_reasons).toEqual([
|
expect(nested_response.data.return_reasons).toHaveLength(1)
|
||||||
expect.objectContaining({
|
expect(nested_response.data.return_reasons).toEqual(
|
||||||
label: "Wrong size",
|
expect.arrayContaining([
|
||||||
description: "Use this if the size was too big",
|
expect.objectContaining({
|
||||||
value: "wrong_size",
|
label: "Wrong size",
|
||||||
return_reason_children: expect.arrayContaining([
|
description: "Use this if the size was too big",
|
||||||
expect.objectContaining({
|
value: "wrong_size",
|
||||||
label: "Too Big",
|
return_reason_children: expect.arrayContaining([
|
||||||
description: "Use this if the size was too big",
|
expect.objectContaining({
|
||||||
value: "too_big",
|
label: "Too Big",
|
||||||
}),
|
description: "Use this if the size was too big",
|
||||||
]),
|
value: "too_big",
|
||||||
}),
|
}),
|
||||||
])
|
]),
|
||||||
|
}),
|
||||||
|
])
|
||||||
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
it("list return reasons", async () => {
|
it("list return reasons", async () => {
|
||||||
@@ -401,11 +404,14 @@ describe("/admin/return-reasons", () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
expect(response.status).toEqual(200)
|
expect(response.status).toEqual(200)
|
||||||
expect(response.data.return_reasons).toEqual([
|
expect(response.data.return_reasons).toHaveLength(1)
|
||||||
expect.objectContaining({
|
expect(response.data.return_reasons).toEqual(
|
||||||
value: "too_big",
|
expect.arrayContaining([
|
||||||
}),
|
expect.objectContaining({
|
||||||
])
|
value: "too_big",
|
||||||
|
}),
|
||||||
|
])
|
||||||
|
)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -832,11 +832,13 @@ describe("sales channels", () => {
|
|||||||
|
|
||||||
expect(response.status).toEqual(200)
|
expect(response.status).toEqual(200)
|
||||||
expect(response.data.orders.length).toEqual(1)
|
expect(response.data.orders.length).toEqual(1)
|
||||||
expect(response.data.orders).toEqual([
|
expect(response.data.orders).toEqual(
|
||||||
expect.objectContaining({
|
expect.arrayContaining([
|
||||||
id: order.id,
|
expect.objectContaining({
|
||||||
}),
|
id: order.id,
|
||||||
])
|
}),
|
||||||
|
])
|
||||||
|
)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -72,13 +72,16 @@ describe("/admin/orders", () => {
|
|||||||
* 1000 * 1.125 = 1125
|
* 1000 * 1.125 = 1125
|
||||||
*/
|
*/
|
||||||
expect(response.data.order.returns[0].refund_amount).toEqual(1125)
|
expect(response.data.order.returns[0].refund_amount).toEqual(1125)
|
||||||
expect(response.data.order.returns[0].items).toEqual([
|
expect(response.data.order.returns[0].items).toHaveLength(1)
|
||||||
expect.objectContaining({
|
expect(response.data.order.returns[0].items).toEqual(
|
||||||
item_id: "test-item",
|
expect.arrayContaining([
|
||||||
quantity: 1,
|
expect.objectContaining({
|
||||||
note: "TOO SMALL",
|
item_id: "test-item",
|
||||||
}),
|
quantity: 1,
|
||||||
])
|
note: "TOO SMALL",
|
||||||
|
}),
|
||||||
|
])
|
||||||
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
test("creates a return w. new tax system", async () => {
|
test("creates a return w. new tax system", async () => {
|
||||||
@@ -113,13 +116,16 @@ describe("/admin/orders", () => {
|
|||||||
*/
|
*/
|
||||||
expect(response.data.order.returns[0].refund_amount).toEqual(1200)
|
expect(response.data.order.returns[0].refund_amount).toEqual(1200)
|
||||||
|
|
||||||
expect(response.data.order.returns[0].items).toEqual([
|
expect(response.data.order.returns[0].items).toHaveLength(1)
|
||||||
expect.objectContaining({
|
expect(response.data.order.returns[0].items).toEqual(
|
||||||
item_id: "test-item",
|
expect.arrayContaining([
|
||||||
quantity: 1,
|
expect.objectContaining({
|
||||||
note: "TOO SMALL",
|
item_id: "test-item",
|
||||||
}),
|
quantity: 1,
|
||||||
])
|
note: "TOO SMALL",
|
||||||
|
}),
|
||||||
|
])
|
||||||
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
test("creates a return w. new tax system + shipping", async () => {
|
test("creates a return w. new tax system + shipping", async () => {
|
||||||
@@ -163,20 +169,26 @@ describe("/admin/orders", () => {
|
|||||||
* shipping method will have 12.5 rate 1000 * 1.125 = 1125
|
* shipping method will have 12.5 rate 1000 * 1.125 = 1125
|
||||||
*/
|
*/
|
||||||
expect(response.data.order.returns[0].refund_amount).toEqual(75)
|
expect(response.data.order.returns[0].refund_amount).toEqual(75)
|
||||||
expect(response.data.order.returns[0].shipping_method.tax_lines).toEqual([
|
expect(response.data.order.returns[0].shipping_method.tax_lines).toHaveLength(1)
|
||||||
expect.objectContaining({
|
expect(response.data.order.returns[0].shipping_method.tax_lines).toEqual(
|
||||||
rate: 12.5,
|
expect.arrayContaining([
|
||||||
name: "default",
|
expect.objectContaining({
|
||||||
code: "default",
|
rate: 12.5,
|
||||||
}),
|
name: "default",
|
||||||
])
|
code: "default",
|
||||||
expect(response.data.order.returns[0].items).toEqual([
|
}),
|
||||||
expect.objectContaining({
|
])
|
||||||
item_id: "test-item",
|
)
|
||||||
quantity: 1,
|
expect(response.data.order.returns[0].items).toHaveLength(1)
|
||||||
note: "TOO SMALL",
|
expect(response.data.order.returns[0].items).toEqual(
|
||||||
}),
|
expect.arrayContaining([
|
||||||
])
|
expect.objectContaining({
|
||||||
|
item_id: "test-item",
|
||||||
|
quantity: 1,
|
||||||
|
note: "TOO SMALL",
|
||||||
|
}),
|
||||||
|
])
|
||||||
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
test("creates a return w. discount", async () => {
|
test("creates a return w. discount", async () => {
|
||||||
@@ -214,13 +226,16 @@ describe("/admin/orders", () => {
|
|||||||
*/
|
*/
|
||||||
expect(response.data.order.returns[0].refund_amount).toEqual(1080)
|
expect(response.data.order.returns[0].refund_amount).toEqual(1080)
|
||||||
|
|
||||||
expect(response.data.order.returns[0].items).toEqual([
|
expect(response.data.order.returns[0].items).toHaveLength(1)
|
||||||
expect.objectContaining({
|
expect(response.data.order.returns[0].items).toEqual(
|
||||||
item_id: "test-item",
|
expect.arrayContaining([
|
||||||
quantity: 1,
|
expect.objectContaining({
|
||||||
note: "TOO SMALL",
|
item_id: "test-item",
|
||||||
}),
|
quantity: 1,
|
||||||
])
|
note: "TOO SMALL",
|
||||||
|
}),
|
||||||
|
])
|
||||||
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
test("receives a return with a claimed line item", async () => {
|
test("receives a return with a claimed line item", async () => {
|
||||||
|
|||||||
@@ -155,17 +155,20 @@ describe("/store/carts", () => {
|
|||||||
response.data.cart.items.sort((a, b) => a.quantity - b.quantity)
|
response.data.cart.items.sort((a, b) => a.quantity - b.quantity)
|
||||||
|
|
||||||
expect(response.status).toEqual(200)
|
expect(response.status).toEqual(200)
|
||||||
expect(response.data.cart.items).toEqual([
|
expect(response.data.cart.items).toHaveLength(2)
|
||||||
expect.objectContaining({
|
expect(response.data.cart.items).toEqual(
|
||||||
variant_id: "test-variant_1",
|
expect.arrayContaining([
|
||||||
quantity: 1,
|
expect.objectContaining({
|
||||||
}),
|
variant_id: "test-variant_1",
|
||||||
expect.objectContaining({
|
quantity: 1,
|
||||||
variant_id: "test-variant-sale",
|
}),
|
||||||
quantity: 2,
|
expect.objectContaining({
|
||||||
unit_price: 800,
|
variant_id: "test-variant-sale",
|
||||||
}),
|
quantity: 2,
|
||||||
])
|
unit_price: 800,
|
||||||
|
}),
|
||||||
|
])
|
||||||
|
)
|
||||||
|
|
||||||
const getRes = await api.post(`/store/carts/${response.data.cart.id}`)
|
const getRes = await api.post(`/store/carts/${response.data.cart.id}`)
|
||||||
expect(getRes.status).toEqual(200)
|
expect(getRes.status).toEqual(200)
|
||||||
@@ -235,15 +238,18 @@ describe("/store/carts", () => {
|
|||||||
)
|
)
|
||||||
.catch((err) => console.log(err))
|
.catch((err) => console.log(err))
|
||||||
|
|
||||||
expect(response.data.cart.items).toEqual([
|
expect(response.data.cart.items).toHaveLength(1)
|
||||||
expect.objectContaining({
|
expect(response.data.cart.items).toEqual(
|
||||||
cart_id: "test-cart",
|
expect.arrayContaining([
|
||||||
unit_price: 1000,
|
expect.objectContaining({
|
||||||
variant_id: "test-variant-quantity",
|
cart_id: "test-cart",
|
||||||
quantity: 1,
|
unit_price: 1000,
|
||||||
adjustments: [],
|
variant_id: "test-variant-quantity",
|
||||||
}),
|
quantity: 1,
|
||||||
])
|
adjustments: [],
|
||||||
|
}),
|
||||||
|
])
|
||||||
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
it("adds line item to cart containing a total fixed discount", async () => {
|
it("adds line item to cart containing a total fixed discount", async () => {
|
||||||
@@ -260,21 +266,24 @@ describe("/store/carts", () => {
|
|||||||
)
|
)
|
||||||
.catch((err) => console.log(err))
|
.catch((err) => console.log(err))
|
||||||
|
|
||||||
expect(response.data.cart.items).toEqual([
|
expect(response.data.cart.items).toHaveLength(1)
|
||||||
expect.objectContaining({
|
expect(response.data.cart.items).toEqual(
|
||||||
cart_id: "test-cart-w-total-fixed-discount",
|
expect.arrayContaining([
|
||||||
unit_price: 1000,
|
expect.objectContaining({
|
||||||
variant_id: "test-variant-quantity",
|
cart_id: "test-cart-w-total-fixed-discount",
|
||||||
quantity: 2,
|
unit_price: 1000,
|
||||||
adjustments: [
|
variant_id: "test-variant-quantity",
|
||||||
expect.objectContaining({
|
quantity: 2,
|
||||||
amount: 100,
|
adjustments: [
|
||||||
discount_id: "total-fixed-100",
|
expect.objectContaining({
|
||||||
description: "discount",
|
amount: 100,
|
||||||
}),
|
discount_id: "total-fixed-100",
|
||||||
],
|
description: "discount",
|
||||||
}),
|
}),
|
||||||
])
|
],
|
||||||
|
}),
|
||||||
|
])
|
||||||
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
it("adds line item to cart containing a total percentage discount", async () => {
|
it("adds line item to cart containing a total percentage discount", async () => {
|
||||||
@@ -291,21 +300,24 @@ describe("/store/carts", () => {
|
|||||||
)
|
)
|
||||||
.catch((err) => console.log(err))
|
.catch((err) => console.log(err))
|
||||||
|
|
||||||
expect(response.data.cart.items).toEqual([
|
expect(response.data.cart.items).toHaveLength(1)
|
||||||
expect.objectContaining({
|
expect(response.data.cart.items).toEqual(
|
||||||
cart_id: "test-cart-w-total-percentage-discount",
|
expect.arrayContaining([
|
||||||
unit_price: 1000,
|
expect.objectContaining({
|
||||||
variant_id: "test-variant-quantity",
|
cart_id: "test-cart-w-total-percentage-discount",
|
||||||
quantity: 2,
|
unit_price: 1000,
|
||||||
adjustments: [
|
variant_id: "test-variant-quantity",
|
||||||
expect.objectContaining({
|
quantity: 2,
|
||||||
amount: 200,
|
adjustments: [
|
||||||
discount_id: "10Percent",
|
expect.objectContaining({
|
||||||
description: "discount",
|
amount: 200,
|
||||||
}),
|
discount_id: "10Percent",
|
||||||
],
|
description: "discount",
|
||||||
}),
|
}),
|
||||||
])
|
],
|
||||||
|
}),
|
||||||
|
])
|
||||||
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
it("adds line item to cart containing an item fixed discount", async () => {
|
it("adds line item to cart containing an item fixed discount", async () => {
|
||||||
@@ -322,21 +334,24 @@ describe("/store/carts", () => {
|
|||||||
)
|
)
|
||||||
.catch((err) => console.log(err))
|
.catch((err) => console.log(err))
|
||||||
|
|
||||||
expect(response.data.cart.items).toEqual([
|
expect(response.data.cart.items).toHaveLength(1)
|
||||||
expect.objectContaining({
|
expect(response.data.cart.items).toEqual(
|
||||||
cart_id: "test-cart-w-item-fixed-discount",
|
expect.arrayContaining([
|
||||||
unit_price: 1000,
|
expect.objectContaining({
|
||||||
variant_id: "test-variant-quantity",
|
cart_id: "test-cart-w-item-fixed-discount",
|
||||||
quantity: 2,
|
unit_price: 1000,
|
||||||
adjustments: [
|
variant_id: "test-variant-quantity",
|
||||||
expect.objectContaining({
|
quantity: 2,
|
||||||
amount: 400,
|
adjustments: [
|
||||||
discount_id: "item-fixed-200",
|
expect.objectContaining({
|
||||||
description: "discount",
|
amount: 400,
|
||||||
}),
|
discount_id: "item-fixed-200",
|
||||||
],
|
description: "discount",
|
||||||
}),
|
}),
|
||||||
])
|
],
|
||||||
|
}),
|
||||||
|
])
|
||||||
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
it("adds line item to cart containing an item percentage discount", async () => {
|
it("adds line item to cart containing an item percentage discount", async () => {
|
||||||
@@ -353,21 +368,24 @@ describe("/store/carts", () => {
|
|||||||
)
|
)
|
||||||
.catch((err) => console.log(err))
|
.catch((err) => console.log(err))
|
||||||
|
|
||||||
expect(response.data.cart.items).toEqual([
|
expect(response.data.cart.items).toHaveLength(1)
|
||||||
expect.objectContaining({
|
expect(response.data.cart.items).toEqual(
|
||||||
cart_id: "test-cart-w-item-percentage-discount",
|
expect.arrayContaining([
|
||||||
unit_price: 1000,
|
expect.objectContaining({
|
||||||
variant_id: "test-variant-quantity",
|
cart_id: "test-cart-w-item-percentage-discount",
|
||||||
quantity: 2,
|
unit_price: 1000,
|
||||||
adjustments: [
|
variant_id: "test-variant-quantity",
|
||||||
expect.objectContaining({
|
quantity: 2,
|
||||||
amount: 300,
|
adjustments: [
|
||||||
discount_id: "item-percentage-15",
|
expect.objectContaining({
|
||||||
description: "discount",
|
amount: 300,
|
||||||
}),
|
discount_id: "item-percentage-15",
|
||||||
],
|
description: "discount",
|
||||||
}),
|
}),
|
||||||
])
|
],
|
||||||
|
}),
|
||||||
|
])
|
||||||
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
it("adds line item to cart time limited sale", async () => {
|
it("adds line item to cart time limited sale", async () => {
|
||||||
@@ -384,14 +402,17 @@ describe("/store/carts", () => {
|
|||||||
)
|
)
|
||||||
.catch((err) => console.log(err))
|
.catch((err) => console.log(err))
|
||||||
|
|
||||||
expect(response.data.cart.items).toEqual([
|
expect(response.data.cart.items).toHaveLength(1)
|
||||||
expect.objectContaining({
|
expect(response.data.cart.items).toEqual(
|
||||||
cart_id: "test-cart",
|
expect.arrayContaining([
|
||||||
unit_price: 800,
|
expect.objectContaining({
|
||||||
variant_id: "test-variant-sale",
|
cart_id: "test-cart",
|
||||||
quantity: 1,
|
unit_price: 800,
|
||||||
}),
|
variant_id: "test-variant-sale",
|
||||||
])
|
quantity: 1,
|
||||||
|
}),
|
||||||
|
])
|
||||||
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
it("adds line item to cart time customer pricing", async () => {
|
it("adds line item to cart time customer pricing", async () => {
|
||||||
@@ -422,14 +443,17 @@ describe("/store/carts", () => {
|
|||||||
)
|
)
|
||||||
.catch((err) => console.log(err))
|
.catch((err) => console.log(err))
|
||||||
|
|
||||||
expect(response.data.cart.items).toEqual([
|
expect(response.data.cart.items).toHaveLength(1)
|
||||||
expect.objectContaining({
|
expect(response.data.cart.items).toEqual(
|
||||||
cart_id: "test-cart",
|
expect.arrayContaining([
|
||||||
unit_price: 700,
|
expect.objectContaining({
|
||||||
variant_id: "test-variant-sale-customer",
|
cart_id: "test-cart",
|
||||||
quantity: 1,
|
unit_price: 700,
|
||||||
}),
|
variant_id: "test-variant-sale-customer",
|
||||||
])
|
quantity: 1,
|
||||||
|
}),
|
||||||
|
])
|
||||||
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
it("adds line item with quantity to cart with quantity discount", async () => {
|
it("adds line item with quantity to cart with quantity discount", async () => {
|
||||||
@@ -446,14 +470,17 @@ describe("/store/carts", () => {
|
|||||||
)
|
)
|
||||||
.catch((err) => console.log(err))
|
.catch((err) => console.log(err))
|
||||||
|
|
||||||
expect(response.data.cart.items).toEqual([
|
expect(response.data.cart.items).toHaveLength(1)
|
||||||
expect.objectContaining({
|
expect(response.data.cart.items).toEqual(
|
||||||
cart_id: "test-cart",
|
expect.arrayContaining([
|
||||||
unit_price: 800,
|
expect.objectContaining({
|
||||||
variant_id: "test-variant-quantity",
|
cart_id: "test-cart",
|
||||||
quantity: 90,
|
unit_price: 800,
|
||||||
}),
|
variant_id: "test-variant-quantity",
|
||||||
])
|
quantity: 90,
|
||||||
|
}),
|
||||||
|
])
|
||||||
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
it("adds line item with quantity to cart with quantity discount no ceiling", async () => {
|
it("adds line item with quantity to cart with quantity discount no ceiling", async () => {
|
||||||
@@ -470,14 +497,17 @@ describe("/store/carts", () => {
|
|||||||
)
|
)
|
||||||
.catch((err) => console.log(err))
|
.catch((err) => console.log(err))
|
||||||
|
|
||||||
expect(response.data.cart.items).toEqual([
|
expect(response.data.cart.items).toHaveLength(1)
|
||||||
expect.objectContaining({
|
expect(response.data.cart.items).toEqual(
|
||||||
cart_id: "test-cart",
|
expect.arrayContaining([
|
||||||
unit_price: 700,
|
expect.objectContaining({
|
||||||
variant_id: "test-variant-quantity",
|
cart_id: "test-cart",
|
||||||
quantity: 900,
|
unit_price: 700,
|
||||||
}),
|
variant_id: "test-variant-quantity",
|
||||||
])
|
quantity: 900,
|
||||||
|
}),
|
||||||
|
])
|
||||||
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
describe("ensures correct line item adjustment generation", () => {
|
describe("ensures correct line item adjustment generation", () => {
|
||||||
@@ -682,17 +712,19 @@ describe("/store/carts", () => {
|
|||||||
.catch((err) => console.log(err))
|
.catch((err) => console.log(err))
|
||||||
|
|
||||||
expect(response.data.cart.items.length).toEqual(1)
|
expect(response.data.cart.items.length).toEqual(1)
|
||||||
expect(response.data.cart.items).toEqual([
|
expect(response.data.cart.items).toEqual(
|
||||||
expect.objectContaining({
|
expect.arrayContaining([
|
||||||
adjustments: [
|
expect.objectContaining({
|
||||||
expect.objectContaining({
|
adjustments: [
|
||||||
item_id: "line-item-2",
|
expect.objectContaining({
|
||||||
amount: 185,
|
item_id: "line-item-2",
|
||||||
discount_id: "medusa-185",
|
amount: 185,
|
||||||
}),
|
discount_id: "medusa-185",
|
||||||
],
|
}),
|
||||||
}),
|
],
|
||||||
])
|
}),
|
||||||
|
])
|
||||||
|
)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@@ -761,21 +793,24 @@ describe("/store/carts", () => {
|
|||||||
)
|
)
|
||||||
.catch((err) => console.log(err))
|
.catch((err) => console.log(err))
|
||||||
|
|
||||||
expect(response.data.cart.items).toEqual([
|
expect(response.data.cart.items).toHaveLength(1)
|
||||||
expect.objectContaining({
|
expect(response.data.cart.items).toEqual(
|
||||||
cart_id: "test-cart-w-total-fixed-discount",
|
expect.arrayContaining([
|
||||||
unit_price: 1000,
|
expect.objectContaining({
|
||||||
variant_id: "test-variant-quantity",
|
cart_id: "test-cart-w-total-fixed-discount",
|
||||||
quantity: 3,
|
unit_price: 1000,
|
||||||
adjustments: [
|
variant_id: "test-variant-quantity",
|
||||||
expect.objectContaining({
|
quantity: 3,
|
||||||
amount: 100,
|
adjustments: [
|
||||||
discount_id: "total-fixed-100",
|
expect.objectContaining({
|
||||||
description: "discount",
|
amount: 100,
|
||||||
}),
|
discount_id: "total-fixed-100",
|
||||||
],
|
description: "discount",
|
||||||
}),
|
}),
|
||||||
])
|
],
|
||||||
|
}),
|
||||||
|
])
|
||||||
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
it("updates line item of a cart containing a total percentage discount", async () => {
|
it("updates line item of a cart containing a total percentage discount", async () => {
|
||||||
@@ -801,21 +836,24 @@ describe("/store/carts", () => {
|
|||||||
)
|
)
|
||||||
.catch((err) => console.log(err))
|
.catch((err) => console.log(err))
|
||||||
|
|
||||||
expect(response.data.cart.items).toEqual([
|
expect(response.data.cart.items).toHaveLength(1)
|
||||||
expect.objectContaining({
|
expect(response.data.cart.items).toEqual(
|
||||||
cart_id: "test-cart-w-total-percentage-discount",
|
expect.arrayContaining([
|
||||||
unit_price: 1000,
|
expect.objectContaining({
|
||||||
variant_id: "test-variant-quantity",
|
cart_id: "test-cart-w-total-percentage-discount",
|
||||||
quantity: 10,
|
unit_price: 1000,
|
||||||
adjustments: [
|
variant_id: "test-variant-quantity",
|
||||||
expect.objectContaining({
|
quantity: 10,
|
||||||
amount: 1000,
|
adjustments: [
|
||||||
discount_id: "10Percent",
|
expect.objectContaining({
|
||||||
description: "discount",
|
amount: 1000,
|
||||||
}),
|
discount_id: "10Percent",
|
||||||
],
|
description: "discount",
|
||||||
}),
|
}),
|
||||||
])
|
],
|
||||||
|
}),
|
||||||
|
])
|
||||||
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
it("updates line item of a cart containing an item fixed discount", async () => {
|
it("updates line item of a cart containing an item fixed discount", async () => {
|
||||||
@@ -841,21 +879,24 @@ describe("/store/carts", () => {
|
|||||||
)
|
)
|
||||||
.catch((err) => console.log(err))
|
.catch((err) => console.log(err))
|
||||||
|
|
||||||
expect(response.data.cart.items).toEqual([
|
expect(response.data.cart.items).toHaveLength(1)
|
||||||
expect.objectContaining({
|
expect(response.data.cart.items).toEqual(
|
||||||
cart_id: "test-cart-w-item-fixed-discount",
|
expect.arrayContaining([
|
||||||
unit_price: 1000,
|
expect.objectContaining({
|
||||||
variant_id: "test-variant-quantity",
|
cart_id: "test-cart-w-item-fixed-discount",
|
||||||
quantity: 4,
|
unit_price: 1000,
|
||||||
adjustments: [
|
variant_id: "test-variant-quantity",
|
||||||
expect.objectContaining({
|
quantity: 4,
|
||||||
amount: 800,
|
adjustments: [
|
||||||
discount_id: "item-fixed-200",
|
expect.objectContaining({
|
||||||
description: "discount",
|
amount: 800,
|
||||||
}),
|
discount_id: "item-fixed-200",
|
||||||
],
|
description: "discount",
|
||||||
}),
|
}),
|
||||||
])
|
],
|
||||||
|
}),
|
||||||
|
])
|
||||||
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
it("updates line item of a cart containing an item percentage discount", async () => {
|
it("updates line item of a cart containing an item percentage discount", async () => {
|
||||||
@@ -881,21 +922,24 @@ describe("/store/carts", () => {
|
|||||||
)
|
)
|
||||||
.catch((err) => console.log(err))
|
.catch((err) => console.log(err))
|
||||||
|
|
||||||
expect(response.data.cart.items).toEqual([
|
expect(response.data.cart.items).toHaveLength(1)
|
||||||
expect.objectContaining({
|
expect(response.data.cart.items).toEqual(
|
||||||
cart_id: "test-cart-w-item-percentage-discount",
|
expect.arrayContaining([
|
||||||
unit_price: 1000,
|
expect.objectContaining({
|
||||||
variant_id: "test-variant-quantity",
|
cart_id: "test-cart-w-item-percentage-discount",
|
||||||
quantity: 3,
|
unit_price: 1000,
|
||||||
adjustments: [
|
variant_id: "test-variant-quantity",
|
||||||
expect.objectContaining({
|
quantity: 3,
|
||||||
amount: 450,
|
adjustments: [
|
||||||
discount_id: "item-percentage-15",
|
expect.objectContaining({
|
||||||
description: "discount",
|
amount: 450,
|
||||||
}),
|
discount_id: "item-percentage-15",
|
||||||
],
|
description: "discount",
|
||||||
}),
|
}),
|
||||||
])
|
],
|
||||||
|
}),
|
||||||
|
])
|
||||||
|
)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -55,12 +55,15 @@ describe("/store/products", () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
expect(response.status).toEqual(200)
|
expect(response.status).toEqual(200)
|
||||||
expect(response.data.products).toEqual([
|
expect(response.data.products).toHaveLength(1)
|
||||||
expect.objectContaining({
|
expect(response.data.products).toEqual(
|
||||||
id: "test-product_filtering_2",
|
expect.arrayContaining([
|
||||||
collection_id: "test-collection2",
|
expect.objectContaining({
|
||||||
}),
|
id: "test-product_filtering_2",
|
||||||
])
|
collection_id: "test-collection2",
|
||||||
|
}),
|
||||||
|
])
|
||||||
|
)
|
||||||
|
|
||||||
for (const notExpect of notExpected) {
|
for (const notExpect of notExpected) {
|
||||||
expect(response.data.products).toEqual(
|
expect(response.data.products).toEqual(
|
||||||
@@ -81,12 +84,15 @@ describe("/store/products", () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
expect(response.status).toEqual(200)
|
expect(response.status).toEqual(200)
|
||||||
expect(response.data.products).toEqual([
|
expect(response.data.products).toHaveLength(1)
|
||||||
expect.objectContaining({
|
expect(response.data.products).toEqual(
|
||||||
id: "test-product_filtering_1",
|
expect.arrayContaining([
|
||||||
collection_id: "test-collection1",
|
expect.objectContaining({
|
||||||
}),
|
id: "test-product_filtering_1",
|
||||||
])
|
collection_id: "test-collection1",
|
||||||
|
}),
|
||||||
|
])
|
||||||
|
)
|
||||||
|
|
||||||
for (const notExpect of notExpected) {
|
for (const notExpect of notExpected) {
|
||||||
expect(response.data.products).toEqual(
|
expect(response.data.products).toEqual(
|
||||||
@@ -106,12 +112,14 @@ describe("/store/products", () => {
|
|||||||
|
|
||||||
expect(response.status).toEqual(200)
|
expect(response.status).toEqual(200)
|
||||||
expect(response.data.products.length).toEqual(1)
|
expect(response.data.products.length).toEqual(1)
|
||||||
expect(response.data.products).toEqual([
|
expect(response.data.products).toEqual(
|
||||||
expect.objectContaining({
|
expect.arrayContaining([
|
||||||
id: "giftcard",
|
expect.objectContaining({
|
||||||
is_giftcard: true,
|
id: "giftcard",
|
||||||
}),
|
is_giftcard: true,
|
||||||
])
|
}),
|
||||||
|
])
|
||||||
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
it("returns non gift card products", async () => {
|
it("returns non gift card products", async () => {
|
||||||
@@ -144,12 +152,15 @@ describe("/store/products", () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
expect(response.status).toEqual(200)
|
expect(response.status).toEqual(200)
|
||||||
expect(response.data.products).toEqual([
|
expect(response.data.products).toHaveLength(1)
|
||||||
expect.objectContaining({
|
expect(response.data.products).toEqual(
|
||||||
id: "test-product_filtering_1",
|
expect.arrayContaining([
|
||||||
collection_id: "test-collection1",
|
expect.objectContaining({
|
||||||
}),
|
id: "test-product_filtering_1",
|
||||||
])
|
collection_id: "test-collection1",
|
||||||
|
}),
|
||||||
|
])
|
||||||
|
)
|
||||||
|
|
||||||
for (const notExpect of notExpected) {
|
for (const notExpect of notExpected) {
|
||||||
expect(response.data.products).toEqual(
|
expect(response.data.products).toEqual(
|
||||||
@@ -172,12 +183,15 @@ describe("/store/products", () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
expect(response.status).toEqual(200)
|
expect(response.status).toEqual(200)
|
||||||
expect(response.data.products).toEqual([
|
expect(response.data.products).toHaveLength(1)
|
||||||
expect.objectContaining({
|
expect(response.data.products).toEqual(
|
||||||
id: "test-product_filtering_2",
|
expect.arrayContaining([
|
||||||
handle: "test-product_filtering_2",
|
expect.objectContaining({
|
||||||
}),
|
id: "test-product_filtering_2",
|
||||||
])
|
handle: "test-product_filtering_2",
|
||||||
|
}),
|
||||||
|
])
|
||||||
|
)
|
||||||
|
|
||||||
for (const notExpect of notExpected) {
|
for (const notExpect of notExpected) {
|
||||||
expect(response.data.products).toEqual(
|
expect(response.data.products).toEqual(
|
||||||
@@ -201,27 +215,29 @@ describe("/store/products", () => {
|
|||||||
|
|
||||||
expect(response.status).toEqual(200)
|
expect(response.status).toEqual(200)
|
||||||
expect(response.data.products.length).toEqual(5)
|
expect(response.data.products.length).toEqual(5)
|
||||||
expect(response.data.products).toEqual([
|
expect(response.data.products).toEqual(
|
||||||
expect.objectContaining({
|
expect.arrayContaining([
|
||||||
id: "test-product1",
|
expect.objectContaining({
|
||||||
collection_id: "test-collection",
|
id: "test-product1",
|
||||||
}),
|
collection_id: "test-collection",
|
||||||
expect.objectContaining({
|
}),
|
||||||
id: "test-product",
|
expect.objectContaining({
|
||||||
collection_id: "test-collection",
|
id: "test-product",
|
||||||
}),
|
collection_id: "test-collection",
|
||||||
expect.objectContaining({
|
}),
|
||||||
id: "test-product_filtering_2",
|
expect.objectContaining({
|
||||||
collection_id: "test-collection2",
|
id: "test-product_filtering_2",
|
||||||
}),
|
collection_id: "test-collection2",
|
||||||
expect.objectContaining({
|
}),
|
||||||
id: "test-product_filtering_1",
|
expect.objectContaining({
|
||||||
collection_id: "test-collection1",
|
id: "test-product_filtering_1",
|
||||||
}),
|
collection_id: "test-collection1",
|
||||||
expect.objectContaining({
|
}),
|
||||||
id: "giftcard",
|
expect.objectContaining({
|
||||||
}),
|
id: "giftcard",
|
||||||
])
|
}),
|
||||||
|
])
|
||||||
|
)
|
||||||
|
|
||||||
for (const notExpect of notExpected) {
|
for (const notExpect of notExpected) {
|
||||||
expect(response.data.products).toEqual(
|
expect(response.data.products).toEqual(
|
||||||
@@ -256,77 +272,80 @@ describe("/store/products", () => {
|
|||||||
console.log(err)
|
console.log(err)
|
||||||
})
|
})
|
||||||
|
|
||||||
expect(response.data.products).toEqual([
|
expect(response.data.products).toHaveLength(5)
|
||||||
expect.objectContaining({
|
expect(response.data.products).toEqual(
|
||||||
id: "test-product1",
|
expect.arrayContaining([
|
||||||
collection_id: "test-collection",
|
expect.objectContaining({
|
||||||
}),
|
id: "test-product1",
|
||||||
expect.objectContaining({
|
collection_id: "test-collection",
|
||||||
id: "test-product",
|
}),
|
||||||
collection_id: "test-collection",
|
expect.objectContaining({
|
||||||
variants: [
|
id: "test-product",
|
||||||
expect.objectContaining({
|
collection_id: "test-collection",
|
||||||
original_price: 100,
|
variants: [
|
||||||
calculated_price: 80,
|
expect.objectContaining({
|
||||||
prices: [
|
original_price: 100,
|
||||||
expect.objectContaining({
|
calculated_price: 80,
|
||||||
id: "test-price",
|
prices: [
|
||||||
currency_code: "usd",
|
expect.objectContaining({
|
||||||
amount: 100,
|
id: "test-price",
|
||||||
}),
|
currency_code: "usd",
|
||||||
expect.objectContaining({
|
amount: 100,
|
||||||
id: "test-price-discount",
|
}),
|
||||||
currency_code: "usd",
|
expect.objectContaining({
|
||||||
amount: 80,
|
id: "test-price-discount",
|
||||||
}),
|
currency_code: "usd",
|
||||||
],
|
amount: 80,
|
||||||
}),
|
}),
|
||||||
expect.objectContaining({
|
],
|
||||||
original_price: 100,
|
}),
|
||||||
calculated_price: 80,
|
expect.objectContaining({
|
||||||
prices: [
|
original_price: 100,
|
||||||
expect.objectContaining({
|
calculated_price: 80,
|
||||||
id: "test-price2",
|
prices: [
|
||||||
currency_code: "usd",
|
expect.objectContaining({
|
||||||
amount: 100,
|
id: "test-price2",
|
||||||
}),
|
currency_code: "usd",
|
||||||
expect.objectContaining({
|
amount: 100,
|
||||||
id: "test-price2-discount",
|
}),
|
||||||
currency_code: "usd",
|
expect.objectContaining({
|
||||||
amount: 80,
|
id: "test-price2-discount",
|
||||||
}),
|
currency_code: "usd",
|
||||||
],
|
amount: 80,
|
||||||
}),
|
}),
|
||||||
expect.objectContaining({
|
],
|
||||||
original_price: 100,
|
}),
|
||||||
calculated_price: 80,
|
expect.objectContaining({
|
||||||
prices: [
|
original_price: 100,
|
||||||
expect.objectContaining({
|
calculated_price: 80,
|
||||||
id: "test-price1",
|
prices: [
|
||||||
currency_code: "usd",
|
expect.objectContaining({
|
||||||
amount: 100,
|
id: "test-price1",
|
||||||
}),
|
currency_code: "usd",
|
||||||
expect.objectContaining({
|
amount: 100,
|
||||||
id: "test-price1-discount",
|
}),
|
||||||
currency_code: "usd",
|
expect.objectContaining({
|
||||||
amount: 80,
|
id: "test-price1-discount",
|
||||||
}),
|
currency_code: "usd",
|
||||||
],
|
amount: 80,
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
}),
|
}),
|
||||||
expect.objectContaining({
|
],
|
||||||
id: "test-product_filtering_2",
|
}),
|
||||||
collection_id: "test-collection2",
|
expect.objectContaining({
|
||||||
}),
|
id: "test-product_filtering_2",
|
||||||
expect.objectContaining({
|
collection_id: "test-collection2",
|
||||||
id: "test-product_filtering_1",
|
}),
|
||||||
collection_id: "test-collection1",
|
expect.objectContaining({
|
||||||
}),
|
id: "test-product_filtering_1",
|
||||||
expect.objectContaining({
|
collection_id: "test-collection1",
|
||||||
id: "giftcard",
|
}),
|
||||||
}),
|
expect.objectContaining({
|
||||||
])
|
id: "giftcard",
|
||||||
|
}),
|
||||||
|
])
|
||||||
|
)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -118,22 +118,25 @@ describe("/store/return-reasons", () => {
|
|||||||
|
|
||||||
expect(response.status).toEqual(200)
|
expect(response.status).toEqual(200)
|
||||||
|
|
||||||
expect(response.data.return_reasons).toEqual([
|
expect(response.data.return_reasons).toHaveLength(2)
|
||||||
expect.objectContaining({
|
expect(response.data.return_reasons).toEqual(
|
||||||
id: rrId,
|
expect.arrayContaining([
|
||||||
value: "wrong_size",
|
expect.objectContaining({
|
||||||
return_reason_children: [
|
id: rrId,
|
||||||
expect.objectContaining({
|
value: "wrong_size",
|
||||||
id: rrId_1,
|
return_reason_children: [
|
||||||
value: "too_big",
|
expect.objectContaining({
|
||||||
}),
|
id: rrId_1,
|
||||||
],
|
value: "too_big",
|
||||||
}),
|
}),
|
||||||
expect.objectContaining({
|
],
|
||||||
id: rrId_2,
|
}),
|
||||||
value: "too_big_1",
|
expect.objectContaining({
|
||||||
}),
|
id: rrId_2,
|
||||||
])
|
value: "too_big_1",
|
||||||
|
}),
|
||||||
|
])
|
||||||
|
)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@@ -241,12 +241,15 @@ describe("/store/carts", () => {
|
|||||||
})
|
})
|
||||||
expect(response.status).toEqual(200)
|
expect(response.status).toEqual(200)
|
||||||
|
|
||||||
expect(response.data.return.items).toEqual([
|
expect(response.data.return.items).toHaveLength(1)
|
||||||
expect.objectContaining({
|
expect(response.data.return.items).toEqual(
|
||||||
reason_id: rrId_child,
|
expect.arrayContaining([
|
||||||
note: "TOO small",
|
expect.objectContaining({
|
||||||
}),
|
reason_id: rrId_child,
|
||||||
])
|
note: "TOO small",
|
||||||
|
}),
|
||||||
|
])
|
||||||
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
it("failes to create a return with an invalid quantity (less than 1)", async () => {
|
it("failes to create a return with an invalid quantity (less than 1)", async () => {
|
||||||
|
|||||||
@@ -290,16 +290,22 @@ describe("Order Taxes", () => {
|
|||||||
response.data.data.items.flatMap((li) => li.tax_lines).length
|
response.data.data.items.flatMap((li) => li.tax_lines).length
|
||||||
).toEqual(2)
|
).toEqual(2)
|
||||||
|
|
||||||
expect(response.data.data.items[0].tax_lines).toEqual([
|
expect(response.data.data.items[0].tax_lines).toHaveLength(1)
|
||||||
expect.objectContaining({
|
expect(response.data.data.items[0].tax_lines).toEqual(
|
||||||
rate: 25,
|
expect.arrayContaining([
|
||||||
}),
|
expect.objectContaining({
|
||||||
])
|
rate: 25,
|
||||||
expect(response.data.data.items[1].tax_lines).toEqual([
|
}),
|
||||||
expect.objectContaining({
|
])
|
||||||
rate: 20,
|
)
|
||||||
}),
|
expect(response.data.data.items[1].tax_lines).toHaveLength(1)
|
||||||
])
|
expect(response.data.data.items[1].tax_lines).toEqual(
|
||||||
|
expect.arrayContaining([
|
||||||
|
expect.objectContaining({
|
||||||
|
rate: 20,
|
||||||
|
}),
|
||||||
|
])
|
||||||
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
test("completing cart creates tax lines", async () => {
|
test("completing cart creates tax lines", async () => {
|
||||||
@@ -381,15 +387,21 @@ describe("Order Taxes", () => {
|
|||||||
expect(response.data.data.tax_total).toEqual(35)
|
expect(response.data.data.tax_total).toEqual(35)
|
||||||
expect(response.data.data.total).toEqual(185)
|
expect(response.data.data.total).toEqual(185)
|
||||||
|
|
||||||
expect(response.data.data.items[0].tax_lines).toEqual([
|
expect(response.data.data.items[0].tax_lines).toHaveLength(1)
|
||||||
expect.objectContaining({
|
expect(response.data.data.items[0].tax_lines).toEqual(
|
||||||
rate: 25,
|
expect.arrayContaining([
|
||||||
}),
|
expect.objectContaining({
|
||||||
])
|
rate: 25,
|
||||||
expect(response.data.data.items[1].tax_lines).toEqual([
|
}),
|
||||||
expect.objectContaining({
|
])
|
||||||
rate: 20,
|
)
|
||||||
}),
|
expect(response.data.data.items[1].tax_lines).toHaveLength(1)
|
||||||
])
|
expect(response.data.data.items[1].tax_lines).toEqual(
|
||||||
|
expect.arrayContaining([
|
||||||
|
expect.objectContaining({
|
||||||
|
rate: 20,
|
||||||
|
}),
|
||||||
|
])
|
||||||
|
)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@@ -69,13 +69,16 @@ describe("Shipping Options Totals Calculations", () => {
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
expect(res.data.shipping_options).toEqual([
|
expect(res.data.shipping_options).toHaveLength(1)
|
||||||
expect.objectContaining({
|
expect(res.data.shipping_options).toEqual(
|
||||||
id: so.id,
|
expect.arrayContaining([
|
||||||
amount: 100,
|
expect.objectContaining({
|
||||||
price_incl_tax: 110,
|
id: so.id,
|
||||||
}),
|
amount: 100,
|
||||||
])
|
price_incl_tax: 110,
|
||||||
|
}),
|
||||||
|
])
|
||||||
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
it("gets correct shipping prices", async () => {
|
it("gets correct shipping prices", async () => {
|
||||||
@@ -98,12 +101,15 @@ describe("Shipping Options Totals Calculations", () => {
|
|||||||
|
|
||||||
const res = await api.get(`/store/shipping-options?region_id=${region.id}`)
|
const res = await api.get(`/store/shipping-options?region_id=${region.id}`)
|
||||||
|
|
||||||
expect(res.data.shipping_options).toEqual([
|
expect(res.data.shipping_options).toHaveLength(1)
|
||||||
expect.objectContaining({
|
expect(res.data.shipping_options).toEqual(
|
||||||
id: so.id,
|
expect.arrayContaining([
|
||||||
amount: 100,
|
expect.objectContaining({
|
||||||
price_incl_tax: 110,
|
id: so.id,
|
||||||
}),
|
amount: 100,
|
||||||
])
|
price_incl_tax: 110,
|
||||||
|
}),
|
||||||
|
])
|
||||||
|
)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@@ -93,13 +93,16 @@ describe("Order Totals", () => {
|
|||||||
headers: { Authorization: `Bearer test_token` },
|
headers: { Authorization: `Bearer test_token` },
|
||||||
})
|
})
|
||||||
|
|
||||||
expect(data.order.gift_card_transactions).toEqual([
|
expect(data.order.gift_card_transactions).toHaveLength(1)
|
||||||
expect.objectContaining({
|
expect(data.order.gift_card_transactions).toEqual(
|
||||||
amount: 160000,
|
expect.arrayContaining([
|
||||||
is_taxable: false,
|
expect.objectContaining({
|
||||||
tax_rate: null,
|
amount: 160000,
|
||||||
}),
|
is_taxable: false,
|
||||||
])
|
tax_rate: null,
|
||||||
|
}),
|
||||||
|
])
|
||||||
|
)
|
||||||
expect(data.order.gift_card_total).toEqual(160000)
|
expect(data.order.gift_card_total).toEqual(160000)
|
||||||
expect(data.order.gift_card_tax_total).toEqual(0)
|
expect(data.order.gift_card_tax_total).toEqual(0)
|
||||||
expect(data.order.total).toEqual(59000)
|
expect(data.order.total).toEqual(59000)
|
||||||
@@ -155,13 +158,16 @@ describe("Order Totals", () => {
|
|||||||
headers: { Authorization: `Bearer test_token` },
|
headers: { Authorization: `Bearer test_token` },
|
||||||
})
|
})
|
||||||
|
|
||||||
expect(data.order.gift_card_transactions).toEqual([
|
expect(data.order.gift_card_transactions).toHaveLength(1)
|
||||||
expect.objectContaining({
|
expect(data.order.gift_card_transactions).toEqual(
|
||||||
amount: 160000,
|
expect.arrayContaining([
|
||||||
is_taxable: true,
|
expect.objectContaining({
|
||||||
tax_rate: 25,
|
amount: 160000,
|
||||||
}),
|
is_taxable: true,
|
||||||
])
|
tax_rate: 25,
|
||||||
|
}),
|
||||||
|
])
|
||||||
|
)
|
||||||
expect(data.order.gift_card_total).toEqual(160000)
|
expect(data.order.gift_card_total).toEqual(160000)
|
||||||
expect(data.order.gift_card_tax_total).toEqual(40000)
|
expect(data.order.gift_card_tax_total).toEqual(40000)
|
||||||
expect(data.order.tax_total).toEqual(3800)
|
expect(data.order.tax_total).toEqual(3800)
|
||||||
|
|||||||
Reference in new issue
Block a user