committed by
GitHub
parent
4692f54b49
commit
80fe362f33
@@ -1,19 +1,20 @@
|
||||
import { MoneyAmount, PriceList, Region } from "@medusajs/medusa"
|
||||
import {
|
||||
MoneyAmount,
|
||||
PriceList,
|
||||
ProductVariantMoneyAmount,
|
||||
Region,
|
||||
} from "@medusajs/medusa"
|
||||
import path from "path"
|
||||
|
||||
import { ProductVariantMoneyAmount } from "@medusajs/medusa"
|
||||
import { bootstrapApp } from "../../../../environment-helpers/bootstrap-app"
|
||||
import setupServer from "../../../../environment-helpers/setup-server"
|
||||
import { setPort, useApi } from "../../../../environment-helpers/use-api"
|
||||
import { startBootstrapApp } from "../../../../environment-helpers/bootstrap-app"
|
||||
import { useApi } from "../../../../environment-helpers/use-api"
|
||||
import { initDb, useDb } from "../../../../environment-helpers/use-db"
|
||||
import { simpleProductFactory } from "../../../../factories"
|
||||
|
||||
jest.setTimeout(30000)
|
||||
|
||||
describe("/store/carts", () => {
|
||||
let medusaProcess
|
||||
let dbConnection
|
||||
let express
|
||||
let shutdownServer
|
||||
|
||||
const doAfterEach = async () => {
|
||||
const db = useDb()
|
||||
@@ -23,18 +24,13 @@ describe("/store/carts", () => {
|
||||
beforeAll(async () => {
|
||||
const cwd = path.resolve(path.join(__dirname, "..", "..", ".."))
|
||||
dbConnection = await initDb({ cwd })
|
||||
medusaProcess = await setupServer({ cwd })
|
||||
const { app, port } = await bootstrapApp({ cwd })
|
||||
setPort(port)
|
||||
express = app.listen(port, () => {
|
||||
process.send?.(port)
|
||||
})
|
||||
shutdownServer = await startBootstrapApp({ cwd })
|
||||
})
|
||||
|
||||
afterAll(async () => {
|
||||
const db = useDb()
|
||||
await db.shutdown()
|
||||
medusaProcess.kill()
|
||||
await shutdownServer()
|
||||
})
|
||||
|
||||
describe("POST /store/carts", () => {
|
||||
|
||||
@@ -1,22 +1,28 @@
|
||||
const path = require("path")
|
||||
|
||||
const {
|
||||
bootstrapApp,
|
||||
startBootstrapApp,
|
||||
} = require("../../../../environment-helpers/bootstrap-app")
|
||||
const { initDb, useDb } = require("../../../../environment-helpers/use-db")
|
||||
const { setPort, useApi } = require("../../../../environment-helpers/use-api")
|
||||
const {
|
||||
useApi,
|
||||
useExpressServer,
|
||||
} = require("../../../../environment-helpers/use-api")
|
||||
|
||||
const adminSeeder = require("../../../../helpers/admin-seeder")
|
||||
const cartSeeder = require("../../../../helpers/cart-seeder")
|
||||
const { simpleProductFactory } = require("../../../../factories")
|
||||
const { simpleSalesChannelFactory } = require("../../../../factories")
|
||||
const {
|
||||
getContainer,
|
||||
} = require("../../../../environment-helpers/use-container")
|
||||
|
||||
jest.setTimeout(30000)
|
||||
|
||||
const adminHeaders = { headers: { "x-medusa-access-token": "test_token" } }
|
||||
|
||||
describe("/store/carts", () => {
|
||||
let express
|
||||
let shutdownServer
|
||||
let appContainer
|
||||
let dbConnection
|
||||
|
||||
@@ -32,19 +38,14 @@ describe("/store/carts", () => {
|
||||
beforeAll(async () => {
|
||||
const cwd = path.resolve(path.join(__dirname, "..", "..", ".."))
|
||||
dbConnection = await initDb({ cwd })
|
||||
const { container, app, port } = await bootstrapApp({ cwd })
|
||||
appContainer = container
|
||||
|
||||
setPort(port)
|
||||
express = app.listen(port, (err) => {
|
||||
process.send(port)
|
||||
})
|
||||
shutdownServer = await startBootstrapApp({ cwd })
|
||||
appContainer = getContainer()
|
||||
})
|
||||
|
||||
afterAll(async () => {
|
||||
const db = useDb()
|
||||
await db.shutdown()
|
||||
express.close()
|
||||
await shutdownServer()
|
||||
})
|
||||
|
||||
afterEach(async () => {
|
||||
|
||||
@@ -2,51 +2,37 @@ const path = require("path")
|
||||
const { ProductVariantInventoryService } = require("@medusajs/medusa")
|
||||
|
||||
const {
|
||||
bootstrapApp,
|
||||
startBootstrapApp,
|
||||
} = require("../../../../environment-helpers/bootstrap-app")
|
||||
const { initDb, useDb } = require("../../../../environment-helpers/use-db")
|
||||
const { setPort, useApi } = require("../../../../environment-helpers/use-api")
|
||||
const {
|
||||
useApi,
|
||||
useExpressServer,
|
||||
} = require("../../../../environment-helpers/use-api")
|
||||
|
||||
const adminSeeder = require("../../../../helpers/admin-seeder")
|
||||
|
||||
jest.setTimeout(30000)
|
||||
|
||||
const {
|
||||
simpleProductFactory,
|
||||
simpleOrderFactory,
|
||||
} = require("../../../../factories")
|
||||
getContainer,
|
||||
} = require("../../../../environment-helpers/use-container")
|
||||
const adminHeaders = { headers: { "x-medusa-access-token": "test_token" } }
|
||||
|
||||
describe("Inventory Items endpoints", () => {
|
||||
let appContainer
|
||||
let dbConnection
|
||||
let express
|
||||
|
||||
let variantId
|
||||
let inventoryItems
|
||||
let locationId
|
||||
let location2Id
|
||||
let location3Id
|
||||
let shutdownServer
|
||||
|
||||
beforeAll(async () => {
|
||||
const cwd = path.resolve(path.join(__dirname, "..", "..", ".."))
|
||||
dbConnection = await initDb({ cwd })
|
||||
|
||||
const { container, app, port } = await bootstrapApp({ cwd })
|
||||
appContainer = container
|
||||
shutdownServer = await startBootstrapApp({ cwd })
|
||||
appContainer = getContainer()
|
||||
|
||||
// Set feature flag
|
||||
const flagRouter = appContainer.resolve("featureFlagRouter")
|
||||
flagRouter.setFlag("many_to_many_inventory", true)
|
||||
|
||||
setPort(port)
|
||||
express = app.listen(port, (err) => {
|
||||
process.send(port)
|
||||
})
|
||||
})
|
||||
|
||||
beforeEach(async () => {
|
||||
await adminSeeder(dbConnection)
|
||||
})
|
||||
|
||||
afterAll(async () => {
|
||||
@@ -55,7 +41,11 @@ describe("Inventory Items endpoints", () => {
|
||||
|
||||
const db = useDb()
|
||||
await db.shutdown()
|
||||
express.close()
|
||||
await shutdownServer()
|
||||
})
|
||||
|
||||
beforeEach(async () => {
|
||||
await adminSeeder(dbConnection)
|
||||
})
|
||||
|
||||
afterEach(async () => {
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
const path = require("path")
|
||||
|
||||
const {
|
||||
bootstrapApp,
|
||||
startBootstrapApp,
|
||||
} = require("../../../../environment-helpers/bootstrap-app")
|
||||
const { initDb, useDb } = require("../../../../environment-helpers/use-db")
|
||||
const { setPort, useApi } = require("../../../../environment-helpers/use-api")
|
||||
const {
|
||||
useApi,
|
||||
useExpressServer,
|
||||
} = require("../../../../environment-helpers/use-api")
|
||||
|
||||
const adminSeeder = require("../../../../helpers/admin-seeder")
|
||||
|
||||
@@ -14,12 +17,15 @@ const {
|
||||
simpleProductFactory,
|
||||
simpleOrderFactory,
|
||||
} = require("../../../../factories")
|
||||
const {
|
||||
getContainer,
|
||||
} = require("../../../../environment-helpers/use-container")
|
||||
const adminHeaders = { headers: { "x-medusa-access-token": "test_token" } }
|
||||
|
||||
describe("Inventory Items endpoints", () => {
|
||||
let appContainer
|
||||
let dbConnection
|
||||
let express
|
||||
let shutdownServer
|
||||
|
||||
let variantId
|
||||
let inventoryItems
|
||||
@@ -30,13 +36,14 @@ describe("Inventory Items endpoints", () => {
|
||||
beforeAll(async () => {
|
||||
const cwd = path.resolve(path.join(__dirname, "..", "..", ".."))
|
||||
dbConnection = await initDb({ cwd })
|
||||
const { container, app, port } = await bootstrapApp({ cwd })
|
||||
appContainer = container
|
||||
shutdownServer = await startBootstrapApp({ cwd })
|
||||
appContainer = getContainer()
|
||||
})
|
||||
|
||||
setPort(port)
|
||||
express = app.listen(port, (err) => {
|
||||
process.send(port)
|
||||
})
|
||||
afterAll(async () => {
|
||||
const db = useDb()
|
||||
await db.shutdown()
|
||||
await shutdownServer()
|
||||
})
|
||||
|
||||
beforeEach(async () => {
|
||||
@@ -122,7 +129,7 @@ describe("Inventory Items endpoints", () => {
|
||||
afterAll(async () => {
|
||||
const db = useDb()
|
||||
await db.shutdown()
|
||||
express.close()
|
||||
await shutdownServer()
|
||||
})
|
||||
|
||||
afterEach(async () => {
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
const path = require("path")
|
||||
|
||||
const {
|
||||
bootstrapApp,
|
||||
startBootstrapApp,
|
||||
} = require("../../../../environment-helpers/bootstrap-app")
|
||||
const { initDb, useDb } = require("../../../../environment-helpers/use-db")
|
||||
const { setPort, useApi } = require("../../../../environment-helpers/use-api")
|
||||
const {
|
||||
useApi,
|
||||
useExpressServer,
|
||||
} = require("../../../../environment-helpers/use-api")
|
||||
|
||||
const adminSeeder = require("../../../../helpers/admin-seeder")
|
||||
const {
|
||||
@@ -18,31 +21,30 @@ const {
|
||||
const {
|
||||
simpleAddressFactory,
|
||||
} = require("../../../../factories/simple-address-factory")
|
||||
const {
|
||||
getContainer,
|
||||
} = require("../../../../environment-helpers/use-container")
|
||||
|
||||
jest.setTimeout(30000)
|
||||
|
||||
const adminHeaders = { headers: { "x-medusa-access-token": "test_token" } }
|
||||
|
||||
describe("/store/carts", () => {
|
||||
let express
|
||||
let shutdownServer
|
||||
let appContainer
|
||||
let dbConnection
|
||||
|
||||
const doAfterEach = async () => {
|
||||
const db = useDb()
|
||||
return await db.teardown()
|
||||
}
|
||||
|
||||
beforeAll(async () => {
|
||||
const cwd = path.resolve(path.join(__dirname, "..", "..", ".."))
|
||||
dbConnection = await initDb({ cwd })
|
||||
const { container, app, port } = await bootstrapApp({ cwd })
|
||||
appContainer = container
|
||||
shutdownServer = await startBootstrapApp({ cwd })
|
||||
appContainer = getContainer()
|
||||
})
|
||||
|
||||
setPort(port)
|
||||
express = app.listen(port, (err) => {
|
||||
process.send(port)
|
||||
})
|
||||
afterAll(async () => {
|
||||
const db = useDb()
|
||||
await db.shutdown()
|
||||
await shutdownServer()
|
||||
})
|
||||
|
||||
beforeEach(async () => {})
|
||||
@@ -51,7 +53,6 @@ describe("/store/carts", () => {
|
||||
const variantId = "test-variant"
|
||||
|
||||
let region
|
||||
let order
|
||||
let invItemId
|
||||
let prodVarInventoryService
|
||||
let inventoryService
|
||||
|
||||
@@ -1,10 +1,14 @@
|
||||
const path = require("path")
|
||||
|
||||
const {
|
||||
bootstrapApp,
|
||||
startBootstrapApp,
|
||||
} = require("../../../../environment-helpers/bootstrap-app")
|
||||
const { initDb, useDb } = require("../../../../environment-helpers/use-db")
|
||||
const { setPort, useApi } = require("../../../../environment-helpers/use-api")
|
||||
const {
|
||||
setPort,
|
||||
useApi,
|
||||
useExpressServer,
|
||||
} = require("../../../../environment-helpers/use-api")
|
||||
|
||||
const adminSeeder = require("../../../../helpers/admin-seeder")
|
||||
const {
|
||||
@@ -17,32 +21,30 @@ const {
|
||||
simpleCartFactory,
|
||||
simpleShippingOptionFactory,
|
||||
} = require("../../../../factories")
|
||||
const {
|
||||
getContainer,
|
||||
} = require("../../../../environment-helpers/use-container")
|
||||
|
||||
jest.setTimeout(150000)
|
||||
|
||||
const adminHeaders = { headers: { "x-medusa-access-token": "test_token" } }
|
||||
|
||||
describe("/store/carts", () => {
|
||||
let express
|
||||
let shutdownServer
|
||||
let appContainer
|
||||
let dbConnection
|
||||
|
||||
beforeAll(async () => {
|
||||
const cwd = path.resolve(path.join(__dirname, "..", "..", ".."))
|
||||
dbConnection = await initDb({ cwd })
|
||||
const { container, app, port } = await bootstrapApp({ cwd })
|
||||
appContainer = container
|
||||
|
||||
setPort(port)
|
||||
express = app.listen(port, (err) => {
|
||||
process.send(port)
|
||||
})
|
||||
shutdownServer = await startBootstrapApp({ cwd })
|
||||
appContainer = getContainer()
|
||||
})
|
||||
|
||||
afterAll(async () => {
|
||||
const db = useDb()
|
||||
await db.shutdown()
|
||||
express.close()
|
||||
await shutdownServer()
|
||||
})
|
||||
|
||||
afterEach(async () => {
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
const path = require("path")
|
||||
|
||||
const {
|
||||
bootstrapApp,
|
||||
startBootstrapApp,
|
||||
} = require("../../../../environment-helpers/bootstrap-app")
|
||||
const { initDb, useDb } = require("../../../../environment-helpers/use-db")
|
||||
const { setPort, useApi } = require("../../../../environment-helpers/use-api")
|
||||
const {
|
||||
useApi,
|
||||
useExpressServer,
|
||||
} = require("../../../../environment-helpers/use-api")
|
||||
|
||||
const {
|
||||
ProductVariantInventoryService,
|
||||
@@ -16,28 +19,26 @@ const adminSeeder = require("../../../../helpers/admin-seeder")
|
||||
jest.setTimeout(30000)
|
||||
|
||||
const { simpleProductFactory } = require("../../../../factories")
|
||||
const {
|
||||
getContainer,
|
||||
} = require("../../../../environment-helpers/use-container")
|
||||
|
||||
describe("Create Variant", () => {
|
||||
let appContainer
|
||||
let dbConnection
|
||||
let express
|
||||
let shutdownServer
|
||||
|
||||
beforeAll(async () => {
|
||||
const cwd = path.resolve(path.join(__dirname, "..", "..", ".."))
|
||||
dbConnection = await initDb({ cwd })
|
||||
const { container, app, port } = await bootstrapApp({ cwd })
|
||||
appContainer = container
|
||||
|
||||
setPort(port)
|
||||
express = app.listen(port, (err) => {
|
||||
process.send(port)
|
||||
})
|
||||
shutdownServer = await startBootstrapApp({ cwd })
|
||||
appContainer = getContainer()
|
||||
})
|
||||
|
||||
afterAll(async () => {
|
||||
const db = useDb()
|
||||
await db.shutdown()
|
||||
express.close()
|
||||
await shutdownServer()
|
||||
})
|
||||
|
||||
afterEach(async () => {
|
||||
|
||||
@@ -1,38 +1,39 @@
|
||||
const path = require("path")
|
||||
|
||||
const {
|
||||
bootstrapApp,
|
||||
startBootstrapApp,
|
||||
} = require("../../../../environment-helpers/bootstrap-app")
|
||||
const { initDb, useDb } = require("../../../../environment-helpers/use-db")
|
||||
const { setPort, useApi } = require("../../../../environment-helpers/use-api")
|
||||
const {
|
||||
useApi,
|
||||
useExpressServer,
|
||||
} = require("../../../../environment-helpers/use-api")
|
||||
|
||||
const adminSeeder = require("../../../../helpers/admin-seeder")
|
||||
|
||||
jest.setTimeout(30000)
|
||||
|
||||
const { simpleProductFactory } = require("../../../../factories")
|
||||
const {
|
||||
getContainer,
|
||||
} = require("../../../../environment-helpers/use-container")
|
||||
|
||||
describe("Delete Variant", () => {
|
||||
let appContainer
|
||||
let dbConnection
|
||||
let express
|
||||
let shutdownServer
|
||||
|
||||
beforeAll(async () => {
|
||||
const cwd = path.resolve(path.join(__dirname, "..", "..", ".."))
|
||||
dbConnection = await initDb({ cwd })
|
||||
const { container, app, port } = await bootstrapApp({ cwd })
|
||||
appContainer = container
|
||||
|
||||
setPort(port)
|
||||
express = app.listen(port, (err) => {
|
||||
process.send(port)
|
||||
})
|
||||
shutdownServer = await startBootstrapApp({ cwd })
|
||||
appContainer = getContainer()
|
||||
})
|
||||
|
||||
afterAll(async () => {
|
||||
const db = useDb()
|
||||
await db.shutdown()
|
||||
express.close()
|
||||
await shutdownServer()
|
||||
})
|
||||
|
||||
afterEach(async () => {
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
const path = require("path")
|
||||
|
||||
const {
|
||||
bootstrapApp,
|
||||
startBootstrapApp,
|
||||
} = require("../../../../environment-helpers/bootstrap-app")
|
||||
const { initDb, useDb } = require("../../../../environment-helpers/use-db")
|
||||
const { setPort, useApi } = require("../../../../environment-helpers/use-api")
|
||||
const {
|
||||
useApi,
|
||||
useExpressServer,
|
||||
} = require("../../../../environment-helpers/use-api")
|
||||
|
||||
const adminSeeder = require("../../../../helpers/admin-seeder")
|
||||
|
||||
@@ -14,13 +17,16 @@ const {
|
||||
simpleProductFactory,
|
||||
simpleSalesChannelFactory,
|
||||
} = require("../../../../factories")
|
||||
const {
|
||||
getContainer,
|
||||
} = require("../../../../environment-helpers/use-container")
|
||||
|
||||
const adminHeaders = { headers: { "x-medusa-access-token": "test_token" } }
|
||||
|
||||
describe("Get products", () => {
|
||||
let appContainer
|
||||
let dbConnection
|
||||
let express
|
||||
let shutdownServer
|
||||
const productId = "test-product"
|
||||
const variantId = "test-variant"
|
||||
let invItem
|
||||
@@ -28,19 +34,14 @@ describe("Get products", () => {
|
||||
beforeAll(async () => {
|
||||
const cwd = path.resolve(path.join(__dirname, "..", "..", ".."))
|
||||
dbConnection = await initDb({ cwd })
|
||||
const { container, app, port } = await bootstrapApp({ cwd })
|
||||
appContainer = container
|
||||
|
||||
setPort(port)
|
||||
express = app.listen(port, (err) => {
|
||||
process.send(port)
|
||||
})
|
||||
shutdownServer = await startBootstrapApp({ cwd })
|
||||
appContainer = getContainer()
|
||||
})
|
||||
|
||||
afterAll(async () => {
|
||||
const db = useDb()
|
||||
await db.shutdown()
|
||||
express.close()
|
||||
await shutdownServer()
|
||||
})
|
||||
|
||||
afterEach(async () => {
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
const path = require("path")
|
||||
|
||||
const {
|
||||
bootstrapApp,
|
||||
startBootstrapApp,
|
||||
} = require("../../../../environment-helpers/bootstrap-app")
|
||||
const { initDb, useDb } = require("../../../../environment-helpers/use-db")
|
||||
const { setPort, useApi } = require("../../../../environment-helpers/use-api")
|
||||
const {
|
||||
useApi,
|
||||
useExpressServer,
|
||||
} = require("../../../../environment-helpers/use-api")
|
||||
|
||||
const adminSeeder = require("../../../../helpers/admin-seeder")
|
||||
|
||||
@@ -14,13 +17,16 @@ const {
|
||||
simpleProductFactory,
|
||||
simpleSalesChannelFactory,
|
||||
} = require("../../../../factories")
|
||||
const {
|
||||
getContainer,
|
||||
} = require("../../../../environment-helpers/use-container")
|
||||
|
||||
const adminHeaders = { headers: { "x-medusa-access-token": "test_token" } }
|
||||
|
||||
describe("Get variant", () => {
|
||||
let appContainer
|
||||
let dbConnection
|
||||
let express
|
||||
let shutdownServer
|
||||
const productId = "test-product"
|
||||
const variantId = "test-variant"
|
||||
let invItem
|
||||
@@ -32,19 +38,14 @@ describe("Get variant", () => {
|
||||
beforeAll(async () => {
|
||||
const cwd = path.resolve(path.join(__dirname, "..", "..", ".."))
|
||||
dbConnection = await initDb({ cwd })
|
||||
const { container, app, port } = await bootstrapApp({ cwd })
|
||||
appContainer = container
|
||||
|
||||
setPort(port)
|
||||
express = app.listen(port, (err) => {
|
||||
process.send(port)
|
||||
})
|
||||
shutdownServer = await startBootstrapApp({ cwd })
|
||||
appContainer = getContainer()
|
||||
})
|
||||
|
||||
afterAll(async () => {
|
||||
const db = useDb()
|
||||
await db.shutdown()
|
||||
express.close()
|
||||
await shutdownServer()
|
||||
})
|
||||
|
||||
afterEach(async () => {
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
const path = require("path")
|
||||
|
||||
const {
|
||||
bootstrapApp,
|
||||
startBootstrapApp,
|
||||
} = require("../../../../environment-helpers/bootstrap-app")
|
||||
const { initDb, useDb } = require("../../../../environment-helpers/use-db")
|
||||
const { setPort, useApi } = require("../../../../environment-helpers/use-api")
|
||||
const {
|
||||
useApi,
|
||||
useExpressServer,
|
||||
} = require("../../../../environment-helpers/use-api")
|
||||
|
||||
const adminSeeder = require("../../../../helpers/admin-seeder")
|
||||
|
||||
@@ -12,30 +15,28 @@ jest.setTimeout(30000)
|
||||
|
||||
const { simpleProductFactory } = require("../../../../factories")
|
||||
const { simpleSalesChannelFactory } = require("../../../../factories")
|
||||
const {
|
||||
getContainer,
|
||||
} = require("../../../../environment-helpers/use-container")
|
||||
|
||||
const adminHeaders = { headers: { "x-medusa-access-token": "test_token" } }
|
||||
|
||||
describe("Create Variant", () => {
|
||||
let appContainer
|
||||
let dbConnection
|
||||
let express
|
||||
let shutdownServer
|
||||
|
||||
beforeAll(async () => {
|
||||
const cwd = path.resolve(path.join(__dirname, "..", "..", ".."))
|
||||
dbConnection = await initDb({ cwd })
|
||||
const { container, app, port } = await bootstrapApp({ cwd })
|
||||
appContainer = container
|
||||
|
||||
setPort(port)
|
||||
express = app.listen(port, (err) => {
|
||||
process.send(port)
|
||||
})
|
||||
shutdownServer = await startBootstrapApp({ cwd })
|
||||
appContainer = getContainer()
|
||||
})
|
||||
|
||||
afterAll(async () => {
|
||||
const db = useDb()
|
||||
await db.shutdown()
|
||||
express.close()
|
||||
await shutdownServer()
|
||||
})
|
||||
|
||||
afterEach(async () => {
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
const path = require("path")
|
||||
|
||||
const {
|
||||
bootstrapApp,
|
||||
startBootstrapApp,
|
||||
} = require("../../../../environment-helpers/bootstrap-app")
|
||||
const { initDb, useDb } = require("../../../../environment-helpers/use-db")
|
||||
const { setPort, useApi } = require("../../../../environment-helpers/use-api")
|
||||
const {
|
||||
useApi,
|
||||
useExpressServer,
|
||||
} = require("../../../../environment-helpers/use-api")
|
||||
|
||||
const adminSeeder = require("../../../../helpers/admin-seeder")
|
||||
|
||||
@@ -12,29 +15,27 @@ jest.setTimeout(30000)
|
||||
|
||||
const { simpleProductFactory } = require("../../../../factories")
|
||||
const { simpleSalesChannelFactory } = require("../../../../factories")
|
||||
const {
|
||||
getContainer,
|
||||
} = require("../../../../environment-helpers/use-container")
|
||||
const adminHeaders = { headers: { "x-medusa-access-token": "test_token" } }
|
||||
|
||||
describe("List Variants", () => {
|
||||
let appContainer
|
||||
let dbConnection
|
||||
let express
|
||||
let shutdownServer
|
||||
|
||||
beforeAll(async () => {
|
||||
const cwd = path.resolve(path.join(__dirname, "..", "..", ".."))
|
||||
dbConnection = await initDb({ cwd })
|
||||
const { container, app, port } = await bootstrapApp({ cwd })
|
||||
appContainer = container
|
||||
|
||||
setPort(port)
|
||||
express = app.listen(port, (err) => {
|
||||
process.send(port)
|
||||
})
|
||||
shutdownServer = await startBootstrapApp({ cwd })
|
||||
appContainer = getContainer()
|
||||
})
|
||||
|
||||
afterAll(async () => {
|
||||
const db = useDb()
|
||||
await db.shutdown()
|
||||
express.close()
|
||||
await shutdownServer()
|
||||
})
|
||||
|
||||
afterEach(async () => {
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
const path = require("path")
|
||||
|
||||
const {
|
||||
bootstrapApp,
|
||||
startBootstrapApp,
|
||||
} = require("../../../../environment-helpers/bootstrap-app")
|
||||
const { initDb, useDb } = require("../../../../environment-helpers/use-db")
|
||||
const { setPort, useApi } = require("../../../../environment-helpers/use-api")
|
||||
const {
|
||||
useApi,
|
||||
useExpressServer,
|
||||
} = require("../../../../environment-helpers/use-api")
|
||||
|
||||
const adminSeeder = require("../../../../helpers/admin-seeder")
|
||||
|
||||
@@ -16,12 +19,15 @@ const {
|
||||
simpleRegionFactory,
|
||||
} = require("../../../../factories")
|
||||
const { simpleSalesChannelFactory } = require("../../../../factories")
|
||||
const {
|
||||
getContainer,
|
||||
} = require("../../../../environment-helpers/use-container")
|
||||
const adminHeaders = { headers: { "x-medusa-access-token": "test_token" } }
|
||||
|
||||
describe("Inventory Items endpoints", () => {
|
||||
let appContainer
|
||||
let dbConnection
|
||||
let express
|
||||
let shutdownServer
|
||||
|
||||
let inventoryItem
|
||||
let locationId
|
||||
@@ -41,13 +47,14 @@ describe("Inventory Items endpoints", () => {
|
||||
beforeAll(async () => {
|
||||
const cwd = path.resolve(path.join(__dirname, "..", "..", ".."))
|
||||
dbConnection = await initDb({ cwd })
|
||||
const { container, app, port } = await bootstrapApp({ cwd })
|
||||
appContainer = container
|
||||
shutdownServer = await startBootstrapApp({ cwd })
|
||||
appContainer = getContainer()
|
||||
})
|
||||
|
||||
setPort(port)
|
||||
express = app.listen(port, (err) => {
|
||||
process.send(port)
|
||||
})
|
||||
afterAll(async () => {
|
||||
const db = useDb()
|
||||
await db.shutdown()
|
||||
await shutdownServer()
|
||||
})
|
||||
|
||||
beforeEach(async () => {
|
||||
@@ -138,12 +145,6 @@ describe("Inventory Items endpoints", () => {
|
||||
})
|
||||
})
|
||||
|
||||
afterAll(async () => {
|
||||
const db = useDb()
|
||||
await db.shutdown()
|
||||
express.close()
|
||||
})
|
||||
|
||||
afterEach(async () => {
|
||||
jest.clearAllMocks()
|
||||
const db = useDb()
|
||||
|
||||
@@ -1,30 +1,30 @@
|
||||
const path = require("path")
|
||||
|
||||
const { bootstrapApp } = require("../../../environment-helpers/bootstrap-app")
|
||||
const {
|
||||
startBootstrapApp,
|
||||
} = require("../../../environment-helpers/bootstrap-app")
|
||||
const { initDb, useDb } = require("../../../environment-helpers/use-db")
|
||||
const { getContainer } = require("../../../environment-helpers/use-container")
|
||||
const { useExpressServer } = require("../../../environment-helpers/use-api")
|
||||
|
||||
jest.setTimeout(50000)
|
||||
|
||||
describe("Inventory Module", () => {
|
||||
let shutdownServer
|
||||
let appContainer
|
||||
let dbConnection
|
||||
let express
|
||||
|
||||
beforeAll(async () => {
|
||||
const cwd = path.resolve(path.join(__dirname, "..", ".."))
|
||||
dbConnection = await initDb({ cwd })
|
||||
const { container, app, port } = await bootstrapApp({ cwd })
|
||||
appContainer = container
|
||||
|
||||
express = app.listen(port, (err) => {
|
||||
process.send(port)
|
||||
})
|
||||
shutdownServer = await startBootstrapApp({ cwd })
|
||||
appContainer = getContainer()
|
||||
})
|
||||
|
||||
afterAll(async () => {
|
||||
const db = useDb()
|
||||
await db.shutdown()
|
||||
express.close()
|
||||
await shutdownServer()
|
||||
})
|
||||
|
||||
afterEach(async () => {
|
||||
|
||||
@@ -1,15 +1,19 @@
|
||||
const path = require("path")
|
||||
|
||||
const { bootstrapApp } = require("../../../environment-helpers/bootstrap-app")
|
||||
const {
|
||||
startBootstrapApp,
|
||||
} = require("../../../environment-helpers/bootstrap-app")
|
||||
const { initDb, useDb } = require("../../../environment-helpers/use-db")
|
||||
const { simpleProductFactory } = require("../../../factories")
|
||||
const { getContainer } = require("../../../environment-helpers/use-container")
|
||||
const { useExpressServer } = require("../../../environment-helpers/use-api")
|
||||
|
||||
jest.setTimeout(50000)
|
||||
|
||||
describe("Inventory Module", () => {
|
||||
let appContainer
|
||||
let dbConnection
|
||||
let express
|
||||
let shutdownServer
|
||||
|
||||
let invItem1
|
||||
let invItem2
|
||||
@@ -19,18 +23,14 @@ describe("Inventory Module", () => {
|
||||
beforeAll(async () => {
|
||||
const cwd = path.resolve(path.join(__dirname, "..", ".."))
|
||||
dbConnection = await initDb({ cwd })
|
||||
const { container, app, port } = await bootstrapApp({ cwd, verbose: false })
|
||||
appContainer = container
|
||||
|
||||
express = app.listen(port, (err) => {
|
||||
process.send(port)
|
||||
})
|
||||
shutdownServer = await startBootstrapApp({ cwd })
|
||||
appContainer = getContainer()
|
||||
})
|
||||
|
||||
afterAll(async () => {
|
||||
const db = useDb()
|
||||
await db.shutdown()
|
||||
express.close()
|
||||
await shutdownServer()
|
||||
})
|
||||
|
||||
describe("ProductVariantInventoryService", () => {
|
||||
|
||||
@@ -1,8 +1,13 @@
|
||||
const path = require("path")
|
||||
|
||||
const { bootstrapApp } = require("../../../environment-helpers/bootstrap-app")
|
||||
const {
|
||||
startBootstrapApp,
|
||||
} = require("../../../environment-helpers/bootstrap-app")
|
||||
const { initDb, useDb } = require("../../../environment-helpers/use-db")
|
||||
const { setPort, useApi } = require("../../../environment-helpers/use-api")
|
||||
const {
|
||||
useApi,
|
||||
useExpressServer,
|
||||
} = require("../../../environment-helpers/use-api")
|
||||
|
||||
const adminSeeder = require("../../../helpers/admin-seeder")
|
||||
|
||||
@@ -14,11 +19,12 @@ const {
|
||||
simpleProductFactory,
|
||||
simpleShippingOptionFactory,
|
||||
} = require("../../../factories")
|
||||
const { getContainer } = require("../../../environment-helpers/use-container")
|
||||
|
||||
describe("medusa-plugin-sendgrid", () => {
|
||||
let appContainer
|
||||
let dbConnection
|
||||
let express
|
||||
let shutdownServer
|
||||
|
||||
const doAfterEach = async () => {
|
||||
const db = useDb()
|
||||
@@ -28,19 +34,14 @@ describe("medusa-plugin-sendgrid", () => {
|
||||
beforeAll(async () => {
|
||||
const cwd = path.resolve(path.join(__dirname, "..", ".."))
|
||||
dbConnection = await initDb({ cwd })
|
||||
const { container, app, port } = await bootstrapApp({ cwd })
|
||||
appContainer = container
|
||||
|
||||
setPort(port)
|
||||
express = app.listen(port, (err) => {
|
||||
process.send(port)
|
||||
})
|
||||
shutdownServer = await startBootstrapApp({ cwd })
|
||||
appContainer = getContainer()
|
||||
})
|
||||
|
||||
afterAll(async () => {
|
||||
const db = useDb()
|
||||
await db.shutdown()
|
||||
express.close()
|
||||
await shutdownServer()
|
||||
})
|
||||
|
||||
afterEach(async () => {
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
import { setPort, useApi } from "../../../environment-helpers/use-api"
|
||||
import { useApi } from "../../../environment-helpers/use-api"
|
||||
import { initDb, useDb } from "../../../environment-helpers/use-db"
|
||||
import { simpleCartFactory, simpleRegionFactory } from "../../../factories"
|
||||
|
||||
import { ModuleRegistrationName } from "@medusajs/modules-sdk"
|
||||
import { AxiosInstance } from "axios"
|
||||
import path from "path"
|
||||
import { bootstrapApp } from "../../../environment-helpers/bootstrap-app"
|
||||
import { startBootstrapApp } from "../../../environment-helpers/bootstrap-app"
|
||||
import { getContainer } from "../../../environment-helpers/use-container"
|
||||
import adminSeeder from "../../../helpers/admin-seeder"
|
||||
|
||||
jest.setTimeout(5000000)
|
||||
@@ -30,24 +31,19 @@ const env = {
|
||||
describe("Link Modules", () => {
|
||||
let medusaContainer
|
||||
let dbConnection
|
||||
let express
|
||||
let shutdownServer
|
||||
|
||||
beforeAll(async () => {
|
||||
const cwd = path.resolve(path.join(__dirname, "..", ".."))
|
||||
dbConnection = await initDb({ cwd, env } as any)
|
||||
|
||||
const { container, app, port } = await bootstrapApp({ cwd, env })
|
||||
medusaContainer = container
|
||||
setPort(port)
|
||||
|
||||
express = app.listen(port)
|
||||
shutdownServer = await startBootstrapApp({ cwd, env })
|
||||
medusaContainer = getContainer()
|
||||
})
|
||||
|
||||
afterAll(async () => {
|
||||
const db = useDb()
|
||||
await db.shutdown()
|
||||
|
||||
express.close()
|
||||
await shutdownServer()
|
||||
})
|
||||
|
||||
beforeEach(async () => {
|
||||
|
||||
@@ -3,7 +3,7 @@ import { initDb, useDb } from "../../../../environment-helpers/use-db"
|
||||
import { Region } from "@medusajs/medusa"
|
||||
import { AxiosInstance } from "axios"
|
||||
import path from "path"
|
||||
import setupServer from "../../../../environment-helpers/setup-server"
|
||||
import { startBootstrapApp } from "../../../../environment-helpers/bootstrap-app"
|
||||
import { useApi } from "../../../../environment-helpers/use-api"
|
||||
import { getContainer } from "../../../../environment-helpers/use-container"
|
||||
import adminSeeder from "../../../../helpers/admin-seeder"
|
||||
@@ -25,19 +25,19 @@ const env = {
|
||||
describe.skip("[Product & Pricing Module] POST /admin/products", () => {
|
||||
let dbConnection
|
||||
let appContainer
|
||||
let medusaProcess
|
||||
let shutdownServer
|
||||
|
||||
beforeAll(async () => {
|
||||
const cwd = path.resolve(path.join(__dirname, "..", "..", ".."))
|
||||
dbConnection = await initDb({ cwd, env } as any)
|
||||
medusaProcess = await setupServer({ cwd, env, bootstrapApp: true } as any)
|
||||
shutdownServer = await startBootstrapApp({ cwd, env })
|
||||
appContainer = getContainer()
|
||||
})
|
||||
|
||||
afterAll(async () => {
|
||||
const db = useDb()
|
||||
await db.shutdown()
|
||||
medusaProcess.kill()
|
||||
await shutdownServer()
|
||||
})
|
||||
|
||||
beforeEach(async () => {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import path from "path"
|
||||
import { bootstrapApp } from "../../../../environment-helpers/bootstrap-app"
|
||||
import { setPort, useApi } from "../../../../environment-helpers/use-api"
|
||||
import { startBootstrapApp } from "../../../../environment-helpers/bootstrap-app"
|
||||
import { useApi } from "../../../../environment-helpers/use-api"
|
||||
import { initDb, useDb } from "../../../../environment-helpers/use-db"
|
||||
|
||||
import adminSeeder from "../../../../helpers/admin-seeder"
|
||||
@@ -9,6 +9,7 @@ import productSeeder from "../../../../helpers/product-seeder"
|
||||
import { Modules, ModulesDefinition } from "@medusajs/modules-sdk"
|
||||
import { Workflows } from "@medusajs/workflows"
|
||||
import { AxiosInstance } from "axios"
|
||||
import { getContainer } from "../../../../environment-helpers/use-container"
|
||||
import {
|
||||
simpleProductFactory,
|
||||
simpleSalesChannelFactory,
|
||||
@@ -24,26 +25,20 @@ const adminHeaders = {
|
||||
|
||||
describe("/admin/products", () => {
|
||||
let dbConnection
|
||||
let express
|
||||
let shutdownServer
|
||||
let medusaContainer
|
||||
|
||||
beforeAll(async () => {
|
||||
const cwd = path.resolve(path.join(__dirname, "..", "..", ".."))
|
||||
dbConnection = await initDb({ cwd } as any)
|
||||
const { app, port, container } = await bootstrapApp({ cwd })
|
||||
medusaContainer = container
|
||||
|
||||
setPort(port)
|
||||
express = app.listen(port, () => {
|
||||
process.send?.(port)
|
||||
})
|
||||
dbConnection = await initDb({ cwd })
|
||||
shutdownServer = await startBootstrapApp({ cwd })
|
||||
medusaContainer = getContainer()
|
||||
})
|
||||
|
||||
afterAll(async () => {
|
||||
const db = useDb()
|
||||
await db.shutdown()
|
||||
|
||||
express.close()
|
||||
await shutdownServer()
|
||||
})
|
||||
|
||||
it("Should have loaded the product module", function () {
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import setupServer from "../../../../environment-helpers/setup-server"
|
||||
import { useApi } from "../../../../environment-helpers/use-api"
|
||||
import { getContainer } from "../../../../environment-helpers/use-container"
|
||||
import { initDb, useDb } from "../../../../environment-helpers/use-db"
|
||||
@@ -7,11 +6,12 @@ import {
|
||||
simpleRegionFactory,
|
||||
} from "../../../../factories"
|
||||
|
||||
import { AxiosInstance } from "axios"
|
||||
import path from "path"
|
||||
import { startBootstrapApp } from "../../../../environment-helpers/bootstrap-app"
|
||||
import adminSeeder from "../../../../helpers/admin-seeder"
|
||||
import { createDefaultRuleTypes } from "../../../helpers/create-default-rule-types"
|
||||
import { createVariantPriceSet } from "../../../helpers/create-variant-price-set"
|
||||
import { AxiosInstance } from "axios"
|
||||
|
||||
jest.setTimeout(50000)
|
||||
|
||||
@@ -26,24 +26,24 @@ const env = {
|
||||
MEDUSA_FF_ISOLATE_PRODUCT_DOMAIN: true,
|
||||
}
|
||||
|
||||
describe("[Product & Pricing Module] POST /admin/products/:id/variants/:id", () => {
|
||||
describe.skip("[Product & Pricing Module] POST /admin/products/:id/variants/:id", () => {
|
||||
let dbConnection
|
||||
let appContainer
|
||||
let medusaProcess
|
||||
let shutdownServer
|
||||
let product
|
||||
let variant
|
||||
|
||||
beforeAll(async () => {
|
||||
const cwd = path.resolve(path.join(__dirname, "..", "..", ".."))
|
||||
dbConnection = await initDb({ cwd, env } as any)
|
||||
medusaProcess = await setupServer({ cwd, env, bootstrapApp: true } as any)
|
||||
shutdownServer = await startBootstrapApp({ cwd, env })
|
||||
appContainer = getContainer()
|
||||
})
|
||||
|
||||
afterAll(async () => {
|
||||
const db = useDb()
|
||||
await db.shutdown()
|
||||
medusaProcess.kill()
|
||||
await shutdownServer()
|
||||
})
|
||||
|
||||
beforeEach(async () => {
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import setupServer from "../../../../environment-helpers/setup-server"
|
||||
import { useApi } from "../../../../environment-helpers/use-api"
|
||||
import { getContainer } from "../../../../environment-helpers/use-container"
|
||||
import { initDb, useDb } from "../../../../environment-helpers/use-db"
|
||||
@@ -7,6 +6,7 @@ import { simpleProductFactory } from "../../../../factories"
|
||||
import { Region } from "@medusajs/medusa"
|
||||
import { AxiosInstance } from "axios"
|
||||
import path from "path"
|
||||
import { startBootstrapApp } from "../../../../environment-helpers/bootstrap-app"
|
||||
import adminSeeder from "../../../../helpers/admin-seeder"
|
||||
import { createDefaultRuleTypes } from "../../../helpers/create-default-rule-types"
|
||||
import { createVariantPriceSet } from "../../../helpers/create-variant-price-set"
|
||||
@@ -27,21 +27,21 @@ const env = {
|
||||
describe.skip("[Product & Pricing Module] POST /admin/products/:id", () => {
|
||||
let dbConnection
|
||||
let appContainer
|
||||
let medusaProcess
|
||||
let shutdownServer
|
||||
let product
|
||||
let variant
|
||||
|
||||
beforeAll(async () => {
|
||||
const cwd = path.resolve(path.join(__dirname, "..", "..", ".."))
|
||||
dbConnection = await initDb({ cwd, env } as any)
|
||||
medusaProcess = await setupServer({ cwd, env, bootstrapApp: true } as any)
|
||||
shutdownServer = await startBootstrapApp({ cwd, env })
|
||||
appContainer = getContainer()
|
||||
})
|
||||
|
||||
afterAll(async () => {
|
||||
const db = useDb()
|
||||
await db.shutdown()
|
||||
medusaProcess.kill()
|
||||
await shutdownServer()
|
||||
})
|
||||
|
||||
beforeEach(async () => {
|
||||
@@ -80,7 +80,7 @@ describe.skip("[Product & Pricing Module] POST /admin/products/:id", () => {
|
||||
})
|
||||
|
||||
it("should update product variant price sets and prices", async () => {
|
||||
const api = useApi()
|
||||
const api = useApi() as any
|
||||
const data = {
|
||||
title: "test product update",
|
||||
variants: [
|
||||
@@ -102,14 +102,13 @@ describe.skip("[Product & Pricing Module] POST /admin/products/:id", () => {
|
||||
],
|
||||
}
|
||||
|
||||
let response = await api.post(
|
||||
await api.post(`/admin/products/${product.id}`, data, adminHeaders)
|
||||
|
||||
const response = await api.get(
|
||||
`/admin/products/${product.id}`,
|
||||
data,
|
||||
adminHeaders
|
||||
)
|
||||
|
||||
response = await api.get(`/admin/products/${product.id}`, adminHeaders)
|
||||
|
||||
expect(response.status).toEqual(200)
|
||||
expect(response.data.product).toEqual(
|
||||
expect.objectContaining({
|
||||
@@ -150,7 +149,7 @@ describe.skip("[Product & Pricing Module] POST /admin/products/:id", () => {
|
||||
|
||||
const moneyAmountToUpdate = priceSet.money_amounts?.[0]
|
||||
|
||||
const api = useApi()
|
||||
const api = useApi() as any
|
||||
const data = {
|
||||
title: "test product update",
|
||||
variants: [
|
||||
@@ -173,14 +172,15 @@ describe.skip("[Product & Pricing Module] POST /admin/products/:id", () => {
|
||||
],
|
||||
}
|
||||
|
||||
let response = await api.post(
|
||||
console.log("I am here first")
|
||||
await api.post(`/admin/products/${product.id}`, data, adminHeaders)
|
||||
console.log("I am here")
|
||||
|
||||
const response = await api.get(
|
||||
`/admin/products/${product.id}`,
|
||||
data,
|
||||
adminHeaders
|
||||
)
|
||||
|
||||
response = await api.get(`/admin/products/${product.id}`, adminHeaders)
|
||||
|
||||
expect(response.status).toEqual(200)
|
||||
expect(response.data.product).toEqual(
|
||||
expect.objectContaining({
|
||||
@@ -248,14 +248,13 @@ describe.skip("[Product & Pricing Module] POST /admin/products/:id", () => {
|
||||
],
|
||||
}
|
||||
|
||||
let response = await api.post(
|
||||
await api.post(`/admin/products/${product.id}`, data, adminHeaders)
|
||||
|
||||
const response = await api.get(
|
||||
`/admin/products/${product.id}`,
|
||||
data,
|
||||
adminHeaders
|
||||
)
|
||||
|
||||
response = await api.get(`/admin/products/${product.id}`, adminHeaders)
|
||||
|
||||
expect(response.status).toEqual(200)
|
||||
expect(response.data.product).toEqual(
|
||||
expect.objectContaining({
|
||||
|
||||
@@ -1,35 +1,27 @@
|
||||
import path from "path"
|
||||
import { startBootstrapApp } from "../../../environment-helpers/bootstrap-app"
|
||||
import { getContainer } from "../../../environment-helpers/use-container"
|
||||
import { initDb, useDb } from "../../../environment-helpers/use-db"
|
||||
import { bootstrapApp } from "../../../environment-helpers/bootstrap-app"
|
||||
import { setPort } from "../../../environment-helpers/use-api"
|
||||
|
||||
jest.setTimeout(30000)
|
||||
|
||||
describe("product", () => {
|
||||
let dbConnection
|
||||
let medusaContainer
|
||||
let productService
|
||||
|
||||
let express
|
||||
let shutdownServer
|
||||
|
||||
beforeAll(async () => {
|
||||
const cwd = path.resolve(path.join(__dirname, "..", ".."))
|
||||
dbConnection = await initDb({ cwd } as any)
|
||||
const { container, port, app } = await bootstrapApp({ cwd })
|
||||
|
||||
setPort(port)
|
||||
express = app.listen(port, () => {
|
||||
process.send!(port)
|
||||
})
|
||||
|
||||
medusaContainer = container
|
||||
await initDb({ cwd })
|
||||
shutdownServer = shutdownServer = await startBootstrapApp({ cwd })
|
||||
medusaContainer = getContainer()
|
||||
})
|
||||
|
||||
afterAll(async () => {
|
||||
const db = useDb()
|
||||
await db.shutdown()
|
||||
|
||||
express.close()
|
||||
await shutdownServer()
|
||||
})
|
||||
|
||||
afterEach(async () => {
|
||||
|
||||
@@ -1,34 +1,35 @@
|
||||
const path = require("path")
|
||||
|
||||
const { bootstrapApp } = require("../../../environment-helpers/bootstrap-app")
|
||||
const {
|
||||
startBootstrapApp,
|
||||
} = require("../../../environment-helpers/bootstrap-app")
|
||||
const { initDb, useDb } = require("../../../environment-helpers/use-db")
|
||||
const { setPort, useApi } = require("../../../environment-helpers/use-api")
|
||||
const {
|
||||
useApi,
|
||||
useExpressServer,
|
||||
} = require("../../../environment-helpers/use-api")
|
||||
|
||||
const adminSeeder = require("../../../helpers/admin-seeder")
|
||||
const { getContainer } = require("../../../environment-helpers/use-container")
|
||||
|
||||
jest.setTimeout(30000)
|
||||
|
||||
describe("Sales channels", () => {
|
||||
let appContainer
|
||||
let dbConnection
|
||||
let express
|
||||
let shutdownServer
|
||||
|
||||
beforeAll(async () => {
|
||||
const cwd = path.resolve(path.join(__dirname, "..", ".."))
|
||||
dbConnection = await initDb({ cwd })
|
||||
const { container, app, port } = await bootstrapApp({ cwd })
|
||||
appContainer = container
|
||||
|
||||
setPort(port)
|
||||
express = app.listen(port, (err) => {
|
||||
process.send(port)
|
||||
})
|
||||
shutdownServer = await startBootstrapApp({ cwd })
|
||||
appContainer = getContainer()
|
||||
})
|
||||
|
||||
afterAll(async () => {
|
||||
const db = useDb()
|
||||
await db.shutdown()
|
||||
express.close()
|
||||
await shutdownServer()
|
||||
})
|
||||
|
||||
afterEach(async () => {
|
||||
|
||||
@@ -1,34 +1,35 @@
|
||||
const path = require("path")
|
||||
|
||||
const { bootstrapApp } = require("../../../environment-helpers/bootstrap-app")
|
||||
const {
|
||||
startBootstrapApp,
|
||||
} = require("../../../environment-helpers/bootstrap-app")
|
||||
const { initDb, useDb } = require("../../../environment-helpers/use-db")
|
||||
const { setPort, useApi } = require("../../../environment-helpers/use-api")
|
||||
const {
|
||||
useApi,
|
||||
useExpressServer,
|
||||
} = require("../../../environment-helpers/use-api")
|
||||
|
||||
const adminSeeder = require("../../../helpers/admin-seeder")
|
||||
const { getContainer } = require("../../../environment-helpers/use-container")
|
||||
|
||||
jest.setTimeout(30000)
|
||||
|
||||
describe("Sales channels", () => {
|
||||
let appContainer
|
||||
let dbConnection
|
||||
let express
|
||||
let shutdownServer
|
||||
|
||||
beforeAll(async () => {
|
||||
const cwd = path.resolve(path.join(__dirname, "..", ".."))
|
||||
dbConnection = await initDb({ cwd })
|
||||
const { container, app, port } = await bootstrapApp({ cwd })
|
||||
appContainer = container
|
||||
|
||||
setPort(port)
|
||||
express = app.listen(port, (err) => {
|
||||
process.send(port)
|
||||
})
|
||||
shutdownServer = await startBootstrapApp({ cwd })
|
||||
appContainer = getContainer()
|
||||
})
|
||||
|
||||
afterAll(async () => {
|
||||
const db = useDb()
|
||||
await db.shutdown()
|
||||
express.close()
|
||||
await shutdownServer()
|
||||
})
|
||||
|
||||
afterEach(async () => {
|
||||
|
||||
@@ -1,10 +1,16 @@
|
||||
const path = require("path")
|
||||
|
||||
const { bootstrapApp } = require("../../../environment-helpers/bootstrap-app")
|
||||
const {
|
||||
startBootstrapApp,
|
||||
} = require("../../../environment-helpers/bootstrap-app")
|
||||
const { initDb, useDb } = require("../../../environment-helpers/use-db")
|
||||
const { setPort, useApi } = require("../../../environment-helpers/use-api")
|
||||
const {
|
||||
useApi,
|
||||
useExpressServer,
|
||||
} = require("../../../environment-helpers/use-api")
|
||||
|
||||
const adminSeeder = require("../../../helpers/admin-seeder")
|
||||
const { getContainer } = require("../../../environment-helpers/use-container")
|
||||
|
||||
jest.setTimeout(30000)
|
||||
|
||||
@@ -13,24 +19,19 @@ const adminHeaders = { headers: { "x-medusa-access-token": "test_token" } }
|
||||
describe("Sales channels", () => {
|
||||
let appContainer
|
||||
let dbConnection
|
||||
let express
|
||||
let shutdownServer
|
||||
|
||||
beforeAll(async () => {
|
||||
const cwd = path.resolve(path.join(__dirname, "..", ".."))
|
||||
dbConnection = await initDb({ cwd })
|
||||
const { container, app, port } = await bootstrapApp({ cwd })
|
||||
appContainer = container
|
||||
|
||||
setPort(port)
|
||||
express = app.listen(port, (err) => {
|
||||
process.send(port)
|
||||
})
|
||||
shutdownServer = await startBootstrapApp({ cwd })
|
||||
appContainer = getContainer()
|
||||
})
|
||||
|
||||
afterAll(async () => {
|
||||
const db = useDb()
|
||||
await db.shutdown()
|
||||
express.close()
|
||||
await shutdownServer()
|
||||
})
|
||||
|
||||
afterEach(async () => {
|
||||
|
||||
@@ -1,30 +1,30 @@
|
||||
const path = require("path")
|
||||
|
||||
const { bootstrapApp } = require("../../../environment-helpers/bootstrap-app")
|
||||
const {
|
||||
startBootstrapApp,
|
||||
} = require("../../../environment-helpers/bootstrap-app")
|
||||
const { initDb, useDb } = require("../../../environment-helpers/use-db")
|
||||
const { getContainer } = require("../../../environment-helpers/use-container")
|
||||
const { useExpressServer } = require("../../../environment-helpers/use-api")
|
||||
|
||||
jest.setTimeout(30000)
|
||||
|
||||
describe("Inventory Module", () => {
|
||||
let appContainer
|
||||
let dbConnection
|
||||
let express
|
||||
let shutdownServer
|
||||
|
||||
beforeAll(async () => {
|
||||
const cwd = path.resolve(path.join(__dirname, "..", ".."))
|
||||
dbConnection = await initDb({ cwd })
|
||||
const { container, app, port } = await bootstrapApp({ cwd })
|
||||
appContainer = container
|
||||
|
||||
express = app.listen(port, (err) => {
|
||||
process.send(port)
|
||||
})
|
||||
shutdownServer = await startBootstrapApp({ cwd })
|
||||
appContainer = getContainer()
|
||||
})
|
||||
|
||||
afterAll(async () => {
|
||||
const db = useDb()
|
||||
await db.shutdown()
|
||||
express.close()
|
||||
await shutdownServer()
|
||||
})
|
||||
|
||||
afterEach(async () => {
|
||||
|
||||
@@ -6,24 +6,27 @@ import {
|
||||
pipe,
|
||||
} from "@medusajs/workflows"
|
||||
import path from "path"
|
||||
import { bootstrapApp } from "../../../../environment-helpers/bootstrap-app"
|
||||
import { startBootstrapApp } from "../../../../environment-helpers/bootstrap-app"
|
||||
import { getContainer } from "../../../../environment-helpers/use-container"
|
||||
import { initDb, useDb } from "../../../../environment-helpers/use-db"
|
||||
|
||||
jest.setTimeout(30000)
|
||||
|
||||
describe("CreateInventoryItem workflow", function () {
|
||||
let medusaContainer
|
||||
let shutdownServer
|
||||
|
||||
beforeAll(async () => {
|
||||
const cwd = path.resolve(path.join(__dirname, "..", "..", ".."))
|
||||
await initDb({ cwd } as any)
|
||||
const { container } = await bootstrapApp({ cwd })
|
||||
medusaContainer = container
|
||||
await initDb({ cwd })
|
||||
shutdownServer = await startBootstrapApp({ cwd, skipExpressListen: true })
|
||||
medusaContainer = getContainer()
|
||||
})
|
||||
|
||||
afterAll(async () => {
|
||||
const db = useDb()
|
||||
await db.shutdown()
|
||||
await shutdownServer()
|
||||
})
|
||||
|
||||
it("should compensate all the invoke if something fails", async () => {
|
||||
|
||||
@@ -7,24 +7,29 @@ import {
|
||||
pipe,
|
||||
} from "@medusajs/workflows"
|
||||
import path from "path"
|
||||
import { bootstrapApp } from "../../../../environment-helpers/bootstrap-app"
|
||||
import { startBootstrapApp } from "../../../../environment-helpers/bootstrap-app"
|
||||
import { getContainer } from "../../../../environment-helpers/use-container"
|
||||
import { initDb, useDb } from "../../../../environment-helpers/use-db"
|
||||
|
||||
jest.setTimeout(30000)
|
||||
|
||||
describe("CreateProduct workflow", function () {
|
||||
let medusaContainer
|
||||
let shutdownServer
|
||||
|
||||
beforeAll(async () => {
|
||||
const cwd = path.resolve(path.join(__dirname, "..", "..", ".."))
|
||||
await initDb({ cwd } as any)
|
||||
const { container } = await bootstrapApp({ cwd })
|
||||
medusaContainer = container
|
||||
await initDb({ cwd })
|
||||
shutdownServer = await startBootstrapApp({ cwd, skipExpressListen: true })
|
||||
medusaContainer = getContainer()
|
||||
})
|
||||
|
||||
afterAll(async () => {
|
||||
console.log("GLOABL GC()", typeof global)
|
||||
|
||||
const db = useDb()
|
||||
await db.shutdown()
|
||||
await shutdownServer()
|
||||
})
|
||||
|
||||
it("should compensate all the invoke if something fails", async () => {
|
||||
|
||||
@@ -7,29 +7,29 @@ import {
|
||||
} from "@medusajs/workflows"
|
||||
import path from "path"
|
||||
|
||||
import { bootstrapApp } from "../../../../environment-helpers/bootstrap-app"
|
||||
import { startBootstrapApp } from "../../../../environment-helpers/bootstrap-app"
|
||||
import { getContainer } from "../../../../environment-helpers/use-container"
|
||||
import { initDb, useDb } from "../../../../environment-helpers/use-db"
|
||||
import { simpleProductFactory } from "../../../../factories"
|
||||
|
||||
jest.setTimeout(30000)
|
||||
|
||||
describe("UpdateProduct workflow", function () {
|
||||
let medusaProcess
|
||||
let dbConnection
|
||||
let medusaContainer
|
||||
let shutdownServer
|
||||
|
||||
beforeAll(async () => {
|
||||
const cwd = path.resolve(path.join(__dirname, "..", "..", ".."))
|
||||
dbConnection = await initDb({ cwd } as any)
|
||||
const { container } = await bootstrapApp({ cwd })
|
||||
medusaContainer = container
|
||||
dbConnection = await initDb({ cwd })
|
||||
shutdownServer = await startBootstrapApp({ cwd, skipExpressListen: true })
|
||||
medusaContainer = getContainer()
|
||||
})
|
||||
|
||||
afterAll(async () => {
|
||||
const db = useDb()
|
||||
await db.shutdown()
|
||||
|
||||
medusaProcess.kill()
|
||||
await shutdownServer()
|
||||
})
|
||||
|
||||
beforeEach(async () => {
|
||||
|
||||
@@ -58,7 +58,7 @@ module.exports = {
|
||||
},
|
||||
[Modules.CACHE]: {
|
||||
resolve: "@medusajs/cache-inmemory",
|
||||
options: { ttl: 5 },
|
||||
options: { ttl: 0 }, // Cache disabled
|
||||
},
|
||||
[Modules.PRODUCT]: {
|
||||
scope: "internal",
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
"license": "MIT",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"test:integration": "jest --silent=false --runInBand --bail --detectOpenHandles --forceExit",
|
||||
"test:integration": "node --expose-gc ./../../node_modules/.bin/jest --silent=false --runInBand --bail --logHeapUsage --forceExit",
|
||||
"build": "babel src -d dist --extensions \".ts,.js\""
|
||||
},
|
||||
"dependencies": {
|
||||
|
||||
Reference in New Issue
Block a user