chore: Migrate modules to use the Module util (#7964)
**What** Apply the `Module` util to each module to handle the export and provide the linkable configuration object. - Most joiner config that does not have any special config are removed/cleaned up in favor of the autogenerated one or simpler one - linkable are now available in all modules - cleaned up the dependencies of the modules FIXES CORE-2410
This commit is contained in:
+54
-1
@@ -1,6 +1,7 @@
|
||||
import { ICustomerModuleService } from "@medusajs/types"
|
||||
import { moduleIntegrationTestRunner } from "medusa-test-utils"
|
||||
import { Modules } from "@medusajs/utils"
|
||||
import { Module, Modules } from "@medusajs/utils"
|
||||
import { CustomerModuleService } from "@services"
|
||||
|
||||
jest.setTimeout(30000)
|
||||
|
||||
@@ -8,6 +9,58 @@ moduleIntegrationTestRunner<ICustomerModuleService>({
|
||||
moduleName: Modules.CUSTOMER,
|
||||
testSuite: ({ service }) => {
|
||||
describe("Customer Module Service", () => {
|
||||
it(`should export the appropriate linkable configuration`, () => {
|
||||
const linkable = Module(Modules.CUSTOMER, {
|
||||
service: CustomerModuleService,
|
||||
}).linkable
|
||||
|
||||
expect(Object.keys(linkable)).toEqual([
|
||||
"address",
|
||||
"customerGroupCustomer",
|
||||
"customerGroup",
|
||||
"customer",
|
||||
])
|
||||
|
||||
Object.keys(linkable).forEach((key) => {
|
||||
delete linkable[key].toJSON
|
||||
})
|
||||
|
||||
expect(linkable).toEqual({
|
||||
address: {
|
||||
id: {
|
||||
linkable: "address_id",
|
||||
primaryKey: "id",
|
||||
serviceName: "customer",
|
||||
field: "address",
|
||||
},
|
||||
},
|
||||
customerGroupCustomer: {
|
||||
id: {
|
||||
linkable: "customer_group_customer_id",
|
||||
primaryKey: "id",
|
||||
serviceName: "customer",
|
||||
field: "customerGroupCustomer",
|
||||
},
|
||||
},
|
||||
customerGroup: {
|
||||
id: {
|
||||
linkable: "customer_group_id",
|
||||
primaryKey: "id",
|
||||
serviceName: "customer",
|
||||
field: "customerGroup",
|
||||
},
|
||||
},
|
||||
customer: {
|
||||
id: {
|
||||
linkable: "customer_id",
|
||||
primaryKey: "id",
|
||||
serviceName: "customer",
|
||||
field: "customer",
|
||||
},
|
||||
},
|
||||
})
|
||||
})
|
||||
|
||||
describe("create", () => {
|
||||
it("should create a single customer", async () => {
|
||||
const customerData = {
|
||||
|
||||
@@ -50,8 +50,6 @@
|
||||
"@mikro-orm/core": "5.9.7",
|
||||
"@mikro-orm/migrations": "5.9.7",
|
||||
"@mikro-orm/postgresql": "5.9.7",
|
||||
"awilix": "^8.0.0",
|
||||
"dotenv": "^16.4.5",
|
||||
"knex": "2.4.2"
|
||||
"awilix": "^8.0.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { ModuleExports } from "@medusajs/types"
|
||||
import { CustomerModuleService } from "@services"
|
||||
import { Module, Modules } from "@medusajs/utils"
|
||||
|
||||
const moduleDefinition: ModuleExports = {
|
||||
export default Module(Modules.CUSTOMER, {
|
||||
service: CustomerModuleService,
|
||||
}
|
||||
export default moduleDefinition
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user