chore(integration-tests): Fixed merge conflict
This commit is contained in:
commit
f7a63f1782
212 files changed
+6791
-3775
No files matched your search
@@ -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",
|
||||
}),
|
||||
])
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -609,16 +618,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]
|
||||
@@ -1468,6 +1480,70 @@ describe("/admin/discounts", () => {
|
||||
})
|
||||
})
|
||||
|
||||
describe("POST /admin/discounts/:id", () => {
|
||||
beforeEach(async () => {
|
||||
await adminSeeder(dbConnection)
|
||||
await dbConnection.manager.insert(DiscountRule, {
|
||||
id: "test-discount-rule",
|
||||
description: "Test discount rule",
|
||||
type: "percentage",
|
||||
value: 10,
|
||||
allocation: "total",
|
||||
})
|
||||
await dbConnection.manager.insert(Discount, {
|
||||
id: "test-discount",
|
||||
code: "TESTING",
|
||||
rule_id: "test-discount-rule",
|
||||
is_dynamic: false,
|
||||
is_disabled: false,
|
||||
ends_at: new Date(),
|
||||
usage_limit: 10,
|
||||
valid_duration: "P1D",
|
||||
})
|
||||
})
|
||||
|
||||
afterEach(async () => {
|
||||
const db = useDb()
|
||||
await db.teardown()
|
||||
})
|
||||
|
||||
it("Removes ends_at, valid_duration and usage_limit when fields are updated with null", async () => {
|
||||
const api = useApi()
|
||||
|
||||
await api
|
||||
.post(
|
||||
"/admin/discounts/test-discount",
|
||||
{
|
||||
ends_at: null,
|
||||
valid_duration: null,
|
||||
usage_limit: null,
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
Authorization: "Bearer test_token",
|
||||
},
|
||||
}
|
||||
)
|
||||
.catch((err) => {
|
||||
console.log(err)
|
||||
})
|
||||
|
||||
const resultingDiscount = await api.get(
|
||||
"/admin/discounts/test-discount",
|
||||
{ headers: { Authorization: "Bearer test_token" } }
|
||||
)
|
||||
|
||||
expect(resultingDiscount.status).toEqual(200)
|
||||
expect(resultingDiscount.data.discount).toEqual(
|
||||
expect.objectContaining({
|
||||
ends_at: null,
|
||||
valid_duration: null,
|
||||
usage_limit: null,
|
||||
})
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
describe("testing for soft-deletion + uniqueness on discount codes", () => {
|
||||
let manager
|
||||
beforeEach(async () => {
|
||||
|
||||
@@ -653,11 +653,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 () => {
|
||||
@@ -807,19 +810,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 () => {
|
||||
@@ -872,27 +877,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 () => {
|
||||
@@ -1288,14 +1300,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 () => {
|
||||
@@ -1385,28 +1400,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 () => {
|
||||
@@ -1424,14 +1442,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 () => {
|
||||
@@ -1467,12 +1488,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 () => {
|
||||
@@ -1513,27 +1537,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 () => {
|
||||
@@ -1565,27 +1592,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 () => {
|
||||
@@ -1617,27 +1647,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([
|
||||
@@ -1826,11 +1859,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)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -353,10 +353,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" }),
|
||||
])
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -1137,52 +1140,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 () => {
|
||||
@@ -1200,9 +1206,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 () => {
|
||||
@@ -1220,12 +1229,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",
|
||||
}),
|
||||
])
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
@@ -160,16 +160,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(
|
||||
@@ -199,16 +202,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(
|
||||
@@ -232,11 +238,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 () => {
|
||||
@@ -317,11 +326,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 () => {
|
||||
@@ -343,16 +355,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(
|
||||
@@ -426,13 +441,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(
|
||||
|
||||
@@ -157,17 +157,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)
|
||||
})
|
||||
|
||||
@@ -184,14 +187,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)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -350,20 +350,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 () => {
|
||||
@@ -396,11 +399,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",
|
||||
}),
|
||||
])
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
@@ -783,11 +783,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,
|
||||
}),
|
||||
])
|
||||
)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
@@ -8,6 +8,17 @@ const orderSeeder = require("../../helpers/order-seeder")
|
||||
const swapSeeder = require("../../helpers/swap-seeder")
|
||||
const adminSeeder = require("../../helpers/admin-seeder")
|
||||
|
||||
const {
|
||||
simpleProductFactory,
|
||||
simpleCartFactory,
|
||||
simpleDiscountFactory,
|
||||
simpleRegionFactory,
|
||||
simpleShippingOptionFactory,
|
||||
} = require("../../factories")
|
||||
const {
|
||||
simpleCustomerFactory,
|
||||
} = require("../../factories/simple-customer-factory")
|
||||
|
||||
jest.setTimeout(30000)
|
||||
|
||||
describe("/admin/swaps", () => {
|
||||
@@ -136,4 +147,208 @@ describe("/admin/swaps", () => {
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
describe("Complete swap flow", () => {
|
||||
beforeEach(async () => {
|
||||
try {
|
||||
await adminSeeder(dbConnection)
|
||||
} catch (err) {
|
||||
console.log(err)
|
||||
throw err
|
||||
}
|
||||
})
|
||||
|
||||
afterEach(async () => {
|
||||
const db = useDb()
|
||||
await db.teardown()
|
||||
})
|
||||
|
||||
it("completes swap and ensures difference due", async () => {
|
||||
// ********* FACTORIES *********
|
||||
const prodA = await simpleProductFactory(dbConnection, {
|
||||
id: "prod-a",
|
||||
variants: [
|
||||
{ id: "prod-a-var", prices: [{ amount: 1000, currency: "dkk" }] },
|
||||
],
|
||||
})
|
||||
|
||||
await simpleProductFactory(dbConnection, {
|
||||
id: "prod-b",
|
||||
variants: [
|
||||
{ id: "prod-b-var", prices: [{ amount: 1000, currency: "dkk" }] },
|
||||
],
|
||||
})
|
||||
|
||||
await simpleRegionFactory(dbConnection, {
|
||||
id: "test-region",
|
||||
currency_code: "dkk",
|
||||
})
|
||||
|
||||
await simpleDiscountFactory(dbConnection, {
|
||||
id: "test-discount",
|
||||
regions: ["test-region"],
|
||||
code: "TEST",
|
||||
rule: {
|
||||
type: "percentage",
|
||||
value: "10",
|
||||
allocation: "total",
|
||||
conditions: [
|
||||
{
|
||||
type: "products",
|
||||
operator: "in",
|
||||
products: [prodA.id],
|
||||
},
|
||||
],
|
||||
},
|
||||
})
|
||||
|
||||
await simpleCustomerFactory(dbConnection, {
|
||||
id: "test-customer",
|
||||
email: "test@customer.com",
|
||||
})
|
||||
|
||||
const so = await simpleShippingOptionFactory(dbConnection, {
|
||||
region_id: "test-region",
|
||||
})
|
||||
|
||||
await simpleCartFactory(dbConnection, {
|
||||
customer: "test-customer",
|
||||
id: "cart-test",
|
||||
line_items: [
|
||||
{
|
||||
id: "line-item",
|
||||
variant_id: "prod-a-var",
|
||||
cart_id: "cart-test",
|
||||
unit_price: 1000,
|
||||
quantity: 1,
|
||||
},
|
||||
],
|
||||
region: "test-region",
|
||||
shipping_address: {
|
||||
address_1: "test",
|
||||
country_code: "us",
|
||||
first_name: "chris",
|
||||
last_name: "rock",
|
||||
postal_code: "101",
|
||||
},
|
||||
})
|
||||
|
||||
const api = useApi()
|
||||
|
||||
// ********* PREPARE CART *********
|
||||
|
||||
try {
|
||||
await api.post("/store/carts/cart-test", {
|
||||
discounts: [{ code: "TEST" }],
|
||||
})
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
}
|
||||
|
||||
await api.post("/store/carts/cart-test/shipping-methods", {
|
||||
option_id: so.id,
|
||||
data: {},
|
||||
})
|
||||
await api.post("/store/carts/cart-test/payment-sessions")
|
||||
const TEST = await api.post("/store/carts/cart-test/payment-session", {
|
||||
provider_id: "test-pay",
|
||||
})
|
||||
|
||||
console.log("Testing, ", TEST.data.cart.items[0])
|
||||
|
||||
// ********* COMPLETE CART *********
|
||||
const completedOrder = await api.post("/store/carts/cart-test/complete")
|
||||
|
||||
// ********* PREPARE ORDER *********
|
||||
const orderId = completedOrder.data.data.id
|
||||
const fulfilledOrder = await api.post(
|
||||
`/admin/orders/${orderId}/fulfillment`,
|
||||
{
|
||||
items: [{ item_id: "line-item", quantity: 1 }],
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
Authorization: "Bearer test_token",
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
const fulfillmentId = fulfilledOrder.data.order.fulfillments[0].id
|
||||
|
||||
await api.post(
|
||||
`/admin/orders/${orderId}/shipment`,
|
||||
{
|
||||
fulfillment_id: fulfillmentId,
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
Authorization: "Bearer test_token",
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
await api.post(
|
||||
`/admin/orders/${orderId}/capture`,
|
||||
{},
|
||||
{
|
||||
headers: {
|
||||
Authorization: "Bearer test_token",
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
// ********* CREATE SWAP *********
|
||||
const createSwap = await api.post(
|
||||
`/admin/orders/${completedOrder.data.data.id}/swaps`,
|
||||
{
|
||||
return_items: [
|
||||
{
|
||||
item_id: "line-item",
|
||||
quantity: 1,
|
||||
},
|
||||
],
|
||||
additional_items: [{ variant_id: "prod-b-var", quantity: 1 }],
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
authorization: "Bearer test_token",
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
let swap = createSwap.data.order.swaps[0]
|
||||
|
||||
// ********* PREPARE SWAP CART *********
|
||||
await api.post(`/store/carts/${swap.cart_id}/shipping-methods`, {
|
||||
option_id: so.id,
|
||||
data: {},
|
||||
})
|
||||
|
||||
await api.post(`/store/carts/${swap.cart_id}/payment-sessions`)
|
||||
await api.post(`/store/carts/${swap.cart_id}/payment-session`, {
|
||||
provider_id: "test-pay",
|
||||
})
|
||||
|
||||
// ********* COMPLETE SWAP CART *********
|
||||
await api.post(`/store/carts/${swap.cart_id}/complete`)
|
||||
|
||||
swap = await api
|
||||
.get(`/admin/swaps/${swap.id}`, {
|
||||
headers: {
|
||||
Authorization: "Bearer test_token",
|
||||
},
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err)
|
||||
})
|
||||
|
||||
const swapCart = await api.get(
|
||||
`/store/carts/${swap.data.swap.cart_id}`,
|
||||
{}
|
||||
)
|
||||
|
||||
// ********* VALIDATE *********
|
||||
expect(swap.data.swap.difference_due).toBe(swapCart.data.cart.total)
|
||||
})
|
||||
})
|
||||
})
|
||||
@@ -68,13 +68,16 @@ describe("/admin/orders", () => {
|
||||
* 1000 * 1.125 = 1125
|
||||
*/
|
||||
expect(response.data.order.returns[0].refund_amount).toEqual(1125)
|
||||
expect(response.data.order.returns[0].items).toEqual([
|
||||
expect.objectContaining({
|
||||
item_id: "test-item",
|
||||
quantity: 1,
|
||||
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,
|
||||
note: "TOO SMALL",
|
||||
}),
|
||||
])
|
||||
)
|
||||
})
|
||||
|
||||
test("creates a return w. new tax system", async () => {
|
||||
@@ -109,13 +112,16 @@ describe("/admin/orders", () => {
|
||||
*/
|
||||
expect(response.data.order.returns[0].refund_amount).toEqual(1200)
|
||||
|
||||
expect(response.data.order.returns[0].items).toEqual([
|
||||
expect.objectContaining({
|
||||
item_id: "test-item",
|
||||
quantity: 1,
|
||||
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,
|
||||
note: "TOO SMALL",
|
||||
}),
|
||||
])
|
||||
)
|
||||
})
|
||||
|
||||
test("creates a return w. new tax system + shipping", async () => {
|
||||
@@ -159,20 +165,26 @@ describe("/admin/orders", () => {
|
||||
* 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].shipping_method.tax_lines).toEqual([
|
||||
expect.objectContaining({
|
||||
rate: 12.5,
|
||||
name: "default",
|
||||
code: "default",
|
||||
}),
|
||||
])
|
||||
expect(response.data.order.returns[0].items).toEqual([
|
||||
expect.objectContaining({
|
||||
item_id: "test-item",
|
||||
quantity: 1,
|
||||
note: "TOO SMALL",
|
||||
}),
|
||||
])
|
||||
expect(response.data.order.returns[0].shipping_method.tax_lines).toHaveLength(1)
|
||||
expect(response.data.order.returns[0].shipping_method.tax_lines).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
rate: 12.5,
|
||||
name: "default",
|
||||
code: "default",
|
||||
}),
|
||||
])
|
||||
)
|
||||
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,
|
||||
note: "TOO SMALL",
|
||||
}),
|
||||
])
|
||||
)
|
||||
})
|
||||
|
||||
test("creates a return w. discount", async () => {
|
||||
@@ -210,13 +222,16 @@ describe("/admin/orders", () => {
|
||||
*/
|
||||
expect(response.data.order.returns[0].refund_amount).toEqual(1080)
|
||||
|
||||
expect(response.data.order.returns[0].items).toEqual([
|
||||
expect.objectContaining({
|
||||
item_id: "test-item",
|
||||
quantity: 1,
|
||||
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,
|
||||
note: "TOO SMALL",
|
||||
}),
|
||||
])
|
||||
)
|
||||
})
|
||||
|
||||
test("receives a return with a claimed line item", async () => {
|
||||
|
||||
@@ -151,17 +151,20 @@ describe("/store/carts", () => {
|
||||
response.data.cart.items.sort((a, b) => a.quantity - b.quantity)
|
||||
|
||||
expect(response.status).toEqual(200)
|
||||
expect(response.data.cart.items).toEqual([
|
||||
expect.objectContaining({
|
||||
variant_id: "test-variant_1",
|
||||
quantity: 1,
|
||||
}),
|
||||
expect.objectContaining({
|
||||
variant_id: "test-variant-sale",
|
||||
quantity: 2,
|
||||
unit_price: 800,
|
||||
}),
|
||||
])
|
||||
expect(response.data.cart.items).toHaveLength(2)
|
||||
expect(response.data.cart.items).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
variant_id: "test-variant_1",
|
||||
quantity: 1,
|
||||
}),
|
||||
expect.objectContaining({
|
||||
variant_id: "test-variant-sale",
|
||||
quantity: 2,
|
||||
unit_price: 800,
|
||||
}),
|
||||
])
|
||||
)
|
||||
|
||||
const getRes = await api.post(`/store/carts/${response.data.cart.id}`)
|
||||
expect(getRes.status).toEqual(200)
|
||||
@@ -226,15 +229,18 @@ describe("/store/carts", () => {
|
||||
)
|
||||
.catch((err) => console.log(err))
|
||||
|
||||
expect(response.data.cart.items).toEqual([
|
||||
expect.objectContaining({
|
||||
cart_id: "test-cart",
|
||||
unit_price: 1000,
|
||||
variant_id: "test-variant-quantity",
|
||||
quantity: 1,
|
||||
adjustments: [],
|
||||
}),
|
||||
])
|
||||
expect(response.data.cart.items).toHaveLength(1)
|
||||
expect(response.data.cart.items).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
cart_id: "test-cart",
|
||||
unit_price: 1000,
|
||||
variant_id: "test-variant-quantity",
|
||||
quantity: 1,
|
||||
adjustments: [],
|
||||
}),
|
||||
])
|
||||
)
|
||||
})
|
||||
|
||||
it("adds line item to cart containing a total fixed discount", async () => {
|
||||
@@ -251,21 +257,24 @@ describe("/store/carts", () => {
|
||||
)
|
||||
.catch((err) => console.log(err))
|
||||
|
||||
expect(response.data.cart.items).toEqual([
|
||||
expect.objectContaining({
|
||||
cart_id: "test-cart-w-total-fixed-discount",
|
||||
unit_price: 1000,
|
||||
variant_id: "test-variant-quantity",
|
||||
quantity: 2,
|
||||
adjustments: [
|
||||
expect.objectContaining({
|
||||
amount: 100,
|
||||
discount_id: "total-fixed-100",
|
||||
description: "discount",
|
||||
}),
|
||||
],
|
||||
}),
|
||||
])
|
||||
expect(response.data.cart.items).toHaveLength(1)
|
||||
expect(response.data.cart.items).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
cart_id: "test-cart-w-total-fixed-discount",
|
||||
unit_price: 1000,
|
||||
variant_id: "test-variant-quantity",
|
||||
quantity: 2,
|
||||
adjustments: [
|
||||
expect.objectContaining({
|
||||
amount: 100,
|
||||
discount_id: "total-fixed-100",
|
||||
description: "discount",
|
||||
}),
|
||||
],
|
||||
}),
|
||||
])
|
||||
)
|
||||
})
|
||||
|
||||
it("adds line item to cart containing a total percentage discount", async () => {
|
||||
@@ -282,21 +291,24 @@ describe("/store/carts", () => {
|
||||
)
|
||||
.catch((err) => console.log(err))
|
||||
|
||||
expect(response.data.cart.items).toEqual([
|
||||
expect.objectContaining({
|
||||
cart_id: "test-cart-w-total-percentage-discount",
|
||||
unit_price: 1000,
|
||||
variant_id: "test-variant-quantity",
|
||||
quantity: 2,
|
||||
adjustments: [
|
||||
expect.objectContaining({
|
||||
amount: 200,
|
||||
discount_id: "10Percent",
|
||||
description: "discount",
|
||||
}),
|
||||
],
|
||||
}),
|
||||
])
|
||||
expect(response.data.cart.items).toHaveLength(1)
|
||||
expect(response.data.cart.items).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
cart_id: "test-cart-w-total-percentage-discount",
|
||||
unit_price: 1000,
|
||||
variant_id: "test-variant-quantity",
|
||||
quantity: 2,
|
||||
adjustments: [
|
||||
expect.objectContaining({
|
||||
amount: 200,
|
||||
discount_id: "10Percent",
|
||||
description: "discount",
|
||||
}),
|
||||
],
|
||||
}),
|
||||
])
|
||||
)
|
||||
})
|
||||
|
||||
it("adds line item to cart containing an item fixed discount", async () => {
|
||||
@@ -313,21 +325,24 @@ describe("/store/carts", () => {
|
||||
)
|
||||
.catch((err) => console.log(err))
|
||||
|
||||
expect(response.data.cart.items).toEqual([
|
||||
expect.objectContaining({
|
||||
cart_id: "test-cart-w-item-fixed-discount",
|
||||
unit_price: 1000,
|
||||
variant_id: "test-variant-quantity",
|
||||
quantity: 2,
|
||||
adjustments: [
|
||||
expect.objectContaining({
|
||||
amount: 400,
|
||||
discount_id: "item-fixed-200",
|
||||
description: "discount",
|
||||
}),
|
||||
],
|
||||
}),
|
||||
])
|
||||
expect(response.data.cart.items).toHaveLength(1)
|
||||
expect(response.data.cart.items).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
cart_id: "test-cart-w-item-fixed-discount",
|
||||
unit_price: 1000,
|
||||
variant_id: "test-variant-quantity",
|
||||
quantity: 2,
|
||||
adjustments: [
|
||||
expect.objectContaining({
|
||||
amount: 400,
|
||||
discount_id: "item-fixed-200",
|
||||
description: "discount",
|
||||
}),
|
||||
],
|
||||
}),
|
||||
])
|
||||
)
|
||||
})
|
||||
|
||||
it("adds line item to cart containing an item percentage discount", async () => {
|
||||
@@ -344,21 +359,24 @@ describe("/store/carts", () => {
|
||||
)
|
||||
.catch((err) => console.log(err))
|
||||
|
||||
expect(response.data.cart.items).toEqual([
|
||||
expect.objectContaining({
|
||||
cart_id: "test-cart-w-item-percentage-discount",
|
||||
unit_price: 1000,
|
||||
variant_id: "test-variant-quantity",
|
||||
quantity: 2,
|
||||
adjustments: [
|
||||
expect.objectContaining({
|
||||
amount: 300,
|
||||
discount_id: "item-percentage-15",
|
||||
description: "discount",
|
||||
}),
|
||||
],
|
||||
}),
|
||||
])
|
||||
expect(response.data.cart.items).toHaveLength(1)
|
||||
expect(response.data.cart.items).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
cart_id: "test-cart-w-item-percentage-discount",
|
||||
unit_price: 1000,
|
||||
variant_id: "test-variant-quantity",
|
||||
quantity: 2,
|
||||
adjustments: [
|
||||
expect.objectContaining({
|
||||
amount: 300,
|
||||
discount_id: "item-percentage-15",
|
||||
description: "discount",
|
||||
}),
|
||||
],
|
||||
}),
|
||||
])
|
||||
)
|
||||
})
|
||||
|
||||
it("adds line item to cart time limited sale", async () => {
|
||||
@@ -375,14 +393,17 @@ describe("/store/carts", () => {
|
||||
)
|
||||
.catch((err) => console.log(err))
|
||||
|
||||
expect(response.data.cart.items).toEqual([
|
||||
expect.objectContaining({
|
||||
cart_id: "test-cart",
|
||||
unit_price: 800,
|
||||
variant_id: "test-variant-sale",
|
||||
quantity: 1,
|
||||
}),
|
||||
])
|
||||
expect(response.data.cart.items).toHaveLength(1)
|
||||
expect(response.data.cart.items).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
cart_id: "test-cart",
|
||||
unit_price: 800,
|
||||
variant_id: "test-variant-sale",
|
||||
quantity: 1,
|
||||
}),
|
||||
])
|
||||
)
|
||||
})
|
||||
|
||||
it("adds line item to cart time customer pricing", async () => {
|
||||
@@ -413,14 +434,17 @@ describe("/store/carts", () => {
|
||||
)
|
||||
.catch((err) => console.log(err))
|
||||
|
||||
expect(response.data.cart.items).toEqual([
|
||||
expect.objectContaining({
|
||||
cart_id: "test-cart",
|
||||
unit_price: 700,
|
||||
variant_id: "test-variant-sale-customer",
|
||||
quantity: 1,
|
||||
}),
|
||||
])
|
||||
expect(response.data.cart.items).toHaveLength(1)
|
||||
expect(response.data.cart.items).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
cart_id: "test-cart",
|
||||
unit_price: 700,
|
||||
variant_id: "test-variant-sale-customer",
|
||||
quantity: 1,
|
||||
}),
|
||||
])
|
||||
)
|
||||
})
|
||||
|
||||
it("adds line item with quantity to cart with quantity discount", async () => {
|
||||
@@ -437,14 +461,17 @@ describe("/store/carts", () => {
|
||||
)
|
||||
.catch((err) => console.log(err))
|
||||
|
||||
expect(response.data.cart.items).toEqual([
|
||||
expect.objectContaining({
|
||||
cart_id: "test-cart",
|
||||
unit_price: 800,
|
||||
variant_id: "test-variant-quantity",
|
||||
quantity: 90,
|
||||
}),
|
||||
])
|
||||
expect(response.data.cart.items).toHaveLength(1)
|
||||
expect(response.data.cart.items).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
cart_id: "test-cart",
|
||||
unit_price: 800,
|
||||
variant_id: "test-variant-quantity",
|
||||
quantity: 90,
|
||||
}),
|
||||
])
|
||||
)
|
||||
})
|
||||
|
||||
it("adds line item with quantity to cart with quantity discount no ceiling", async () => {
|
||||
@@ -461,14 +488,17 @@ describe("/store/carts", () => {
|
||||
)
|
||||
.catch((err) => console.log(err))
|
||||
|
||||
expect(response.data.cart.items).toEqual([
|
||||
expect.objectContaining({
|
||||
cart_id: "test-cart",
|
||||
unit_price: 700,
|
||||
variant_id: "test-variant-quantity",
|
||||
quantity: 900,
|
||||
}),
|
||||
])
|
||||
expect(response.data.cart.items).toHaveLength(1)
|
||||
expect(response.data.cart.items).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
cart_id: "test-cart",
|
||||
unit_price: 700,
|
||||
variant_id: "test-variant-quantity",
|
||||
quantity: 900,
|
||||
}),
|
||||
])
|
||||
)
|
||||
})
|
||||
|
||||
describe("ensures correct line item adjustment generation", () => {
|
||||
@@ -665,17 +695,19 @@ describe("/store/carts", () => {
|
||||
.catch((err) => console.log(err))
|
||||
|
||||
expect(response.data.cart.items.length).toEqual(1)
|
||||
expect(response.data.cart.items).toEqual([
|
||||
expect.objectContaining({
|
||||
adjustments: [
|
||||
expect.objectContaining({
|
||||
item_id: "line-item-2",
|
||||
amount: 185,
|
||||
discount_id: "medusa-185",
|
||||
}),
|
||||
],
|
||||
}),
|
||||
])
|
||||
expect(response.data.cart.items).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
adjustments: [
|
||||
expect.objectContaining({
|
||||
item_id: "line-item-2",
|
||||
amount: 185,
|
||||
discount_id: "medusa-185",
|
||||
}),
|
||||
],
|
||||
}),
|
||||
])
|
||||
)
|
||||
})
|
||||
})
|
||||
})
|
||||
@@ -739,21 +771,24 @@ describe("/store/carts", () => {
|
||||
)
|
||||
.catch((err) => console.log(err))
|
||||
|
||||
expect(response.data.cart.items).toEqual([
|
||||
expect.objectContaining({
|
||||
cart_id: "test-cart-w-total-fixed-discount",
|
||||
unit_price: 1000,
|
||||
variant_id: "test-variant-quantity",
|
||||
quantity: 3,
|
||||
adjustments: [
|
||||
expect.objectContaining({
|
||||
amount: 100,
|
||||
discount_id: "total-fixed-100",
|
||||
description: "discount",
|
||||
}),
|
||||
],
|
||||
}),
|
||||
])
|
||||
expect(response.data.cart.items).toHaveLength(1)
|
||||
expect(response.data.cart.items).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
cart_id: "test-cart-w-total-fixed-discount",
|
||||
unit_price: 1000,
|
||||
variant_id: "test-variant-quantity",
|
||||
quantity: 3,
|
||||
adjustments: [
|
||||
expect.objectContaining({
|
||||
amount: 100,
|
||||
discount_id: "total-fixed-100",
|
||||
description: "discount",
|
||||
}),
|
||||
],
|
||||
}),
|
||||
])
|
||||
)
|
||||
})
|
||||
|
||||
it("updates line item of a cart containing a total percentage discount", async () => {
|
||||
@@ -779,21 +814,24 @@ describe("/store/carts", () => {
|
||||
)
|
||||
.catch((err) => console.log(err))
|
||||
|
||||
expect(response.data.cart.items).toEqual([
|
||||
expect.objectContaining({
|
||||
cart_id: "test-cart-w-total-percentage-discount",
|
||||
unit_price: 1000,
|
||||
variant_id: "test-variant-quantity",
|
||||
quantity: 10,
|
||||
adjustments: [
|
||||
expect.objectContaining({
|
||||
amount: 1000,
|
||||
discount_id: "10Percent",
|
||||
description: "discount",
|
||||
}),
|
||||
],
|
||||
}),
|
||||
])
|
||||
expect(response.data.cart.items).toHaveLength(1)
|
||||
expect(response.data.cart.items).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
cart_id: "test-cart-w-total-percentage-discount",
|
||||
unit_price: 1000,
|
||||
variant_id: "test-variant-quantity",
|
||||
quantity: 10,
|
||||
adjustments: [
|
||||
expect.objectContaining({
|
||||
amount: 1000,
|
||||
discount_id: "10Percent",
|
||||
description: "discount",
|
||||
}),
|
||||
],
|
||||
}),
|
||||
])
|
||||
)
|
||||
})
|
||||
|
||||
it("updates line item of a cart containing an item fixed discount", async () => {
|
||||
@@ -819,21 +857,24 @@ describe("/store/carts", () => {
|
||||
)
|
||||
.catch((err) => console.log(err))
|
||||
|
||||
expect(response.data.cart.items).toEqual([
|
||||
expect.objectContaining({
|
||||
cart_id: "test-cart-w-item-fixed-discount",
|
||||
unit_price: 1000,
|
||||
variant_id: "test-variant-quantity",
|
||||
quantity: 4,
|
||||
adjustments: [
|
||||
expect.objectContaining({
|
||||
amount: 800,
|
||||
discount_id: "item-fixed-200",
|
||||
description: "discount",
|
||||
}),
|
||||
],
|
||||
}),
|
||||
])
|
||||
expect(response.data.cart.items).toHaveLength(1)
|
||||
expect(response.data.cart.items).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
cart_id: "test-cart-w-item-fixed-discount",
|
||||
unit_price: 1000,
|
||||
variant_id: "test-variant-quantity",
|
||||
quantity: 4,
|
||||
adjustments: [
|
||||
expect.objectContaining({
|
||||
amount: 800,
|
||||
discount_id: "item-fixed-200",
|
||||
description: "discount",
|
||||
}),
|
||||
],
|
||||
}),
|
||||
])
|
||||
)
|
||||
})
|
||||
|
||||
it("updates line item of a cart containing an item percentage discount", async () => {
|
||||
@@ -859,21 +900,24 @@ describe("/store/carts", () => {
|
||||
)
|
||||
.catch((err) => console.log(err))
|
||||
|
||||
expect(response.data.cart.items).toEqual([
|
||||
expect.objectContaining({
|
||||
cart_id: "test-cart-w-item-percentage-discount",
|
||||
unit_price: 1000,
|
||||
variant_id: "test-variant-quantity",
|
||||
quantity: 3,
|
||||
adjustments: [
|
||||
expect.objectContaining({
|
||||
amount: 450,
|
||||
discount_id: "item-percentage-15",
|
||||
description: "discount",
|
||||
}),
|
||||
],
|
||||
}),
|
||||
])
|
||||
expect(response.data.cart.items).toHaveLength(1)
|
||||
expect(response.data.cart.items).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
cart_id: "test-cart-w-item-percentage-discount",
|
||||
unit_price: 1000,
|
||||
variant_id: "test-variant-quantity",
|
||||
quantity: 3,
|
||||
adjustments: [
|
||||
expect.objectContaining({
|
||||
amount: 450,
|
||||
discount_id: "item-percentage-15",
|
||||
description: "discount",
|
||||
}),
|
||||
],
|
||||
}),
|
||||
])
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -1564,6 +1608,36 @@ describe("/store/carts", () => {
|
||||
expect(getRes.data.type).toEqual("order")
|
||||
})
|
||||
|
||||
it("complete cart with 100% discount", async () => {
|
||||
await simpleDiscountFactory(dbConnection, {
|
||||
code: "100PERCENT",
|
||||
rule: {
|
||||
type: "percentage",
|
||||
value: 100,
|
||||
},
|
||||
regions: ["test-region"],
|
||||
})
|
||||
|
||||
const api = useApi()
|
||||
|
||||
await api
|
||||
.post(`/store/carts/test-cart-3`, {
|
||||
discounts: [{ code: "100PERCENT" }],
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err.response.data)
|
||||
})
|
||||
|
||||
const getRes = await api
|
||||
.post(`/store/carts/test-cart-3/complete`)
|
||||
.catch((err) => {
|
||||
console.log(err.response.data)
|
||||
})
|
||||
|
||||
expect(getRes.status).toEqual(200)
|
||||
expect(getRes.data.type).toEqual("order")
|
||||
})
|
||||
|
||||
it("complete cart with items inventory covered", async () => {
|
||||
const api = useApi()
|
||||
const getRes = await api.post(`/store/carts/test-cart-2/complete-cart`)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
const path = require("path")
|
||||
const { Address, Customer } = require("@medusajs/medusa")
|
||||
const { Address, Customer, Order, Region } = require("@medusajs/medusa")
|
||||
|
||||
const setupServer = require("../../../helpers/setup-server")
|
||||
const { useApi } = require("../../../helpers/use-api")
|
||||
@@ -19,7 +19,7 @@ describe("/store/customers", () => {
|
||||
beforeAll(async () => {
|
||||
const cwd = path.resolve(path.join(__dirname, "..", ".."))
|
||||
dbConnection = await initDb({ cwd })
|
||||
medusaProcess = await setupServer({ cwd })
|
||||
medusaProcess = await setupServer({ cwd, verbose: false })
|
||||
})
|
||||
|
||||
afterAll(async () => {
|
||||
@@ -89,6 +89,150 @@ describe("/store/customers", () => {
|
||||
})
|
||||
})
|
||||
|
||||
describe("GET /store/customers/me/orders", () => {
|
||||
beforeEach(async () => {
|
||||
const manager = dbConnection.manager
|
||||
await manager.query(`ALTER SEQUENCE order_display_id_seq RESTART WITH 1`)
|
||||
|
||||
await manager.insert(Address, {
|
||||
id: "addr_test",
|
||||
first_name: "String",
|
||||
last_name: "Stringson",
|
||||
address_1: "String st",
|
||||
city: "Stringville",
|
||||
postal_code: "1236",
|
||||
province: "ca",
|
||||
country_code: "us",
|
||||
})
|
||||
|
||||
await manager.insert(Region, {
|
||||
id: "region",
|
||||
name: "Test Region",
|
||||
currency_code: "usd",
|
||||
tax_rate: 0,
|
||||
})
|
||||
|
||||
await manager.insert(Customer, {
|
||||
id: "test_customer",
|
||||
first_name: "John",
|
||||
last_name: "Deere",
|
||||
email: "john@deere.com",
|
||||
password_hash:
|
||||
"c2NyeXB0AAEAAAABAAAAAVMdaddoGjwU1TafDLLlBKnOTQga7P2dbrfgf3fB+rCD/cJOMuGzAvRdKutbYkVpuJWTU39P7OpuWNkUVoEETOVLMJafbI8qs8Qx/7jMQXkN", // password matching "test"
|
||||
has_account: true,
|
||||
})
|
||||
|
||||
await manager.insert(Customer, {
|
||||
id: "test_customer1",
|
||||
first_name: "John",
|
||||
last_name: "Deere",
|
||||
email: "joh1n@deere.com",
|
||||
password_hash:
|
||||
"c2NyeXB0AAEAAAABAAAAAVMdaddoGjwU1TafDLLlBKnOTQga7P2dbrfgf3fB+rCD/cJOMuGzAvRdKutbYkVpuJWTU39P7OpuWNkUVoEETOVLMJafbI8qs8Qx/7jMQXkN", // password matching "test"
|
||||
has_account: true,
|
||||
})
|
||||
|
||||
await manager.insert(Order, {
|
||||
id: "order_test_completed",
|
||||
email: "test1@email.com",
|
||||
display_id: 1,
|
||||
customer_id: "test_customer",
|
||||
region_id: "region",
|
||||
status: "completed",
|
||||
tax_rate: 0,
|
||||
currency_code: "usd",
|
||||
})
|
||||
|
||||
await manager.insert(Order, {
|
||||
id: "order_test_completed1",
|
||||
email: "test1@email.com",
|
||||
display_id: 2,
|
||||
customer_id: "test_customer1",
|
||||
region_id: "region",
|
||||
status: "completed",
|
||||
tax_rate: 0,
|
||||
currency_code: "usd",
|
||||
})
|
||||
|
||||
await manager.insert(Order, {
|
||||
id: "order_test_canceled",
|
||||
email: "test1@email.com",
|
||||
display_id: 3,
|
||||
customer_id: "test_customer",
|
||||
region_id: "region",
|
||||
status: "canceled",
|
||||
tax_rate: 0,
|
||||
currency_code: "usd",
|
||||
})
|
||||
})
|
||||
|
||||
afterEach(async () => {
|
||||
await doAfterEach()
|
||||
})
|
||||
|
||||
it("looks up completed orders", async () => {
|
||||
const api = useApi()
|
||||
|
||||
const authResponse = await api.post("/store/auth", {
|
||||
email: "john@deere.com",
|
||||
password: "test",
|
||||
})
|
||||
|
||||
const [authCookie] = authResponse.headers["set-cookie"][0].split(";")
|
||||
|
||||
const response = await api
|
||||
.get("/store/customers/me/orders?status[]=completed", {
|
||||
headers: {
|
||||
Cookie: authCookie,
|
||||
},
|
||||
})
|
||||
.catch((err) => {
|
||||
return err.response
|
||||
})
|
||||
expect(response.status).toEqual(200)
|
||||
expect(response.data.orders[0].display_id).toEqual(1)
|
||||
expect(response.data.orders[0].email).toEqual("test1@email.com")
|
||||
expect(response.data.orders.length).toEqual(1)
|
||||
})
|
||||
|
||||
it("looks up cancelled and completed orders", async () => {
|
||||
const api = useApi()
|
||||
|
||||
const authResponse = await api.post("/store/auth", {
|
||||
email: "john@deere.com",
|
||||
password: "test",
|
||||
})
|
||||
|
||||
const [authCookie] = authResponse.headers["set-cookie"][0].split(";")
|
||||
|
||||
const response = await api
|
||||
.get(
|
||||
"/store/customers/me/orders?status[]=completed&status[]=canceled",
|
||||
{
|
||||
headers: {
|
||||
Cookie: authCookie,
|
||||
},
|
||||
}
|
||||
)
|
||||
.catch((err) => {
|
||||
return console.log(err.response.data.message)
|
||||
})
|
||||
|
||||
expect(response.status).toEqual(200)
|
||||
expect(response.data.orders).toEqual([
|
||||
expect.objectContaining({
|
||||
display_id: 3,
|
||||
status: "canceled",
|
||||
}),
|
||||
expect.objectContaining({
|
||||
display_id: 1,
|
||||
status: "completed",
|
||||
}),
|
||||
])
|
||||
expect(response.data.orders.length).toEqual(2)
|
||||
})
|
||||
})
|
||||
|
||||
describe("POST /store/customers/me", () => {
|
||||
beforeEach(async () => {
|
||||
const manager = dbConnection.manager
|
||||
|
||||
@@ -7,14 +7,14 @@ const {
|
||||
Product,
|
||||
ProductVariant,
|
||||
LineItem,
|
||||
Payment,
|
||||
} = require("@medusajs/medusa")
|
||||
|
||||
const setupServer = require("../../../helpers/setup-server")
|
||||
const { useApi } = require("../../../helpers/use-api")
|
||||
const { initDb, useDb } = require("../../../helpers/use-db")
|
||||
|
||||
const swapSeeder = require("../../helpers/swap-seeder")
|
||||
const cartSeeder = require("../../helpers/cart-seeder")
|
||||
const { simpleRegionFactory, simpleProductFactory } = require("../../factories")
|
||||
const { MedusaError } = require("medusa-core-utils")
|
||||
|
||||
jest.setTimeout(30000)
|
||||
|
||||
@@ -25,7 +25,7 @@ describe("/store/carts", () => {
|
||||
beforeAll(async () => {
|
||||
const cwd = path.resolve(path.join(__dirname, "..", ".."))
|
||||
dbConnection = await initDb({ cwd })
|
||||
medusaProcess = await setupServer({ cwd })
|
||||
medusaProcess = await setupServer({ cwd, verbose: false })
|
||||
})
|
||||
|
||||
afterAll(async () => {
|
||||
@@ -147,4 +147,156 @@ describe("/store/carts", () => {
|
||||
expect(response.status).toEqual(404)
|
||||
})
|
||||
})
|
||||
|
||||
describe("Cart Completion with INSUFFICIENT_INVENTORY", () => {
|
||||
afterEach(async () => {
|
||||
const db = useDb()
|
||||
await db.teardown()
|
||||
})
|
||||
|
||||
it("recovers from failed completion", async () => {
|
||||
const api = useApi()
|
||||
|
||||
const region = await simpleRegionFactory(dbConnection)
|
||||
const product = await simpleProductFactory(dbConnection)
|
||||
|
||||
const cartRes = await api
|
||||
.post("/store/carts", {
|
||||
region_id: region.id,
|
||||
})
|
||||
.catch((err) => {
|
||||
return err.response
|
||||
})
|
||||
|
||||
const cartId = cartRes.data.cart.id
|
||||
|
||||
await api.post(`/store/carts/${cartId}/line-items`, {
|
||||
variant_id: product.variants[0].id,
|
||||
quantity: 1,
|
||||
})
|
||||
await api.post(`/store/carts/${cartId}`, {
|
||||
email: "testmailer@medusajs.com",
|
||||
})
|
||||
await api.post(`/store/carts/${cartId}/payment-sessions`)
|
||||
|
||||
const manager = dbConnection.manager
|
||||
await manager.update(
|
||||
ProductVariant,
|
||||
{ id: product.variants[0].id },
|
||||
{
|
||||
inventory_quantity: 0,
|
||||
}
|
||||
)
|
||||
|
||||
const responseFail = await api
|
||||
.post(`/store/carts/${cartId}/complete`)
|
||||
.catch((err) => {
|
||||
return err.response
|
||||
})
|
||||
|
||||
expect(responseFail.status).toEqual(409)
|
||||
expect(responseFail.data.type).toEqual("not_allowed")
|
||||
expect(responseFail.data.code).toEqual(
|
||||
MedusaError.Codes.INSUFFICIENT_INVENTORY
|
||||
)
|
||||
|
||||
let payments = await manager.find(Payment, { cart_id: cartId })
|
||||
expect(payments).toHaveLength(1)
|
||||
expect(payments).toContainEqual(
|
||||
expect.objectContaining({
|
||||
canceled_at: expect.any(Date),
|
||||
})
|
||||
)
|
||||
|
||||
await manager.update(
|
||||
ProductVariant,
|
||||
{ id: product.variants[0].id },
|
||||
{
|
||||
inventory_quantity: 1,
|
||||
}
|
||||
)
|
||||
|
||||
const responseSuccess = await api
|
||||
.post(`/store/carts/${cartId}/complete`)
|
||||
.catch((err) => {
|
||||
return err.response
|
||||
})
|
||||
|
||||
expect(responseSuccess.status).toEqual(200)
|
||||
expect(responseSuccess.data.type).toEqual("order")
|
||||
|
||||
payments = await manager.find(Payment, { cart_id: cartId })
|
||||
expect(payments).toHaveLength(2)
|
||||
expect(payments).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
canceled_at: null,
|
||||
}),
|
||||
])
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
describe("Cart consecutive completion", () => {
|
||||
afterEach(async () => {
|
||||
const db = useDb()
|
||||
await db.teardown()
|
||||
})
|
||||
|
||||
it("should fails on cart already completed", async () => {
|
||||
const api = useApi()
|
||||
const manager = dbConnection.manager
|
||||
|
||||
const region = await simpleRegionFactory(dbConnection)
|
||||
const product = await simpleProductFactory(dbConnection)
|
||||
|
||||
const cartRes = await api
|
||||
.post("/store/carts", {
|
||||
region_id: region.id,
|
||||
})
|
||||
.catch((err) => {
|
||||
return err.response
|
||||
})
|
||||
|
||||
const cartId = cartRes.data.cart.id
|
||||
|
||||
await api.post(`/store/carts/${cartId}/line-items`, {
|
||||
variant_id: product.variants[0].id,
|
||||
quantity: 1,
|
||||
})
|
||||
await api.post(`/store/carts/${cartId}`, {
|
||||
email: "testmailer@medusajs.com",
|
||||
})
|
||||
await api.post(`/store/carts/${cartId}/payment-sessions`)
|
||||
|
||||
const responseSuccess = await api
|
||||
.post(`/store/carts/${cartId}/complete`)
|
||||
.catch((err) => {
|
||||
return err.response
|
||||
})
|
||||
|
||||
expect(responseSuccess.status).toEqual(200)
|
||||
expect(responseSuccess.data.type).toEqual("order")
|
||||
|
||||
const payments = await manager.find(Payment, { cart_id: cartId })
|
||||
expect(payments).toHaveLength(1)
|
||||
expect(payments).toContainEqual(
|
||||
expect.objectContaining({
|
||||
canceled_at: null,
|
||||
})
|
||||
)
|
||||
|
||||
const responseFail = await api
|
||||
.post(`/store/carts/${cartId}/complete`)
|
||||
.catch((err) => {
|
||||
return err.response
|
||||
})
|
||||
|
||||
expect(responseFail.status).toEqual(409)
|
||||
expect(responseFail.data.code).toEqual("cart_incompatible_state")
|
||||
expect(responseFail.data.message).toEqual(
|
||||
"Cart has already been completed"
|
||||
)
|
||||
})
|
||||
})
|
||||
})
|
||||
@@ -50,12 +50,15 @@ describe("/store/products", () => {
|
||||
})
|
||||
|
||||
expect(response.status).toEqual(200)
|
||||
expect(response.data.products).toEqual([
|
||||
expect.objectContaining({
|
||||
id: "test-product_filtering_2",
|
||||
collection_id: "test-collection2",
|
||||
}),
|
||||
])
|
||||
expect(response.data.products).toHaveLength(1)
|
||||
expect(response.data.products).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
id: "test-product_filtering_2",
|
||||
collection_id: "test-collection2",
|
||||
}),
|
||||
])
|
||||
)
|
||||
|
||||
for (const notExpect of notExpected) {
|
||||
expect(response.data.products).toEqual(
|
||||
@@ -76,12 +79,15 @@ describe("/store/products", () => {
|
||||
})
|
||||
|
||||
expect(response.status).toEqual(200)
|
||||
expect(response.data.products).toEqual([
|
||||
expect.objectContaining({
|
||||
id: "test-product_filtering_1",
|
||||
collection_id: "test-collection1",
|
||||
}),
|
||||
])
|
||||
expect(response.data.products).toHaveLength(1)
|
||||
expect(response.data.products).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
id: "test-product_filtering_1",
|
||||
collection_id: "test-collection1",
|
||||
}),
|
||||
])
|
||||
)
|
||||
|
||||
for (const notExpect of notExpected) {
|
||||
expect(response.data.products).toEqual(
|
||||
@@ -101,12 +107,14 @@ describe("/store/products", () => {
|
||||
|
||||
expect(response.status).toEqual(200)
|
||||
expect(response.data.products.length).toEqual(1)
|
||||
expect(response.data.products).toEqual([
|
||||
expect.objectContaining({
|
||||
id: "giftcard",
|
||||
is_giftcard: true,
|
||||
}),
|
||||
])
|
||||
expect(response.data.products).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
id: "giftcard",
|
||||
is_giftcard: true,
|
||||
}),
|
||||
])
|
||||
)
|
||||
})
|
||||
|
||||
it("returns non gift card products", async () => {
|
||||
@@ -139,12 +147,15 @@ describe("/store/products", () => {
|
||||
})
|
||||
|
||||
expect(response.status).toEqual(200)
|
||||
expect(response.data.products).toEqual([
|
||||
expect.objectContaining({
|
||||
id: "test-product_filtering_1",
|
||||
collection_id: "test-collection1",
|
||||
}),
|
||||
])
|
||||
expect(response.data.products).toHaveLength(1)
|
||||
expect(response.data.products).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
id: "test-product_filtering_1",
|
||||
collection_id: "test-collection1",
|
||||
}),
|
||||
])
|
||||
)
|
||||
|
||||
for (const notExpect of notExpected) {
|
||||
expect(response.data.products).toEqual(
|
||||
@@ -167,12 +178,15 @@ describe("/store/products", () => {
|
||||
})
|
||||
|
||||
expect(response.status).toEqual(200)
|
||||
expect(response.data.products).toEqual([
|
||||
expect.objectContaining({
|
||||
id: "test-product_filtering_2",
|
||||
handle: "test-product_filtering_2",
|
||||
}),
|
||||
])
|
||||
expect(response.data.products).toHaveLength(1)
|
||||
expect(response.data.products).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
id: "test-product_filtering_2",
|
||||
handle: "test-product_filtering_2",
|
||||
}),
|
||||
])
|
||||
)
|
||||
|
||||
for (const notExpect of notExpected) {
|
||||
expect(response.data.products).toEqual(
|
||||
@@ -196,27 +210,29 @@ describe("/store/products", () => {
|
||||
|
||||
expect(response.status).toEqual(200)
|
||||
expect(response.data.products.length).toEqual(5)
|
||||
expect(response.data.products).toEqual([
|
||||
expect.objectContaining({
|
||||
id: "test-product1",
|
||||
collection_id: "test-collection",
|
||||
}),
|
||||
expect.objectContaining({
|
||||
id: "test-product",
|
||||
collection_id: "test-collection",
|
||||
}),
|
||||
expect.objectContaining({
|
||||
id: "test-product_filtering_2",
|
||||
collection_id: "test-collection2",
|
||||
}),
|
||||
expect.objectContaining({
|
||||
id: "test-product_filtering_1",
|
||||
collection_id: "test-collection1",
|
||||
}),
|
||||
expect.objectContaining({
|
||||
id: "giftcard",
|
||||
}),
|
||||
])
|
||||
expect(response.data.products).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
id: "test-product1",
|
||||
collection_id: "test-collection",
|
||||
}),
|
||||
expect.objectContaining({
|
||||
id: "test-product",
|
||||
collection_id: "test-collection",
|
||||
}),
|
||||
expect.objectContaining({
|
||||
id: "test-product_filtering_2",
|
||||
collection_id: "test-collection2",
|
||||
}),
|
||||
expect.objectContaining({
|
||||
id: "test-product_filtering_1",
|
||||
collection_id: "test-collection1",
|
||||
}),
|
||||
expect.objectContaining({
|
||||
id: "giftcard",
|
||||
}),
|
||||
])
|
||||
)
|
||||
|
||||
for (const notExpect of notExpected) {
|
||||
expect(response.data.products).toEqual(
|
||||
@@ -246,77 +262,80 @@ describe("/store/products", () => {
|
||||
console.log(err)
|
||||
})
|
||||
|
||||
expect(response.data.products).toEqual([
|
||||
expect.objectContaining({
|
||||
id: "test-product1",
|
||||
collection_id: "test-collection",
|
||||
}),
|
||||
expect.objectContaining({
|
||||
id: "test-product",
|
||||
collection_id: "test-collection",
|
||||
variants: [
|
||||
expect.objectContaining({
|
||||
original_price: 100,
|
||||
calculated_price: 80,
|
||||
prices: [
|
||||
expect.objectContaining({
|
||||
id: "test-price",
|
||||
currency_code: "usd",
|
||||
amount: 100,
|
||||
}),
|
||||
expect.objectContaining({
|
||||
id: "test-price-discount",
|
||||
currency_code: "usd",
|
||||
amount: 80,
|
||||
}),
|
||||
],
|
||||
}),
|
||||
expect.objectContaining({
|
||||
original_price: 100,
|
||||
calculated_price: 80,
|
||||
prices: [
|
||||
expect.objectContaining({
|
||||
id: "test-price2",
|
||||
currency_code: "usd",
|
||||
amount: 100,
|
||||
}),
|
||||
expect.objectContaining({
|
||||
id: "test-price2-discount",
|
||||
currency_code: "usd",
|
||||
amount: 80,
|
||||
}),
|
||||
],
|
||||
}),
|
||||
expect.objectContaining({
|
||||
original_price: 100,
|
||||
calculated_price: 80,
|
||||
prices: [
|
||||
expect.objectContaining({
|
||||
id: "test-price1",
|
||||
currency_code: "usd",
|
||||
amount: 100,
|
||||
}),
|
||||
expect.objectContaining({
|
||||
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_1",
|
||||
collection_id: "test-collection1",
|
||||
}),
|
||||
expect.objectContaining({
|
||||
id: "giftcard",
|
||||
}),
|
||||
])
|
||||
expect(response.data.products).toHaveLength(5)
|
||||
expect(response.data.products).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
id: "test-product1",
|
||||
collection_id: "test-collection",
|
||||
}),
|
||||
expect.objectContaining({
|
||||
id: "test-product",
|
||||
collection_id: "test-collection",
|
||||
variants: [
|
||||
expect.objectContaining({
|
||||
original_price: 100,
|
||||
calculated_price: 80,
|
||||
prices: [
|
||||
expect.objectContaining({
|
||||
id: "test-price",
|
||||
currency_code: "usd",
|
||||
amount: 100,
|
||||
}),
|
||||
expect.objectContaining({
|
||||
id: "test-price-discount",
|
||||
currency_code: "usd",
|
||||
amount: 80,
|
||||
}),
|
||||
],
|
||||
}),
|
||||
expect.objectContaining({
|
||||
original_price: 100,
|
||||
calculated_price: 80,
|
||||
prices: [
|
||||
expect.objectContaining({
|
||||
id: "test-price2",
|
||||
currency_code: "usd",
|
||||
amount: 100,
|
||||
}),
|
||||
expect.objectContaining({
|
||||
id: "test-price2-discount",
|
||||
currency_code: "usd",
|
||||
amount: 80,
|
||||
}),
|
||||
],
|
||||
}),
|
||||
expect.objectContaining({
|
||||
original_price: 100,
|
||||
calculated_price: 80,
|
||||
prices: [
|
||||
expect.objectContaining({
|
||||
id: "test-price1",
|
||||
currency_code: "usd",
|
||||
amount: 100,
|
||||
}),
|
||||
expect.objectContaining({
|
||||
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_1",
|
||||
collection_id: "test-collection1",
|
||||
}),
|
||||
expect.objectContaining({
|
||||
id: "giftcard",
|
||||
}),
|
||||
])
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
@@ -108,22 +108,25 @@ describe("/store/return-reasons", () => {
|
||||
|
||||
expect(response.status).toEqual(200)
|
||||
|
||||
expect(response.data.return_reasons).toEqual([
|
||||
expect.objectContaining({
|
||||
id: rrId,
|
||||
value: "wrong_size",
|
||||
return_reason_children: [
|
||||
expect.objectContaining({
|
||||
id: rrId_1,
|
||||
value: "too_big",
|
||||
}),
|
||||
],
|
||||
}),
|
||||
expect.objectContaining({
|
||||
id: rrId_2,
|
||||
value: "too_big_1",
|
||||
}),
|
||||
])
|
||||
expect(response.data.return_reasons).toHaveLength(2)
|
||||
expect(response.data.return_reasons).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
id: rrId,
|
||||
value: "wrong_size",
|
||||
return_reason_children: [
|
||||
expect.objectContaining({
|
||||
id: rrId_1,
|
||||
value: "too_big",
|
||||
}),
|
||||
],
|
||||
}),
|
||||
expect.objectContaining({
|
||||
id: rrId_2,
|
||||
value: "too_big_1",
|
||||
}),
|
||||
])
|
||||
)
|
||||
})
|
||||
})
|
||||
})
|
||||
@@ -241,12 +241,15 @@ describe("/store/carts", () => {
|
||||
})
|
||||
expect(response.status).toEqual(200)
|
||||
|
||||
expect(response.data.return.items).toEqual([
|
||||
expect.objectContaining({
|
||||
reason_id: rrId_child,
|
||||
note: "TOO small",
|
||||
}),
|
||||
])
|
||||
expect(response.data.return.items).toHaveLength(1)
|
||||
expect(response.data.return.items).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
reason_id: rrId_child,
|
||||
note: "TOO small",
|
||||
}),
|
||||
])
|
||||
)
|
||||
})
|
||||
|
||||
it("failes to create a return with an invalid quantity (less than 1)", async () => {
|
||||
|
||||
@@ -6,8 +6,6 @@ const { initDb, useDb } = require("../../../helpers/use-db")
|
||||
|
||||
const {
|
||||
simpleProductTaxRateFactory,
|
||||
simpleShippingTaxRateFactory,
|
||||
simpleShippingOptionFactory,
|
||||
simpleCartFactory,
|
||||
simpleRegionFactory,
|
||||
simpleProductFactory,
|
||||
|
||||
@@ -286,16 +286,22 @@ describe("Order Taxes", () => {
|
||||
response.data.data.items.flatMap((li) => li.tax_lines).length
|
||||
).toEqual(2)
|
||||
|
||||
expect(response.data.data.items[0].tax_lines).toEqual([
|
||||
expect.objectContaining({
|
||||
rate: 25,
|
||||
}),
|
||||
])
|
||||
expect(response.data.data.items[1].tax_lines).toEqual([
|
||||
expect.objectContaining({
|
||||
rate: 20,
|
||||
}),
|
||||
])
|
||||
expect(response.data.data.items[0].tax_lines).toHaveLength(1)
|
||||
expect(response.data.data.items[0].tax_lines).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
rate: 25,
|
||||
}),
|
||||
])
|
||||
)
|
||||
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 () => {
|
||||
@@ -377,15 +383,21 @@ describe("Order Taxes", () => {
|
||||
expect(response.data.data.tax_total).toEqual(35)
|
||||
expect(response.data.data.total).toEqual(185)
|
||||
|
||||
expect(response.data.data.items[0].tax_lines).toEqual([
|
||||
expect.objectContaining({
|
||||
rate: 25,
|
||||
}),
|
||||
])
|
||||
expect(response.data.data.items[1].tax_lines).toEqual([
|
||||
expect.objectContaining({
|
||||
rate: 20,
|
||||
}),
|
||||
])
|
||||
expect(response.data.data.items[0].tax_lines).toHaveLength(1)
|
||||
expect(response.data.data.items[0].tax_lines).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
rate: 25,
|
||||
}),
|
||||
])
|
||||
)
|
||||
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,
|
||||
}),
|
||||
])
|
||||
)
|
||||
})
|
||||
})
|
||||
@@ -64,13 +64,16 @@ describe("Shipping Options Totals Calculations", () => {
|
||||
},
|
||||
})
|
||||
|
||||
expect(res.data.shipping_options).toEqual([
|
||||
expect.objectContaining({
|
||||
id: so.id,
|
||||
amount: 100,
|
||||
price_incl_tax: 110,
|
||||
}),
|
||||
])
|
||||
expect(res.data.shipping_options).toHaveLength(1)
|
||||
expect(res.data.shipping_options).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
id: so.id,
|
||||
amount: 100,
|
||||
price_incl_tax: 110,
|
||||
}),
|
||||
])
|
||||
)
|
||||
})
|
||||
|
||||
it("gets correct shipping prices", async () => {
|
||||
@@ -93,12 +96,15 @@ describe("Shipping Options Totals Calculations", () => {
|
||||
|
||||
const res = await api.get(`/store/shipping-options?region_id=${region.id}`)
|
||||
|
||||
expect(res.data.shipping_options).toEqual([
|
||||
expect.objectContaining({
|
||||
id: so.id,
|
||||
amount: 100,
|
||||
price_incl_tax: 110,
|
||||
}),
|
||||
])
|
||||
expect(res.data.shipping_options).toHaveLength(1)
|
||||
expect(res.data.shipping_options).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
id: so.id,
|
||||
amount: 100,
|
||||
price_incl_tax: 110,
|
||||
}),
|
||||
])
|
||||
)
|
||||
})
|
||||
})
|
||||
@@ -89,13 +89,16 @@ describe("Order Totals", () => {
|
||||
headers: { Authorization: `Bearer test_token` },
|
||||
})
|
||||
|
||||
expect(data.order.gift_card_transactions).toEqual([
|
||||
expect.objectContaining({
|
||||
amount: 160000,
|
||||
is_taxable: false,
|
||||
tax_rate: null,
|
||||
}),
|
||||
])
|
||||
expect(data.order.gift_card_transactions).toHaveLength(1)
|
||||
expect(data.order.gift_card_transactions).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
amount: 160000,
|
||||
is_taxable: false,
|
||||
tax_rate: null,
|
||||
}),
|
||||
])
|
||||
)
|
||||
expect(data.order.gift_card_total).toEqual(160000)
|
||||
expect(data.order.gift_card_tax_total).toEqual(0)
|
||||
expect(data.order.total).toEqual(59000)
|
||||
@@ -151,13 +154,16 @@ describe("Order Totals", () => {
|
||||
headers: { Authorization: `Bearer test_token` },
|
||||
})
|
||||
|
||||
expect(data.order.gift_card_transactions).toEqual([
|
||||
expect.objectContaining({
|
||||
amount: 160000,
|
||||
is_taxable: true,
|
||||
tax_rate: 25,
|
||||
}),
|
||||
])
|
||||
expect(data.order.gift_card_transactions).toHaveLength(1)
|
||||
expect(data.order.gift_card_transactions).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
amount: 160000,
|
||||
is_taxable: true,
|
||||
tax_rate: 25,
|
||||
}),
|
||||
])
|
||||
)
|
||||
expect(data.order.gift_card_total).toEqual(160000)
|
||||
expect(data.order.gift_card_tax_total).toEqual(40000)
|
||||
expect(data.order.tax_total).toEqual(3800)
|
||||
|
||||
Reference in new issue
Block a user