chore(integration): throw errors on catch blocks (#2091)
Why: Suppressing errors and not failing the execution will lead to misleading errors of the following tests. Fixes CORE-461
This commit is contained in:
committed by
GitHub
parent
5a964e6439
commit
ffd6234356
@@ -44,13 +44,8 @@ describe("/admin/orders", () => {
|
||||
|
||||
describe("GET /admin/orders", () => {
|
||||
beforeEach(async () => {
|
||||
try {
|
||||
await adminSeeder(dbConnection)
|
||||
await orderSeeder(dbConnection)
|
||||
} catch (err) {
|
||||
console.log(err)
|
||||
throw err
|
||||
}
|
||||
await adminSeeder(dbConnection)
|
||||
await orderSeeder(dbConnection)
|
||||
})
|
||||
|
||||
afterEach(async () => {
|
||||
@@ -129,14 +124,9 @@ describe("/admin/orders", () => {
|
||||
|
||||
describe("GET /admin/orders", () => {
|
||||
beforeEach(async () => {
|
||||
try {
|
||||
await adminSeeder(dbConnection)
|
||||
await orderSeeder(dbConnection)
|
||||
await swapSeeder(dbConnection)
|
||||
} catch (err) {
|
||||
console.log(err)
|
||||
throw err
|
||||
}
|
||||
await adminSeeder(dbConnection)
|
||||
await orderSeeder(dbConnection)
|
||||
await swapSeeder(dbConnection)
|
||||
|
||||
const manager = dbConnection.manager
|
||||
|
||||
@@ -276,14 +266,9 @@ describe("/admin/orders", () => {
|
||||
|
||||
describe("POST /admin/orders/:id/swaps", () => {
|
||||
beforeEach(async () => {
|
||||
try {
|
||||
await adminSeeder(dbConnection)
|
||||
await orderSeeder(dbConnection)
|
||||
await claimSeeder(dbConnection)
|
||||
} catch (err) {
|
||||
console.log(err)
|
||||
throw err
|
||||
}
|
||||
await adminSeeder(dbConnection)
|
||||
await orderSeeder(dbConnection)
|
||||
await claimSeeder(dbConnection)
|
||||
})
|
||||
|
||||
afterEach(async () => {
|
||||
@@ -318,14 +303,9 @@ describe("/admin/orders", () => {
|
||||
|
||||
describe("POST /admin/orders/:id/claims", () => {
|
||||
beforeEach(async () => {
|
||||
try {
|
||||
await adminSeeder(dbConnection)
|
||||
await orderSeeder(dbConnection)
|
||||
await claimSeeder(dbConnection)
|
||||
} catch (err) {
|
||||
console.log(err)
|
||||
throw err
|
||||
}
|
||||
await adminSeeder(dbConnection)
|
||||
await orderSeeder(dbConnection)
|
||||
await claimSeeder(dbConnection)
|
||||
})
|
||||
|
||||
afterEach(async () => {
|
||||
@@ -1216,14 +1196,9 @@ describe("/admin/orders", () => {
|
||||
|
||||
describe("POST /admin/orders/:id/claims", () => {
|
||||
beforeEach(async () => {
|
||||
try {
|
||||
await adminSeeder(dbConnection)
|
||||
await orderSeeder(dbConnection)
|
||||
await swapSeeder(dbConnection)
|
||||
} catch (err) {
|
||||
console.log(err)
|
||||
throw err
|
||||
}
|
||||
await adminSeeder(dbConnection)
|
||||
await orderSeeder(dbConnection)
|
||||
await swapSeeder(dbConnection)
|
||||
})
|
||||
|
||||
afterEach(async () => {
|
||||
@@ -1272,21 +1247,16 @@ describe("/admin/orders", () => {
|
||||
describe("POST /admin/orders/:id/return", () => {
|
||||
let rrId
|
||||
beforeEach(async () => {
|
||||
try {
|
||||
await adminSeeder(dbConnection)
|
||||
await orderSeeder(dbConnection)
|
||||
await adminSeeder(dbConnection)
|
||||
await orderSeeder(dbConnection)
|
||||
|
||||
const created = dbConnection.manager.create(ReturnReason, {
|
||||
value: "too_big",
|
||||
label: "Too Big",
|
||||
})
|
||||
const result = await dbConnection.manager.save(created)
|
||||
const created = dbConnection.manager.create(ReturnReason, {
|
||||
value: "too_big",
|
||||
label: "Too Big",
|
||||
})
|
||||
const result = await dbConnection.manager.save(created)
|
||||
|
||||
rrId = result.id
|
||||
} catch (err) {
|
||||
console.log(err)
|
||||
throw err
|
||||
}
|
||||
rrId = result.id
|
||||
})
|
||||
|
||||
afterEach(async () => {
|
||||
@@ -1392,17 +1362,12 @@ describe("/admin/orders", () => {
|
||||
|
||||
describe("GET /admin/orders", () => {
|
||||
beforeEach(async () => {
|
||||
try {
|
||||
await adminSeeder(dbConnection)
|
||||
// Manually insert date for filtering
|
||||
const createdAt = new Date("26 January 1997 12:00 UTC")
|
||||
await orderSeeder(dbConnection, {
|
||||
created_at: createdAt.toISOString(),
|
||||
})
|
||||
} catch (err) {
|
||||
console.log(err)
|
||||
throw err
|
||||
}
|
||||
await adminSeeder(dbConnection)
|
||||
// Manually insert date for filtering
|
||||
const createdAt = new Date("26 January 1997 12:00 UTC")
|
||||
await orderSeeder(dbConnection, {
|
||||
created_at: createdAt.toISOString(),
|
||||
})
|
||||
})
|
||||
|
||||
afterEach(async () => {
|
||||
@@ -1521,16 +1486,18 @@ describe("/admin/orders", () => {
|
||||
|
||||
expect(response.status).toEqual(200)
|
||||
expect(response.data.count).toEqual(2)
|
||||
expect(response.data.orders).toEqual(expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
id: "test-order",
|
||||
shipping_address: expect.objectContaining({ first_name: "lebron" }),
|
||||
}),
|
||||
expect.objectContaining({
|
||||
id: "discount-order",
|
||||
shipping_address: expect.objectContaining({ first_name: "lebron" }),
|
||||
}),
|
||||
]))
|
||||
expect(response.data.orders).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
id: "test-order",
|
||||
shipping_address: expect.objectContaining({ first_name: "lebron" }),
|
||||
}),
|
||||
expect.objectContaining({
|
||||
id: "discount-order",
|
||||
shipping_address: expect.objectContaining({ first_name: "lebron" }),
|
||||
}),
|
||||
])
|
||||
)
|
||||
})
|
||||
|
||||
it("successfully lists orders with greater than", async () => {
|
||||
@@ -1727,14 +1694,9 @@ describe("/admin/orders", () => {
|
||||
|
||||
describe("POST /admin/orders/:id/swaps", () => {
|
||||
beforeEach(async () => {
|
||||
try {
|
||||
await adminSeeder(dbConnection)
|
||||
await orderSeeder(dbConnection)
|
||||
await swapSeeder(dbConnection)
|
||||
} catch (err) {
|
||||
console.log(err)
|
||||
throw err
|
||||
}
|
||||
await adminSeeder(dbConnection)
|
||||
await orderSeeder(dbConnection)
|
||||
await swapSeeder(dbConnection)
|
||||
})
|
||||
|
||||
afterEach(async () => {
|
||||
@@ -2137,33 +2099,29 @@ describe("/admin/orders", () => {
|
||||
})
|
||||
|
||||
it("Only allows canceling swap after canceling fulfillments", async () => {
|
||||
try {
|
||||
const swap_id = "swap-w-f"
|
||||
const swap_id = "swap-w-f"
|
||||
|
||||
const swap = await callGet({
|
||||
path: `/admin/swaps/${swap_id}`,
|
||||
get: "swap",
|
||||
})
|
||||
const swap = await callGet({
|
||||
path: `/admin/swaps/${swap_id}`,
|
||||
get: "swap",
|
||||
})
|
||||
|
||||
const { order_id } = swap
|
||||
const { order_id } = swap
|
||||
|
||||
const expectCancelToReturn = partial(expectPostCallToReturn, {
|
||||
path: `/admin/orders/${order_id}/swaps/${swap_id}/cancel`,
|
||||
})
|
||||
const expectCancelToReturn = partial(expectPostCallToReturn, {
|
||||
path: `/admin/orders/${order_id}/swaps/${swap_id}/cancel`,
|
||||
})
|
||||
|
||||
await expectCancelToReturn({ code: 400 })
|
||||
await expectCancelToReturn({ code: 400 })
|
||||
|
||||
await expectAllPostCallsToReturn({
|
||||
code: 200,
|
||||
col: swap.fulfillments,
|
||||
pathf: (f) =>
|
||||
`/admin/orders/${order_id}/swaps/${swap_id}/fulfillments/${f.id}/cancel`,
|
||||
})
|
||||
await expectAllPostCallsToReturn({
|
||||
code: 200,
|
||||
col: swap.fulfillments,
|
||||
pathf: (f) =>
|
||||
`/admin/orders/${order_id}/swaps/${swap_id}/fulfillments/${f.id}/cancel`,
|
||||
})
|
||||
|
||||
await expectCancelToReturn({ code: 200 })
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
}
|
||||
await expectCancelToReturn({ code: 200 })
|
||||
})
|
||||
|
||||
it("Only allows canceling swap after canceling return", async () => {
|
||||
|
||||
Reference in New Issue
Block a user