feat(core-flows,medusa,types,utils): rename psma to prices (#6796)

What:

Renames pricesetmoneyamount to prices

Co-authored-by: Adrien de Peretti <25098370+adrien2p@users.noreply.github.com>
This commit is contained in:
Riqwan Thamir
2024-03-25 13:15:25 +00:00
committed by GitHub
co-authored by Adrien de Peretti
parent fbc369705d
commit 9073d7aba3
80 changed files with 1056 additions and 2276 deletions
@@ -4,10 +4,10 @@ import {
} from "../../../../factories"
import { IPricingModuleService } from "@medusajs/types"
import { medusaIntegrationTestRunner } from "medusa-test-utils"
import adminSeeder from "../../../../helpers/admin-seeder"
import { createDefaultRuleTypes } from "../../../helpers/create-default-rule-types"
import { createVariantPriceSet } from "../../../helpers/create-variant-price-set"
import { medusaIntegrationTestRunner } from "medusa-test-utils"
jest.setTimeout(50000)
@@ -100,11 +100,10 @@ medusaIntegrationTestRunner({
})
it("should delete prices in batch based on product ids", async () => {
let priceSetMoneyAmounts =
await pricingModuleService.listPriceSetMoneyAmounts({
price_set_id: [priceSet.id],
})
expect(priceSetMoneyAmounts.length).toEqual(2)
let prices = await pricingModuleService.listPrices({
price_set_id: [priceSet.id],
})
expect(prices.length).toEqual(2)
const deleteRes = await api.delete(
`/admin/price-lists/${priceListId}/products/prices/batch`,
@@ -117,13 +116,12 @@ medusaIntegrationTestRunner({
)
expect(deleteRes.status).toEqual(200)
priceSetMoneyAmounts =
await pricingModuleService.listPriceSetMoneyAmounts({
price_set_id: [priceSet.id],
})
prices = await pricingModuleService.listPrices({
price_set_id: [priceSet.id],
})
expect(priceSetMoneyAmounts.length).toEqual(1)
expect(priceSetMoneyAmounts).toEqual([
expect(prices.length).toEqual(1)
expect(prices).toEqual([
expect.objectContaining({
price_list: null,
}),
@@ -131,11 +129,10 @@ medusaIntegrationTestRunner({
})
it("should delete prices based on single product id", async () => {
let priceSetMoneyAmounts =
await pricingModuleService.listPriceSetMoneyAmounts({
price_set_id: [priceSet.id],
})
expect(priceSetMoneyAmounts.length).toEqual(2)
let prices = await pricingModuleService.listPrices({
price_set_id: [priceSet.id],
})
expect(prices.length).toEqual(2)
const deleteRes = await api.delete(
`/admin/price-lists/${priceListId}/products/${product.id}/prices`,
@@ -143,13 +140,12 @@ medusaIntegrationTestRunner({
)
expect(deleteRes.status).toEqual(200)
priceSetMoneyAmounts =
await pricingModuleService.listPriceSetMoneyAmounts({
price_set_id: [priceSet.id],
})
prices = await pricingModuleService.listPrices({
price_set_id: [priceSet.id],
})
expect(priceSetMoneyAmounts.length).toEqual(1)
expect(priceSetMoneyAmounts).toEqual([
expect(prices.length).toEqual(1)
expect(prices).toEqual([
expect.objectContaining({
price_list: null,
}),
@@ -4,10 +4,10 @@ import {
} from "../../../../factories"
import { IPricingModuleService } from "@medusajs/types"
import { medusaIntegrationTestRunner } from "medusa-test-utils"
import adminSeeder from "../../../../helpers/admin-seeder"
import { createDefaultRuleTypes } from "../../../helpers/create-default-rule-types"
import { createVariantPriceSet } from "../../../helpers/create-variant-price-set"
import { medusaIntegrationTestRunner } from "medusa-test-utils"
jest.setTimeout(50000)
@@ -94,10 +94,10 @@ medusaIntegrationTestRunner({
const result = await api.post(`admin/price-lists`, data, adminHeaders)
const priceListId = result.data.price_list.id
let psmas = await pricingModuleService.listPriceSetMoneyAmounts({
let prices = await pricingModuleService.listPrices({
price_list_id: [priceListId],
})
expect(psmas.length).toEqual(1)
expect(prices.length).toEqual(1)
const deleteRes = await api.delete(
`/admin/price-lists/${priceListId}/variants/${variant.id}/prices`,
@@ -105,10 +105,10 @@ medusaIntegrationTestRunner({
)
expect(deleteRes.status).toEqual(200)
psmas = await pricingModuleService.listPriceSetMoneyAmounts({
prices = await pricingModuleService.listPrices({
price_list_id: [priceListId],
})
expect(psmas.length).toEqual(0)
expect(prices.length).toEqual(0)
})
})
},
@@ -4,10 +4,10 @@ import {
} from "../../../../factories"
import { IPricingModuleService } from "@medusajs/types"
import { medusaIntegrationTestRunner } from "medusa-test-utils"
import adminSeeder from "../../../../helpers/admin-seeder"
import { createDefaultRuleTypes } from "../../../helpers/create-default-rule-types"
import { createVariantPriceSet } from "../../../helpers/create-variant-price-set"
import { medusaIntegrationTestRunner } from "medusa-test-utils"
jest.setTimeout(50000)
@@ -98,16 +98,16 @@ medusaIntegrationTestRunner({
const res = await api.post(`admin/price-lists`, data, adminHeaders)
const priceListId = res.data.price_list.id
let psmas = await pricingModuleService.listPriceSetMoneyAmounts(
let prices = await pricingModuleService.listPrices(
{
price_list_id: [priceListId],
},
{ relations: ["money_amount"] }
{}
)
expect(psmas.length).toEqual(2)
expect(prices.length).toEqual(2)
const deletePrice = psmas[0].money_amount
const deletePrice = prices[0]
const deleteRes = await api.delete(
`/admin/price-lists/${priceListId}/prices/batch`,
{
@@ -119,10 +119,10 @@ medusaIntegrationTestRunner({
)
expect(deleteRes.status).toEqual(200)
psmas = await pricingModuleService.listPriceSetMoneyAmounts({
prices = await pricingModuleService.listPrices({
price_list_id: [priceListId],
})
expect(psmas.length).toEqual(1)
expect(prices.length).toEqual(1)
})
})
},
@@ -366,11 +366,11 @@ medusaIntegrationTestRunner({
const result = await api.post(`admin/price-lists`, data, adminHeaders)
const priceListId = result.data.price_list.id
let psmas = await pricingModule.listPriceSetMoneyAmounts({
let prices = await pricingModule.listPrices({
price_list_id: [priceListId],
})
expect(psmas.length).toEqual(1)
expect(prices.length).toEqual(1)
const deleteRes = await api.delete(
`/admin/price-lists/${priceListId}`,
@@ -385,10 +385,10 @@ medusaIntegrationTestRunner({
expect(afterDelete.response.status).toEqual(404)
psmas = await pricingModule.listPriceSetMoneyAmounts({
prices = await pricingModule.listPrices({
price_list_id: [priceListId],
})
expect(psmas.length).toEqual(0)
expect(prices.length).toEqual(0)
})
it("should idempotently return a success even if price lists dont exist", async () => {
@@ -609,13 +609,13 @@ medusaIntegrationTestRunner({
const [priceList] = await pricingModule.listPriceLists(
{ id: [createdPriceList.id] },
{ relations: ["price_set_money_amounts"] }
{ relations: ["prices"] }
)
const psmaIdToDelete = priceList.price_set_money_amounts![0].id
const priceIdToDelete = priceList.prices![0].id
const response = await api.post(
`/admin/price-lists/${priceList.id}/prices/batch/remove`,
{ ids: [psmaIdToDelete] },
{ ids: [priceIdToDelete] },
adminHeaders
)
@@ -19,7 +19,8 @@ const env = {
medusaIntegrationTestRunner({
env,
testSuite: ({ dbConnection, getContainer, api }) => {
describe("/admin/products", () => {
// TODO: unskip this when there is a module compatible productSeeder
describe.skip("/admin/products", () => {
let medusaContainer
beforeAll(async () => {
@@ -41,6 +41,6 @@ export const createVariantPriceSet = async ({
})
return await pricingModuleService.retrieve(priceSet.id, {
relations: ["price_set_money_amounts"],
relations: ["prices"],
})
}