fix: integration tests modules 2 (#6599)
Currently, if the v2 flag is not enabled it can lead to issues if the modules are part of the medusa config as they will get loaded anyway leading to issues if the migrations did not ran
This commit is contained in:
@@ -22,7 +22,7 @@ import {
|
|||||||
import adminSeeder from "../../../../helpers/admin-seeder"
|
import adminSeeder from "../../../../helpers/admin-seeder"
|
||||||
import { medusaIntegrationTestRunner } from "medusa-test-utils"
|
import { medusaIntegrationTestRunner } from "medusa-test-utils"
|
||||||
|
|
||||||
jest.setTimeout(50000)
|
jest.setTimeout(200000)
|
||||||
|
|
||||||
const env = { MEDUSA_FF_MEDUSA_V2: true }
|
const env = { MEDUSA_FF_MEDUSA_V2: true }
|
||||||
|
|
||||||
|
|||||||
@@ -1,16 +1,20 @@
|
|||||||
import { initialize, runMigrations } from "@medusajs/link-modules"
|
import { initialize, runMigrations } from "@medusajs/link-modules"
|
||||||
import { MedusaModule, ModuleJoinerConfig } from "@medusajs/modules-sdk"
|
import { MedusaModule, ModuleJoinerConfig } from "@medusajs/modules-sdk"
|
||||||
|
import { medusaIntegrationTestRunner } from "medusa-test-utils/dist"
|
||||||
|
|
||||||
jest.setTimeout(5000000)
|
jest.setTimeout(5000000)
|
||||||
|
|
||||||
const DB_HOST = process.env.DB_HOST
|
medusaIntegrationTestRunner({
|
||||||
const DB_USERNAME = process.env.DB_USERNAME
|
force_modules_migration: true,
|
||||||
const DB_PASSWORD = process.env.DB_PASSWORD
|
testSuite: ({ dbConnection, getContainer }) => {
|
||||||
const DB_NAME = process.env.DB_TEMP_NAME
|
let DB_URL
|
||||||
const DB_URL = `postgres://${DB_USERNAME}:${DB_PASSWORD}@${DB_HOST}/${DB_NAME}`
|
let container
|
||||||
|
|
||||||
describe("Link Modules", () => {
|
|
||||||
let links
|
let links
|
||||||
|
|
||||||
|
beforeAll(async () => {
|
||||||
|
DB_URL = dbConnection.manager.connection.options.url
|
||||||
|
container = getContainer()
|
||||||
|
|
||||||
const linkDefinition: ModuleJoinerConfig[] = [
|
const linkDefinition: ModuleJoinerConfig[] = [
|
||||||
{
|
{
|
||||||
serviceName: "linkServiceName",
|
serviceName: "linkServiceName",
|
||||||
@@ -51,7 +55,6 @@ describe("Link Modules", () => {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
beforeAll(async () => {
|
|
||||||
jest.spyOn(MedusaModule, "getLoadedModules").mockImplementation((() => {
|
jest.spyOn(MedusaModule, "getLoadedModules").mockImplementation((() => {
|
||||||
return [{ moduleA: [{}] }, { moduleB: [{}] }]
|
return [{ moduleA: [{}] }, { moduleB: [{}] }]
|
||||||
}) as any)
|
}) as any)
|
||||||
@@ -64,6 +67,7 @@ describe("Link Modules", () => {
|
|||||||
jest.clearAllMocks()
|
jest.clearAllMocks()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
describe("Link Modules", () => {
|
||||||
it("Should insert values in a declared link", async function () {
|
it("Should insert values in a declared link", async function () {
|
||||||
// simple
|
// simple
|
||||||
await links.linkServiceName.create("modA_id", "modB_id")
|
await links.linkServiceName.create("modA_id", "modB_id")
|
||||||
@@ -128,6 +132,23 @@ describe("Link Modules", () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it("Should dismiss the link of a given pair of keys", async function () {
|
it("Should dismiss the link of a given pair of keys", async function () {
|
||||||
|
// simple
|
||||||
|
await links.linkServiceName.create("modA_id", "modB_id")
|
||||||
|
|
||||||
|
// extra fields
|
||||||
|
await links.linkServiceName.create("123", "abc", {
|
||||||
|
extra_field: 333,
|
||||||
|
another_field: "value**",
|
||||||
|
})
|
||||||
|
|
||||||
|
// bulk
|
||||||
|
await links.linkServiceName.create([
|
||||||
|
["111", "aaa", { another_field: "test" }],
|
||||||
|
["222", "bbb"],
|
||||||
|
["333", "ccc", { extra_field: 2 }],
|
||||||
|
["444", "bbb"],
|
||||||
|
])
|
||||||
|
|
||||||
// simple
|
// simple
|
||||||
const dismissSingle = await links.linkServiceName.dismiss(
|
const dismissSingle = await links.linkServiceName.dismiss(
|
||||||
"modA_id",
|
"modA_id",
|
||||||
@@ -163,6 +184,23 @@ describe("Link Modules", () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it("Should delete all the links related to a given key", async function () {
|
it("Should delete all the links related to a given key", async function () {
|
||||||
|
// simple
|
||||||
|
await links.linkServiceName.create("modA_id", "modB_id")
|
||||||
|
|
||||||
|
// extra fields
|
||||||
|
await links.linkServiceName.create("123", "abc", {
|
||||||
|
extra_field: 333,
|
||||||
|
another_field: "value**",
|
||||||
|
})
|
||||||
|
|
||||||
|
// bulk
|
||||||
|
await links.linkServiceName.create([
|
||||||
|
["111", "aaa", { another_field: "test" }],
|
||||||
|
["222", "bbb"],
|
||||||
|
["333", "ccc", { extra_field: 2 }],
|
||||||
|
["444", "bbb"],
|
||||||
|
])
|
||||||
|
|
||||||
await links.linkServiceName.softDelete({
|
await links.linkServiceName.softDelete({
|
||||||
inventory_item_id: "bbb",
|
inventory_item_id: "bbb",
|
||||||
})
|
})
|
||||||
@@ -186,3 +224,5 @@ describe("Link Modules", () => {
|
|||||||
])
|
])
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import { medusaIntegrationTestRunner } from "medusa-test-utils"
|
|||||||
jest.setTimeout(30000)
|
jest.setTimeout(30000)
|
||||||
|
|
||||||
medusaIntegrationTestRunner({
|
medusaIntegrationTestRunner({
|
||||||
|
force_modules_migration: true,
|
||||||
testSuite: ({ dbConnection }) => {
|
testSuite: ({ dbConnection }) => {
|
||||||
describe("Standalone Modules", () => {
|
describe("Standalone Modules", () => {
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
|
|||||||
@@ -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=true --concurrency=50% --detectOpenHandles --logHeapUsage --forceExit",
|
"test:integration": "node --expose-gc ./../../node_modules/.bin/jest --ci --silent=true -i --detectOpenHandles --logHeapUsage --forceExit",
|
||||||
"build": "babel src -d dist --extensions \".ts,.js\""
|
"build": "babel src -d dist --extensions \".ts,.js\""
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|||||||
Reference in New Issue
Block a user