refactor: migrate promotion module (#10410)
This commit is contained in:
@@ -2,6 +2,7 @@ import { CreateCampaignDTO } from "@medusajs/framework/types"
|
||||
import { SqlEntityManager } from "@mikro-orm/postgresql"
|
||||
import { Campaign } from "@models"
|
||||
import { defaultCampaignsData } from "./data"
|
||||
import { toMikroORMEntity } from "@medusajs/framework/utils"
|
||||
|
||||
export * from "./data"
|
||||
|
||||
@@ -12,7 +13,7 @@ export async function createCampaigns(
|
||||
const campaigns: Campaign[] = []
|
||||
|
||||
for (let campaignData of campaignsData) {
|
||||
let campaign = manager.create(Campaign, campaignData)
|
||||
let campaign = manager.create(toMikroORMEntity(Campaign), campaignData)
|
||||
|
||||
manager.persist(campaign)
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ import {
|
||||
IPromotionModuleService,
|
||||
PromotionDTO,
|
||||
} from "@medusajs/framework/types"
|
||||
import { isPresent } from "@medusajs/framework/utils"
|
||||
import { isPresent, toMikroORMEntity } from "@medusajs/framework/utils"
|
||||
import { SqlEntityManager } from "@mikro-orm/postgresql"
|
||||
import { Promotion } from "@models"
|
||||
import { defaultPromotionsData } from "./data"
|
||||
@@ -17,7 +17,7 @@ export async function createPromotions(
|
||||
const promotions: Promotion[] = []
|
||||
|
||||
for (let promotionData of promotionsData) {
|
||||
let promotion = manager.create(Promotion, promotionData)
|
||||
let promotion = manager.create(toMikroORMEntity(Promotion), promotionData)
|
||||
|
||||
manager.persist(promotion)
|
||||
await manager.flush()
|
||||
|
||||
@@ -508,7 +508,7 @@ moduleIntegrationTestRunner({
|
||||
)
|
||||
})
|
||||
|
||||
it("should create a buyget promotion with rules successfully", async () => {
|
||||
it("should create a budget promotion with rules successfully", async () => {
|
||||
const createdPromotion = await createDefaultPromotion(service, {
|
||||
type: PromotionType.BUYGET,
|
||||
application_method: {
|
||||
@@ -638,7 +638,7 @@ moduleIntegrationTestRunner({
|
||||
application_method: expect.objectContaining({
|
||||
target_type: "order",
|
||||
allocation: "across",
|
||||
max_quantity: 0,
|
||||
max_quantity: null,
|
||||
}),
|
||||
})
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user