fix: integration-tests/modules (#6595)
This commit is contained in:
1 parent
51bb6f1e89
commit
f0ef0a8784
9 files changed
+17
-22
No files matched your search
@@ -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 Scrypt = require("scrypt-kdf")
|
||||||
const { User } = require("@medusajs/medusa")
|
const { User } = require("@medusajs/medusa/dist/models/user")
|
||||||
|
|
||||||
module.exports = async (dataSource, data = {}) => {
|
module.exports = async (dataSource, data = {}) => {
|
||||||
const manager = dataSource.manager
|
const manager = dataSource.manager
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ medusaIntegrationTestRunner({
|
|||||||
})
|
})
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
await createAdminUser(dbConnection, adminHeaders)
|
await createAdminUser(dbConnection, adminHeaders, appContainer)
|
||||||
})
|
})
|
||||||
|
|
||||||
it("compensates rules correctly", async () => {
|
it("compensates rules correctly", async () => {
|
||||||
|
|||||||
@@ -12,8 +12,14 @@ medusaIntegrationTestRunner({
|
|||||||
env,
|
env,
|
||||||
testSuite: ({ dbConnection, getContainer, api }) => {
|
testSuite: ({ dbConnection, getContainer, api }) => {
|
||||||
describe("POST /admin/users/me", () => {
|
describe("POST /admin/users/me", () => {
|
||||||
|
let container
|
||||||
|
|
||||||
|
beforeAll(() => {
|
||||||
|
container = getContainer()
|
||||||
|
})
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
await createAdminUser(dbConnection, adminHeaders)
|
await createAdminUser(dbConnection, adminHeaders, container)
|
||||||
})
|
})
|
||||||
|
|
||||||
it("gets the current user", async () => {
|
it("gets the current user", async () => {
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ jest.setTimeout(5000000)
|
|||||||
|
|
||||||
const env = {
|
const env = {
|
||||||
MEDUSA_FF_MEDUSA_V2: false,
|
MEDUSA_FF_MEDUSA_V2: false,
|
||||||
MEDUSA_FF_SALES_CHANNELS: true,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
workflowEngineTestSuite(env, { force_modules_migration: true })
|
workflowEngineTestSuite(env, { force_modules_migration: true })
|
||||||
@@ -5,7 +5,7 @@
|
|||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"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\""
|
"build": "babel src -d dist --extensions \".ts,.js\""
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|||||||
@@ -182,7 +182,6 @@ export function medusaIntegrationTestRunner({
|
|||||||
} as MedusaSuiteOptions
|
} as MedusaSuiteOptions
|
||||||
|
|
||||||
const beforeAll_ = async () => {
|
const beforeAll_ = async () => {
|
||||||
try {
|
|
||||||
await dbUtils.create(dbName)
|
await dbUtils.create(dbName)
|
||||||
const { dbDataSource, pgConnection } = await initDb({
|
const { dbDataSource, pgConnection } = await initDb({
|
||||||
cwd,
|
cwd,
|
||||||
@@ -208,9 +207,6 @@ export function medusaIntegrationTestRunner({
|
|||||||
|
|
||||||
container = container_
|
container = container_
|
||||||
shutdown = shutdown_
|
shutdown = shutdown_
|
||||||
} catch (error) {
|
|
||||||
console.error("Error setting up integration environment:", error)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const afterEach_ = async () => {
|
const afterEach_ = async () => {
|
||||||
@@ -225,12 +221,8 @@ export function medusaIntegrationTestRunner({
|
|||||||
beforeAll(beforeAll_)
|
beforeAll(beforeAll_)
|
||||||
afterEach(afterEach_)
|
afterEach(afterEach_)
|
||||||
afterAll(async () => {
|
afterAll(async () => {
|
||||||
try {
|
|
||||||
await dbUtils.shutdown(dbName)
|
await dbUtils.shutdown(dbName)
|
||||||
await shutdown()
|
await shutdown()
|
||||||
} catch (error) {
|
|
||||||
console.error("Error shutting down integration environment:", error)
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
|
||||||
testSuite(options!)
|
testSuite(options!)
|
||||||
|
|||||||
@@ -113,26 +113,18 @@ export function moduleIntegrationTestRunner({
|
|||||||
} as SuiteOptions
|
} as SuiteOptions
|
||||||
|
|
||||||
const beforeEach_ = async () => {
|
const beforeEach_ = async () => {
|
||||||
try {
|
|
||||||
await MikroOrmWrapper.setupDatabase()
|
await MikroOrmWrapper.setupDatabase()
|
||||||
const output = await initModules(moduleOptions_)
|
const output = await initModules(moduleOptions_)
|
||||||
shutdown = output.shutdown
|
shutdown = output.shutdown
|
||||||
medusaApp = output.medusaApp
|
medusaApp = output.medusaApp
|
||||||
moduleService = output.medusaApp.modules[moduleName]
|
moduleService = output.medusaApp.modules[moduleName]
|
||||||
} catch (error) {
|
|
||||||
console.error("Error setting up database:", error)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const afterEach_ = async () => {
|
const afterEach_ = async () => {
|
||||||
try {
|
|
||||||
await MikroOrmWrapper.clearDatabase()
|
await MikroOrmWrapper.clearDatabase()
|
||||||
await shutdown()
|
await shutdown()
|
||||||
moduleService = {}
|
moduleService = {}
|
||||||
medusaApp = {} as MedusaAppOutput
|
medusaApp = {} as MedusaAppOutput
|
||||||
} catch (error) {
|
|
||||||
console.error("Error tearing down database:", error)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return describe("", () => {
|
return describe("", () => {
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ import {
|
|||||||
MedusaV2Flag,
|
MedusaV2Flag,
|
||||||
} from "@medusajs/utils"
|
} from "@medusajs/utils"
|
||||||
import { asValue } from "awilix"
|
import { asValue } from "awilix"
|
||||||
import { remoteQueryFetchData } from ".."
|
import { remoteQueryFetchData } from "../utils/remote-query-fetch-data"
|
||||||
import { joinerConfig } from "../joiner-config"
|
import { joinerConfig } from "../joiner-config"
|
||||||
|
|
||||||
export function mergeDefaultModules(
|
export function mergeDefaultModules(
|
||||||
|
|||||||
Reference in new issue
Block a user