fix: integration-tests/modules (#6595)
This commit is contained in:
committed by
GitHub
parent
51bb6f1e89
commit
f0ef0a8784
6
.changeset/fluffy-dancers-rest.md
Normal file
6
.changeset/fluffy-dancers-rest.md
Normal file
@@ -0,0 +1,6 @@
|
||||
---
|
||||
"@medusajs/medusa": patch
|
||||
"medusa-test-utils": patch
|
||||
---
|
||||
|
||||
fix: integration-tests/modules
|
||||
@@ -1,5 +1,5 @@
|
||||
const Scrypt = require("scrypt-kdf")
|
||||
const { User } = require("@medusajs/medusa")
|
||||
const { User } = require("@medusajs/medusa/dist/models/user")
|
||||
|
||||
module.exports = async (dataSource, data = {}) => {
|
||||
const manager = dataSource.manager
|
||||
|
||||
@@ -28,7 +28,7 @@ medusaIntegrationTestRunner({
|
||||
})
|
||||
|
||||
beforeEach(async () => {
|
||||
await createAdminUser(dbConnection, adminHeaders)
|
||||
await createAdminUser(dbConnection, adminHeaders, appContainer)
|
||||
})
|
||||
|
||||
it("compensates rules correctly", async () => {
|
||||
|
||||
@@ -12,8 +12,14 @@ medusaIntegrationTestRunner({
|
||||
env,
|
||||
testSuite: ({ dbConnection, getContainer, api }) => {
|
||||
describe("POST /admin/users/me", () => {
|
||||
let container
|
||||
|
||||
beforeAll(() => {
|
||||
container = getContainer()
|
||||
})
|
||||
|
||||
beforeEach(async () => {
|
||||
await createAdminUser(dbConnection, adminHeaders)
|
||||
await createAdminUser(dbConnection, adminHeaders, container)
|
||||
})
|
||||
|
||||
it("gets the current user", async () => {
|
||||
|
||||
@@ -4,7 +4,6 @@ jest.setTimeout(5000000)
|
||||
|
||||
const env = {
|
||||
MEDUSA_FF_MEDUSA_V2: false,
|
||||
MEDUSA_FF_SALES_CHANNELS: true,
|
||||
}
|
||||
|
||||
workflowEngineTestSuite(env, { force_modules_migration: true })
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
"license": "MIT",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"test:integration": "node --expose-gc ./../../node_modules/.bin/jest --ci --silent=false -i --detectOpenHandles --logHeapUsage --forceExit",
|
||||
"test:integration": "node --expose-gc ./../../node_modules/.bin/jest --ci --silent=true --concurrency=50% --detectOpenHandles --logHeapUsage --forceExit",
|
||||
"build": "babel src -d dist --extensions \".ts,.js\""
|
||||
},
|
||||
"dependencies": {
|
||||
|
||||
@@ -182,35 +182,31 @@ export function medusaIntegrationTestRunner({
|
||||
} as MedusaSuiteOptions
|
||||
|
||||
const beforeAll_ = async () => {
|
||||
try {
|
||||
await dbUtils.create(dbName)
|
||||
const { dbDataSource, pgConnection } = await initDb({
|
||||
cwd,
|
||||
env,
|
||||
force_modules_migration,
|
||||
database_extra: {},
|
||||
dbUrl: dbConfig.clientUrl,
|
||||
dbSchema: dbConfig.schema,
|
||||
})
|
||||
dbUtils.db_ = dbDataSource
|
||||
dbUtils.pgConnection_ = pgConnection
|
||||
await dbUtils.create(dbName)
|
||||
const { dbDataSource, pgConnection } = await initDb({
|
||||
cwd,
|
||||
env,
|
||||
force_modules_migration,
|
||||
database_extra: {},
|
||||
dbUrl: dbConfig.clientUrl,
|
||||
dbSchema: dbConfig.schema,
|
||||
})
|
||||
dbUtils.db_ = dbDataSource
|
||||
dbUtils.pgConnection_ = pgConnection
|
||||
|
||||
const {
|
||||
shutdown: shutdown_,
|
||||
container: container_,
|
||||
port,
|
||||
} = await startBootstrapApp({
|
||||
cwd,
|
||||
env,
|
||||
})
|
||||
const {
|
||||
shutdown: shutdown_,
|
||||
container: container_,
|
||||
port,
|
||||
} = await startBootstrapApp({
|
||||
cwd,
|
||||
env,
|
||||
})
|
||||
|
||||
apiUtils = axios.create({ baseURL: `http://localhost:${port}` })
|
||||
apiUtils = axios.create({ baseURL: `http://localhost:${port}` })
|
||||
|
||||
container = container_
|
||||
shutdown = shutdown_
|
||||
} catch (error) {
|
||||
console.error("Error setting up integration environment:", error)
|
||||
}
|
||||
container = container_
|
||||
shutdown = shutdown_
|
||||
}
|
||||
|
||||
const afterEach_ = async () => {
|
||||
@@ -225,12 +221,8 @@ export function medusaIntegrationTestRunner({
|
||||
beforeAll(beforeAll_)
|
||||
afterEach(afterEach_)
|
||||
afterAll(async () => {
|
||||
try {
|
||||
await dbUtils.shutdown(dbName)
|
||||
await shutdown()
|
||||
} catch (error) {
|
||||
console.error("Error shutting down integration environment:", error)
|
||||
}
|
||||
await dbUtils.shutdown(dbName)
|
||||
await shutdown()
|
||||
})
|
||||
|
||||
testSuite(options!)
|
||||
|
||||
@@ -113,26 +113,18 @@ export function moduleIntegrationTestRunner({
|
||||
} as SuiteOptions
|
||||
|
||||
const beforeEach_ = async () => {
|
||||
try {
|
||||
await MikroOrmWrapper.setupDatabase()
|
||||
const output = await initModules(moduleOptions_)
|
||||
shutdown = output.shutdown
|
||||
medusaApp = output.medusaApp
|
||||
moduleService = output.medusaApp.modules[moduleName]
|
||||
} catch (error) {
|
||||
console.error("Error setting up database:", error)
|
||||
}
|
||||
await MikroOrmWrapper.setupDatabase()
|
||||
const output = await initModules(moduleOptions_)
|
||||
shutdown = output.shutdown
|
||||
medusaApp = output.medusaApp
|
||||
moduleService = output.medusaApp.modules[moduleName]
|
||||
}
|
||||
|
||||
const afterEach_ = async () => {
|
||||
try {
|
||||
await MikroOrmWrapper.clearDatabase()
|
||||
await shutdown()
|
||||
moduleService = {}
|
||||
medusaApp = {} as MedusaAppOutput
|
||||
} catch (error) {
|
||||
console.error("Error tearing down database:", error)
|
||||
}
|
||||
await MikroOrmWrapper.clearDatabase()
|
||||
await shutdown()
|
||||
moduleService = {}
|
||||
medusaApp = {} as MedusaAppOutput
|
||||
}
|
||||
|
||||
return describe("", () => {
|
||||
|
||||
@@ -21,7 +21,7 @@ import {
|
||||
MedusaV2Flag,
|
||||
} from "@medusajs/utils"
|
||||
import { asValue } from "awilix"
|
||||
import { remoteQueryFetchData } from ".."
|
||||
import { remoteQueryFetchData } from "../utils/remote-query-fetch-data"
|
||||
import { joinerConfig } from "../joiner-config"
|
||||
|
||||
export function mergeDefaultModules(
|
||||
|
||||
Reference in New Issue
Block a user