Chore/rm main entity concept (#7709)
**What** Update the `MedusaService` class, factory and types to remove the concept of main modules. The idea being that all method will be explicitly named and suffixes to represent the object you are trying to manipulate. This pr also includes various fixes in different modules Co-authored-by: Stevche Radevski <4820812+sradevski@users.noreply.github.com> Co-authored-by: Oli Juhl <59018053+olivermrbl@users.noreply.github.com>
This commit is contained in:
co-authored by
Stevche Radevski
Oli Juhl
parent
2895ccfba8
commit
48963f55ef
@@ -1,76 +1,49 @@
|
||||
import { IPaymentModuleService } from "@medusajs/types"
|
||||
import { SqlEntityManager } from "@mikro-orm/postgresql"
|
||||
|
||||
import { Modules } from "@medusajs/modules-sdk"
|
||||
import { initModules } from "medusa-test-utils"
|
||||
import { MikroOrmWrapper } from "../../utils"
|
||||
import { getInitModuleConfig } from "../../utils/get-init-module-config"
|
||||
import { createPaymentCollections } from "../../__fixtures__"
|
||||
import { moduleIntegrationTestRunner } from "medusa-test-utils"
|
||||
|
||||
jest.setTimeout(30000)
|
||||
|
||||
describe("Payment Module Service", () => {
|
||||
let service: IPaymentModuleService
|
||||
let repositoryManager: SqlEntityManager
|
||||
let shutdownFunc: () => Promise<void>
|
||||
moduleIntegrationTestRunner<IPaymentModuleService>({
|
||||
moduleName: Modules.PAYMENT,
|
||||
testSuite: ({ service }) => {
|
||||
describe("Payment Module Service", () => {
|
||||
describe("providers", () => {
|
||||
it("should load payment plugins", async () => {
|
||||
let error = await service
|
||||
.createPaymentCollections([
|
||||
{
|
||||
amount: 200,
|
||||
region_id: "req_123",
|
||||
} as any,
|
||||
])
|
||||
.catch((e) => e)
|
||||
|
||||
beforeAll(async () => {
|
||||
await MikroOrmWrapper.setupDatabase()
|
||||
|
||||
const initModulesConfig = getInitModuleConfig()
|
||||
const { medusaApp, shutdown } = await initModules(initModulesConfig)
|
||||
service = medusaApp.modules[Modules.PAYMENT]
|
||||
|
||||
shutdownFunc = shutdown
|
||||
})
|
||||
|
||||
afterAll(async () => {
|
||||
await shutdownFunc()
|
||||
})
|
||||
|
||||
beforeEach(async () => {
|
||||
await MikroOrmWrapper.setupDatabase()
|
||||
repositoryManager = await MikroOrmWrapper.forkManager()
|
||||
|
||||
await createPaymentCollections(repositoryManager)
|
||||
})
|
||||
|
||||
afterEach(async () => {
|
||||
await MikroOrmWrapper.clearDatabase()
|
||||
})
|
||||
|
||||
describe("providers", () => {
|
||||
it("should load payment plugins", async () => {
|
||||
let error = await service
|
||||
.createPaymentCollections([
|
||||
{
|
||||
amount: 200,
|
||||
region_id: "req_123",
|
||||
} as any,
|
||||
])
|
||||
.catch((e) => e)
|
||||
|
||||
expect(error.message).toContain(
|
||||
"Value for PaymentCollection.currency_code is required, 'undefined' found"
|
||||
)
|
||||
})
|
||||
|
||||
it("should create a payment collection successfully", async () => {
|
||||
const [createdPaymentCollection] = await service.createPaymentCollections(
|
||||
[{ currency_code: "USD", amount: 200, region_id: "reg_123" }]
|
||||
)
|
||||
|
||||
expect(createdPaymentCollection).toEqual(
|
||||
expect.objectContaining({
|
||||
id: expect.any(String),
|
||||
status: "not_paid",
|
||||
payment_providers: [],
|
||||
payment_sessions: [],
|
||||
payments: [],
|
||||
currency_code: "USD",
|
||||
amount: 200,
|
||||
expect(error.message).toContain(
|
||||
"Value for PaymentCollection.currency_code is required, 'undefined' found"
|
||||
)
|
||||
})
|
||||
)
|
||||
|
||||
it("should create a payment collection successfully", async () => {
|
||||
const [createdPaymentCollection] =
|
||||
await service.createPaymentCollections([
|
||||
{ currency_code: "USD", amount: 200, region_id: "reg_123" },
|
||||
])
|
||||
|
||||
expect(createdPaymentCollection).toEqual(
|
||||
expect.objectContaining({
|
||||
id: expect.any(String),
|
||||
status: "not_paid",
|
||||
payment_providers: [],
|
||||
payment_sessions: [],
|
||||
payments: [],
|
||||
currency_code: "USD",
|
||||
amount: 200,
|
||||
})
|
||||
)
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
},
|
||||
})
|
||||
|
||||
+3
-9
@@ -1,10 +1,7 @@
|
||||
import { Modules } from "@medusajs/modules-sdk"
|
||||
import { IPaymentModuleService } from "@medusajs/types"
|
||||
import { promiseAll } from "@medusajs/utils"
|
||||
import {
|
||||
moduleIntegrationTestRunner,
|
||||
SuiteOptions,
|
||||
} from "medusa-test-utils/dist"
|
||||
import { moduleIntegrationTestRunner } from "medusa-test-utils/dist"
|
||||
import {
|
||||
createPaymentCollections,
|
||||
createPayments,
|
||||
@@ -13,12 +10,9 @@ import {
|
||||
|
||||
jest.setTimeout(30000)
|
||||
|
||||
moduleIntegrationTestRunner({
|
||||
moduleIntegrationTestRunner<IPaymentModuleService>({
|
||||
moduleName: Modules.PAYMENT,
|
||||
testSuite: ({
|
||||
MikroOrmWrapper,
|
||||
service,
|
||||
}: SuiteOptions<IPaymentModuleService>) => {
|
||||
testSuite: ({ MikroOrmWrapper, service }) => {
|
||||
describe("Payment Module Service", () => {
|
||||
describe("Payment Flow", () => {
|
||||
it("complete payment flow successfully", async () => {
|
||||
|
||||
Reference in New Issue
Block a user