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:
Carlos R. L. Rodrigues authored and GitHub committed 2022-08-25 06:36:24 +00:00
1 parent 5a964e6439
commit ffd6234356
50 files changed
+1038 -1619

No files matched your search

+1 -1
View File
@@ -143,7 +143,7 @@ jobs:
working-directory: integration-tests/api working-directory: integration-tests/api
- name: Run integration tests - name: Run integration tests
run: yarn test --runInBand run: yarn test
working-directory: integration-tests/api working-directory: integration-tests/api
env: env:
DB_PASSWORD: postgres DB_PASSWORD: postgres
@@ -18,11 +18,7 @@ describe("/admin/auth", () => {
dbConnection = await initDb({ cwd }) dbConnection = await initDb({ cwd })
medusaProcess = await setupServer({ cwd }) medusaProcess = await setupServer({ cwd })
try { await adminSeeder(dbConnection)
await adminSeeder(dbConnection)
} catch (e) {
throw e
}
}) })
afterAll(async () => { afterAll(async () => {
@@ -25,13 +25,8 @@ describe("/admin/collections", () => {
describe("/admin/collections/:id", () => { describe("/admin/collections/:id", () => {
beforeEach(async () => { beforeEach(async () => {
try { await adminSeeder(dbConnection)
await adminSeeder(dbConnection) await productSeeder(dbConnection)
await productSeeder(dbConnection)
} catch (err) {
console.log(err)
throw err
}
}) })
afterEach(async () => { afterEach(async () => {
@@ -128,13 +123,8 @@ describe("/admin/collections", () => {
describe("/admin/collections", () => { describe("/admin/collections", () => {
beforeEach(async () => { beforeEach(async () => {
try { await adminSeeder(dbConnection)
await adminSeeder(dbConnection) await productSeeder(dbConnection)
await productSeeder(dbConnection)
} catch (err) {
console.log(err)
throw err
}
}) })
afterEach(async () => { afterEach(async () => {
@@ -27,13 +27,8 @@ describe("/admin/customer-groups", () => {
describe("POST /admin/customer-groups", () => { describe("POST /admin/customer-groups", () => {
beforeEach(async () => { beforeEach(async () => {
try { await adminSeeder(dbConnection)
await adminSeeder(dbConnection) await customerSeeder(dbConnection)
await customerSeeder(dbConnection)
} catch (err) {
console.log(err)
throw err
}
}) })
afterEach(async () => { afterEach(async () => {
@@ -88,13 +83,8 @@ describe("/admin/customer-groups", () => {
describe("DELETE /admin/customer-groups", () => { describe("DELETE /admin/customer-groups", () => {
beforeEach(async () => { beforeEach(async () => {
try { await adminSeeder(dbConnection)
await adminSeeder(dbConnection) await customerSeeder(dbConnection)
await customerSeeder(dbConnection)
} catch (err) {
console.log(err)
throw err
}
}) })
afterEach(async () => { afterEach(async () => {
@@ -195,13 +185,8 @@ describe("/admin/customer-groups", () => {
describe("GET /admin/customer-groups/{id}/customers", () => { describe("GET /admin/customer-groups/{id}/customers", () => {
beforeEach(async () => { beforeEach(async () => {
try { await adminSeeder(dbConnection)
await adminSeeder(dbConnection) await customerSeeder(dbConnection)
await customerSeeder(dbConnection)
} catch (err) {
console.log(err)
throw err
}
}) })
afterEach(async () => { afterEach(async () => {
@@ -242,13 +227,8 @@ describe("/admin/customer-groups", () => {
describe("POST /admin/customer-groups/{id}/customers/batch", () => { describe("POST /admin/customer-groups/{id}/customers/batch", () => {
beforeEach(async () => { beforeEach(async () => {
try { await adminSeeder(dbConnection)
await adminSeeder(dbConnection) await customerSeeder(dbConnection)
await customerSeeder(dbConnection)
} catch (err) {
console.log(err)
throw err
}
}) })
afterEach(async () => { afterEach(async () => {
@@ -418,13 +398,8 @@ describe("/admin/customer-groups", () => {
describe("POST /admin/customer-groups/:id", () => { describe("POST /admin/customer-groups/:id", () => {
beforeEach(async () => { beforeEach(async () => {
try { await adminSeeder(dbConnection)
await adminSeeder(dbConnection) await customerSeeder(dbConnection)
await customerSeeder(dbConnection)
} catch (err) {
console.log(err)
throw err
}
}) })
afterEach(async () => { afterEach(async () => {
@@ -500,13 +475,8 @@ describe("/admin/customer-groups", () => {
describe("GET /admin/customer-groups", () => { describe("GET /admin/customer-groups", () => {
beforeEach(async () => { beforeEach(async () => {
try { await adminSeeder(dbConnection)
await adminSeeder(dbConnection) await customerSeeder(dbConnection)
await customerSeeder(dbConnection)
} catch (err) {
console.log(err)
throw err
}
}) })
afterEach(async () => { afterEach(async () => {
@@ -559,13 +529,8 @@ describe("/admin/customer-groups", () => {
describe("GET /admin/customer-groups/:id", () => { describe("GET /admin/customer-groups/:id", () => {
beforeEach(async () => { beforeEach(async () => {
try { await adminSeeder(dbConnection)
await adminSeeder(dbConnection) await customerSeeder(dbConnection)
await customerSeeder(dbConnection)
} catch (err) {
console.log(err)
throw err
}
}) })
afterEach(async () => { afterEach(async () => {
@@ -641,13 +606,8 @@ describe("/admin/customer-groups", () => {
describe("DELETE /admin/customer-groups/{id}/batch", () => { describe("DELETE /admin/customer-groups/{id}/batch", () => {
beforeEach(async () => { beforeEach(async () => {
try { await adminSeeder(dbConnection)
await adminSeeder(dbConnection) await customerSeeder(dbConnection)
await customerSeeder(dbConnection)
} catch (err) {
console.log(err)
throw err
}
}) })
afterEach(async () => { afterEach(async () => {
@@ -28,13 +28,8 @@ describe("/admin/customers", () => {
describe("GET /admin/customers", () => { describe("GET /admin/customers", () => {
beforeEach(async () => { beforeEach(async () => {
try { await adminSeeder(dbConnection)
await adminSeeder(dbConnection) await customerSeeder(dbConnection)
await customerSeeder(dbConnection)
} catch (err) {
console.log(err)
throw err
}
}) })
afterEach(async () => { afterEach(async () => {
@@ -164,12 +159,7 @@ describe("/admin/customers", () => {
describe("POST /admin/customers", () => { describe("POST /admin/customers", () => {
beforeEach(async () => { beforeEach(async () => {
try { await adminSeeder(dbConnection)
await adminSeeder(dbConnection)
} catch (err) {
console.log(err)
throw err
}
}) })
afterEach(async () => { afterEach(async () => {
@@ -213,13 +203,8 @@ describe("/admin/customers", () => {
describe("POST /admin/customers/:id", () => { describe("POST /admin/customers/:id", () => {
beforeEach(async () => { beforeEach(async () => {
try { await adminSeeder(dbConnection)
await adminSeeder(dbConnection) await customerSeeder(dbConnection)
await customerSeeder(dbConnection)
} catch (err) {
console.log(err)
throw err
}
}) })
afterEach(async () => { afterEach(async () => {
@@ -368,13 +353,8 @@ describe("/admin/customers", () => {
describe("GET /admin/customers/:id", () => { describe("GET /admin/customers/:id", () => {
beforeEach(async () => { beforeEach(async () => {
try { await adminSeeder(dbConnection)
await adminSeeder(dbConnection) await customerSeeder(dbConnection)
await customerSeeder(dbConnection)
} catch (err) {
console.log(err)
throw err
}
}) })
afterEach(async () => { afterEach(async () => {
@@ -427,13 +427,8 @@ describe("/admin/discounts", () => {
describe("POST /admin/discounts", () => { describe("POST /admin/discounts", () => {
beforeEach(async () => { beforeEach(async () => {
try { await adminSeeder(dbConnection)
await adminSeeder(dbConnection) await discountSeeder(dbConnection)
await discountSeeder(dbConnection)
} catch (err) {
console.log(err)
throw err
}
}) })
afterEach(async () => { afterEach(async () => {
@@ -2150,11 +2145,7 @@ describe("/admin/discounts", () => {
describe("GET /admin/discounts/:id/conditions/:condition_id", () => { describe("GET /admin/discounts/:id/conditions/:condition_id", () => {
beforeEach(async () => { beforeEach(async () => {
try { await adminSeeder(dbConnection)
await adminSeeder(dbConnection)
} catch (err) {
console.log(err)
}
const prod = await simpleProductFactory(dbConnection, { const prod = await simpleProductFactory(dbConnection, {
type: "pants", type: "pants",
@@ -28,13 +28,8 @@ describe("/admin/draft-orders", () => {
describe("POST /admin/draft-orders", () => { describe("POST /admin/draft-orders", () => {
beforeEach(async () => { beforeEach(async () => {
try { await adminSeeder(dbConnection)
await adminSeeder(dbConnection) await draftOrderSeeder(dbConnection)
await draftOrderSeeder(dbConnection)
} catch (err) {
console.log(err)
throw err
}
}) })
afterEach(async () => { afterEach(async () => {
@@ -359,7 +354,7 @@ describe("/admin/draft-orders", () => {
const payload = { const payload = {
email: "oli@test.dk", email: "oli@test.dk",
shipping_address: "oli-shipping", shipping_address: "oli-shipping",
discounts: [{ code: "TEST" }, { code: "free-shipping"}], discounts: [{ code: "TEST" }, { code: "free-shipping" }],
items: [ items: [
{ {
variant_id: "test-variant", variant_id: "test-variant",
@@ -426,7 +421,7 @@ describe("/admin/draft-orders", () => {
}), }),
expect.objectContaining({ expect.objectContaining({
code: "free-shipping", code: "free-shipping",
}) }),
]) ])
) )
}) })
@@ -524,12 +519,8 @@ describe("/admin/draft-orders", () => {
}) })
describe("GET /admin/draft-orders", () => { describe("GET /admin/draft-orders", () => {
beforeEach(async () => { beforeEach(async () => {
try { await adminSeeder(dbConnection)
await adminSeeder(dbConnection) await draftOrderSeeder(dbConnection)
await draftOrderSeeder(dbConnection)
} catch (err) {
throw err
}
}) })
afterEach(async () => { afterEach(async () => {
@@ -605,13 +596,8 @@ describe("/admin/draft-orders", () => {
describe("DELETE /admin/draft-orders/:id", () => { describe("DELETE /admin/draft-orders/:id", () => {
beforeEach(async () => { beforeEach(async () => {
try { await adminSeeder(dbConnection)
await adminSeeder(dbConnection) await draftOrderSeeder(dbConnection)
await draftOrderSeeder(dbConnection)
} catch (err) {
console.log(err)
throw err
}
}) })
afterEach(async () => { afterEach(async () => {
@@ -644,12 +630,8 @@ describe("/admin/draft-orders", () => {
describe("POST /admin/draft-orders/:id/line-items/:line_id", () => { describe("POST /admin/draft-orders/:id/line-items/:line_id", () => {
beforeEach(async () => { beforeEach(async () => {
try { await adminSeeder(dbConnection)
await adminSeeder(dbConnection) await draftOrderSeeder(dbConnection, { status: "open" })
await draftOrderSeeder(dbConnection, { status: "open" })
} catch (err) {
throw err
}
}) })
afterEach(async () => { afterEach(async () => {
@@ -733,12 +715,8 @@ describe("/admin/draft-orders", () => {
describe("POST /admin/draft-orders/:id", () => { describe("POST /admin/draft-orders/:id", () => {
beforeEach(async () => { beforeEach(async () => {
try { await adminSeeder(dbConnection)
await adminSeeder(dbConnection) await draftOrderSeeder(dbConnection, { status: "open" })
await draftOrderSeeder(dbConnection, { status: "open" })
} catch (err) {
throw err
}
}) })
afterEach(async () => { afterEach(async () => {
@@ -28,32 +28,28 @@ describe("/admin/gift-cards", () => {
describe("GET /admin/gift-cards", () => { describe("GET /admin/gift-cards", () => {
beforeEach(async () => { beforeEach(async () => {
const manager = dbConnection.manager const manager = dbConnection.manager
try {
await adminSeeder(dbConnection) await adminSeeder(dbConnection)
await manager.insert(Region, { await manager.insert(Region, {
id: "test-region", id: "test-region",
name: "Test Region", name: "Test Region",
currency_code: "usd", currency_code: "usd",
tax_rate: 0, tax_rate: 0,
}) })
await manager.insert(GiftCard, { await manager.insert(GiftCard, {
id: "gift_test", id: "gift_test",
code: "GC_TEST", code: "GC_TEST",
value: 20000, value: 20000,
balance: 20000, balance: 20000,
region_id: "test-region", region_id: "test-region",
}) })
await manager.insert(GiftCard, { await manager.insert(GiftCard, {
id: "another_gift_test", id: "another_gift_test",
code: "CARD_TEST", code: "CARD_TEST",
value: 200000, value: 200000,
balance: 200000, balance: 200000,
region_id: "test-region", region_id: "test-region",
}) })
} catch (err) {
console.log(err)
throw err
}
}) })
afterEach(async () => { afterEach(async () => {
@@ -136,25 +132,21 @@ describe("/admin/gift-cards", () => {
describe("POST /admin/gift-cards", () => { describe("POST /admin/gift-cards", () => {
beforeEach(async () => { beforeEach(async () => {
const manager = dbConnection.manager const manager = dbConnection.manager
try {
await adminSeeder(dbConnection) await adminSeeder(dbConnection)
await manager.insert(Region, { await manager.insert(Region, {
id: "region", id: "region",
name: "Test Region", name: "Test Region",
currency_code: "usd", currency_code: "usd",
tax_rate: 0, tax_rate: 0,
}) })
await manager.insert(GiftCard, { await manager.insert(GiftCard, {
id: "gift_test", id: "gift_test",
code: "GC_TEST", code: "GC_TEST",
value: 20000, value: 20000,
balance: 20000, balance: 20000,
region_id: "region", region_id: "region",
}) })
} catch (err) {
console.log(err)
throw err
}
}) })
afterEach(async () => { afterEach(async () => {
+19 -35
View File
@@ -36,13 +36,10 @@ describe("/admin/notes", () => {
describe("GET /admin/notes/:id", () => { describe("GET /admin/notes/:id", () => {
beforeEach(async () => { beforeEach(async () => {
const manager = dbConnection.manager const manager = dbConnection.manager
try {
await adminSeeder(dbConnection)
await manager.insert(Note, note) await adminSeeder(dbConnection)
} catch (err) {
console.log(err) await manager.insert(Note, note)
}
}) })
afterEach(async () => { afterEach(async () => {
@@ -73,11 +70,7 @@ describe("/admin/notes", () => {
describe("POST /admin/notes", () => { describe("POST /admin/notes", () => {
beforeEach(async () => { beforeEach(async () => {
try { await adminSeeder(dbConnection)
await adminSeeder(dbConnection)
} catch (err) {
console.log(err)
}
}) })
afterEach(async () => { afterEach(async () => {
@@ -121,19 +114,16 @@ describe("/admin/notes", () => {
describe("GET /admin/notes", () => { describe("GET /admin/notes", () => {
beforeEach(async () => { beforeEach(async () => {
const manager = dbConnection.manager const manager = dbConnection.manager
try {
await adminSeeder(dbConnection)
await manager.insert(Note, { ...note, id: "note1" }) await adminSeeder(dbConnection)
await manager.insert(Note, { ...note, id: "note2" })
await manager.insert(Note, { await manager.insert(Note, { ...note, id: "note1" })
...note, await manager.insert(Note, { ...note, id: "note2" })
id: "note3", await manager.insert(Note, {
resource_id: "resource2", ...note,
}) id: "note3",
} catch (err) { resource_id: "resource2",
console.log(err) })
}
}) })
afterEach(async () => { afterEach(async () => {
@@ -178,13 +168,10 @@ describe("/admin/notes", () => {
describe("POST /admin/notes/:id", () => { describe("POST /admin/notes/:id", () => {
beforeEach(async () => { beforeEach(async () => {
const manager = dbConnection.manager const manager = dbConnection.manager
try {
await adminSeeder(dbConnection)
await manager.insert(Note, note) await adminSeeder(dbConnection)
} catch (err) {
console.log(err) await manager.insert(Note, note)
}
}) })
afterEach(async () => { afterEach(async () => {
@@ -226,13 +213,10 @@ describe("/admin/notes", () => {
describe("DELETE /admin/notes/:id", () => { describe("DELETE /admin/notes/:id", () => {
beforeEach(async () => { beforeEach(async () => {
const manager = dbConnection.manager const manager = dbConnection.manager
try {
await adminSeeder(dbConnection)
await manager.insert(Note, note) await adminSeeder(dbConnection)
} catch (err) {
console.log(err) await manager.insert(Note, note)
}
}) })
afterEach(async () => { afterEach(async () => {
+60 -102
View File
@@ -44,13 +44,8 @@ describe("/admin/orders", () => {
describe("GET /admin/orders", () => { describe("GET /admin/orders", () => {
beforeEach(async () => { beforeEach(async () => {
try { await adminSeeder(dbConnection)
await adminSeeder(dbConnection) await orderSeeder(dbConnection)
await orderSeeder(dbConnection)
} catch (err) {
console.log(err)
throw err
}
}) })
afterEach(async () => { afterEach(async () => {
@@ -129,14 +124,9 @@ describe("/admin/orders", () => {
describe("GET /admin/orders", () => { describe("GET /admin/orders", () => {
beforeEach(async () => { beforeEach(async () => {
try { await adminSeeder(dbConnection)
await adminSeeder(dbConnection) await orderSeeder(dbConnection)
await orderSeeder(dbConnection) await swapSeeder(dbConnection)
await swapSeeder(dbConnection)
} catch (err) {
console.log(err)
throw err
}
const manager = dbConnection.manager const manager = dbConnection.manager
@@ -276,14 +266,9 @@ describe("/admin/orders", () => {
describe("POST /admin/orders/:id/swaps", () => { describe("POST /admin/orders/:id/swaps", () => {
beforeEach(async () => { beforeEach(async () => {
try { await adminSeeder(dbConnection)
await adminSeeder(dbConnection) await orderSeeder(dbConnection)
await orderSeeder(dbConnection) await claimSeeder(dbConnection)
await claimSeeder(dbConnection)
} catch (err) {
console.log(err)
throw err
}
}) })
afterEach(async () => { afterEach(async () => {
@@ -318,14 +303,9 @@ describe("/admin/orders", () => {
describe("POST /admin/orders/:id/claims", () => { describe("POST /admin/orders/:id/claims", () => {
beforeEach(async () => { beforeEach(async () => {
try { await adminSeeder(dbConnection)
await adminSeeder(dbConnection) await orderSeeder(dbConnection)
await orderSeeder(dbConnection) await claimSeeder(dbConnection)
await claimSeeder(dbConnection)
} catch (err) {
console.log(err)
throw err
}
}) })
afterEach(async () => { afterEach(async () => {
@@ -1216,14 +1196,9 @@ describe("/admin/orders", () => {
describe("POST /admin/orders/:id/claims", () => { describe("POST /admin/orders/:id/claims", () => {
beforeEach(async () => { beforeEach(async () => {
try { await adminSeeder(dbConnection)
await adminSeeder(dbConnection) await orderSeeder(dbConnection)
await orderSeeder(dbConnection) await swapSeeder(dbConnection)
await swapSeeder(dbConnection)
} catch (err) {
console.log(err)
throw err
}
}) })
afterEach(async () => { afterEach(async () => {
@@ -1272,21 +1247,16 @@ describe("/admin/orders", () => {
describe("POST /admin/orders/:id/return", () => { describe("POST /admin/orders/:id/return", () => {
let rrId let rrId
beforeEach(async () => { beforeEach(async () => {
try { await adminSeeder(dbConnection)
await adminSeeder(dbConnection) await orderSeeder(dbConnection)
await orderSeeder(dbConnection)
const created = dbConnection.manager.create(ReturnReason, { const created = dbConnection.manager.create(ReturnReason, {
value: "too_big", value: "too_big",
label: "Too Big", label: "Too Big",
}) })
const result = await dbConnection.manager.save(created) const result = await dbConnection.manager.save(created)
rrId = result.id rrId = result.id
} catch (err) {
console.log(err)
throw err
}
}) })
afterEach(async () => { afterEach(async () => {
@@ -1392,17 +1362,12 @@ describe("/admin/orders", () => {
describe("GET /admin/orders", () => { describe("GET /admin/orders", () => {
beforeEach(async () => { beforeEach(async () => {
try { await adminSeeder(dbConnection)
await adminSeeder(dbConnection) // Manually insert date for filtering
// Manually insert date for filtering const createdAt = new Date("26 January 1997 12:00 UTC")
const createdAt = new Date("26 January 1997 12:00 UTC") await orderSeeder(dbConnection, {
await orderSeeder(dbConnection, { created_at: createdAt.toISOString(),
created_at: createdAt.toISOString(), })
})
} catch (err) {
console.log(err)
throw err
}
}) })
afterEach(async () => { afterEach(async () => {
@@ -1521,16 +1486,18 @@ describe("/admin/orders", () => {
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.orders).toEqual(expect.arrayContaining([ expect(response.data.orders).toEqual(
expect.objectContaining({ expect.arrayContaining([
id: "test-order", expect.objectContaining({
shipping_address: expect.objectContaining({ first_name: "lebron" }), id: "test-order",
}), shipping_address: expect.objectContaining({ first_name: "lebron" }),
expect.objectContaining({ }),
id: "discount-order", expect.objectContaining({
shipping_address: expect.objectContaining({ first_name: "lebron" }), id: "discount-order",
}), shipping_address: expect.objectContaining({ first_name: "lebron" }),
])) }),
])
)
}) })
it("successfully lists orders with greater than", async () => { it("successfully lists orders with greater than", async () => {
@@ -1727,14 +1694,9 @@ describe("/admin/orders", () => {
describe("POST /admin/orders/:id/swaps", () => { describe("POST /admin/orders/:id/swaps", () => {
beforeEach(async () => { beforeEach(async () => {
try { await adminSeeder(dbConnection)
await adminSeeder(dbConnection) await orderSeeder(dbConnection)
await orderSeeder(dbConnection) await swapSeeder(dbConnection)
await swapSeeder(dbConnection)
} catch (err) {
console.log(err)
throw err
}
}) })
afterEach(async () => { afterEach(async () => {
@@ -2137,33 +2099,29 @@ describe("/admin/orders", () => {
}) })
it("Only allows canceling swap after canceling fulfillments", async () => { 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({ const swap = await callGet({
path: `/admin/swaps/${swap_id}`, path: `/admin/swaps/${swap_id}`,
get: "swap", get: "swap",
}) })
const { order_id } = swap const { order_id } = swap
const expectCancelToReturn = partial(expectPostCallToReturn, { const expectCancelToReturn = partial(expectPostCallToReturn, {
path: `/admin/orders/${order_id}/swaps/${swap_id}/cancel`, path: `/admin/orders/${order_id}/swaps/${swap_id}/cancel`,
}) })
await expectCancelToReturn({ code: 400 }) await expectCancelToReturn({ code: 400 })
await expectAllPostCallsToReturn({ await expectAllPostCallsToReturn({
code: 200, code: 200,
col: swap.fulfillments, col: swap.fulfillments,
pathf: (f) => pathf: (f) =>
`/admin/orders/${order_id}/swaps/${swap_id}/fulfillments/${f.id}/cancel`, `/admin/orders/${order_id}/swaps/${swap_id}/fulfillments/${f.id}/cancel`,
}) })
await expectCancelToReturn({ code: 200 }) await expectCancelToReturn({ code: 200 })
} catch (e) {
console.log(e)
}
}) })
it("Only allows canceling swap after canceling return", async () => { it("Only allows canceling swap after canceling return", async () => {
@@ -37,14 +37,9 @@ describe("/admin/price-lists", () => {
describe("POST /admin/price-list", () => { describe("POST /admin/price-list", () => {
beforeEach(async () => { beforeEach(async () => {
try { await adminSeeder(dbConnection)
await adminSeeder(dbConnection) await customerSeeder(dbConnection)
await customerSeeder(dbConnection) await productSeeder(dbConnection)
await productSeeder(dbConnection)
} catch (err) {
console.log(err)
throw err
}
}) })
afterEach(async () => { afterEach(async () => {
@@ -116,14 +111,9 @@ describe("/admin/price-lists", () => {
describe("GET /admin/price-lists", () => { describe("GET /admin/price-lists", () => {
beforeEach(async () => { beforeEach(async () => {
try { await adminSeeder(dbConnection)
await adminSeeder(dbConnection) await productSeeder(dbConnection)
await productSeeder(dbConnection) await priceListSeeder(dbConnection)
await priceListSeeder(dbConnection)
} catch (err) {
console.log(err)
throw err
}
}) })
afterEach(async () => { afterEach(async () => {
@@ -372,15 +362,10 @@ describe("/admin/price-lists", () => {
describe("POST /admin/price-lists/:id", () => { describe("POST /admin/price-lists/:id", () => {
beforeEach(async () => { beforeEach(async () => {
try { await adminSeeder(dbConnection)
await adminSeeder(dbConnection) await customerSeeder(dbConnection)
await customerSeeder(dbConnection) await productSeeder(dbConnection)
await productSeeder(dbConnection) await priceListSeeder(dbConnection)
await priceListSeeder(dbConnection)
} catch (err) {
console.log(err)
throw err
}
}) })
afterEach(async () => { afterEach(async () => {
@@ -659,14 +644,9 @@ describe("/admin/price-lists", () => {
describe("POST /admin/price-lists/:id/prices/batch", () => { describe("POST /admin/price-lists/:id/prices/batch", () => {
beforeEach(async () => { beforeEach(async () => {
try { await adminSeeder(dbConnection)
await adminSeeder(dbConnection) await productSeeder(dbConnection)
await productSeeder(dbConnection) await priceListSeeder(dbConnection)
await priceListSeeder(dbConnection)
} catch (err) {
console.log(err)
throw err
}
}) })
afterEach(async () => { afterEach(async () => {
@@ -949,14 +929,9 @@ describe("/admin/price-lists", () => {
describe("DELETE /admin/price-lists/:id", () => { describe("DELETE /admin/price-lists/:id", () => {
beforeEach(async () => { beforeEach(async () => {
try { await adminSeeder(dbConnection)
await adminSeeder(dbConnection) await productSeeder(dbConnection)
await productSeeder(dbConnection) await priceListSeeder(dbConnection)
await priceListSeeder(dbConnection)
} catch (err) {
console.log(err)
throw err
}
}) })
afterEach(async () => { afterEach(async () => {
@@ -1001,14 +976,9 @@ describe("/admin/price-lists", () => {
describe("tests cascade on delete", () => { describe("tests cascade on delete", () => {
beforeEach(async () => { beforeEach(async () => {
try { await adminSeeder(dbConnection)
await adminSeeder(dbConnection) await productSeeder(dbConnection)
await productSeeder(dbConnection) await priceListSeeder(dbConnection)
await priceListSeeder(dbConnection)
} catch (err) {
console.log(err)
throw err
}
}) })
afterEach(async () => { afterEach(async () => {
@@ -1045,14 +1015,9 @@ describe("/admin/price-lists", () => {
describe("DELETE /admin/price-lists/:id/prices/batch", () => { describe("DELETE /admin/price-lists/:id/prices/batch", () => {
beforeEach(async () => { beforeEach(async () => {
try { await adminSeeder(dbConnection)
await adminSeeder(dbConnection) await productSeeder(dbConnection)
await productSeeder(dbConnection) await priceListSeeder(dbConnection)
await priceListSeeder(dbConnection)
} catch (err) {
console.log(err)
throw err
}
}) })
afterEach(async () => { afterEach(async () => {
@@ -1102,59 +1067,54 @@ describe("/admin/price-lists", () => {
describe("GET /admin/price-lists/:id/products", () => { describe("GET /admin/price-lists/:id/products", () => {
let tag let tag
beforeEach(async () => { beforeEach(async () => {
try { await adminSeeder(dbConnection)
await adminSeeder(dbConnection)
await simpleProductFactory( await simpleProductFactory(
dbConnection, dbConnection,
{ {
id: "test-prod-1", id: "test-prod-1",
title: "MedusaHeadphones", title: "MedusaHeadphones",
variants: [{ id: "test-variant-1" }, { id: "test-variant-2" }], variants: [{ id: "test-variant-1" }, { id: "test-variant-2" }],
}, },
1 1
) )
const prod = await simpleProductFactory( const prod = await simpleProductFactory(
dbConnection, dbConnection,
{ {
id: "test-prod-2", id: "test-prod-2",
tags: ["test-tag"], tags: ["test-tag"],
variants: [{ id: "test-variant-3" }, { id: "test-variant-4" }], variants: [{ id: "test-variant-3" }, { id: "test-variant-4" }],
}, },
2 2
) )
tag = prod.tags[0].id tag = prod.tags[0].id
await simpleProductFactory( await simpleProductFactory(
dbConnection, dbConnection,
{ {
id: "test-prod-3", id: "test-prod-3",
variants: [{ id: "test-variant-5" }], variants: [{ id: "test-variant-5" }],
}, },
3 3
) )
await simplePriceListFactory(dbConnection, { await simplePriceListFactory(dbConnection, {
id: "test-list", id: "test-list",
customer_groups: ["test-group"], customer_groups: ["test-group"],
prices: [ prices: [
{ variant_id: "test-variant-1", currency_code: "usd", amount: 150 }, { variant_id: "test-variant-1", currency_code: "usd", amount: 150 },
{ variant_id: "test-variant-4", currency_code: "usd", amount: 150 }, { variant_id: "test-variant-4", currency_code: "usd", amount: 150 },
], ],
}) })
await simplePriceListFactory(dbConnection, { await simplePriceListFactory(dbConnection, {
id: "test-list-2", id: "test-list-2",
prices: [ prices: [
{ variant_id: "test-variant-1", currency_code: "usd", amount: 200 }, { variant_id: "test-variant-1", currency_code: "usd", amount: 200 },
{ variant_id: "test-variant-4", currency_code: "usd", amount: 200 }, { variant_id: "test-variant-4", currency_code: "usd", amount: 200 },
], ],
}) })
} catch (err) {
console.log(err)
throw err
}
}) })
afterEach(async () => { afterEach(async () => {
@@ -1278,61 +1238,56 @@ describe("/admin/price-lists", () => {
} }
beforeEach(async () => { beforeEach(async () => {
try { await adminSeeder(dbConnection)
await adminSeeder(dbConnection)
product1 = await simpleProductFactory( product1 = await simpleProductFactory(
dbConnection, dbConnection,
{ {
id: "test-prod-1", id: "test-prod-1",
title: "some product", title: "some product",
variants: [ variants: [
{ {
id: `simple-test-variant-${Math.random() * 1000}`, id: `simple-test-variant-${Math.random() * 1000}`,
title: "Test", title: "Test",
prices: [{ currency: "usd", amount: 100 }], prices: [{ currency: "usd", amount: 100 }],
}, },
{ {
id: `simple-test-variant-${Math.random() * 1000}`, id: `simple-test-variant-${Math.random() * 1000}`,
title: "Test 2", title: "Test 2",
prices: [{ currency: "usd", amount: 200 }], prices: [{ currency: "usd", amount: 200 }],
}, },
],
},
1
)
product2 = await simpleProductFactory(
dbConnection,
{
id: "test-prod-2",
title: "some product 2",
},
2
)
await simplePriceListFactory(dbConnection, {
id: "test-list",
customer_groups: ["test-group"],
prices: [
...product1.variants.map((variant, i) => ({
id: getCustomPriceIdFromVariant(variant.id, i),
variant_id: variant.id,
currency_code: "usd",
amount: (i + 1) * 150,
})),
...product2.variants.map((variant, i) => ({
id: getCustomPriceIdFromVariant(variant.id, i),
variant_id: variant.id,
currency_code: "usd",
amount: (i + 1) * 150,
})),
], ],
}) },
} catch (err) { 1
console.log(err) )
throw err
} product2 = await simpleProductFactory(
dbConnection,
{
id: "test-prod-2",
title: "some product 2",
},
2
)
await simplePriceListFactory(dbConnection, {
id: "test-list",
customer_groups: ["test-group"],
prices: [
...product1.variants.map((variant, i) => ({
id: getCustomPriceIdFromVariant(variant.id, i),
variant_id: variant.id,
currency_code: "usd",
amount: (i + 1) * 150,
})),
...product2.variants.map((variant, i) => ({
id: getCustomPriceIdFromVariant(variant.id, i),
variant_id: variant.id,
currency_code: "usd",
amount: (i + 1) * 150,
})),
],
})
}) })
afterEach(async () => { afterEach(async () => {
@@ -28,13 +28,8 @@ describe("/admin/product-tags", () => {
describe("GET /admin/product-tags", () => { describe("GET /admin/product-tags", () => {
beforeEach(async () => { beforeEach(async () => {
try { await productSeeder(dbConnection)
await productSeeder(dbConnection) await adminSeeder(dbConnection)
await adminSeeder(dbConnection)
} catch (err) {
console.log(err)
throw err
}
}) })
afterEach(async () => { afterEach(async () => {
@@ -28,13 +28,8 @@ describe("/admin/product-types", () => {
describe("GET /admin/product-types", () => { describe("GET /admin/product-types", () => {
beforeEach(async () => { beforeEach(async () => {
try { await productSeeder(dbConnection)
await productSeeder(dbConnection) await adminSeeder(dbConnection)
await adminSeeder(dbConnection)
} catch (err) {
console.log(err)
throw err
}
}) })
afterEach(async () => { afterEach(async () => {
@@ -62,10 +57,7 @@ describe("/admin/product-types", () => {
updated_at: expect.any(String), updated_at: expect.any(String),
} }
expect(res.data.product_types).toMatchSnapshot([ expect(res.data.product_types).toMatchSnapshot([typeMatch, typeMatch])
typeMatch,
typeMatch,
])
}) })
it("returns a list of product types matching free text search param", async () => { it("returns a list of product types matching free text search param", async () => {
@@ -90,13 +82,11 @@ describe("/admin/product-types", () => {
// The value of the type should match the search param // The value of the type should match the search param
expect(res.data.product_types.map((pt) => pt.value)).toEqual([ expect(res.data.product_types.map((pt) => pt.value)).toEqual([
"test-type-new" "test-type-new",
]) ])
// Should only return one type as there is only one match to the search param // Should only return one type as there is only one match to the search param
expect(res.data.product_types).toMatchSnapshot([ expect(res.data.product_types).toMatchSnapshot([typeMatch])
typeMatch
])
}) })
}) })
}) })
@@ -34,13 +34,8 @@ describe("/admin/products", () => {
describe("GET /admin/products", () => { describe("GET /admin/products", () => {
beforeEach(async () => { beforeEach(async () => {
try { await productSeeder(dbConnection)
await productSeeder(dbConnection) await adminSeeder(dbConnection)
await adminSeeder(dbConnection)
} catch (err) {
console.log(err)
throw err
}
}) })
afterEach(async () => { afterEach(async () => {
@@ -852,13 +847,8 @@ describe("/admin/products", () => {
describe("POST /admin/products", () => { describe("POST /admin/products", () => {
beforeEach(async () => { beforeEach(async () => {
try { await productSeeder(dbConnection)
await productSeeder(dbConnection) await adminSeeder(dbConnection)
await adminSeeder(dbConnection)
} catch (err) {
console.log(err)
throw err
}
}) })
afterEach(async () => { afterEach(async () => {
@@ -1427,13 +1417,8 @@ describe("/admin/products", () => {
describe("GET /admin/products/:id/variants", () => { describe("GET /admin/products/:id/variants", () => {
beforeEach(async () => { beforeEach(async () => {
try { await productSeeder(dbConnection)
await productSeeder(dbConnection) await adminSeeder(dbConnection)
await adminSeeder(dbConnection)
} catch (err) {
console.log(err)
throw err
}
}) })
afterEach(async () => { afterEach(async () => {
@@ -1481,14 +1466,9 @@ describe("/admin/products", () => {
describe("updates a variant's default prices (ignores prices associated with a Price List)", () => { describe("updates a variant's default prices (ignores prices associated with a Price List)", () => {
beforeEach(async () => { beforeEach(async () => {
try { await productSeeder(dbConnection)
await productSeeder(dbConnection) await adminSeeder(dbConnection)
await adminSeeder(dbConnection) await priceListSeeder(dbConnection)
await priceListSeeder(dbConnection)
} catch (err) {
console.log(err)
throw err
}
}) })
afterEach(async () => { afterEach(async () => {
@@ -1757,13 +1737,8 @@ describe("/admin/products", () => {
describe("testing for soft-deletion + uniqueness on handles, collection and variant properties", () => { describe("testing for soft-deletion + uniqueness on handles, collection and variant properties", () => {
beforeEach(async () => { beforeEach(async () => {
try { await productSeeder(dbConnection)
await productSeeder(dbConnection) await adminSeeder(dbConnection)
await adminSeeder(dbConnection)
} catch (err) {
console.log(err)
throw err
}
}) })
afterEach(async () => { afterEach(async () => {
@@ -2256,13 +2231,8 @@ describe("/admin/products", () => {
describe("GET /admin/products/tag-usage", () => { describe("GET /admin/products/tag-usage", () => {
beforeEach(async () => { beforeEach(async () => {
try { await productSeeder(dbConnection)
await productSeeder(dbConnection) await adminSeeder(dbConnection)
await adminSeeder(dbConnection)
} catch (err) {
console.log(err)
throw err
}
}) })
afterEach(async () => { afterEach(async () => {
+22 -32
View File
@@ -27,23 +27,18 @@ describe("/admin/regions", () => {
describe("Remove region from country on delete", () => { describe("Remove region from country on delete", () => {
beforeEach(async () => { beforeEach(async () => {
try { await adminSeeder(dbConnection)
await adminSeeder(dbConnection) const manager = dbConnection.manager
const manager = dbConnection.manager await manager.insert(Region, {
await manager.insert(Region, { id: "test-region",
id: "test-region", name: "Test Region",
name: "Test Region", currency_code: "usd",
currency_code: "usd", tax_rate: 0,
tax_rate: 0, })
})
await manager.query( await manager.query(
`UPDATE "country" SET region_id='test-region' WHERE iso_2 = 'us'` `UPDATE "country" SET region_id='test-region' WHERE iso_2 = 'us'`
) )
} catch (err) {
console.log(err)
throw err
}
}) })
afterEach(async () => { afterEach(async () => {
@@ -203,23 +198,18 @@ describe("/admin/regions", () => {
describe("DELETE /admin/regions/:id", () => { describe("DELETE /admin/regions/:id", () => {
beforeEach(async () => { beforeEach(async () => {
try { await adminSeeder(dbConnection)
await adminSeeder(dbConnection) const manager = dbConnection.manager
const manager = dbConnection.manager await manager.insert(Region, {
await manager.insert(Region, { id: "test-region",
id: "test-region", name: "Test Region",
name: "Test Region", currency_code: "usd",
currency_code: "usd", tax_rate: 0,
tax_rate: 0, })
})
await manager.query( await manager.query(
`UPDATE "country" SET region_id='test-region' WHERE iso_2 = 'us'` `UPDATE "country" SET region_id='test-region' WHERE iso_2 = 'us'`
) )
} catch (err) {
console.log(err)
throw err
}
}) })
afterEach(async () => { afterEach(async () => {
@@ -27,12 +27,7 @@ describe("/admin/return-reasons", () => {
describe("POST /admin/return-reasons", () => { describe("POST /admin/return-reasons", () => {
beforeEach(async () => { beforeEach(async () => {
try { await adminSeeder(dbConnection)
await adminSeeder(dbConnection)
} catch (err) {
console.log(err)
throw err
}
}) })
afterEach(async () => { afterEach(async () => {
@@ -31,20 +31,15 @@ describe("/admin/returns", () => {
let rrId let rrId
beforeEach(async () => { beforeEach(async () => {
try { await adminSeeder(dbConnection)
await adminSeeder(dbConnection) await orderSeeder(dbConnection)
await orderSeeder(dbConnection)
const created = dbConnection.manager.create(ReturnReason, { const created = dbConnection.manager.create(ReturnReason, {
value: "too_big", value: "too_big",
label: "Too Big", label: "Too Big",
}) })
const resultRR = await dbConnection.manager.save(created) const resultRR = await dbConnection.manager.save(created)
rrId = resultRR.id rrId = resultRR.id
} catch (err) {
console.log(err)
throw err
}
}) })
afterEach(async () => { afterEach(async () => {
@@ -231,9 +226,9 @@ describe("/admin/returns", () => {
}, },
], ],
return_shipping: { return_shipping: {
option_id: "test-option", option_id: "test-option",
price: 0, price: 0,
} },
}, },
{ {
headers: { headers: {
@@ -52,15 +52,11 @@ describe("sales channels", () => {
let salesChannel let salesChannel
beforeEach(async () => { beforeEach(async () => {
try { await adminSeeder(dbConnection)
await adminSeeder(dbConnection) salesChannel = await simpleSalesChannelFactory(dbConnection, {
salesChannel = await simpleSalesChannelFactory(dbConnection, { name: "test name",
name: "test name", description: "test description",
description: "test description", })
})
} catch (e) {
console.error(e)
}
}) })
afterEach(async () => { afterEach(async () => {
@@ -92,19 +88,15 @@ describe("sales channels", () => {
let salesChannel2 let salesChannel2
beforeEach(async () => { beforeEach(async () => {
try { await adminSeeder(dbConnection)
await adminSeeder(dbConnection) salesChannel1 = await simpleSalesChannelFactory(dbConnection, {
salesChannel1 = await simpleSalesChannelFactory(dbConnection, { name: "test name",
name: "test name", description: "test description",
description: "test description", })
}) salesChannel2 = await simpleSalesChannelFactory(dbConnection, {
salesChannel2 = await simpleSalesChannelFactory(dbConnection, { name: "test name 2",
name: "test name 2", description: "test description 2",
description: "test description 2", })
})
} catch (e) {
console.error(e)
}
}) })
afterEach(async () => { afterEach(async () => {
@@ -207,15 +199,11 @@ describe("sales channels", () => {
let sc let sc
beforeEach(async () => { beforeEach(async () => {
try { await adminSeeder(dbConnection)
await adminSeeder(dbConnection) sc = await simpleSalesChannelFactory(dbConnection, {
sc = await simpleSalesChannelFactory(dbConnection, { name: "test name",
name: "test name", description: "test description",
description: "test description", })
})
} catch (err) {
console.log(err)
}
}) })
afterEach(async () => { afterEach(async () => {
@@ -256,11 +244,7 @@ describe("sales channels", () => {
describe("POST /admin/sales-channels", () => { describe("POST /admin/sales-channels", () => {
beforeEach(async () => { beforeEach(async () => {
try { await adminSeeder(dbConnection)
await adminSeeder(dbConnection)
} catch (e) {
console.error(e)
}
}) })
afterEach(async () => { afterEach(async () => {
@@ -324,21 +308,17 @@ describe("sales channels", () => {
let salesChannel let salesChannel
beforeEach(async () => { beforeEach(async () => {
try { await adminSeeder(dbConnection)
await adminSeeder(dbConnection) salesChannel = await simpleSalesChannelFactory(dbConnection, {
salesChannel = await simpleSalesChannelFactory(dbConnection, { name: "test name",
name: "test name", description: "test description",
description: "test description", })
})
await simpleSalesChannelFactory(dbConnection, { await simpleSalesChannelFactory(dbConnection, {
name: "Default channel", name: "Default channel",
id: "test-channel", id: "test-channel",
is_default: true, is_default: true,
}) })
} catch (e) {
console.error(e)
}
}) })
afterEach(async () => { afterEach(async () => {
@@ -454,18 +434,14 @@ describe("sales channels", () => {
describe("GET /admin/orders/:id", () => { describe("GET /admin/orders/:id", () => {
let order let order
beforeEach(async () => { beforeEach(async () => {
try { await adminSeeder(dbConnection)
await adminSeeder(dbConnection)
order = await simpleOrderFactory(dbConnection, { order = await simpleOrderFactory(dbConnection, {
sales_channel: { sales_channel: {
name: "test name", name: "test name",
description: "test description", description: "test description",
}, },
}) })
} catch (err) {
console.log(err)
}
}) })
afterEach(async () => { afterEach(async () => {
@@ -495,18 +471,14 @@ describe("sales channels", () => {
describe("GET /admin/orders?expand=sales_channels", () => { describe("GET /admin/orders?expand=sales_channels", () => {
beforeEach(async () => { beforeEach(async () => {
try { await adminSeeder(dbConnection)
await adminSeeder(dbConnection)
await simpleOrderFactory(dbConnection, { await simpleOrderFactory(dbConnection, {
sales_channel: { sales_channel: {
name: "test name", name: "test name",
description: "test description", description: "test description",
}, },
}) })
} catch (err) {
console.log(err)
}
}) })
afterEach(async () => { afterEach(async () => {
@@ -537,24 +509,20 @@ describe("sales channels", () => {
describe("GET /admin/product/:id", () => { describe("GET /admin/product/:id", () => {
let product let product
beforeEach(async () => { beforeEach(async () => {
try { await adminSeeder(dbConnection)
await adminSeeder(dbConnection)
product = await simpleProductFactory(dbConnection, { product = await simpleProductFactory(dbConnection, {
sales_channels: [ sales_channels: [
{ {
name: "webshop", name: "webshop",
description: "Webshop sales channel", description: "Webshop sales channel",
}, },
{ {
name: "amazon", name: "amazon",
description: "Amazon sales channel", description: "Amazon sales channel",
}, },
], ],
}) })
} catch (err) {
console.log(err)
}
}) })
afterEach(async () => { afterEach(async () => {
@@ -589,24 +557,20 @@ describe("sales channels", () => {
describe("GET /admin/products?expand[]=sales_channels", () => { describe("GET /admin/products?expand[]=sales_channels", () => {
beforeEach(async () => { beforeEach(async () => {
try { await adminSeeder(dbConnection)
await adminSeeder(dbConnection)
await simpleProductFactory(dbConnection, { await simpleProductFactory(dbConnection, {
sales_channels: [ sales_channels: [
{ {
name: "webshop", name: "webshop",
description: "Webshop sales channel", description: "Webshop sales channel",
}, },
{ {
name: "amazon", name: "amazon",
description: "Amazon sales channel", description: "Amazon sales channel",
}, },
], ],
}) })
} catch (err) {
console.log(err)
}
}) })
afterEach(async () => { afterEach(async () => {
@@ -645,20 +609,16 @@ describe("sales channels", () => {
let product let product
beforeEach(async () => { beforeEach(async () => {
try { await adminSeeder(dbConnection)
await adminSeeder(dbConnection) product = await simpleProductFactory(dbConnection, {
product = await simpleProductFactory(dbConnection, { id: "product_1",
id: "product_1", title: "test title",
title: "test title", })
}) salesChannel = await simpleSalesChannelFactory(dbConnection, {
salesChannel = await simpleSalesChannelFactory(dbConnection, { name: "test name",
name: "test name", description: "test description",
description: "test description", products: [product],
products: [product], })
})
} catch (e) {
console.error(e)
}
}) })
afterEach(async () => { afterEach(async () => {
@@ -730,19 +690,15 @@ describe("sales channels", () => {
let product let product
beforeEach(async () => { beforeEach(async () => {
try { await adminSeeder(dbConnection)
await adminSeeder(dbConnection) salesChannel = await simpleSalesChannelFactory(dbConnection, {
salesChannel = await simpleSalesChannelFactory(dbConnection, { name: "test name",
name: "test name", description: "test description",
description: "test description", })
}) product = await simpleProductFactory(dbConnection, {
product = await simpleProductFactory(dbConnection, { id: "product_1",
id: "product_1", title: "test title",
title: "test title", })
})
} catch (e) {
console.error(e)
}
}) })
afterEach(async () => { afterEach(async () => {
@@ -798,19 +754,14 @@ describe("sales channels", () => {
let order let order
beforeEach(async () => { beforeEach(async () => {
try { await adminSeeder(dbConnection)
await adminSeeder(dbConnection) order = await simpleOrderFactory(dbConnection, {
order = await simpleOrderFactory(dbConnection, { sales_channel: {
sales_channel: { name: "test name",
name: "test name", description: "test description",
description: "test description", },
}, })
}) await orderSeeder(dbConnection)
await orderSeeder(dbConnection)
} catch (err) {
console.log(err)
throw err
}
}) })
afterEach(async () => { afterEach(async () => {
@@ -850,19 +801,14 @@ describe("sales channels", () => {
let salesChannel let salesChannel
beforeEach(async () => { beforeEach(async () => {
try { await productSeeder(dbConnection)
await productSeeder(dbConnection) await adminSeeder(dbConnection)
await adminSeeder(dbConnection) const product = await simpleProductFactory(dbConnection, productData)
const product = await simpleProductFactory(dbConnection, productData) salesChannel = await simpleSalesChannelFactory(dbConnection, {
salesChannel = await simpleSalesChannelFactory(dbConnection, { name: "test name",
name: "test name", description: "test description",
description: "test description", products: [product],
products: [product], })
})
} catch (err) {
console.log(err)
throw err
}
}) })
afterEach(async () => { afterEach(async () => {
@@ -900,17 +846,12 @@ describe("sales channels", () => {
let salesChannel let salesChannel
beforeEach(async () => { beforeEach(async () => {
try { await productSeeder(dbConnection)
await productSeeder(dbConnection) await adminSeeder(dbConnection)
await adminSeeder(dbConnection) salesChannel = await simpleSalesChannelFactory(dbConnection, {
salesChannel = await simpleSalesChannelFactory(dbConnection, { name: "test name",
name: "test name", description: "test description",
description: "test description", })
})
} catch (err) {
console.log(err)
throw err
}
}) })
afterEach(async () => { afterEach(async () => {
@@ -965,17 +906,12 @@ describe("sales channels", () => {
let salesChannel let salesChannel
beforeEach(async () => { beforeEach(async () => {
try { await productSeeder(dbConnection)
await productSeeder(dbConnection) await adminSeeder(dbConnection)
await adminSeeder(dbConnection) salesChannel = await simpleSalesChannelFactory(dbConnection, {
salesChannel = await simpleSalesChannelFactory(dbConnection, { name: "test name",
name: "test name", description: "test description",
description: "test description", })
})
} catch (err) {
console.log(err)
throw err
}
}) })
afterEach(async () => { afterEach(async () => {
@@ -32,13 +32,8 @@ describe("/admin/shipping-options", () => {
describe("POST /admin/shipping-options/:id", () => { describe("POST /admin/shipping-options/:id", () => {
beforeEach(async () => { beforeEach(async () => {
try { await adminSeeder(dbConnection)
await adminSeeder(dbConnection) await shippingOptionSeeder(dbConnection)
await shippingOptionSeeder(dbConnection)
} catch (err) {
console.error(err)
throw err
}
}) })
afterEach(async () => { afterEach(async () => {
@@ -254,40 +249,35 @@ describe("/admin/shipping-options", () => {
let payload let payload
beforeEach(async () => { beforeEach(async () => {
try { await adminSeeder(dbConnection)
await adminSeeder(dbConnection) await shippingOptionSeeder(dbConnection)
await shippingOptionSeeder(dbConnection)
const api = useApi() const api = useApi()
await api.post( await api.post(
`/admin/regions/region`, `/admin/regions/region`,
{ {
fulfillment_providers: ["test-ful"], fulfillment_providers: ["test-ful"],
},
{
headers: {
Authorization: "Bearer test_token",
}, },
{
headers: {
Authorization: "Bearer test_token",
},
}
)
const manager = dbConnection.manager
const defaultProfile = await manager.findOne(ShippingProfile, {
type: "default",
})
payload = {
name: "Test option",
amount: 100,
price_type: "flat_rate",
region_id: "region",
provider_id: "test-ful",
data: {},
profile_id: defaultProfile.id,
} }
} catch (err) { )
console.error(err)
throw err const manager = dbConnection.manager
const defaultProfile = await manager.findOne(ShippingProfile, {
type: "default",
})
payload = {
name: "Test option",
amount: 100,
price_type: "flat_rate",
region_id: "region",
provider_id: "test-ful",
data: {},
profile_id: defaultProfile.id,
} }
}) })
@@ -385,13 +375,8 @@ describe("/admin/shipping-options", () => {
}) })
describe("GET /admin/shipping-options", () => { describe("GET /admin/shipping-options", () => {
beforeEach(async () => { beforeEach(async () => {
try { await adminSeeder(dbConnection)
await adminSeeder(dbConnection) await shippingOptionSeeder(dbConnection)
await shippingOptionSeeder(dbConnection)
} catch (err) {
console.error(err)
throw err
}
}) })
afterEach(async () => { afterEach(async () => {
+6 -14
View File
@@ -28,13 +28,9 @@ describe("/admin/swaps", () => {
describe("GET /admin/swaps/:id", () => { describe("GET /admin/swaps/:id", () => {
beforeEach(async () => { beforeEach(async () => {
try { await adminSeeder(dbConnection)
await adminSeeder(dbConnection) await orderSeeder(dbConnection)
await orderSeeder(dbConnection) await swapSeeder(dbConnection)
await swapSeeder(dbConnection)
} catch (err) {
throw err
}
}) })
afterEach(async () => { afterEach(async () => {
@@ -106,13 +102,9 @@ describe("/admin/swaps", () => {
describe("GET /admin/swaps/", () => { describe("GET /admin/swaps/", () => {
beforeEach(async () => { beforeEach(async () => {
try { await adminSeeder(dbConnection)
await adminSeeder(dbConnection) await orderSeeder(dbConnection)
await orderSeeder(dbConnection) await swapSeeder(dbConnection)
await swapSeeder(dbConnection)
} catch (err) {
throw err
}
}) })
afterEach(async () => { afterEach(async () => {
@@ -28,13 +28,8 @@ describe("/admin/products", () => {
describe("GET /admin/product-variants", () => { describe("GET /admin/product-variants", () => {
beforeEach(async () => { beforeEach(async () => {
try { await productSeeder(dbConnection)
await productSeeder(dbConnection) await adminSeeder(dbConnection)
await adminSeeder(dbConnection)
} catch (err) {
console.log(err)
throw err
}
}) })
afterEach(async () => { afterEach(async () => {
@@ -18,42 +18,37 @@ const adminReqConfig = {
} }
const setupJobDb = async (dbConnection) => { const setupJobDb = async (dbConnection) => {
try { await adminSeeder(dbConnection)
await adminSeeder(dbConnection) await userSeeder(dbConnection)
await userSeeder(dbConnection)
await simpleBatchJobFactory(dbConnection, { await simpleBatchJobFactory(dbConnection, {
id: "job_1", id: "job_1",
type: "product-export", type: "product-export",
created_by: "admin_user", created_by: "admin_user",
}) })
await simpleBatchJobFactory(dbConnection, { await simpleBatchJobFactory(dbConnection, {
id: "job_2", id: "job_2",
type: "product-export", type: "product-export",
created_by: "admin_user", created_by: "admin_user",
}) })
await simpleBatchJobFactory(dbConnection, { await simpleBatchJobFactory(dbConnection, {
id: "job_3", id: "job_3",
type: "product-export", type: "product-export",
created_by: "admin_user", created_by: "admin_user",
}) })
await simpleBatchJobFactory(dbConnection, { await simpleBatchJobFactory(dbConnection, {
id: "job_4", id: "job_4",
type: "product-export", type: "product-export",
status: "awaiting_confirmation", status: "awaiting_confirmation",
created_by: "member-user", created_by: "member-user",
}) })
await simpleBatchJobFactory(dbConnection, { await simpleBatchJobFactory(dbConnection, {
id: "job_5", id: "job_5",
type: "product-export", type: "product-export",
status: "completed", status: "completed",
completed_at: "2022-06-27T22:00:00.000Z", completed_at: "2022-06-27T22:00:00.000Z",
created_by: "admin_user", created_by: "admin_user",
}) })
} catch (err) {
console.log(err)
throw err
}
} }
describe("/admin/batch-jobs", () => { describe("/admin/batch-jobs", () => {
@@ -251,18 +246,13 @@ describe("/admin/batch-jobs", () => {
describe("POST /admin/batch-jobs/:id/cancel", () => { describe("POST /admin/batch-jobs/:id/cancel", () => {
beforeEach(async () => { beforeEach(async () => {
try { await setupJobDb(dbConnection)
await setupJobDb(dbConnection) await simpleBatchJobFactory(dbConnection, {
await simpleBatchJobFactory(dbConnection, { id: "job_complete",
id: "job_complete", type: "product-export",
type: "product-export", created_by: "admin_user",
created_by: "admin_user", completed_at: new Date(),
completed_at: new Date(), })
})
} catch (e) {
console.log(e)
throw e
}
}) })
afterEach(async () => { afterEach(async () => {
@@ -47,14 +47,9 @@ describe("Batchjob with type order-export", () => {
}) })
beforeEach(async () => { beforeEach(async () => {
try { await adminSeeder(dbConnection)
await adminSeeder(dbConnection) await userSeeder(dbConnection)
await userSeeder(dbConnection) await orderSeeder(dbConnection)
await orderSeeder(dbConnection)
} catch (e) {
console.log(e)
throw e
}
}) })
afterEach(async () => { afterEach(async () => {
@@ -47,14 +47,9 @@ describe("Batch job of product-export type", () => {
}) })
beforeEach(async () => { beforeEach(async () => {
try { await productSeeder(dbConnection)
await productSeeder(dbConnection) await adminSeeder(dbConnection)
await adminSeeder(dbConnection) await userSeeder(dbConnection)
await userSeeder(dbConnection)
} catch (e) {
console.log(e)
throw e
}
}) })
afterEach(async () => { afterEach(async () => {
@@ -24,12 +24,8 @@ describe("Claims", () => {
beforeAll(async () => { beforeAll(async () => {
const cwd = path.resolve(path.join(__dirname, "..", "..")) const cwd = path.resolve(path.join(__dirname, "..", ".."))
try { dbConnection = await initDb({ cwd })
dbConnection = await initDb({ cwd }) medusaProcess = await setupServer({ cwd })
medusaProcess = await setupServer({ cwd })
} catch (error) {
console.log(error)
}
}) })
afterAll(async () => { afterAll(async () => {
@@ -20,17 +20,13 @@ describe("Line Item - Sales Channel", () => {
beforeAll(async () => { beforeAll(async () => {
const cwd = path.resolve(path.join(__dirname, "..", "..")) const cwd = path.resolve(path.join(__dirname, "..", ".."))
try { const [process, connection] = await startServerWithEnvironment({
const [process, connection] = await startServerWithEnvironment({ cwd,
cwd, env: { MEDUSA_FF_SALES_CHANNELS: true },
env: { MEDUSA_FF_SALES_CHANNELS: true }, verbose: false,
verbose: false, })
}) dbConnection = connection
dbConnection = connection medusaProcess = process
medusaProcess = process
} catch (error) {
console.log(error)
}
}) })
afterAll(async () => { afterAll(async () => {
@@ -40,53 +36,48 @@ describe("Line Item - Sales Channel", () => {
}) })
beforeEach(async () => { beforeEach(async () => {
try { await simpleProductFactory(dbConnection, {
await simpleProductFactory(dbConnection, { id: "test-product-in-sales-channel",
id: "test-product-in-sales-channel", title: "test product belonging to a channel",
title: "test product belonging to a channel", sales_channels: [
sales_channels: [ {
{
id: "main-sales-channel",
name: "Main sales channel",
description: "Main sales channel",
is_disabled: false,
},
],
variants: [
{
id: "test-variant-sales-channel",
title: "test variant in sales channel",
product_id: "test-product-in-sales-channel",
inventory_quantity: 1000,
prices: [
{
currency: "usd",
amount: 59,
},
],
},
],
})
await simpleProductFactory(dbConnection, {
id: "test-product-no-sales-channel",
variants: [
{
id: "test-variant-no-sales-channel",
},
],
})
await simpleCartFactory(dbConnection, {
id: "test-cart-with-sales-channel",
sales_channel: {
id: "main-sales-channel", id: "main-sales-channel",
name: "Main sales channel",
description: "Main sales channel",
is_disabled: false,
}, },
}) ],
} catch (err) { variants: [
console.log(err) {
throw err id: "test-variant-sales-channel",
} title: "test variant in sales channel",
product_id: "test-product-in-sales-channel",
inventory_quantity: 1000,
prices: [
{
currency: "usd",
amount: 59,
},
],
},
],
})
await simpleProductFactory(dbConnection, {
id: "test-product-no-sales-channel",
variants: [
{
id: "test-variant-no-sales-channel",
},
],
})
await simpleCartFactory(dbConnection, {
id: "test-cart-with-sales-channel",
sales_channel: {
id: "main-sales-channel",
},
})
}) })
afterEach(async () => { afterEach(async () => {
@@ -22,12 +22,8 @@ describe("Line Item Adjustments", () => {
beforeAll(async () => { beforeAll(async () => {
const cwd = path.resolve(path.join(__dirname, "..", "..")) const cwd = path.resolve(path.join(__dirname, "..", ".."))
try { dbConnection = await initDb({ cwd })
dbConnection = await initDb({ cwd }) medusaProcess = await setupServer({ cwd })
medusaProcess = await setupServer({ cwd })
} catch (error) {
console.log(error)
}
}) })
afterAll(async () => { afterAll(async () => {
@@ -41,60 +37,55 @@ describe("Line Item Adjustments", () => {
discount, discount,
lineItemId = "line-test" lineItemId = "line-test"
beforeEach(async () => { beforeEach(async () => {
try { await cartSeeder(dbConnection)
await cartSeeder(dbConnection) discount = await simpleDiscountFactory(dbConnection, {
discount = await simpleDiscountFactory(dbConnection, { code: "MEDUSATEST",
code: "MEDUSATEST", id: "discount-test",
id: "discount-test", rule: {
rule: { value: 100,
value: 100, type: "fixed",
type: "fixed", allocation: "total",
allocation: "total", },
}, regions: ["test-region"],
regions: ["test-region"], })
}) cart = await simpleCartFactory(
cart = await simpleCartFactory( dbConnection,
dbConnection, {
{ customer: "test-customer",
customer: "test-customer", id: "cart-test",
id: "cart-test", line_items: [
line_items: [ {
{ id: lineItemId,
id: lineItemId, variant_id: "test-variant",
variant_id: "test-variant", cart_id: "cart-test",
cart_id: "cart-test", unit_price: 1000,
unit_price: 1000, quantity: 1,
quantity: 1, adjustments: [
adjustments: [ {
{ amount: 10,
amount: 10, discount_id: discount.id,
discount_id: discount.id, description: "discount",
description: "discount", item_id: lineItemId,
item_id: lineItemId, },
}, ],
],
},
],
region: "test-region",
shipping_address: {
address_1: "test",
country_code: "us",
first_name: "chris",
last_name: "rock",
postal_code: "101",
}, },
shipping_methods: [ ],
{ region: "test-region",
shipping_option: "test-option", shipping_address: {
}, address_1: "test",
], country_code: "us",
first_name: "chris",
last_name: "rock",
postal_code: "101",
}, },
100 shipping_methods: [
) {
} catch (err) { shipping_option: "test-option",
console.log(err) },
throw err ],
} },
100
)
}) })
afterEach(async () => { afterEach(async () => {
@@ -28,13 +28,8 @@ describe("Promotions", () => {
describe("Money amount", () => { describe("Money amount", () => {
beforeEach(async () => { beforeEach(async () => {
try { await adminSeeder(dbConnection)
await adminSeeder(dbConnection) await promotionsSeeder(dbConnection)
await promotionsSeeder(dbConnection)
} catch (err) {
console.log(err)
throw err
}
}) })
afterEach(async () => { afterEach(async () => {
@@ -23,12 +23,8 @@ describe("/admin/orders", () => {
beforeAll(async () => { beforeAll(async () => {
const cwd = path.resolve(path.join(__dirname, "..", "..")) const cwd = path.resolve(path.join(__dirname, "..", ".."))
try { dbConnection = await initDb({ cwd })
dbConnection = await initDb({ cwd }) medusaProcess = await setupServer({ cwd })
medusaProcess = await setupServer({ cwd })
} catch (error) {
console.log(error)
}
}) })
afterAll(async () => { afterAll(async () => {
+74 -114
View File
@@ -46,12 +46,8 @@ describe("/store/carts", () => {
beforeAll(async () => { beforeAll(async () => {
const cwd = path.resolve(path.join(__dirname, "..", "..")) const cwd = path.resolve(path.join(__dirname, "..", ".."))
try { dbConnection = await initDb({ cwd })
dbConnection = await initDb({ cwd }) medusaProcess = await setupServer({ cwd, verbose: false })
medusaProcess = await setupServer({ cwd, verbose: false })
} catch (error) {
console.log(error)
}
}) })
afterAll(async () => { afterAll(async () => {
@@ -207,13 +203,8 @@ describe("/store/carts", () => {
describe("POST /store/carts/:id/line-items", () => { describe("POST /store/carts/:id/line-items", () => {
beforeEach(async () => { beforeEach(async () => {
try { await cartSeeder(dbConnection)
await cartSeeder(dbConnection) await swapSeeder(dbConnection)
await swapSeeder(dbConnection)
} catch (err) {
console.log(err)
throw err
}
}) })
afterEach(async () => { afterEach(async () => {
@@ -495,57 +486,49 @@ describe("/store/carts", () => {
let discountCart let discountCart
let discount let discount
beforeEach(async () => { beforeEach(async () => {
try { discount = await simpleDiscountFactory(dbConnection, discountData, 100)
discount = await simpleDiscountFactory( discountCart = await simpleCartFactory(
dbConnection, dbConnection,
discountData, {
100 id: "discount-cart",
) customer: "test-customer",
discountCart = await simpleCartFactory( region: "test-region",
dbConnection, shipping_address: {
{ address_1: "next door",
id: "discount-cart", first_name: "lebron",
customer: "test-customer", last_name: "james",
region: "test-region", country_code: "dk",
shipping_address: { postal_code: "100",
address_1: "next door",
first_name: "lebron",
last_name: "james",
country_code: "dk",
postal_code: "100",
},
line_items: [
{
id: "test-li",
variant_id: "test-variant",
quantity: 1,
unit_price: 100,
adjustments: [
{
amount: 185,
description: "discount",
discount_id: "medusa-185",
},
],
},
],
shipping_methods: [
{
shipping_option: "test-option",
price: 1000,
},
],
}, },
100 line_items: [
) {
await dbConnection.manager id: "test-li",
.createQueryBuilder() variant_id: "test-variant",
.relation(Cart, "discounts") quantity: 1,
.of(discountCart) unit_price: 100,
.add(discount) adjustments: [
} catch (err) { {
console.log(err) amount: 185,
} description: "discount",
discount_id: "medusa-185",
},
],
},
],
shipping_methods: [
{
shipping_option: "test-option",
price: 1000,
},
],
},
100
)
await dbConnection.manager
.createQueryBuilder()
.relation(Cart, "discounts")
.of(discountCart)
.add(discount)
}) })
afterEach(async () => { afterEach(async () => {
@@ -699,13 +682,8 @@ describe("/store/carts", () => {
describe("POST /store/carts/:id/line-items/:line_id", () => { describe("POST /store/carts/:id/line-items/:line_id", () => {
beforeEach(async () => { beforeEach(async () => {
try { await cartSeeder(dbConnection)
await cartSeeder(dbConnection) await swapSeeder(dbConnection)
await swapSeeder(dbConnection)
} catch (err) {
console.log(err)
throw err
}
}) })
afterEach(async () => { afterEach(async () => {
@@ -901,13 +879,8 @@ describe("/store/carts", () => {
describe("POST /store/carts/:id", () => { describe("POST /store/carts/:id", () => {
beforeEach(async () => { beforeEach(async () => {
try { await cartSeeder(dbConnection)
await cartSeeder(dbConnection) await swapSeeder(dbConnection)
await swapSeeder(dbConnection)
} catch (err) {
console.log(err)
throw err
}
}) })
afterEach(async () => { afterEach(async () => {
@@ -1738,11 +1711,7 @@ describe("/store/carts", () => {
const api = useApi() const api = useApi()
try { await api.post(`/store/carts/swap-cart/complete-cart`)
await api.post(`/store/carts/swap-cart/complete-cart`)
} catch (error) {
console.log(error)
}
// check to see if payment is authorized and cart is completed // check to see if payment is authorized and cart is completed
const res = await api.get(`/store/carts/swap-cart`) const res = await api.get(`/store/carts/swap-cart`)
@@ -1753,35 +1722,31 @@ describe("/store/carts", () => {
describe("POST /store/carts/:id/shipping-methods", () => { describe("POST /store/carts/:id/shipping-methods", () => {
beforeEach(async () => { beforeEach(async () => {
try { await cartSeeder(dbConnection)
await cartSeeder(dbConnection) const manager = dbConnection.manager
const manager = dbConnection.manager
const _cart = await manager.create(Cart, { const _cart = await manager.create(Cart, {
id: "test-cart-with-cso", id: "test-cart-with-cso",
customer_id: "some-customer", customer_id: "some-customer",
email: "some-customer@email.com", email: "some-customer@email.com",
shipping_address: { shipping_address: {
id: "test-shipping-address", id: "test-shipping-address",
first_name: "lebron", first_name: "lebron",
country_code: "us", country_code: "us",
}, },
region_id: "test-region", region_id: "test-region",
currency_code: "usd", currency_code: "usd",
type: "swap", type: "swap",
}) })
const cartWithCustomSo = await manager.save(_cart) const cartWithCustomSo = await manager.save(_cart)
await manager.insert(CustomShippingOption, { await manager.insert(CustomShippingOption, {
id: "another-cso-test", id: "another-cso-test",
cart_id: "test-cart-with-cso", cart_id: "test-cart-with-cso",
shipping_option_id: "test-option", shipping_option_id: "test-option",
price: 5, price: 5,
}) })
} catch (err) {
console.log(err)
}
}) })
afterEach(async () => { afterEach(async () => {
@@ -2059,12 +2024,7 @@ describe("/store/carts", () => {
describe("shipping address + region updates", () => { describe("shipping address + region updates", () => {
beforeEach(async () => { beforeEach(async () => {
try { await cartSeeder(dbConnection)
await cartSeeder(dbConnection)
} catch (err) {
console.log(err)
throw err
}
}) })
afterEach(async () => { afterEach(async () => {
@@ -25,12 +25,7 @@ describe("/store/collections", () => {
describe("/store/collections/:id", () => { describe("/store/collections/:id", () => {
beforeEach(async () => { beforeEach(async () => {
try { await productSeeder(dbConnection)
await productSeeder(dbConnection)
} catch (err) {
console.log(err)
throw err
}
}) })
afterEach(async () => { afterEach(async () => {
@@ -55,12 +50,7 @@ describe("/store/collections", () => {
describe("/store/collections", () => { describe("/store/collections", () => {
beforeEach(async () => { beforeEach(async () => {
try { await productSeeder(dbConnection)
await productSeeder(dbConnection)
} catch (err) {
console.log(err)
throw err
}
}) })
afterEach(async () => { afterEach(async () => {
@@ -27,12 +27,7 @@ describe("/store/carts (draft-orders)", () => {
describe("POST /admin/draft-order", () => { describe("POST /admin/draft-order", () => {
beforeEach(async () => { beforeEach(async () => {
try { await draftOrderSeeder(dbConnection)
await draftOrderSeeder(dbConnection)
} catch (err) {
console.log(err)
throw err
}
}) })
afterEach(async () => { afterEach(async () => {
@@ -26,30 +26,25 @@ describe("/store/variants", () => {
describe("GET /store/variants", () => { describe("GET /store/variants", () => {
beforeEach(async () => { beforeEach(async () => {
try { await productSeeder(dbConnection)
await productSeeder(dbConnection)
await simpleProductFactory( await simpleProductFactory(
dbConnection, dbConnection,
{ {
title: "prod", title: "prod",
variants: [ variants: [
{ {
title: "test1", title: "test1",
inventory_quantity: 10, inventory_quantity: 10,
}, },
{ {
title: "test2", title: "test2",
inventory_quantity: 12, inventory_quantity: 12,
}, },
], ],
}, },
100 100
) )
} catch (err) {
console.log(err)
throw err
}
}) })
afterEach(async () => { afterEach(async () => {
@@ -169,30 +164,25 @@ describe("/store/variants", () => {
describe("GET /store/variants advanced pricing", () => { describe("GET /store/variants advanced pricing", () => {
beforeEach(async () => { beforeEach(async () => {
try { await storeProductSeeder(dbConnection)
await storeProductSeeder(dbConnection)
await simpleProductFactory( await simpleProductFactory(
dbConnection, dbConnection,
{ {
title: "prod", title: "prod",
variants: [ variants: [
{ {
title: "test1", title: "test1",
inventory_quantity: 10, inventory_quantity: 10,
}, },
{ {
title: "test2", title: "test2",
inventory_quantity: 12, inventory_quantity: 12,
}, },
], ],
}, },
100 100
) )
} catch (err) {
console.log(err)
throw err
}
}) })
afterEach(async () => { afterEach(async () => {
@@ -26,13 +26,8 @@ describe("/store/products", () => {
describe("GET /store/products", () => { describe("GET /store/products", () => {
beforeEach(async () => { beforeEach(async () => {
try { await productSeeder(dbConnection)
await productSeeder(dbConnection) await adminSeeder(dbConnection)
await adminSeeder(dbConnection)
} catch (err) {
console.log(err)
throw err
}
}) })
afterEach(async () => { afterEach(async () => {
@@ -233,13 +228,8 @@ describe("/store/products", () => {
describe("list params", () => { describe("list params", () => {
beforeEach(async () => { beforeEach(async () => {
try { await productSeeder(dbConnection)
await productSeeder(dbConnection) await adminSeeder(dbConnection)
await adminSeeder(dbConnection)
} catch (err) {
console.log(err)
throw err
}
}) })
afterEach(async () => { afterEach(async () => {
@@ -332,32 +322,27 @@ describe("/store/products", () => {
describe("list params", () => { describe("list params", () => {
beforeEach(async () => { beforeEach(async () => {
try { await adminSeeder(dbConnection)
await adminSeeder(dbConnection)
await simpleProductFactory( await simpleProductFactory(
dbConnection, dbConnection,
{ {
title: "testprod", title: "testprod",
status: "published", status: "published",
variants: [{ title: "test-variant" }], variants: [{ title: "test-variant" }],
}, },
11 11
) )
await simpleProductFactory( await simpleProductFactory(
dbConnection, dbConnection,
{ {
title: "testprod3", title: "testprod3",
status: "published", status: "published",
variants: [{ title: "test-variant1" }], variants: [{ title: "test-variant1" }],
}, },
12 12
) )
} catch (err) {
console.log(err)
throw err
}
}) })
afterEach(async () => { afterEach(async () => {
@@ -400,13 +385,8 @@ describe("/store/products", () => {
describe("/store/products/:id", () => { describe("/store/products/:id", () => {
beforeEach(async () => { beforeEach(async () => {
try { await productSeeder(dbConnection)
await productSeeder(dbConnection) await adminSeeder(dbConnection)
await adminSeeder(dbConnection)
} catch (err) {
console.log(err)
throw err
}
}) })
afterEach(async () => { afterEach(async () => {
@@ -28,18 +28,13 @@ describe("/store/return-reasons", () => {
let rrId let rrId
beforeEach(async () => { beforeEach(async () => {
try { const created = dbConnection.manager.create(ReturnReason, {
const created = dbConnection.manager.create(ReturnReason, { value: "wrong_size",
value: "wrong_size", label: "Wrong size",
label: "Wrong size", })
})
const result = await dbConnection.manager.save(created) const result = await dbConnection.manager.save(created)
rrId = result.id rrId = result.id
} catch (err) {
console.log(err)
throw err
}
}) })
afterEach(async () => { afterEach(async () => {
@@ -73,35 +68,30 @@ describe("/store/return-reasons", () => {
let rrId_2 let rrId_2
beforeEach(async () => { beforeEach(async () => {
try { const created = dbConnection.manager.create(ReturnReason, {
const created = dbConnection.manager.create(ReturnReason, { value: "wrong_size",
value: "wrong_size", label: "Wrong size",
label: "Wrong size", })
})
const result = await dbConnection.manager.save(created) const result = await dbConnection.manager.save(created)
rrId = result.id rrId = result.id
const created_child = dbConnection.manager.create(ReturnReason, { const created_child = dbConnection.manager.create(ReturnReason, {
value: "too_big", value: "too_big",
label: "Too Big", label: "Too Big",
parent_return_reason_id: rrId, parent_return_reason_id: rrId,
}) })
const result_child = await dbConnection.manager.save(created_child) const result_child = await dbConnection.manager.save(created_child)
rrId_1 = result_child.id rrId_1 = result_child.id
const created_2 = dbConnection.manager.create(ReturnReason, { const created_2 = dbConnection.manager.create(ReturnReason, {
value: "too_big_1", value: "too_big_1",
label: "Too Big 1", label: "Too Big 1",
}) })
const result_2 = await dbConnection.manager.save(created_2) const result_2 = await dbConnection.manager.save(created_2)
rrId_2 = result_2.id rrId_2 = result_2.id
} catch (err) {
console.log(err)
throw err
}
}) })
afterEach(async () => { afterEach(async () => {
@@ -6,7 +6,9 @@ const { useDb } = require("../../../helpers/use-db")
const adminSeeder = require("../../helpers/admin-seeder") const adminSeeder = require("../../helpers/admin-seeder")
const { const {
simpleSalesChannelFactory, simpleSalesChannelFactory,
simpleCartFactory, simpleRegionFactory, simpleProductFactory, simpleCartFactory,
simpleRegionFactory,
simpleProductFactory,
} = require("../../factories") } = require("../../factories")
const startServerWithEnvironment = const startServerWithEnvironment =
@@ -47,29 +49,25 @@ describe("sales channels", () => {
let disabledSalesChannel let disabledSalesChannel
beforeEach(async () => { beforeEach(async () => {
try { await adminSeeder(dbConnection)
await adminSeeder(dbConnection) await simpleRegionFactory(dbConnection, {
await simpleRegionFactory(dbConnection, { name: "Test region",
name: "Test region", tax_rate: 0,
tax_rate: 0, })
}) await simpleSalesChannelFactory(dbConnection, {
await simpleSalesChannelFactory(dbConnection, { name: "Default Sales Channel",
name: "Default Sales Channel", description: "Created by Medusa",
description: "Created by Medusa", is_default: true,
is_default: true })
}) disabledSalesChannel = await simpleSalesChannelFactory(dbConnection, {
disabledSalesChannel = await simpleSalesChannelFactory(dbConnection, { name: "disabled cart sales channel",
name: "disabled cart sales channel", description: "disabled cart sales channel description",
description: "disabled cart sales channel description", is_disabled: true,
is_disabled: true, })
}) salesChannel = await simpleSalesChannelFactory(dbConnection, {
salesChannel = await simpleSalesChannelFactory(dbConnection, { name: "cart sales channel",
name: "cart sales channel", description: "cart sales channel description",
description: "cart sales channel description", })
})
} catch (err) {
console.log(err)
}
}) })
afterEach(async () => { afterEach(async () => {
@@ -94,7 +92,11 @@ describe("sales channels", () => {
it("returns a cart with the given sales channel", async () => { it("returns a cart with the given sales channel", async () => {
const api = useApi() const api = useApi()
const response = await api.post(`/store/carts`, { sales_channel_id: salesChannel.id }, adminReqConfig) const response = await api.post(
`/store/carts`,
{ sales_channel_id: salesChannel.id },
adminReqConfig
)
expect(response.data.cart.sales_channel).toBeTruthy() expect(response.data.cart.sales_channel).toBeTruthy()
expect(response.data.cart.sales_channel).toEqual( expect(response.data.cart.sales_channel).toEqual(
@@ -108,14 +110,18 @@ describe("sales channels", () => {
it("throw if the given sales channel is disabled", async () => { it("throw if the given sales channel is disabled", async () => {
const api = useApi() const api = useApi()
const err = await api.post( const err = await api
`/store/carts`, .post(
{ sales_channel_id: disabledSalesChannel.id }, `/store/carts`,
adminReqConfig { sales_channel_id: disabledSalesChannel.id },
).catch(err => err) adminReqConfig
)
.catch((err) => err)
expect(err.response.status).toEqual(400) expect(err.response.status).toEqual(400)
expect(err.response.data.message).toBe(`Unable to assign the cart to a disabled Sales Channel "disabled cart sales channel"`) expect(err.response.data.message).toBe(
`Unable to assign the cart to a disabled Sales Channel "disabled cart sales channel"`
)
}) })
}) })
@@ -125,81 +131,68 @@ describe("sales channels", () => {
let cart let cart
beforeEach(async () => { beforeEach(async () => {
try { await adminSeeder(dbConnection)
await adminSeeder(dbConnection) await simpleRegionFactory(dbConnection, {
await simpleRegionFactory(dbConnection, { name: "Test region",
name: "Test region", currency_code: "usd",
currency_code: "usd", tax_rate: 0,
tax_rate: 0, })
})
salesChannel1 = await simpleSalesChannelFactory(dbConnection, { salesChannel1 = await simpleSalesChannelFactory(dbConnection, {
name: "salesChannel1", name: "salesChannel1",
description: "salesChannel1", description: "salesChannel1",
}) })
salesChannel2 = await simpleSalesChannelFactory(dbConnection, { salesChannel2 = await simpleSalesChannelFactory(dbConnection, {
name: "salesChannel2", name: "salesChannel2",
description: "salesChannel2", description: "salesChannel2",
}) })
disabledSalesChannel = await simpleSalesChannelFactory(dbConnection, { disabledSalesChannel = await simpleSalesChannelFactory(dbConnection, {
name: "disabled cart sales channel", name: "disabled cart sales channel",
description: "disabled cart sales channel description", description: "disabled cart sales channel description",
is_disabled: true, is_disabled: true,
}) })
product1 = await simpleProductFactory( product1 = await simpleProductFactory(dbConnection, {
dbConnection, title: "prod 1",
sales_channels: [salesChannel1],
variants: [
{ {
title: "prod 1", id: "test-variant",
sales_channels: [salesChannel1], prices: [
variants: [
{
id: "test-variant",
prices: [
{
amount: 50,
currency: "usd",
variant_id: "test-variant",
},
],
},
],
},
)
product2 = await simpleProductFactory(
dbConnection,
{
sales_channels: [salesChannel2],
variants: [
{
id: "test-variant-2",
prices: [
{
amount: 100,
currency: "usd",
variant_id: "test-variant-2",
},
],
},
],
},
)
cart = await simpleCartFactory(
dbConnection,
{
sales_channel: salesChannel1,
line_items: [
{ {
amount: 50,
currency: "usd",
variant_id: "test-variant", variant_id: "test-variant",
unit_price: 50,
}, },
], ],
}, },
) ],
} catch (err) { })
console.log(err) product2 = await simpleProductFactory(dbConnection, {
} sales_channels: [salesChannel2],
variants: [
{
id: "test-variant-2",
prices: [
{
amount: 100,
currency: "usd",
variant_id: "test-variant-2",
},
],
},
],
})
cart = await simpleCartFactory(dbConnection, {
sales_channel: salesChannel1,
line_items: [
{
variant_id: "test-variant",
unit_price: 50,
},
],
})
}) })
afterEach(async () => { afterEach(async () => {
@@ -207,52 +200,57 @@ describe("sales channels", () => {
await db.teardown() await db.teardown()
}) })
it( it("updates a cart sales channels should remove the items that does not belongs to the new sales channel", async () => {
"updates a cart sales channels should remove the items that does not belongs to the new sales channel", const api = useApi()
async () => {
const api = useApi()
let response = await api.get(`/store/carts/${cart.id}`, adminReqConfig) let response = await api.get(`/store/carts/${cart.id}`, adminReqConfig)
expect(response.data.cart.sales_channel).toBeTruthy() expect(response.data.cart.sales_channel).toBeTruthy()
expect(response.data.cart.sales_channel).toEqual( expect(response.data.cart.sales_channel).toEqual(
expect.objectContaining({ expect.objectContaining({
name: salesChannel1.name, name: salesChannel1.name,
description: salesChannel1.description, description: salesChannel1.description,
}) })
) )
expect(response.data.cart.items.length).toBe(1) expect(response.data.cart.items.length).toBe(1)
expect(response.data.cart.items[0].variant.product).toEqual( expect(response.data.cart.items[0].variant.product).toEqual(
expect.objectContaining({ expect.objectContaining({
id: product1.id, id: product1.id,
title: product1.title, title: product1.title,
}) })
) )
response = await api.post(`/store/carts/${cart.id}`, { sales_channel_id: salesChannel2.id }, adminReqConfig) response = await api.post(
`/store/carts/${cart.id}`,
{ sales_channel_id: salesChannel2.id },
adminReqConfig
)
expect(response.data.cart.sales_channel).toBeTruthy() expect(response.data.cart.sales_channel).toBeTruthy()
expect(response.data.cart.sales_channel).toEqual( expect(response.data.cart.sales_channel).toEqual(
expect.objectContaining({ expect.objectContaining({
name: salesChannel2.name, name: salesChannel2.name,
description: salesChannel2.description, description: salesChannel2.description,
}) })
) )
expect(response.data.cart.items.length).toBe(0) expect(response.data.cart.items.length).toBe(0)
} })
)
it("throw if the given sales channel is disabled", async () => { it("throw if the given sales channel is disabled", async () => {
const api = useApi() const api = useApi()
const err = await api.post( const err = await api
`/store/carts/${cart.id}`, .post(
{ sales_channel_id: disabledSalesChannel.id }, `/store/carts/${cart.id}`,
adminReqConfig { sales_channel_id: disabledSalesChannel.id },
).catch(err => err) adminReqConfig
)
.catch((err) => err)
expect(err.response.status).toEqual(400) expect(err.response.status).toEqual(400)
expect(err.response.data.message).toBe("Unable to assign the cart to a disabled Sales Channel \"disabled cart sales channel\"") expect(err.response.data.message).toBe(
`Unable to assign the cart to a disabled Sales Channel "disabled cart sales channel"`
)
}) })
}) })
@@ -260,18 +258,14 @@ describe("sales channels", () => {
let cart let cart
beforeEach(async () => { beforeEach(async () => {
try { await adminSeeder(dbConnection)
await adminSeeder(dbConnection)
cart = await simpleCartFactory(dbConnection, { cart = await simpleCartFactory(dbConnection, {
sales_channel: { sales_channel: {
name: "test name", name: "test name",
description: "test description", description: "test description",
}, },
}) })
} catch (err) {
console.log(err)
}
}) })
afterEach(async () => { afterEach(async () => {
+23 -31
View File
@@ -1,8 +1,5 @@
const path = require("path") const path = require("path")
const { const { ShippingProfile, ShippingOption } = require("@medusajs/medusa")
ShippingProfile,
ShippingOption,
} = require("@medusajs/medusa")
const setupServer = require("../../../helpers/setup-server") const setupServer = require("../../../helpers/setup-server")
const { useApi } = require("../../../helpers/use-api") const { useApi } = require("../../../helpers/use-api")
@@ -30,35 +27,30 @@ describe("/store/carts", () => {
describe("/store/swaps", () => { describe("/store/swaps", () => {
beforeEach(async () => { beforeEach(async () => {
try { await orderSeeder(dbConnection)
await orderSeeder(dbConnection)
const manager = dbConnection.manager const manager = dbConnection.manager
await manager.query( await manager.query(
`UPDATE "swap" SET cart_id='test-cart-2' WHERE id = 'test-swap'` `UPDATE "swap" SET cart_id='test-cart-2' WHERE id = 'test-swap'`
) )
await manager.query( await manager.query(
`UPDATE "payment" SET swap_id=NULL WHERE id = 'test-payment-swap'` `UPDATE "payment" SET swap_id=NULL WHERE id = 'test-payment-swap'`
) )
const defaultProfile = await manager.findOne(ShippingProfile, { const defaultProfile = await manager.findOne(ShippingProfile, {
type: "default", type: "default",
}) })
await manager.insert(ShippingOption, { await manager.insert(ShippingOption, {
id: "return-option", id: "return-option",
name: "Test ret", name: "Test ret",
profile_id: defaultProfile.id, profile_id: defaultProfile.id,
region_id: "test-region", region_id: "test-region",
provider_id: "test-ful", provider_id: "test-ful",
data: {}, data: {},
price_type: "flat_rate", price_type: "flat_rate",
amount: 1000, amount: 1000,
is_return: true, is_return: true,
}) })
} catch (err) {
console.log(err)
throw err
}
}) })
afterEach(async () => { afterEach(async () => {
@@ -25,12 +25,8 @@ describe("Swaps", () => {
beforeAll(async () => { beforeAll(async () => {
const cwd = path.resolve(path.join(__dirname, "..", "..")) const cwd = path.resolve(path.join(__dirname, "..", ".."))
try { dbConnection = await initDb({ cwd })
dbConnection = await initDb({ cwd }) medusaProcess = await setupServer({ cwd })
medusaProcess = await setupServer({ cwd })
} catch (error) {
console.log(error)
}
}) })
afterAll(async () => { afterAll(async () => {
@@ -26,12 +26,8 @@ describe("/admin/tax-rates", () => {
beforeAll(async () => { beforeAll(async () => {
const cwd = path.resolve(path.join(__dirname, "..", "..")) const cwd = path.resolve(path.join(__dirname, "..", ".."))
try { dbConnection = await initDb({ cwd })
dbConnection = await initDb({ cwd }) medusaProcess = await setupServer({ cwd })
medusaProcess = await setupServer({ cwd })
} catch (error) {
console.log(error)
}
}) })
afterAll(async () => { afterAll(async () => {
@@ -27,12 +27,8 @@ describe("Automatic Cart Taxes", () => {
beforeAll(async () => { beforeAll(async () => {
const cwd = path.resolve(path.join(__dirname, "..", "..")) const cwd = path.resolve(path.join(__dirname, "..", ".."))
try { dbConnection = await initDb({ cwd })
dbConnection = await initDb({ cwd }) medusaProcess = await setupServer({ cwd })
medusaProcess = await setupServer({ cwd })
} catch (error) {
console.log(error)
}
}) })
afterAll(async () => { afterAll(async () => {
@@ -32,12 +32,7 @@ describe("Cart Totals Calculations", () => {
}) })
beforeEach(async () => { beforeEach(async () => {
try { await adminSeeder(dbConnection)
await adminSeeder(dbConnection)
} catch (err) {
console.log(err)
throw err
}
}) })
afterEach(async () => { afterEach(async () => {
@@ -26,12 +26,8 @@ describe("Manual Cart Taxes", () => {
beforeAll(async () => { beforeAll(async () => {
const cwd = path.resolve(path.join(__dirname, "..", "..")) const cwd = path.resolve(path.join(__dirname, "..", ".."))
try { dbConnection = await initDb({ cwd })
dbConnection = await initDb({ cwd }) medusaProcess = await setupServer({ cwd })
medusaProcess = await setupServer({ cwd })
} catch (error) {
console.log(error)
}
}) })
afterAll(async () => { afterAll(async () => {
@@ -25,12 +25,8 @@ describe("Order Taxes", () => {
beforeAll(async () => { beforeAll(async () => {
const cwd = path.resolve(path.join(__dirname, "..", "..")) const cwd = path.resolve(path.join(__dirname, "..", ".."))
try { dbConnection = await initDb({ cwd })
dbConnection = await initDb({ cwd }) medusaProcess = await setupServer({ cwd })
medusaProcess = await setupServer({ cwd })
} catch (error) {
console.log(error)
}
}) })
afterAll(async () => { afterAll(async () => {
@@ -32,12 +32,7 @@ describe("Shipping Options Totals Calculations", () => {
}) })
beforeEach(async () => { beforeEach(async () => {
try { await adminSeeder(dbConnection)
await adminSeeder(dbConnection)
} catch (err) {
console.log(err)
throw err
}
}) })
afterEach(async () => { afterEach(async () => {
@@ -25,12 +25,8 @@ describe("Order Totals", () => {
beforeAll(async () => { beforeAll(async () => {
const cwd = path.resolve(path.join(__dirname, "..", "..")) const cwd = path.resolve(path.join(__dirname, "..", ".."))
try { dbConnection = await initDb({ cwd })
dbConnection = await initDb({ cwd }) medusaProcess = await setupServer({ cwd })
medusaProcess = await setupServer({ cwd })
} catch (error) {
console.log(error)
}
}) })
afterAll(async () => { afterAll(async () => {
+1 -1
View File
@@ -4,7 +4,7 @@
"main": "index.js", "main": "index.js",
"license": "MIT", "license": "MIT",
"scripts": { "scripts": {
"test": "jest --silent=false", "test": "jest --silent=false --runInBand --bail",
"build": "babel src -d dist --extensions \".ts,.js\"" "build": "babel src -d dist --extensions \".ts,.js\""
}, },
"dependencies": { "dependencies": {
+16 -20
View File
@@ -5,30 +5,26 @@ const importFrom = require("import-from")
module.exports = { module.exports = {
bootstrapApp: async ({ cwd } = {}) => { bootstrapApp: async ({ cwd } = {}) => {
try { const app = express()
const app = express()
const loaders = importFrom( const loaders = importFrom(
cwd || process.cwd(), cwd || process.cwd(),
"@medusajs/medusa/dist/loaders" "@medusajs/medusa/dist/loaders"
).default ).default
const { container, dbConnection } = await loaders({ const { container, dbConnection } = await loaders({
directory: path.resolve(cwd || process.cwd()), directory: path.resolve(cwd || process.cwd()),
expressApp: app, expressApp: app,
isTest: false, isTest: false,
}) })
const PORT = await getPort() const PORT = await getPort()
return { return {
container, container,
db: dbConnection, db: dbConnection,
app, app,
port: PORT, port: PORT,
}
} catch (e) {
console.log(e)
} }
}, },
} }
+44 -49
View File
@@ -24,65 +24,60 @@ class DatabaseFactory {
} }
async createTemplateDb_({ cwd }) { async createTemplateDb_({ cwd }) {
try { // const cwd = path.resolve(path.join(__dirname, ".."))
// const cwd = path.resolve(path.join(__dirname, "..")) const connection = await this.getMasterConnection()
const connection = await this.getMasterConnection() const migrationDir = path.resolve(
const migrationDir = path.resolve( path.join(
path.join(
cwd,
`node_modules`,
`@medusajs`,
`medusa`,
`dist`,
`migrations`,
`*.js`
)
)
const { getEnabledMigrations } = require(path.join(
cwd, cwd,
`node_modules`, `node_modules`,
`@medusajs`, `@medusajs`,
`medusa`, `medusa`,
`dist`, `dist`,
`commands`, `migrations`,
`utils`, `*.js`
`get-migrations`
))
// filter migrations to only include those that dont have feature flags
const enabledMigrations = await getEnabledMigrations(
[migrationDir],
(flag) => false
) )
)
await dropDatabase( const { getEnabledMigrations } = require(path.join(
{ cwd,
databaseName: this.templateDbName, `node_modules`,
errorIfNonExist: false, `@medusajs`,
}, `medusa`,
pgGodCredentials `dist`,
) `commands`,
await createDatabase( `utils`,
{ databaseName: this.templateDbName }, `get-migrations`
pgGodCredentials ))
)
const templateDbConnection = await createConnection({ // filter migrations to only include those that dont have feature flags
type: "postgres", const enabledMigrations = await getEnabledMigrations(
name: "templateConnection", [migrationDir],
url: `${DB_URL}/${this.templateDbName}`, (flag) => false
migrations: enabledMigrations, )
})
await templateDbConnection.runMigrations() await dropDatabase(
await templateDbConnection.close() {
databaseName: this.templateDbName,
errorIfNonExist: false,
},
pgGodCredentials
)
await createDatabase(
{ databaseName: this.templateDbName },
pgGodCredentials
)
return connection const templateDbConnection = await createConnection({
} catch (err) { type: "postgres",
console.log("error in createTemplateDb_") name: "templateConnection",
console.log(err) url: `${DB_URL}/${this.templateDbName}`,
} migrations: enabledMigrations,
})
await templateDbConnection.runMigrations()
await templateDbConnection.close()
return connection
} }
async getMasterConnection() { async getMasterConnection() {
@@ -27,19 +27,14 @@ describe("medusa-plugin-sendgrid", () => {
beforeAll(async () => { beforeAll(async () => {
const cwd = path.resolve(path.join(__dirname, "..", "..")) const cwd = path.resolve(path.join(__dirname, "..", ".."))
try { dbConnection = await initDb({ cwd })
dbConnection = await initDb({ cwd }) const { container, app, port } = await bootstrapApp({ cwd })
const { container, app, port } = await bootstrapApp({ cwd }) appContainer = container
appContainer = container
setPort(port) setPort(port)
express = app.listen(port, (err) => { express = app.listen(port, (err) => {
process.send(port) process.send(port)
}) })
} catch (error) {
console.log(error)
throw error
}
}) })
afterAll(async () => { afterAll(async () => {
+4 -4
View File
@@ -64,10 +64,10 @@
"jest": "jest", "jest": "jest",
"test": "turbo run test", "test": "turbo run test",
"prettier": "prettier", "prettier": "prettier",
"test:integration": "NODE_ENV=test jest --runInBand --config=integration-tests/jest.config.js", "test:integration": "NODE_ENV=test jest --runInBand --bail --config=integration-tests/jest.config.js",
"test:integration:api": "NODE_ENV=test jest --runInBand --config=integration-tests/jest.config.js --projects=integration-tests/api", "test:integration:api": "NODE_ENV=test jest --runInBand --bail --config=integration-tests/jest.config.js --projects=integration-tests/api",
"test:integration:plugins": "NODE_ENV=test jest --runInBand --config=integration-tests/jest.config.js --projects=integration-tests/plugins", "test:integration:plugins": "NODE_ENV=test jest --runInBand --bail --config=integration-tests/jest.config.js --projects=integration-tests/plugins",
"test:fixtures": "NODE_ENV=test jest --config=docs-util/jest.config.js --runInBand", "test:fixtures": "NODE_ENV=test jest --config=docs-util/jest.config.js --runInBand --bail",
"openapi:generate": "node ./scripts/build-openapi.js", "openapi:generate": "node ./scripts/build-openapi.js",
"generate:services": "typedoc --options typedoc.services.js", "generate:services": "typedoc --options typedoc.services.js",
"generate:js-client": "typedoc --options typedoc.js-client.js", "generate:js-client": "typedoc --options typedoc.js-client.js",