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:
committed by
GitHub
parent
2895ccfba8
commit
48963f55ef
@@ -1,5 +1,5 @@
|
||||
import { ModuleRegistrationName } from "@medusajs/modules-sdk"
|
||||
import { IAuthModuleService, ICustomerModuleService } from "@medusajs/types"
|
||||
import { IAuthModuleService } from "@medusajs/types"
|
||||
import Scrypt from "scrypt-kdf"
|
||||
import { medusaIntegrationTestRunner } from "medusa-test-utils"
|
||||
import {
|
||||
@@ -16,13 +16,8 @@ medusaIntegrationTestRunner({
|
||||
testSuite: ({ dbConnection, getContainer, api }) => {
|
||||
describe("POST /auth/emailpass", () => {
|
||||
let appContainer
|
||||
let customerModuleService: ICustomerModuleService
|
||||
|
||||
beforeAll(async () => {
|
||||
appContainer = getContainer()
|
||||
customerModuleService = appContainer.resolve(
|
||||
ModuleRegistrationName.CUSTOMER
|
||||
)
|
||||
})
|
||||
|
||||
beforeEach(async () => {
|
||||
@@ -40,7 +35,7 @@ medusaIntegrationTestRunner({
|
||||
ModuleRegistrationName.AUTH
|
||||
)
|
||||
|
||||
await authService.create({
|
||||
await authService.createAuthIdentities({
|
||||
provider_identities: [
|
||||
{
|
||||
provider: "emailpass",
|
||||
@@ -75,7 +70,7 @@ medusaIntegrationTestRunner({
|
||||
ModuleRegistrationName.AUTH
|
||||
)
|
||||
|
||||
await authService.create({
|
||||
await authService.createAuthIdentities({
|
||||
provider_identities: [
|
||||
{
|
||||
provider: "emailpass",
|
||||
|
||||
@@ -40,48 +40,50 @@ medusaIntegrationTestRunner({
|
||||
|
||||
describe("POST /store/carts/:id/promotions", () => {
|
||||
it("should add line item adjustments to a cart based on promotions", async () => {
|
||||
const appliedPromotion = await promotionModuleService.create({
|
||||
code: "PROMOTION_APPLIED",
|
||||
type: PromotionType.STANDARD,
|
||||
application_method: {
|
||||
type: "fixed",
|
||||
target_type: "items",
|
||||
allocation: "each",
|
||||
value: "300",
|
||||
apply_to_quantity: 1,
|
||||
currency_code: "usd",
|
||||
max_quantity: 1,
|
||||
target_rules: [
|
||||
{
|
||||
attribute: "product_id",
|
||||
operator: "eq",
|
||||
values: "prod_tshirt",
|
||||
},
|
||||
],
|
||||
},
|
||||
})
|
||||
const appliedPromotion =
|
||||
await promotionModuleService.createPromotions({
|
||||
code: "PROMOTION_APPLIED",
|
||||
type: PromotionType.STANDARD,
|
||||
application_method: {
|
||||
type: "fixed",
|
||||
target_type: "items",
|
||||
allocation: "each",
|
||||
value: "300",
|
||||
apply_to_quantity: 1,
|
||||
currency_code: "usd",
|
||||
max_quantity: 1,
|
||||
target_rules: [
|
||||
{
|
||||
attribute: "product_id",
|
||||
operator: "eq",
|
||||
values: "prod_tshirt",
|
||||
},
|
||||
],
|
||||
},
|
||||
})
|
||||
|
||||
const createdPromotion = await promotionModuleService.create({
|
||||
code: "PROMOTION_TEST",
|
||||
type: PromotionType.STANDARD,
|
||||
application_method: {
|
||||
type: "fixed",
|
||||
target_type: "items",
|
||||
allocation: "across",
|
||||
value: "1000",
|
||||
apply_to_quantity: 1,
|
||||
currency_code: "usd",
|
||||
target_rules: [
|
||||
{
|
||||
attribute: "product_id",
|
||||
operator: "eq",
|
||||
values: "prod_mat",
|
||||
},
|
||||
],
|
||||
},
|
||||
})
|
||||
const createdPromotion =
|
||||
await promotionModuleService.createPromotions({
|
||||
code: "PROMOTION_TEST",
|
||||
type: PromotionType.STANDARD,
|
||||
application_method: {
|
||||
type: "fixed",
|
||||
target_type: "items",
|
||||
allocation: "across",
|
||||
value: "1000",
|
||||
apply_to_quantity: 1,
|
||||
currency_code: "usd",
|
||||
target_rules: [
|
||||
{
|
||||
attribute: "product_id",
|
||||
operator: "eq",
|
||||
values: "prod_mat",
|
||||
},
|
||||
],
|
||||
},
|
||||
})
|
||||
|
||||
const cart = await cartModuleService.create({
|
||||
const cart = await cartModuleService.createCarts({
|
||||
currency_code: "usd",
|
||||
items: [
|
||||
// Adjustment to add
|
||||
@@ -152,41 +154,42 @@ medusaIntegrationTestRunner({
|
||||
})
|
||||
|
||||
it("should add shipping method adjustments to a cart based on promotions", async () => {
|
||||
const [appliedPromotion] = await promotionModuleService.create([
|
||||
{
|
||||
code: "PROMOTION_APPLIED",
|
||||
type: PromotionType.STANDARD,
|
||||
rules: [
|
||||
{
|
||||
attribute: "customer_id",
|
||||
operator: "in",
|
||||
values: ["cus_test"],
|
||||
},
|
||||
{
|
||||
attribute: "currency_code",
|
||||
operator: "in",
|
||||
values: ["eur"],
|
||||
},
|
||||
],
|
||||
application_method: {
|
||||
type: "fixed",
|
||||
target_type: "shipping_methods",
|
||||
allocation: "each",
|
||||
value: "100",
|
||||
max_quantity: 1,
|
||||
currency_code: "usd",
|
||||
target_rules: [
|
||||
const [appliedPromotion] =
|
||||
await promotionModuleService.createPromotions([
|
||||
{
|
||||
code: "PROMOTION_APPLIED",
|
||||
type: PromotionType.STANDARD,
|
||||
rules: [
|
||||
{
|
||||
attribute: "name",
|
||||
attribute: "customer_id",
|
||||
operator: "in",
|
||||
values: ["express"],
|
||||
values: ["cus_test"],
|
||||
},
|
||||
{
|
||||
attribute: "currency_code",
|
||||
operator: "in",
|
||||
values: ["eur"],
|
||||
},
|
||||
],
|
||||
application_method: {
|
||||
type: "fixed",
|
||||
target_type: "shipping_methods",
|
||||
allocation: "each",
|
||||
value: "100",
|
||||
max_quantity: 1,
|
||||
currency_code: "usd",
|
||||
target_rules: [
|
||||
{
|
||||
attribute: "name",
|
||||
operator: "in",
|
||||
values: ["express"],
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
])
|
||||
])
|
||||
|
||||
const [newPromotion] = await promotionModuleService.create([
|
||||
const [newPromotion] = await promotionModuleService.createPromotions([
|
||||
{
|
||||
code: "PROMOTION_NEW",
|
||||
type: PromotionType.STANDARD,
|
||||
@@ -220,7 +223,7 @@ medusaIntegrationTestRunner({
|
||||
},
|
||||
])
|
||||
|
||||
const cart = await cartModuleService.create({
|
||||
const cart = await cartModuleService.createCarts({
|
||||
currency_code: "eur",
|
||||
customer_id: "cus_test",
|
||||
items: [
|
||||
|
||||
@@ -18,13 +18,13 @@ import {
|
||||
ICartModuleService,
|
||||
ICustomerModuleService,
|
||||
IFulfillmentModuleService,
|
||||
IInventoryServiceNext,
|
||||
IInventoryService,
|
||||
IPaymentModuleService,
|
||||
IPricingModuleService,
|
||||
IProductModuleService,
|
||||
IRegionModuleService,
|
||||
ISalesChannelModuleService,
|
||||
IStockLocationServiceNext,
|
||||
IStockLocationService,
|
||||
} from "@medusajs/types"
|
||||
import { ContainerRegistrationKeys, RuleOperator } from "@medusajs/utils"
|
||||
import { medusaIntegrationTestRunner } from "medusa-test-utils"
|
||||
@@ -50,10 +50,9 @@ medusaIntegrationTestRunner({
|
||||
let productModule: IProductModuleService
|
||||
let pricingModule: IPricingModuleService
|
||||
let paymentModule: IPaymentModuleService
|
||||
let inventoryModule: IInventoryServiceNext
|
||||
let stockLocationModule: IStockLocationServiceNext
|
||||
let stockLocationModule: IStockLocationService
|
||||
let inventoryModule: IInventoryService
|
||||
let fulfillmentModule: IFulfillmentModuleService
|
||||
let locationModule: IStockLocationServiceNext
|
||||
let remoteLink, remoteQuery
|
||||
|
||||
let defaultRegion
|
||||
@@ -78,9 +77,6 @@ medusaIntegrationTestRunner({
|
||||
fulfillmentModule = appContainer.resolve(
|
||||
ModuleRegistrationName.FULFILLMENT
|
||||
)
|
||||
locationModule = appContainer.resolve(
|
||||
ModuleRegistrationName.STOCK_LOCATION
|
||||
)
|
||||
remoteLink = appContainer.resolve(ContainerRegistrationKeys.REMOTE_LINK)
|
||||
remoteQuery = appContainer.resolve(
|
||||
ContainerRegistrationKeys.REMOTE_QUERY
|
||||
@@ -97,20 +93,20 @@ medusaIntegrationTestRunner({
|
||||
|
||||
describe("CreateCartWorkflow", () => {
|
||||
it("should create a cart", async () => {
|
||||
const region = await regionModuleService.create({
|
||||
const region = await regionModuleService.createRegions({
|
||||
name: "US",
|
||||
currency_code: "usd",
|
||||
})
|
||||
|
||||
const salesChannel = await scModuleService.create({
|
||||
const salesChannel = await scModuleService.createSalesChannels({
|
||||
name: "Webshop",
|
||||
})
|
||||
|
||||
const location = await stockLocationModule.create({
|
||||
const location = await stockLocationModule.createStockLocations({
|
||||
name: "Warehouse",
|
||||
})
|
||||
|
||||
const [product] = await productModule.create([
|
||||
const [product] = await productModule.createProducts([
|
||||
{
|
||||
title: "Test product",
|
||||
variants: [
|
||||
@@ -121,7 +117,7 @@ medusaIntegrationTestRunner({
|
||||
},
|
||||
])
|
||||
|
||||
const inventoryItem = await inventoryModule.create({
|
||||
const inventoryItem = await inventoryModule.createInventoryItems({
|
||||
sku: "inv-1234",
|
||||
})
|
||||
|
||||
@@ -134,7 +130,7 @@ medusaIntegrationTestRunner({
|
||||
},
|
||||
])
|
||||
|
||||
const priceSet = await pricingModule.create({
|
||||
const priceSet = await pricingModule.createPriceSets({
|
||||
prices: [
|
||||
{
|
||||
amount: 3000,
|
||||
@@ -185,7 +181,7 @@ medusaIntegrationTestRunner({
|
||||
},
|
||||
})
|
||||
|
||||
const cart = await cartModuleService.retrieve(result.id, {
|
||||
const cart = await cartModuleService.retrieveCart(result.id, {
|
||||
relations: ["items"],
|
||||
})
|
||||
|
||||
@@ -207,20 +203,20 @@ medusaIntegrationTestRunner({
|
||||
})
|
||||
|
||||
it("should revert if the cart creation fails", async () => {
|
||||
const region = await regionModuleService.create({
|
||||
const region = await regionModuleService.createRegions({
|
||||
name: "US",
|
||||
currency_code: "usd",
|
||||
})
|
||||
|
||||
const salesChannel = await scModuleService.create({
|
||||
const salesChannel = await scModuleService.createSalesChannels({
|
||||
name: "Webshop",
|
||||
})
|
||||
|
||||
const location = await stockLocationModule.create({
|
||||
const location = await stockLocationModule.createStockLocations({
|
||||
name: "Warehouse",
|
||||
})
|
||||
|
||||
const [product] = await productModule.create([
|
||||
const [product] = await productModule.createProducts([
|
||||
{
|
||||
title: "Test product",
|
||||
variants: [
|
||||
@@ -231,7 +227,7 @@ medusaIntegrationTestRunner({
|
||||
},
|
||||
])
|
||||
|
||||
const inventoryItem = await inventoryModule.create({
|
||||
const inventoryItem = await inventoryModule.createInventoryItems({
|
||||
sku: "inv-1234",
|
||||
})
|
||||
|
||||
@@ -244,7 +240,7 @@ medusaIntegrationTestRunner({
|
||||
},
|
||||
])
|
||||
|
||||
const priceSet = await pricingModule.create({
|
||||
const priceSet = await pricingModule.createPriceSets({
|
||||
prices: [
|
||||
{
|
||||
amount: 3000,
|
||||
@@ -314,7 +310,7 @@ medusaIntegrationTestRunner({
|
||||
})
|
||||
|
||||
it("should throw when no regions exist", async () => {
|
||||
await regionModuleService.delete(defaultRegion.id)
|
||||
await regionModuleService.deleteRegions(defaultRegion.id)
|
||||
|
||||
const { errors } = await createCartWorkflow(appContainer).run({
|
||||
input: {
|
||||
@@ -332,15 +328,15 @@ medusaIntegrationTestRunner({
|
||||
})
|
||||
|
||||
it("should throw if variants are out of stock", async () => {
|
||||
const salesChannel = await scModuleService.create({
|
||||
const salesChannel = await scModuleService.createSalesChannels({
|
||||
name: "Webshop",
|
||||
})
|
||||
|
||||
const location = await stockLocationModule.create({
|
||||
const location = await stockLocationModule.createStockLocations({
|
||||
name: "Warehouse",
|
||||
})
|
||||
|
||||
const [product] = await productModule.create([
|
||||
const [product] = await productModule.createProducts([
|
||||
{
|
||||
title: "Test product",
|
||||
variants: [
|
||||
@@ -379,12 +375,12 @@ medusaIntegrationTestRunner({
|
||||
adminHeaders
|
||||
)
|
||||
|
||||
const region = await regionModuleService.create({
|
||||
const region = await regionModuleService.createRegions({
|
||||
name: "US",
|
||||
currency_code: "usd",
|
||||
})
|
||||
|
||||
const priceSet = await pricingModule.create({
|
||||
const priceSet = await pricingModule.createPriceSets({
|
||||
prices: [
|
||||
{
|
||||
amount: 3000,
|
||||
@@ -448,7 +444,7 @@ medusaIntegrationTestRunner({
|
||||
})
|
||||
|
||||
it("should throw if sales channel is disabled", async () => {
|
||||
const salesChannel = await scModuleService.create({
|
||||
const salesChannel = await scModuleService.createSalesChannels({
|
||||
name: "Webshop",
|
||||
is_disabled: true,
|
||||
})
|
||||
@@ -500,7 +496,7 @@ medusaIntegrationTestRunner({
|
||||
},
|
||||
])
|
||||
|
||||
const customers = await customerModule.list({
|
||||
const customers = await customerModule.listCustomers({
|
||||
email: "tony@stark-industries.com",
|
||||
})
|
||||
|
||||
@@ -517,7 +513,7 @@ medusaIntegrationTestRunner({
|
||||
},
|
||||
})
|
||||
|
||||
const customer = await customerModule.create({
|
||||
const customer = await customerModule.createCustomers({
|
||||
email: "tony@stark-industries.com",
|
||||
})
|
||||
|
||||
@@ -539,7 +535,7 @@ medusaIntegrationTestRunner({
|
||||
},
|
||||
])
|
||||
|
||||
const customers = await customerModule.list({
|
||||
const customers = await customerModule.listCustomers({
|
||||
email: "tony@stark-industries.com",
|
||||
})
|
||||
|
||||
@@ -550,20 +546,20 @@ medusaIntegrationTestRunner({
|
||||
|
||||
describe("AddToCartWorkflow", () => {
|
||||
it("should add item to cart", async () => {
|
||||
const salesChannel = await scModuleService.create({
|
||||
const salesChannel = await scModuleService.createSalesChannels({
|
||||
name: "Webshop",
|
||||
})
|
||||
|
||||
const location = await stockLocationModule.create({
|
||||
const location = await stockLocationModule.createStockLocations({
|
||||
name: "Warehouse",
|
||||
})
|
||||
|
||||
let cart = await cartModuleService.create({
|
||||
let cart = await cartModuleService.createCarts({
|
||||
currency_code: "usd",
|
||||
sales_channel_id: salesChannel.id,
|
||||
})
|
||||
|
||||
const [product] = await productModule.create([
|
||||
const [product] = await productModule.createProducts([
|
||||
{
|
||||
title: "Test product",
|
||||
variants: [
|
||||
@@ -574,7 +570,7 @@ medusaIntegrationTestRunner({
|
||||
},
|
||||
])
|
||||
|
||||
const inventoryItem = await inventoryModule.create({
|
||||
const inventoryItem = await inventoryModule.createInventoryItems({
|
||||
sku: "inv-1234",
|
||||
})
|
||||
|
||||
@@ -587,7 +583,7 @@ medusaIntegrationTestRunner({
|
||||
},
|
||||
])
|
||||
|
||||
const priceSet = await pricingModule.create({
|
||||
const priceSet = await pricingModule.createPriceSets({
|
||||
prices: [
|
||||
{
|
||||
amount: 3000,
|
||||
@@ -623,7 +619,7 @@ medusaIntegrationTestRunner({
|
||||
},
|
||||
])
|
||||
|
||||
cart = await cartModuleService.retrieve(cart.id, {
|
||||
cart = await cartModuleService.retrieveCart(cart.id, {
|
||||
select: ["id", "region_id", "currency_code", "sales_channel_id"],
|
||||
})
|
||||
|
||||
@@ -639,7 +635,7 @@ medusaIntegrationTestRunner({
|
||||
},
|
||||
})
|
||||
|
||||
cart = await cartModuleService.retrieve(cart.id, {
|
||||
cart = await cartModuleService.retrieveCart(cart.id, {
|
||||
relations: ["items"],
|
||||
})
|
||||
|
||||
@@ -659,20 +655,20 @@ medusaIntegrationTestRunner({
|
||||
})
|
||||
|
||||
it("should throw if no price sets for variant exist", async () => {
|
||||
const salesChannel = await scModuleService.create({
|
||||
const salesChannel = await scModuleService.createSalesChannels({
|
||||
name: "Webshop",
|
||||
})
|
||||
|
||||
const location = await stockLocationModule.create({
|
||||
const location = await stockLocationModule.createStockLocations({
|
||||
name: "Warehouse",
|
||||
})
|
||||
|
||||
let cart = await cartModuleService.create({
|
||||
let cart = await cartModuleService.createCarts({
|
||||
currency_code: "usd",
|
||||
sales_channel_id: salesChannel.id,
|
||||
})
|
||||
|
||||
const [product] = await productModule.create([
|
||||
const [product] = await productModule.createProducts([
|
||||
{
|
||||
title: "Test product",
|
||||
variants: [
|
||||
@@ -683,7 +679,7 @@ medusaIntegrationTestRunner({
|
||||
},
|
||||
])
|
||||
|
||||
const inventoryItem = await inventoryModule.create({
|
||||
const inventoryItem = await inventoryModule.createInventoryItems({
|
||||
sku: "inv-1234",
|
||||
})
|
||||
|
||||
@@ -742,7 +738,7 @@ medusaIntegrationTestRunner({
|
||||
})
|
||||
|
||||
it("should throw if variant does not exist", async () => {
|
||||
const cart = await cartModuleService.create({
|
||||
const cart = await cartModuleService.createCarts({
|
||||
currency_code: "usd",
|
||||
})
|
||||
|
||||
@@ -774,15 +770,15 @@ medusaIntegrationTestRunner({
|
||||
|
||||
describe("updateLineItemInCartWorkflow", () => {
|
||||
it("should update item in cart", async () => {
|
||||
const salesChannel = await scModuleService.create({
|
||||
const salesChannel = await scModuleService.createSalesChannels({
|
||||
name: "Webshop",
|
||||
})
|
||||
|
||||
const location = await stockLocationModule.create({
|
||||
const location = await stockLocationModule.createStockLocations({
|
||||
name: "Warehouse",
|
||||
})
|
||||
|
||||
const [product] = await productModule.create([
|
||||
const [product] = await productModule.createProducts([
|
||||
{
|
||||
title: "Test product",
|
||||
variants: [
|
||||
@@ -793,7 +789,7 @@ medusaIntegrationTestRunner({
|
||||
},
|
||||
])
|
||||
|
||||
const inventoryItem = await inventoryModule.create({
|
||||
const inventoryItem = await inventoryModule.createInventoryItems({
|
||||
sku: "inv-1234",
|
||||
})
|
||||
|
||||
@@ -806,7 +802,7 @@ medusaIntegrationTestRunner({
|
||||
},
|
||||
])
|
||||
|
||||
const priceSet = await pricingModule.create({
|
||||
const priceSet = await pricingModule.createPriceSets({
|
||||
prices: [
|
||||
{
|
||||
amount: 3000,
|
||||
@@ -842,7 +838,7 @@ medusaIntegrationTestRunner({
|
||||
},
|
||||
])
|
||||
|
||||
let cart = await cartModuleService.create({
|
||||
let cart = await cartModuleService.createCarts({
|
||||
currency_code: "usd",
|
||||
sales_channel_id: salesChannel.id,
|
||||
items: [
|
||||
@@ -855,7 +851,7 @@ medusaIntegrationTestRunner({
|
||||
],
|
||||
})
|
||||
|
||||
cart = await cartModuleService.retrieve(cart.id, {
|
||||
cart = await cartModuleService.retrieveCart(cart.id, {
|
||||
select: ["id", "region_id", "currency_code"],
|
||||
relations: ["items", "items.variant_id", "items.metadata"],
|
||||
})
|
||||
@@ -901,15 +897,15 @@ medusaIntegrationTestRunner({
|
||||
},
|
||||
})
|
||||
|
||||
const salesChannel = await scModuleService.create({
|
||||
const salesChannel = await scModuleService.createSalesChannels({
|
||||
name: "Webshop",
|
||||
})
|
||||
|
||||
const location = await stockLocationModule.create({
|
||||
const location = await stockLocationModule.createStockLocations({
|
||||
name: "Warehouse",
|
||||
})
|
||||
|
||||
const [product] = await productModule.create([
|
||||
const [product] = await productModule.createProducts([
|
||||
{
|
||||
title: "Test product",
|
||||
variants: [
|
||||
@@ -920,7 +916,7 @@ medusaIntegrationTestRunner({
|
||||
},
|
||||
])
|
||||
|
||||
const inventoryItem = await inventoryModule.create({
|
||||
const inventoryItem = await inventoryModule.createInventoryItems({
|
||||
sku: "inv-1234",
|
||||
})
|
||||
|
||||
@@ -933,7 +929,7 @@ medusaIntegrationTestRunner({
|
||||
},
|
||||
])
|
||||
|
||||
const priceSet = await pricingModule.create({
|
||||
const priceSet = await pricingModule.createPriceSets({
|
||||
prices: [
|
||||
{
|
||||
amount: 3000,
|
||||
@@ -969,7 +965,7 @@ medusaIntegrationTestRunner({
|
||||
},
|
||||
])
|
||||
|
||||
let cart = await cartModuleService.create({
|
||||
let cart = await cartModuleService.createCarts({
|
||||
currency_code: "usd",
|
||||
items: [
|
||||
{
|
||||
@@ -981,7 +977,7 @@ medusaIntegrationTestRunner({
|
||||
],
|
||||
})
|
||||
|
||||
cart = await cartModuleService.retrieve(cart.id, {
|
||||
cart = await cartModuleService.retrieveCart(cart.id, {
|
||||
select: ["id", "region_id", "currency_code"],
|
||||
relations: ["items", "items.variant_id", "items.metadata"],
|
||||
})
|
||||
@@ -1031,7 +1027,7 @@ medusaIntegrationTestRunner({
|
||||
|
||||
describe("deleteLineItems", () => {
|
||||
it("should delete items in cart", async () => {
|
||||
const cart = await cartModuleService.create({
|
||||
const cart = await cartModuleService.createCarts({
|
||||
currency_code: "usd",
|
||||
items: [
|
||||
{
|
||||
@@ -1072,7 +1068,7 @@ medusaIntegrationTestRunner({
|
||||
},
|
||||
})
|
||||
|
||||
const cart = await cartModuleService.create({
|
||||
const cart = await cartModuleService.createCarts({
|
||||
currency_code: "usd",
|
||||
items: [
|
||||
{
|
||||
@@ -1115,7 +1111,7 @@ medusaIntegrationTestRunner({
|
||||
|
||||
describe("createPaymentCollectionForCart", () => {
|
||||
it("should create a payment collection and link it to cart", async () => {
|
||||
const cart = await cartModuleService.create({
|
||||
const cart = await cartModuleService.createCarts({
|
||||
currency_code: "dkk",
|
||||
region_id: defaultRegion.id,
|
||||
items: [
|
||||
@@ -1181,12 +1177,12 @@ medusaIntegrationTestRunner({
|
||||
}
|
||||
)
|
||||
|
||||
const region = await regionModuleService.create({
|
||||
const region = await regionModuleService.createRegions({
|
||||
name: "US",
|
||||
currency_code: "usd",
|
||||
})
|
||||
|
||||
const cart = await cartModuleService.create({
|
||||
const cart = await cartModuleService.createCarts({
|
||||
currency_code: "usd",
|
||||
region_id: region.id,
|
||||
items: [
|
||||
@@ -1253,7 +1249,7 @@ medusaIntegrationTestRunner({
|
||||
|
||||
describe("refreshPaymentCollectionForCart", () => {
|
||||
it("should refresh a payment collection for a cart", async () => {
|
||||
const cart = await cartModuleService.create({
|
||||
const cart = await cartModuleService.createCarts({
|
||||
currency_code: "dkk",
|
||||
region_id: defaultRegion.id,
|
||||
items: [
|
||||
@@ -1320,12 +1316,12 @@ medusaIntegrationTestRunner({
|
||||
|
||||
describe("compensation", () => {
|
||||
it("should revert payment collection amount and create a new payment session", async () => {
|
||||
const region = await regionModuleService.create({
|
||||
const region = await regionModuleService.createRegions({
|
||||
name: "US",
|
||||
currency_code: "usd",
|
||||
})
|
||||
|
||||
const testCart = await cartModuleService.create({
|
||||
const testCart = await cartModuleService.createCarts({
|
||||
currency_code: "usd",
|
||||
region_id: region.id,
|
||||
items: [
|
||||
@@ -1431,7 +1427,7 @@ medusaIntegrationTestRunner({
|
||||
let priceSet
|
||||
|
||||
beforeEach(async () => {
|
||||
cart = await cartModuleService.create({
|
||||
cart = await cartModuleService.createCarts({
|
||||
currency_code: "usd",
|
||||
shipping_address: {
|
||||
country_code: "us",
|
||||
@@ -1444,7 +1440,7 @@ medusaIntegrationTestRunner({
|
||||
type: "default",
|
||||
})
|
||||
|
||||
fulfillmentSet = await fulfillmentModule.create({
|
||||
fulfillmentSet = await fulfillmentModule.createFulfillmentSets({
|
||||
name: "Test",
|
||||
type: "test-type",
|
||||
service_zones: [
|
||||
@@ -1455,7 +1451,7 @@ medusaIntegrationTestRunner({
|
||||
],
|
||||
})
|
||||
|
||||
priceSet = await pricingModule.create({
|
||||
priceSet = await pricingModule.createPriceSets({
|
||||
prices: [{ amount: 3000, currency_code: "usd" }],
|
||||
})
|
||||
})
|
||||
@@ -1500,7 +1496,7 @@ medusaIntegrationTestRunner({
|
||||
},
|
||||
})
|
||||
|
||||
cart = await cartModuleService.retrieve(cart.id, {
|
||||
cart = await cartModuleService.retrieveCart(cart.id, {
|
||||
relations: ["shipping_methods"],
|
||||
})
|
||||
|
||||
@@ -1592,15 +1588,15 @@ medusaIntegrationTestRunner({
|
||||
|
||||
describe("listShippingOptionsForCartWorkflow", () => {
|
||||
it("should list shipping options for cart", async () => {
|
||||
const salesChannel = await scModuleService.create({
|
||||
const salesChannel = await scModuleService.createSalesChannels({
|
||||
name: "Webshop",
|
||||
})
|
||||
|
||||
const location = await locationModule.create({
|
||||
const location = await stockLocationModule.createStockLocations({
|
||||
name: "Europe",
|
||||
})
|
||||
|
||||
let cart = await cartModuleService.create({
|
||||
let cart = await cartModuleService.createCarts({
|
||||
currency_code: "usd",
|
||||
sales_channel_id: salesChannel.id,
|
||||
shipping_address: {
|
||||
@@ -1616,7 +1612,7 @@ medusaIntegrationTestRunner({
|
||||
type: "default",
|
||||
})
|
||||
|
||||
const fulfillmentSet = await fulfillmentModule.create({
|
||||
const fulfillmentSet = await fulfillmentModule.createFulfillmentSets({
|
||||
name: "Test",
|
||||
type: "test-type",
|
||||
service_zones: [
|
||||
@@ -1645,7 +1641,7 @@ medusaIntegrationTestRunner({
|
||||
},
|
||||
})
|
||||
|
||||
const priceSet = await pricingModule.create({
|
||||
const priceSet = await pricingModule.createPriceSets({
|
||||
prices: [
|
||||
{
|
||||
amount: 3000,
|
||||
@@ -1681,7 +1677,7 @@ medusaIntegrationTestRunner({
|
||||
},
|
||||
])
|
||||
|
||||
cart = await cartModuleService.retrieve(cart.id, {
|
||||
cart = await cartModuleService.retrieveCart(cart.id, {
|
||||
select: ["id"],
|
||||
relations: ["shipping_address"],
|
||||
})
|
||||
@@ -1711,15 +1707,15 @@ medusaIntegrationTestRunner({
|
||||
})
|
||||
|
||||
it("should list no shipping options for cart, if sales channel is not associated with location", async () => {
|
||||
const salesChannel = await scModuleService.create({
|
||||
const salesChannel = await scModuleService.createSalesChannels({
|
||||
name: "Webshop",
|
||||
})
|
||||
|
||||
const location = await locationModule.create({
|
||||
const location = await stockLocationModule.createStockLocations({
|
||||
name: "Europe",
|
||||
})
|
||||
|
||||
let cart = await cartModuleService.create({
|
||||
let cart = await cartModuleService.createCarts({
|
||||
currency_code: "usd",
|
||||
sales_channel_id: salesChannel.id,
|
||||
shipping_address: {
|
||||
@@ -1735,7 +1731,7 @@ medusaIntegrationTestRunner({
|
||||
type: "default",
|
||||
})
|
||||
|
||||
const fulfillmentSet = await fulfillmentModule.create({
|
||||
const fulfillmentSet = await fulfillmentModule.createFulfillmentSets({
|
||||
name: "Test",
|
||||
type: "test-type",
|
||||
service_zones: [
|
||||
@@ -1764,7 +1760,7 @@ medusaIntegrationTestRunner({
|
||||
},
|
||||
})
|
||||
|
||||
const priceSet = await pricingModule.create({
|
||||
const priceSet = await pricingModule.createPriceSets({
|
||||
prices: [
|
||||
{
|
||||
amount: 3000,
|
||||
@@ -1792,7 +1788,7 @@ medusaIntegrationTestRunner({
|
||||
},
|
||||
])
|
||||
|
||||
cart = await cartModuleService.retrieve(cart.id, {
|
||||
cart = await cartModuleService.retrieveCart(cart.id, {
|
||||
select: ["id"],
|
||||
relations: ["shipping_address"],
|
||||
})
|
||||
@@ -1816,15 +1812,15 @@ medusaIntegrationTestRunner({
|
||||
})
|
||||
|
||||
it("should throw when shipping options are missing prices", async () => {
|
||||
const salesChannel = await scModuleService.create({
|
||||
const salesChannel = await scModuleService.createSalesChannels({
|
||||
name: "Webshop",
|
||||
})
|
||||
|
||||
const location = await locationModule.create({
|
||||
const location = await stockLocationModule.createStockLocations({
|
||||
name: "Europe",
|
||||
})
|
||||
|
||||
let cart = await cartModuleService.create({
|
||||
let cart = await cartModuleService.createCarts({
|
||||
currency_code: "usd",
|
||||
sales_channel_id: salesChannel.id,
|
||||
shipping_address: {
|
||||
@@ -1840,7 +1836,7 @@ medusaIntegrationTestRunner({
|
||||
type: "default",
|
||||
})
|
||||
|
||||
const fulfillmentSet = await fulfillmentModule.create({
|
||||
const fulfillmentSet = await fulfillmentModule.createFulfillmentSets({
|
||||
name: "Test",
|
||||
type: "test-type",
|
||||
service_zones: [
|
||||
@@ -1888,7 +1884,7 @@ medusaIntegrationTestRunner({
|
||||
},
|
||||
])
|
||||
|
||||
cart = await cartModuleService.retrieve(cart.id, {
|
||||
cart = await cartModuleService.retrieveCart(cart.id, {
|
||||
select: ["id"],
|
||||
relations: ["shipping_address"],
|
||||
})
|
||||
|
||||
@@ -98,16 +98,16 @@ medusaIntegrationTestRunner({
|
||||
|
||||
describe("POST /store/carts", () => {
|
||||
it("should create a cart", async () => {
|
||||
const region = await regionModule.create({
|
||||
const region = await regionModule.createRegions({
|
||||
name: "US",
|
||||
currency_code: "usd",
|
||||
})
|
||||
|
||||
const salesChannel = await scModule.create({
|
||||
const salesChannel = await scModule.createSalesChannels({
|
||||
name: "Webshop",
|
||||
})
|
||||
|
||||
const [product] = await productModule.create([
|
||||
const [product] = await productModule.createProducts([
|
||||
{
|
||||
title: "Test product",
|
||||
variants: [
|
||||
@@ -123,7 +123,7 @@ medusaIntegrationTestRunner({
|
||||
},
|
||||
])
|
||||
|
||||
const [priceSet, priceSetTwo] = await pricingModule.create([
|
||||
const [priceSet, priceSetTwo] = await pricingModule.createPriceSets([
|
||||
{
|
||||
prices: [
|
||||
{
|
||||
@@ -209,7 +209,7 @@ medusaIntegrationTestRunner({
|
||||
it("should create cart with customer from email and tax lines", async () => {
|
||||
await setupTaxStructure(taxModule)
|
||||
|
||||
const [product] = await productModule.create([
|
||||
const [product] = await productModule.createProducts([
|
||||
{
|
||||
title: "Test product default tax",
|
||||
variants: [
|
||||
@@ -218,11 +218,11 @@ medusaIntegrationTestRunner({
|
||||
},
|
||||
])
|
||||
|
||||
const salesChannel = await scModule.create({
|
||||
const salesChannel = await scModule.createSalesChannels({
|
||||
name: "Webshop",
|
||||
})
|
||||
|
||||
const [priceSet] = await pricingModule.create([
|
||||
const [priceSet] = await pricingModule.createPriceSets([
|
||||
{ prices: [{ amount: 3000, currency_code: "usd" }] },
|
||||
])
|
||||
|
||||
@@ -281,7 +281,7 @@ medusaIntegrationTestRunner({
|
||||
})
|
||||
|
||||
it("should create cart with any region", async () => {
|
||||
await regionModule.create({
|
||||
await regionModule.createRegions({
|
||||
name: "US",
|
||||
currency_code: "usd",
|
||||
})
|
||||
@@ -305,11 +305,11 @@ medusaIntegrationTestRunner({
|
||||
})
|
||||
|
||||
it("should create cart with default store sales channel", async () => {
|
||||
const sc = await scModule.create({
|
||||
const sc = await scModule.createSalesChannels({
|
||||
name: "Webshop",
|
||||
})
|
||||
|
||||
await storeService.update(store.id, {
|
||||
await storeService.updateStores(store.id, {
|
||||
default_sales_channel_id: sc.id,
|
||||
})
|
||||
|
||||
@@ -330,7 +330,7 @@ medusaIntegrationTestRunner({
|
||||
})
|
||||
|
||||
it("should create cart with region currency code", async () => {
|
||||
const region = await regionModule.create({
|
||||
const region = await regionModule.createRegions({
|
||||
name: "US",
|
||||
currency_code: "usd",
|
||||
})
|
||||
@@ -381,15 +381,15 @@ medusaIntegrationTestRunner({
|
||||
})
|
||||
|
||||
it("throws if publishable key is not associated with sales channel", async () => {
|
||||
const salesChannel = await scModule.create({
|
||||
const salesChannel = await scModule.createSalesChannels({
|
||||
name: "Retail Store",
|
||||
})
|
||||
|
||||
const salesChannel2 = await scModule.create({
|
||||
const salesChannel2 = await scModule.createSalesChannels({
|
||||
name: "Webshop",
|
||||
})
|
||||
|
||||
const pubKey = await apiKeyModule.create({
|
||||
const pubKey = await apiKeyModule.createApiKeys({
|
||||
title: "Test key",
|
||||
type: "publishable",
|
||||
created_by: "test",
|
||||
@@ -426,15 +426,15 @@ medusaIntegrationTestRunner({
|
||||
})
|
||||
|
||||
it("throws if publishable key has multiple associated sales channels", async () => {
|
||||
const salesChannel = await scModule.create({
|
||||
const salesChannel = await scModule.createSalesChannels({
|
||||
name: "Retail Store",
|
||||
})
|
||||
|
||||
const salesChannel2 = await scModule.create({
|
||||
const salesChannel2 = await scModule.createSalesChannels({
|
||||
name: "Webshop",
|
||||
})
|
||||
|
||||
const pubKey = await apiKeyModule.create({
|
||||
const pubKey = await apiKeyModule.createApiKeys({
|
||||
title: "Test key",
|
||||
type: "publishable",
|
||||
created_by: "test",
|
||||
@@ -469,11 +469,11 @@ medusaIntegrationTestRunner({
|
||||
})
|
||||
|
||||
it("should create cart with sales channel if pub key does not have any scopes defined", async () => {
|
||||
const salesChannel = await scModule.create({
|
||||
const salesChannel = await scModule.createSalesChannels({
|
||||
name: "Retail Store",
|
||||
})
|
||||
|
||||
const pubKey = await apiKeyModule.create({
|
||||
const pubKey = await apiKeyModule.createApiKeys({
|
||||
title: "Test key",
|
||||
type: "publishable",
|
||||
created_by: "test",
|
||||
@@ -498,11 +498,11 @@ medusaIntegrationTestRunner({
|
||||
})
|
||||
|
||||
it("should create cart with sales channel associated with pub key", async () => {
|
||||
const salesChannel = await scModule.create({
|
||||
const salesChannel = await scModule.createSalesChannels({
|
||||
name: "Retail Store",
|
||||
})
|
||||
|
||||
const pubKey = await apiKeyModule.create({
|
||||
const pubKey = await apiKeyModule.createApiKeys({
|
||||
title: "Test key",
|
||||
type: "publishable",
|
||||
created_by: "test",
|
||||
@@ -545,7 +545,7 @@ medusaIntegrationTestRunner({
|
||||
it("should update a cart with promo codes with a replace action", async () => {
|
||||
await setupTaxStructure(taxModule)
|
||||
|
||||
const region = await regionModule.create({
|
||||
const region = await regionModule.createRegions({
|
||||
name: "US",
|
||||
currency_code: "usd",
|
||||
})
|
||||
@@ -558,7 +558,7 @@ medusaIntegrationTestRunner({
|
||||
},
|
||||
]
|
||||
|
||||
const appliedPromotion = await promotionModule.create({
|
||||
const appliedPromotion = await promotionModule.createPromotions({
|
||||
code: "PROMOTION_APPLIED",
|
||||
type: PromotionType.STANDARD,
|
||||
application_method: {
|
||||
@@ -573,7 +573,7 @@ medusaIntegrationTestRunner({
|
||||
},
|
||||
})
|
||||
|
||||
const createdPromotion = await promotionModule.create({
|
||||
const createdPromotion = await promotionModule.createPromotions({
|
||||
code: "PROMOTION_TEST",
|
||||
type: PromotionType.STANDARD,
|
||||
application_method: {
|
||||
@@ -587,7 +587,7 @@ medusaIntegrationTestRunner({
|
||||
},
|
||||
})
|
||||
|
||||
const cart = await cartModule.create({
|
||||
const cart = await cartModule.createCarts({
|
||||
currency_code: "usd",
|
||||
email: "tony@stark.com",
|
||||
region_id: region.id,
|
||||
@@ -686,13 +686,13 @@ medusaIntegrationTestRunner({
|
||||
it("should not generate tax lines if region is not present or automatic taxes is false", async () => {
|
||||
await setupTaxStructure(taxModule)
|
||||
|
||||
const region = await regionModule.create({
|
||||
const region = await regionModule.createRegions({
|
||||
name: "US",
|
||||
currency_code: "usd",
|
||||
automatic_taxes: false,
|
||||
})
|
||||
|
||||
const cart = await cartModule.create({
|
||||
const cart = await cartModule.createCarts({
|
||||
currency_code: "usd",
|
||||
email: "tony@stark.com",
|
||||
shipping_address: {
|
||||
@@ -732,7 +732,7 @@ medusaIntegrationTestRunner({
|
||||
})
|
||||
)
|
||||
|
||||
await cartModule.update(cart.id, {
|
||||
await cartModule.updateCarts(cart.id, {
|
||||
region_id: region.id,
|
||||
})
|
||||
|
||||
@@ -758,16 +758,16 @@ medusaIntegrationTestRunner({
|
||||
it("should update a cart's region, sales channel, customer data and tax lines", async () => {
|
||||
await setupTaxStructure(taxModule)
|
||||
|
||||
const region = await regionModule.create({
|
||||
const region = await regionModule.createRegions({
|
||||
name: "us",
|
||||
currency_code: "usd",
|
||||
})
|
||||
|
||||
const salesChannel = await scModule.create({
|
||||
const salesChannel = await scModule.createSalesChannels({
|
||||
name: "Webshop",
|
||||
})
|
||||
|
||||
const cart = await cartModule.create({
|
||||
const cart = await cartModule.createCarts({
|
||||
currency_code: "eur",
|
||||
email: "tony@stark.com",
|
||||
shipping_address: {
|
||||
@@ -795,7 +795,7 @@ medusaIntegrationTestRunner({
|
||||
type: "default",
|
||||
})
|
||||
|
||||
const fulfillmentSet = await fulfillmentModule.create({
|
||||
const fulfillmentSet = await fulfillmentModule.createFulfillmentSets({
|
||||
name: "Test",
|
||||
type: "test-type",
|
||||
service_zones: [
|
||||
@@ -967,12 +967,12 @@ medusaIntegrationTestRunner({
|
||||
it("should remove invalid shipping methods", async () => {
|
||||
await setupTaxStructure(taxModule)
|
||||
|
||||
const region = await regionModule.create({
|
||||
const region = await regionModule.createRegions({
|
||||
name: "US",
|
||||
currency_code: "usd",
|
||||
})
|
||||
|
||||
const cart = await cartModule.create({
|
||||
const cart = await cartModule.createCarts({
|
||||
region_id: region.id,
|
||||
currency_code: "eur",
|
||||
email: "tony@stark.com",
|
||||
@@ -992,7 +992,7 @@ medusaIntegrationTestRunner({
|
||||
type: "default",
|
||||
})
|
||||
|
||||
const fulfillmentSet = await fulfillmentModule.create({
|
||||
const fulfillmentSet = await fulfillmentModule.createFulfillmentSets({
|
||||
name: "Test",
|
||||
type: "test-type",
|
||||
service_zones: [
|
||||
@@ -1101,12 +1101,12 @@ medusaIntegrationTestRunner({
|
||||
|
||||
describe("POST /store/carts/:id", () => {
|
||||
it("should create and update a cart", async () => {
|
||||
const region = await regionModule.create({
|
||||
const region = await regionModule.createRegions({
|
||||
name: "US",
|
||||
currency_code: "usd",
|
||||
})
|
||||
|
||||
const salesChannel = await scModule.create({
|
||||
const salesChannel = await scModule.createSalesChannels({
|
||||
name: "Webshop",
|
||||
})
|
||||
|
||||
@@ -1151,16 +1151,16 @@ medusaIntegrationTestRunner({
|
||||
|
||||
describe("GET /store/carts", () => {
|
||||
it("should get cart", async () => {
|
||||
const region = await regionModule.create({
|
||||
const region = await regionModule.createRegions({
|
||||
name: "US",
|
||||
currency_code: "usd",
|
||||
})
|
||||
|
||||
const salesChannel = await scModule.create({
|
||||
const salesChannel = await scModule.createSalesChannels({
|
||||
name: "Webshop",
|
||||
})
|
||||
|
||||
const cart = await cartModule.create({
|
||||
const cart = await cartModule.createCarts({
|
||||
currency_code: "usd",
|
||||
items: [
|
||||
{
|
||||
@@ -1250,22 +1250,22 @@ medusaIntegrationTestRunner({
|
||||
beforeEach(async () => {
|
||||
await setupTaxStructure(taxModule)
|
||||
|
||||
region = await regionModule.create({
|
||||
region = await regionModule.createRegions({
|
||||
name: "US",
|
||||
currency_code: "usd",
|
||||
})
|
||||
})
|
||||
|
||||
it("should add item to cart", async () => {
|
||||
const customer = await customerModule.create({
|
||||
const customer = await customerModule.createCustomers({
|
||||
email: "tony@stark-industries.com",
|
||||
})
|
||||
|
||||
const salesChannel = await scModule.create({
|
||||
const salesChannel = await scModule.createSalesChannels({
|
||||
name: "Webshop",
|
||||
})
|
||||
|
||||
const [productWithSpecialTax] = await productModule.create([
|
||||
const [productWithSpecialTax] = await productModule.createProducts([
|
||||
{
|
||||
// This product ID is setup in the tax structure fixture (setupTaxStructure)
|
||||
id: "product_id_1",
|
||||
@@ -1274,7 +1274,7 @@ medusaIntegrationTestRunner({
|
||||
} as any,
|
||||
])
|
||||
|
||||
const [productWithDefaultTax] = await productModule.create([
|
||||
const [productWithDefaultTax] = await productModule.createProducts([
|
||||
{
|
||||
title: "Test product default tax",
|
||||
variants: [
|
||||
@@ -1283,7 +1283,7 @@ medusaIntegrationTestRunner({
|
||||
},
|
||||
])
|
||||
|
||||
const cart = await cartModule.create({
|
||||
const cart = await cartModule.createCarts({
|
||||
currency_code: "usd",
|
||||
customer_id: customer.id,
|
||||
sales_channel_id: salesChannel.id,
|
||||
@@ -1308,7 +1308,7 @@ medusaIntegrationTestRunner({
|
||||
],
|
||||
})
|
||||
|
||||
const appliedPromotion = await promotionModule.create({
|
||||
const appliedPromotion = await promotionModule.createPromotions({
|
||||
code: "PROMOTION_APPLIED",
|
||||
type: PromotionType.STANDARD,
|
||||
application_method: {
|
||||
@@ -1337,14 +1337,15 @@ medusaIntegrationTestRunner({
|
||||
},
|
||||
])
|
||||
|
||||
const [priceSet, priceSetDefaultTax] = await pricingModule.create([
|
||||
{
|
||||
prices: [{ amount: 3000, currency_code: "usd" }],
|
||||
},
|
||||
{
|
||||
prices: [{ amount: 2000, currency_code: "usd" }],
|
||||
},
|
||||
])
|
||||
const [priceSet, priceSetDefaultTax] =
|
||||
await pricingModule.createPriceSets([
|
||||
{
|
||||
prices: [{ amount: 3000, currency_code: "usd" }],
|
||||
},
|
||||
{
|
||||
prices: [{ amount: 2000, currency_code: "usd" }],
|
||||
},
|
||||
])
|
||||
|
||||
await remoteLink.create([
|
||||
{
|
||||
@@ -1520,12 +1521,12 @@ medusaIntegrationTestRunner({
|
||||
|
||||
describe("POST /store/payment-collections", () => {
|
||||
it("should create a payment collection for the cart", async () => {
|
||||
const region = await regionModule.create({
|
||||
const region = await regionModule.createRegions({
|
||||
name: "US",
|
||||
currency_code: "usd",
|
||||
})
|
||||
|
||||
const cart = await cartModule.create({
|
||||
const cart = await cartModule.createCarts({
|
||||
currency_code: "usd",
|
||||
region_id: region.id,
|
||||
})
|
||||
@@ -1547,12 +1548,12 @@ medusaIntegrationTestRunner({
|
||||
})
|
||||
|
||||
it("should return an existing payment collection for the cart", async () => {
|
||||
const region = await regionModule.create({
|
||||
const region = await regionModule.createRegions({
|
||||
name: "US",
|
||||
currency_code: "usd",
|
||||
})
|
||||
|
||||
const cart = await cartModule.create({
|
||||
const cart = await cartModule.createCarts({
|
||||
currency_code: "usd",
|
||||
region_id: region.id,
|
||||
})
|
||||
@@ -1580,17 +1581,17 @@ medusaIntegrationTestRunner({
|
||||
})
|
||||
|
||||
it("should create a new payment collection for a new cart", async () => {
|
||||
const region = await regionModule.create({
|
||||
const region = await regionModule.createRegions({
|
||||
name: "US",
|
||||
currency_code: "usd",
|
||||
})
|
||||
|
||||
const firstCart = await cartModule.create({
|
||||
const firstCart = await cartModule.createCarts({
|
||||
currency_code: "usd",
|
||||
region_id: region.id,
|
||||
})
|
||||
|
||||
const secondCart = await cartModule.create({
|
||||
const secondCart = await cartModule.createCarts({
|
||||
currency_code: "usd",
|
||||
region_id: region.id,
|
||||
})
|
||||
@@ -1622,13 +1623,13 @@ medusaIntegrationTestRunner({
|
||||
it("should update a carts tax lines when region.automatic_taxes is false", async () => {
|
||||
await setupTaxStructure(taxModule)
|
||||
|
||||
const region = await regionModule.create({
|
||||
const region = await regionModule.createRegions({
|
||||
name: "US",
|
||||
currency_code: "usd",
|
||||
automatic_taxes: false,
|
||||
})
|
||||
|
||||
const cart = await cartModule.create({
|
||||
const cart = await cartModule.createCarts({
|
||||
currency_code: "usd",
|
||||
region_id: region.id,
|
||||
shipping_address: {
|
||||
@@ -1679,13 +1680,13 @@ medusaIntegrationTestRunner({
|
||||
it("should throw error when shipping is not present", async () => {
|
||||
await setupTaxStructure(taxModule)
|
||||
|
||||
const region = await regionModule.create({
|
||||
const region = await regionModule.createRegions({
|
||||
name: "US",
|
||||
currency_code: "usd",
|
||||
automatic_taxes: false,
|
||||
})
|
||||
|
||||
const cart = await cartModule.create({
|
||||
const cart = await cartModule.createCarts({
|
||||
currency_code: "usd",
|
||||
region_id: region.id,
|
||||
items: [
|
||||
@@ -1713,7 +1714,7 @@ medusaIntegrationTestRunner({
|
||||
|
||||
describe("POST /store/carts/:id/shipping-methods", () => {
|
||||
it("should add a shipping methods to a cart", async () => {
|
||||
const cart = await cartModule.create({
|
||||
const cart = await cartModule.createCarts({
|
||||
currency_code: "usd",
|
||||
shipping_address: { country_code: "us" },
|
||||
items: [],
|
||||
@@ -1725,7 +1726,7 @@ medusaIntegrationTestRunner({
|
||||
type: "default",
|
||||
})
|
||||
|
||||
const fulfillmentSet = await fulfillmentModule.create({
|
||||
const fulfillmentSet = await fulfillmentModule.createFulfillmentSets({
|
||||
name: "Test",
|
||||
type: "test-type",
|
||||
service_zones: [
|
||||
@@ -1736,7 +1737,7 @@ medusaIntegrationTestRunner({
|
||||
],
|
||||
})
|
||||
|
||||
const priceSet = await pricingModule.create({
|
||||
const priceSet = await pricingModule.createPriceSets({
|
||||
prices: [{ amount: 3000, currency_code: "usd" }],
|
||||
})
|
||||
|
||||
@@ -1809,7 +1810,7 @@ medusaIntegrationTestRunner({
|
||||
beforeEach(async () => {
|
||||
await setupTaxStructure(taxModule)
|
||||
|
||||
region = await regionService.create({
|
||||
region = await regionService.createRegions({
|
||||
name: "Test region",
|
||||
countries: ["US"],
|
||||
currency_code: "usd",
|
||||
@@ -1861,7 +1862,7 @@ medusaIntegrationTestRunner({
|
||||
type: "default",
|
||||
})
|
||||
|
||||
fulfillmentSet = await fulfillmentModule.create({
|
||||
fulfillmentSet = await fulfillmentModule.createFulfillmentSets({
|
||||
name: "Test",
|
||||
type: "test-type",
|
||||
service_zones: [
|
||||
|
||||
@@ -40,49 +40,51 @@ medusaIntegrationTestRunner({
|
||||
|
||||
describe("DELETE /store/carts/:id/promotions", () => {
|
||||
it("should remove line item adjustments from a cart based on promotions", async () => {
|
||||
const appliedPromotion = await promotionModuleService.create({
|
||||
code: "PROMOTION_APPLIED",
|
||||
type: PromotionType.STANDARD,
|
||||
application_method: {
|
||||
type: "fixed",
|
||||
target_type: "items",
|
||||
allocation: "each",
|
||||
value: "300",
|
||||
apply_to_quantity: 1,
|
||||
currency_code: "usd",
|
||||
max_quantity: 1,
|
||||
target_rules: [
|
||||
{
|
||||
attribute: "product_id",
|
||||
operator: "eq",
|
||||
values: "prod_tshirt",
|
||||
},
|
||||
],
|
||||
},
|
||||
})
|
||||
const appliedPromotion =
|
||||
await promotionModuleService.createPromotions({
|
||||
code: "PROMOTION_APPLIED",
|
||||
type: PromotionType.STANDARD,
|
||||
application_method: {
|
||||
type: "fixed",
|
||||
target_type: "items",
|
||||
allocation: "each",
|
||||
value: "300",
|
||||
apply_to_quantity: 1,
|
||||
currency_code: "usd",
|
||||
max_quantity: 1,
|
||||
target_rules: [
|
||||
{
|
||||
attribute: "product_id",
|
||||
operator: "eq",
|
||||
values: "prod_tshirt",
|
||||
},
|
||||
],
|
||||
},
|
||||
})
|
||||
|
||||
const appliedPromotionToRemove = await promotionModuleService.create({
|
||||
code: "PROMOTION_APPLIED_TO_REMOVE",
|
||||
type: PromotionType.STANDARD,
|
||||
application_method: {
|
||||
type: "fixed",
|
||||
target_type: "items",
|
||||
allocation: "each",
|
||||
value: "300",
|
||||
apply_to_quantity: 1,
|
||||
currency_code: "usd",
|
||||
max_quantity: 1,
|
||||
target_rules: [
|
||||
{
|
||||
attribute: "product_id",
|
||||
operator: "eq",
|
||||
values: "prod_tshirt",
|
||||
},
|
||||
],
|
||||
},
|
||||
})
|
||||
const appliedPromotionToRemove =
|
||||
await promotionModuleService.createPromotions({
|
||||
code: "PROMOTION_APPLIED_TO_REMOVE",
|
||||
type: PromotionType.STANDARD,
|
||||
application_method: {
|
||||
type: "fixed",
|
||||
target_type: "items",
|
||||
allocation: "each",
|
||||
value: "300",
|
||||
apply_to_quantity: 1,
|
||||
currency_code: "usd",
|
||||
max_quantity: 1,
|
||||
target_rules: [
|
||||
{
|
||||
attribute: "product_id",
|
||||
operator: "eq",
|
||||
values: "prod_tshirt",
|
||||
},
|
||||
],
|
||||
},
|
||||
})
|
||||
|
||||
const cart = await cartModuleService.create({
|
||||
const cart = await cartModuleService.createCarts({
|
||||
currency_code: "usd",
|
||||
items: [
|
||||
{
|
||||
@@ -170,71 +172,73 @@ medusaIntegrationTestRunner({
|
||||
})
|
||||
|
||||
it("should add shipping method adjustments to a cart based on promotions", async () => {
|
||||
const appliedPromotion = await promotionModuleService.create({
|
||||
code: "PROMOTION_APPLIED",
|
||||
type: PromotionType.STANDARD,
|
||||
rules: [
|
||||
{
|
||||
attribute: "customer_id",
|
||||
operator: "in",
|
||||
values: ["cus_test"],
|
||||
},
|
||||
{
|
||||
attribute: "currency_code",
|
||||
operator: "in",
|
||||
values: ["eur"],
|
||||
},
|
||||
],
|
||||
application_method: {
|
||||
type: "fixed",
|
||||
target_type: "shipping_methods",
|
||||
allocation: "each",
|
||||
value: "100",
|
||||
max_quantity: 1,
|
||||
currency_code: "usd",
|
||||
target_rules: [
|
||||
const appliedPromotion =
|
||||
await promotionModuleService.createPromotions({
|
||||
code: "PROMOTION_APPLIED",
|
||||
type: PromotionType.STANDARD,
|
||||
rules: [
|
||||
{
|
||||
attribute: "name",
|
||||
attribute: "customer_id",
|
||||
operator: "in",
|
||||
values: ["express"],
|
||||
values: ["cus_test"],
|
||||
},
|
||||
{
|
||||
attribute: "currency_code",
|
||||
operator: "in",
|
||||
values: ["eur"],
|
||||
},
|
||||
],
|
||||
},
|
||||
})
|
||||
application_method: {
|
||||
type: "fixed",
|
||||
target_type: "shipping_methods",
|
||||
allocation: "each",
|
||||
value: "100",
|
||||
max_quantity: 1,
|
||||
currency_code: "usd",
|
||||
target_rules: [
|
||||
{
|
||||
attribute: "name",
|
||||
operator: "in",
|
||||
values: ["express"],
|
||||
},
|
||||
],
|
||||
},
|
||||
})
|
||||
|
||||
const appliedPromotionToRemove = await promotionModuleService.create({
|
||||
code: "PROMOTION_APPLIED_TO_REMOVE",
|
||||
type: PromotionType.STANDARD,
|
||||
rules: [
|
||||
{
|
||||
attribute: "customer_id",
|
||||
operator: "in",
|
||||
values: ["cus_test"],
|
||||
},
|
||||
{
|
||||
attribute: "currency_code",
|
||||
operator: "in",
|
||||
values: ["eur"],
|
||||
},
|
||||
],
|
||||
application_method: {
|
||||
type: "fixed",
|
||||
target_type: "shipping_methods",
|
||||
allocation: "each",
|
||||
value: "100",
|
||||
max_quantity: 1,
|
||||
currency_code: "usd",
|
||||
target_rules: [
|
||||
const appliedPromotionToRemove =
|
||||
await promotionModuleService.createPromotions({
|
||||
code: "PROMOTION_APPLIED_TO_REMOVE",
|
||||
type: PromotionType.STANDARD,
|
||||
rules: [
|
||||
{
|
||||
attribute: "name",
|
||||
attribute: "customer_id",
|
||||
operator: "in",
|
||||
values: ["express"],
|
||||
values: ["cus_test"],
|
||||
},
|
||||
{
|
||||
attribute: "currency_code",
|
||||
operator: "in",
|
||||
values: ["eur"],
|
||||
},
|
||||
],
|
||||
},
|
||||
})
|
||||
application_method: {
|
||||
type: "fixed",
|
||||
target_type: "shipping_methods",
|
||||
allocation: "each",
|
||||
value: "100",
|
||||
max_quantity: 1,
|
||||
currency_code: "usd",
|
||||
target_rules: [
|
||||
{
|
||||
attribute: "name",
|
||||
operator: "in",
|
||||
values: ["express"],
|
||||
},
|
||||
],
|
||||
},
|
||||
})
|
||||
|
||||
const cart = await cartModuleService.create({
|
||||
const cart = await cartModuleService.createCarts({
|
||||
currency_code: "eur",
|
||||
customer_id: "cus_test",
|
||||
items: [
|
||||
|
||||
@@ -29,10 +29,10 @@ medusaIntegrationTestRunner({
|
||||
})
|
||||
|
||||
it("should batch add customers to a group", async () => {
|
||||
const group = await customerModuleService.createCustomerGroup({
|
||||
const group = await customerModuleService.createCustomerGroups({
|
||||
name: "VIP",
|
||||
})
|
||||
const customers = await customerModuleService.create([
|
||||
const customers = await customerModuleService.createCustomers([
|
||||
{
|
||||
first_name: "Test",
|
||||
last_name: "Test",
|
||||
|
||||
@@ -29,10 +29,10 @@ medusaIntegrationTestRunner({
|
||||
})
|
||||
|
||||
it("should batch delete customers from a group", async () => {
|
||||
const group = await customerModuleService.createCustomerGroup({
|
||||
const group = await customerModuleService.createCustomerGroups({
|
||||
name: "VIP",
|
||||
})
|
||||
const customers = await customerModuleService.create([
|
||||
const customers = await customerModuleService.createCustomers([
|
||||
{
|
||||
first_name: "Test",
|
||||
last_name: "Test",
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
import { ICustomerModuleService } from "@medusajs/types"
|
||||
import { ModuleRegistrationName } from "@medusajs/modules-sdk"
|
||||
import { createAdminUser } from "../../../../helpers/create-admin-user"
|
||||
import { medusaIntegrationTestRunner } from "medusa-test-utils"
|
||||
|
||||
@@ -15,13 +13,9 @@ medusaIntegrationTestRunner({
|
||||
testSuite: ({ dbConnection, getContainer, api }) => {
|
||||
describe("POST /admin/customer-groups", () => {
|
||||
let appContainer
|
||||
let customerModuleService: ICustomerModuleService
|
||||
|
||||
beforeAll(async () => {
|
||||
appContainer = getContainer()
|
||||
customerModuleService = appContainer.resolve(
|
||||
ModuleRegistrationName.CUSTOMER
|
||||
)
|
||||
})
|
||||
|
||||
beforeEach(async () => {
|
||||
|
||||
@@ -29,7 +29,7 @@ medusaIntegrationTestRunner({
|
||||
})
|
||||
|
||||
it("should delete a group", async () => {
|
||||
const group = await customerModuleService.createCustomerGroup({
|
||||
const group = await customerModuleService.createCustomerGroups({
|
||||
name: "VIP",
|
||||
})
|
||||
|
||||
|
||||
@@ -29,11 +29,11 @@ medusaIntegrationTestRunner({
|
||||
})
|
||||
|
||||
it("should get all customer groups and its count", async () => {
|
||||
const group = await customerModuleService.createCustomerGroup({
|
||||
const group = await customerModuleService.createCustomerGroups({
|
||||
name: "Test",
|
||||
})
|
||||
|
||||
const customers = await customerModuleService.create([
|
||||
const customers = await customerModuleService.createCustomers([
|
||||
{
|
||||
first_name: "Test",
|
||||
last_name: "Test",
|
||||
|
||||
@@ -29,7 +29,7 @@ medusaIntegrationTestRunner({
|
||||
})
|
||||
|
||||
it("should get all customer groups and its count", async () => {
|
||||
await customerModuleService.createCustomerGroup({
|
||||
await customerModuleService.createCustomerGroups({
|
||||
name: "Test",
|
||||
})
|
||||
|
||||
@@ -46,7 +46,7 @@ medusaIntegrationTestRunner({
|
||||
})
|
||||
|
||||
it("should support searching of customer groups", async () => {
|
||||
await customerModuleService.createCustomerGroup([
|
||||
await customerModuleService.createCustomerGroups([
|
||||
{
|
||||
name: "First group",
|
||||
},
|
||||
|
||||
@@ -29,7 +29,7 @@ medusaIntegrationTestRunner({
|
||||
})
|
||||
|
||||
it("should retrieve customer group", async () => {
|
||||
const group = await customerModuleService.createCustomerGroup({
|
||||
const group = await customerModuleService.createCustomerGroups({
|
||||
name: "Test",
|
||||
})
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ medusaIntegrationTestRunner({
|
||||
})
|
||||
|
||||
it("should update a customer group", async () => {
|
||||
const customer = await customerModuleService.createCustomerGroup({
|
||||
const customer = await customerModuleService.createCustomerGroups({
|
||||
name: "VIP",
|
||||
})
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ medusaIntegrationTestRunner({
|
||||
})
|
||||
it("should create a customer address", async () => {
|
||||
// Create a customer
|
||||
const customer = await customerModuleService.create({
|
||||
const customer = await customerModuleService.createCustomers({
|
||||
first_name: "John",
|
||||
last_name: "Doe",
|
||||
})
|
||||
@@ -56,16 +56,16 @@ medusaIntegrationTestRunner({
|
||||
])
|
||||
)
|
||||
|
||||
const customerWithAddresses = await customerModuleService.retrieve(
|
||||
customer.id,
|
||||
{ relations: ["addresses"] }
|
||||
)
|
||||
const customerWithAddresses =
|
||||
await customerModuleService.retrieveCustomer(customer.id, {
|
||||
relations: ["addresses"],
|
||||
})
|
||||
|
||||
expect(customerWithAddresses.addresses?.length).toEqual(1)
|
||||
})
|
||||
|
||||
it("sets new shipping address as default and unsets the old one", async () => {
|
||||
const customer = await customerModuleService.create({
|
||||
const customer = await customerModuleService.createCustomers({
|
||||
first_name: "John",
|
||||
last_name: "Doe",
|
||||
addresses: [
|
||||
@@ -100,7 +100,7 @@ medusaIntegrationTestRunner({
|
||||
})
|
||||
|
||||
it("sets new billing address as default and unsets the old one", async () => {
|
||||
const customer = await customerModuleService.create({
|
||||
const customer = await customerModuleService.createCustomers({
|
||||
first_name: "John",
|
||||
last_name: "Doe",
|
||||
addresses: [
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
import { ICustomerModuleService } from "@medusajs/types"
|
||||
import { ModuleRegistrationName } from "@medusajs/modules-sdk"
|
||||
import { createAdminUser } from "../../../../helpers/create-admin-user"
|
||||
import { medusaIntegrationTestRunner } from "medusa-test-utils"
|
||||
|
||||
@@ -15,13 +13,8 @@ medusaIntegrationTestRunner({
|
||||
testSuite: ({ dbConnection, getContainer, api }) => {
|
||||
describe("POST /admin/customers", () => {
|
||||
let appContainer
|
||||
let customerModuleService: ICustomerModuleService
|
||||
|
||||
beforeAll(async () => {
|
||||
appContainer = getContainer()
|
||||
customerModuleService = appContainer.resolve(
|
||||
ModuleRegistrationName.CUSTOMER
|
||||
)
|
||||
})
|
||||
|
||||
beforeEach(async () => {
|
||||
|
||||
@@ -29,12 +29,12 @@ medusaIntegrationTestRunner({
|
||||
})
|
||||
|
||||
it("should update a customer address", async () => {
|
||||
const customer = await customerModuleService.create({
|
||||
const customer = await customerModuleService.createCustomers({
|
||||
first_name: "John",
|
||||
last_name: "Doe",
|
||||
})
|
||||
|
||||
const address = await customerModuleService.addAddresses({
|
||||
const address = await customerModuleService.createAddresses({
|
||||
customer_id: customer.id,
|
||||
first_name: "John",
|
||||
last_name: "Doe",
|
||||
@@ -48,7 +48,7 @@ medusaIntegrationTestRunner({
|
||||
|
||||
expect(response.status).toEqual(200)
|
||||
|
||||
const updatedCustomer = await customerModuleService.retrieve(
|
||||
const updatedCustomer = await customerModuleService.retrieveCustomer(
|
||||
customer.id,
|
||||
{
|
||||
relations: ["addresses"],
|
||||
|
||||
@@ -29,7 +29,7 @@ medusaIntegrationTestRunner({
|
||||
})
|
||||
|
||||
it("should delete a customer", async () => {
|
||||
const customer = await customerModuleService.create({
|
||||
const customer = await customerModuleService.createCustomers({
|
||||
first_name: "John",
|
||||
last_name: "Doe",
|
||||
})
|
||||
@@ -41,7 +41,7 @@ medusaIntegrationTestRunner({
|
||||
|
||||
expect(response.status).toEqual(200)
|
||||
|
||||
const deletedCustomer = await customerModuleService.retrieve(
|
||||
const deletedCustomer = await customerModuleService.retrieveCustomer(
|
||||
customer.id,
|
||||
{
|
||||
withDeleted: true,
|
||||
|
||||
@@ -29,7 +29,7 @@ medusaIntegrationTestRunner({
|
||||
})
|
||||
|
||||
it("should get all customer addresses and its count", async () => {
|
||||
const [customer] = await customerModuleService.create([
|
||||
const [customer] = await customerModuleService.createCustomers([
|
||||
{
|
||||
first_name: "Test",
|
||||
last_name: "Test",
|
||||
@@ -94,7 +94,7 @@ medusaIntegrationTestRunner({
|
||||
})
|
||||
|
||||
it("should support searching through the addresses", async () => {
|
||||
const [customer] = await customerModuleService.create([
|
||||
const [customer] = await customerModuleService.createCustomers([
|
||||
{
|
||||
first_name: "Test",
|
||||
last_name: "Test",
|
||||
|
||||
@@ -32,7 +32,7 @@ medusaIntegrationTestRunner({
|
||||
})
|
||||
|
||||
it("should get all customers and its count", async () => {
|
||||
await customerModuleService.create([
|
||||
await customerModuleService.createCustomers([
|
||||
{
|
||||
first_name: "Test",
|
||||
last_name: "Test",
|
||||
@@ -55,11 +55,11 @@ medusaIntegrationTestRunner({
|
||||
})
|
||||
|
||||
it("should get all customers in specific customer group and its count", async () => {
|
||||
const vipGroup = await customerModuleService.createCustomerGroup({
|
||||
const vipGroup = await customerModuleService.createCustomerGroups({
|
||||
name: "VIP",
|
||||
})
|
||||
|
||||
const [john] = await customerModuleService.create([
|
||||
const [john] = await customerModuleService.createCustomers([
|
||||
{
|
||||
first_name: "John",
|
||||
last_name: "Doe",
|
||||
@@ -94,7 +94,7 @@ medusaIntegrationTestRunner({
|
||||
})
|
||||
|
||||
it("should filter customers by last name", async () => {
|
||||
await customerModuleService.create([
|
||||
await customerModuleService.createCustomers([
|
||||
{
|
||||
first_name: "Jane",
|
||||
last_name: "Doe",
|
||||
@@ -143,7 +143,7 @@ medusaIntegrationTestRunner({
|
||||
})
|
||||
|
||||
it("should support searching of customers", async () => {
|
||||
await customerModuleService.create([
|
||||
await customerModuleService.createCustomers([
|
||||
{
|
||||
first_name: "Jane",
|
||||
last_name: "Doe",
|
||||
|
||||
@@ -29,12 +29,12 @@ medusaIntegrationTestRunner({
|
||||
})
|
||||
|
||||
it("should update a customer address", async () => {
|
||||
const customer = await customerModuleService.create({
|
||||
const customer = await customerModuleService.createCustomers({
|
||||
first_name: "John",
|
||||
last_name: "Doe",
|
||||
})
|
||||
|
||||
const address = await customerModuleService.addAddresses({
|
||||
const address = await customerModuleService.createAddresses({
|
||||
customer_id: customer.id,
|
||||
first_name: "John",
|
||||
last_name: "Doe",
|
||||
@@ -62,11 +62,11 @@ medusaIntegrationTestRunner({
|
||||
})
|
||||
|
||||
it("updates a new address to be default and unsets old one", async () => {
|
||||
const customer = await customerModuleService.create({
|
||||
const customer = await customerModuleService.createCustomers({
|
||||
first_name: "John",
|
||||
last_name: "Doe",
|
||||
})
|
||||
const [, address] = await customerModuleService.addAddresses([
|
||||
const [, address] = await customerModuleService.createAddresses([
|
||||
{
|
||||
customer_id: customer.id,
|
||||
first_name: "John",
|
||||
@@ -104,11 +104,11 @@ medusaIntegrationTestRunner({
|
||||
|
||||
// do the same as above but for billing address
|
||||
it("updates a new address to be default and unsets old one", async () => {
|
||||
const customer = await customerModuleService.create({
|
||||
const customer = await customerModuleService.createCustomers({
|
||||
first_name: "John",
|
||||
last_name: "Doe",
|
||||
})
|
||||
const [, address] = await customerModuleService.addAddresses([
|
||||
const [, address] = await customerModuleService.createAddresses([
|
||||
{
|
||||
customer_id: customer.id,
|
||||
first_name: "John",
|
||||
|
||||
@@ -29,7 +29,7 @@ medusaIntegrationTestRunner({
|
||||
})
|
||||
|
||||
it("should update a customer", async () => {
|
||||
const customer = await customerModuleService.create({
|
||||
const customer = await customerModuleService.createCustomers({
|
||||
first_name: "John",
|
||||
last_name: "Doe",
|
||||
})
|
||||
|
||||
@@ -47,10 +47,10 @@ medusaIntegrationTestRunner({
|
||||
})
|
||||
)
|
||||
|
||||
const customerWithAddresses = await customerModuleService.retrieve(
|
||||
customer.id,
|
||||
{ relations: ["addresses"] }
|
||||
)
|
||||
const customerWithAddresses =
|
||||
await customerModuleService.retrieveCustomer(customer.id, {
|
||||
relations: ["addresses"],
|
||||
})
|
||||
|
||||
expect(customerWithAddresses.addresses?.length).toEqual(1)
|
||||
})
|
||||
|
||||
@@ -35,9 +35,13 @@ medusaIntegrationTestRunner({
|
||||
const { http } = appContainer.resolve(
|
||||
ContainerRegistrationKeys.CONFIG_MODULE
|
||||
).projectConfig
|
||||
const authIdentity = await authService.create({
|
||||
entity_id: "store_user",
|
||||
provider: "emailpass",
|
||||
const authIdentity = await authService.createAuthIdentities({
|
||||
provider_identities: [
|
||||
{
|
||||
entity_id: "store_user",
|
||||
provider: "emailpass",
|
||||
},
|
||||
],
|
||||
})
|
||||
|
||||
const token = jwt.sign(authIdentity, http.jwtSecret)
|
||||
|
||||
@@ -26,7 +26,7 @@ medusaIntegrationTestRunner({
|
||||
appContainer
|
||||
)
|
||||
|
||||
const address = await customerModuleService.addAddresses({
|
||||
const address = await customerModuleService.createAddresses({
|
||||
customer_id: customer.id,
|
||||
first_name: "John",
|
||||
last_name: "Doe",
|
||||
@@ -40,7 +40,7 @@ medusaIntegrationTestRunner({
|
||||
|
||||
expect(response.status).toEqual(200)
|
||||
|
||||
const updatedCustomer = await customerModuleService.retrieve(
|
||||
const updatedCustomer = await customerModuleService.retrieveCustomer(
|
||||
customer.id,
|
||||
{
|
||||
relations: ["addresses"],
|
||||
@@ -53,11 +53,11 @@ medusaIntegrationTestRunner({
|
||||
it("should fail to delete another customer's address", async () => {
|
||||
const { jwt } = await createAuthenticatedCustomer(appContainer)
|
||||
|
||||
const otherCustomer = await customerModuleService.create({
|
||||
const otherCustomer = await customerModuleService.createCustomers({
|
||||
first_name: "Jane",
|
||||
last_name: "Doe",
|
||||
})
|
||||
const address = await customerModuleService.addAddresses({
|
||||
const address = await customerModuleService.createAddresses({
|
||||
customer_id: otherCustomer.id,
|
||||
first_name: "John",
|
||||
last_name: "Doe",
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
import { ICustomerModuleService } from "@medusajs/types"
|
||||
import { ModuleRegistrationName } from "@medusajs/modules-sdk"
|
||||
import { createAuthenticatedCustomer } from "../../../helpers/create-authenticated-customer"
|
||||
import { medusaIntegrationTestRunner } from "medusa-test-utils"
|
||||
|
||||
@@ -12,13 +10,8 @@ medusaIntegrationTestRunner({
|
||||
testSuite: ({ dbConnection, getContainer, api }) => {
|
||||
describe("GET /store/customers", () => {
|
||||
let appContainer
|
||||
let customerModuleService: ICustomerModuleService
|
||||
|
||||
beforeAll(async () => {
|
||||
appContainer = getContainer()
|
||||
customerModuleService = appContainer.resolve(
|
||||
ModuleRegistrationName.CUSTOMER
|
||||
)
|
||||
})
|
||||
|
||||
it("should retrieve auth user's customer", async () => {
|
||||
|
||||
@@ -26,7 +26,7 @@ medusaIntegrationTestRunner({
|
||||
appContainer
|
||||
)
|
||||
|
||||
await customerModuleService.addAddresses([
|
||||
await customerModuleService.createAddresses([
|
||||
{
|
||||
first_name: "Test",
|
||||
last_name: "Test",
|
||||
@@ -47,7 +47,7 @@ medusaIntegrationTestRunner({
|
||||
},
|
||||
])
|
||||
|
||||
await customerModuleService.create({
|
||||
await customerModuleService.createCustomers({
|
||||
first_name: "Test Test",
|
||||
last_name: "Test Test",
|
||||
addresses: [
|
||||
|
||||
@@ -26,7 +26,7 @@ medusaIntegrationTestRunner({
|
||||
appContainer
|
||||
)
|
||||
|
||||
const address = await customerModuleService.addAddresses({
|
||||
const address = await customerModuleService.createAddresses({
|
||||
customer_id: customer.id,
|
||||
first_name: "John",
|
||||
last_name: "Doe",
|
||||
@@ -54,12 +54,12 @@ medusaIntegrationTestRunner({
|
||||
it("should fail to update another customer's address", async () => {
|
||||
const { jwt } = await createAuthenticatedCustomer(appContainer)
|
||||
|
||||
const otherCustomer = await customerModuleService.create({
|
||||
const otherCustomer = await customerModuleService.createCustomers({
|
||||
first_name: "Jane",
|
||||
last_name: "Doe",
|
||||
})
|
||||
|
||||
const address = await customerModuleService.addAddresses({
|
||||
const address = await customerModuleService.createAddresses({
|
||||
customer_id: otherCustomer.id,
|
||||
first_name: "John",
|
||||
last_name: "Doe",
|
||||
|
||||
@@ -109,7 +109,7 @@ export async function setupFullDataFulfillmentStructure(
|
||||
name: "test_" + randomString,
|
||||
type: "default",
|
||||
})
|
||||
const fulfillmentSet = await service.create({
|
||||
const fulfillmentSet = await service.createFulfillmentSets({
|
||||
name: "test_" + randomString,
|
||||
type: "test-type",
|
||||
})
|
||||
|
||||
@@ -105,7 +105,7 @@ export const setupTaxStructure = async (service: ITaxModuleService) => {
|
||||
])
|
||||
|
||||
const [calProd, calType, deType, canProd, canType, qcType] =
|
||||
await service.create([
|
||||
await service.createTaxRates([
|
||||
{
|
||||
tax_region_id: cal.id,
|
||||
name: "CA Reduced Rate for Products",
|
||||
|
||||
@@ -48,7 +48,7 @@ medusaIntegrationTestRunner({
|
||||
type: "default",
|
||||
})
|
||||
|
||||
const fulfillmentSet = await service.create({
|
||||
const fulfillmentSet = await service.createFulfillmentSets({
|
||||
name: "test",
|
||||
type: "test-type",
|
||||
})
|
||||
@@ -111,7 +111,7 @@ medusaIntegrationTestRunner({
|
||||
type: "default",
|
||||
})
|
||||
|
||||
const fulfillmentSet = await service.create({
|
||||
const fulfillmentSet = await service.createFulfillmentSets({
|
||||
name: "test",
|
||||
type: "test-type",
|
||||
})
|
||||
@@ -190,7 +190,7 @@ medusaIntegrationTestRunner({
|
||||
type: "default",
|
||||
})
|
||||
|
||||
const fulfillmentSet = await service.create({
|
||||
const fulfillmentSet = await service.createFulfillmentSets({
|
||||
name: "test",
|
||||
type: "test-type",
|
||||
})
|
||||
|
||||
@@ -40,7 +40,7 @@ medusaIntegrationTestRunner({
|
||||
it("should allow to create a full data structure after the backward compatible migration have run on top of the medusa v1 database", async () => {
|
||||
await setupFullDataFulfillmentStructure(service, { providerId })
|
||||
|
||||
const fulfillmentSets = await service.list(
|
||||
const fulfillmentSets = await service.listFulfillmentSets(
|
||||
{},
|
||||
{
|
||||
relations: [
|
||||
@@ -119,7 +119,7 @@ medusaIntegrationTestRunner({
|
||||
type: "default",
|
||||
})
|
||||
|
||||
const fulfillmentSet = await service.create({
|
||||
const fulfillmentSet = await service.createFulfillmentSets({
|
||||
name: "test",
|
||||
type: "test-type",
|
||||
})
|
||||
|
||||
@@ -41,20 +41,20 @@ medusaIntegrationTestRunner({
|
||||
})
|
||||
|
||||
it("should query carts, sales channels, customers, regions with remote query", async () => {
|
||||
const region = await regionModule.create({
|
||||
const region = await regionModule.createRegions({
|
||||
name: "Region",
|
||||
currency_code: "usd",
|
||||
})
|
||||
|
||||
const customer = await customerModule.create({
|
||||
const customer = await customerModule.createCustomers({
|
||||
email: "tony@stark.com",
|
||||
})
|
||||
|
||||
const salesChannel = await scModuleService.create({
|
||||
const salesChannel = await scModuleService.createSalesChannels({
|
||||
name: "Webshop",
|
||||
})
|
||||
|
||||
const cart = await cartModuleService.create({
|
||||
const cart = await cartModuleService.createCarts({
|
||||
email: "tony@stark.com",
|
||||
currency_code: "usd",
|
||||
region_id: region.id,
|
||||
|
||||
@@ -23,12 +23,12 @@ medusaIntegrationTestRunner({
|
||||
})
|
||||
|
||||
it("should query carts and regions with remote query", async () => {
|
||||
const region = await regionModule.create({
|
||||
const region = await regionModule.createRegions({
|
||||
name: "Region",
|
||||
currency_code: "usd",
|
||||
})
|
||||
|
||||
const cart = await cartModuleService.create({
|
||||
const cart = await cartModuleService.createCarts({
|
||||
email: "tony@stark.com",
|
||||
currency_code: "usd",
|
||||
region_id: region.id,
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
import { ModuleRegistrationName, Modules } from "@medusajs/modules-sdk"
|
||||
import {
|
||||
IFulfillmentModuleService,
|
||||
ISalesChannelModuleService,
|
||||
IStockLocationServiceNext,
|
||||
IStockLocationService,
|
||||
} from "@medusajs/types"
|
||||
import {
|
||||
ContainerRegistrationKeys,
|
||||
@@ -20,8 +19,7 @@ medusaIntegrationTestRunner({
|
||||
describe("FulfillmentSet and Location", () => {
|
||||
let appContainer
|
||||
let fulfillmentModule: IFulfillmentModuleService
|
||||
let locationModule: IStockLocationServiceNext
|
||||
let scService: ISalesChannelModuleService
|
||||
let locationModule: IStockLocationService
|
||||
let remoteQuery
|
||||
let remoteLink
|
||||
|
||||
@@ -33,7 +31,6 @@ medusaIntegrationTestRunner({
|
||||
locationModule = appContainer.resolve(
|
||||
ModuleRegistrationName.STOCK_LOCATION
|
||||
)
|
||||
scService = appContainer.resolve(ModuleRegistrationName.SALES_CHANNEL)
|
||||
remoteQuery = appContainer.resolve(
|
||||
ContainerRegistrationKeys.REMOTE_QUERY
|
||||
)
|
||||
@@ -41,12 +38,12 @@ medusaIntegrationTestRunner({
|
||||
})
|
||||
|
||||
it("should query fulfillment set and location link with remote query", async () => {
|
||||
const fulfillmentSet = await fulfillmentModule.create({
|
||||
const fulfillmentSet = await fulfillmentModule.createFulfillmentSets({
|
||||
name: "Test fulfillment set",
|
||||
type: "delivery",
|
||||
})
|
||||
|
||||
const euWarehouse = await locationModule.create({
|
||||
const euWarehouse = await locationModule.createStockLocations({
|
||||
name: "EU Warehouse",
|
||||
})
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ medusaIntegrationTestRunner({
|
||||
})
|
||||
|
||||
it("should query product variants and price set link with remote query", async () => {
|
||||
const [product] = await productModule.create([
|
||||
const [product] = await productModule.createProducts([
|
||||
{
|
||||
title: "Test product",
|
||||
variants: [
|
||||
@@ -52,7 +52,7 @@ medusaIntegrationTestRunner({
|
||||
},
|
||||
])
|
||||
|
||||
const [priceSet1, priceSet2] = await pricingModule.create([
|
||||
const [priceSet1, priceSet2] = await pricingModule.createPriceSets([
|
||||
{
|
||||
rules: [{ rule_attribute: "customer_group_id" }],
|
||||
prices: [
|
||||
|
||||
@@ -31,11 +31,11 @@ medusaIntegrationTestRunner({
|
||||
})
|
||||
|
||||
it("should query api key and sales channels link with remote query", async () => {
|
||||
const salesChannel = await scModuleService.create({
|
||||
const salesChannel = await scModuleService.createSalesChannels({
|
||||
name: "Webshop",
|
||||
})
|
||||
|
||||
const apiKeys = await apiKeyModule.create([
|
||||
const apiKeys = await apiKeyModule.createApiKeys([
|
||||
{
|
||||
title: "Api key",
|
||||
type: "publishable",
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { ModuleRegistrationName, Modules } from "@medusajs/modules-sdk"
|
||||
import { IPaymentModuleService, IRegionModuleService } from "@medusajs/types"
|
||||
import { IRegionModuleService } from "@medusajs/types"
|
||||
import { medusaIntegrationTestRunner } from "medusa-test-utils"
|
||||
import {ContainerRegistrationKeys} from "@medusajs/utils";
|
||||
import { ContainerRegistrationKeys } from "@medusajs/utils"
|
||||
|
||||
jest.setTimeout(50000)
|
||||
|
||||
@@ -13,20 +13,20 @@ medusaIntegrationTestRunner({
|
||||
describe("Region and Payment Providers", () => {
|
||||
let appContainer
|
||||
let regionModule: IRegionModuleService
|
||||
let paymentModule: IPaymentModuleService
|
||||
let remoteQuery
|
||||
let remoteLink
|
||||
|
||||
beforeAll(async () => {
|
||||
appContainer = getContainer()
|
||||
regionModule = appContainer.resolve(ModuleRegistrationName.REGION)
|
||||
paymentModule = appContainer.resolve(ModuleRegistrationName.PAYMENT)
|
||||
remoteQuery = appContainer.resolve(ContainerRegistrationKeys.REMOTE_QUERY)
|
||||
remoteQuery = appContainer.resolve(
|
||||
ContainerRegistrationKeys.REMOTE_QUERY
|
||||
)
|
||||
remoteLink = appContainer.resolve(ContainerRegistrationKeys.REMOTE_LINK)
|
||||
})
|
||||
|
||||
it("should query region and payment provider link with remote query", async () => {
|
||||
const region = await regionModule.create({
|
||||
const region = await regionModule.createRegions({
|
||||
name: "North America",
|
||||
currency_code: "usd",
|
||||
})
|
||||
@@ -87,7 +87,7 @@ medusaIntegrationTestRunner({
|
||||
}),
|
||||
expect.objectContaining({
|
||||
id: "pp_system_default_2",
|
||||
regions: []
|
||||
regions: [],
|
||||
}),
|
||||
])
|
||||
)
|
||||
|
||||
@@ -30,23 +30,23 @@ medusaIntegrationTestRunner({
|
||||
})
|
||||
|
||||
it("should query carts, sales channels, customers, regions with remote query", async () => {
|
||||
const scWebshop = await scService.create({
|
||||
const scWebshop = await scService.createSalesChannels({
|
||||
name: "Webshop",
|
||||
})
|
||||
|
||||
const scCphStore = await scService.create({
|
||||
const scCphStore = await scService.createSalesChannels({
|
||||
name: "CPH store",
|
||||
})
|
||||
|
||||
const scNycStore = await scService.create({
|
||||
const scNycStore = await scService.createSalesChannels({
|
||||
name: "NYC store",
|
||||
})
|
||||
|
||||
const euWarehouse = await locationService.create({
|
||||
const euWarehouse = await locationService.createStockLocations({
|
||||
name: "EU Warehouse",
|
||||
})
|
||||
|
||||
const usWarehouse = await locationService.create({
|
||||
const usWarehouse = await locationService.createStockLocations({
|
||||
name: "US Warehouse",
|
||||
})
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ medusaIntegrationTestRunner({
|
||||
name: "Test",
|
||||
type: "default",
|
||||
})
|
||||
const fulfillmentSet = await fulfillmentModule.create({
|
||||
const fulfillmentSet = await fulfillmentModule.createFulfillmentSets({
|
||||
name: "Test",
|
||||
type: "test-type",
|
||||
})
|
||||
@@ -65,7 +65,7 @@ medusaIntegrationTestRunner({
|
||||
},
|
||||
})
|
||||
|
||||
const priceSet = await pricingModule.create({
|
||||
const priceSet = await pricingModule.createPriceSets({
|
||||
prices: [
|
||||
{
|
||||
amount: 3000,
|
||||
|
||||
@@ -25,7 +25,7 @@ medusaIntegrationTestRunner({
|
||||
})
|
||||
|
||||
it("should query store and default currency with remote query", async () => {
|
||||
const store = await storeModuleService.create({
|
||||
const store = await storeModuleService.createStores({
|
||||
name: "Store",
|
||||
default_currency_code: "usd",
|
||||
supported_currency_codes: ["usd"],
|
||||
|
||||
@@ -28,7 +28,7 @@ medusaIntegrationTestRunner({
|
||||
Modules.PRODUCT
|
||||
] as unknown as IProductModuleService
|
||||
|
||||
const productList = await product.list()
|
||||
const productList = await product.listProducts()
|
||||
|
||||
expect(productList).toEqual(expect.arrayContaining([]))
|
||||
})
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { ModuleRegistrationName, Modules } from "@medusajs/modules-sdk"
|
||||
import { IPaymentModuleService, IRegionModuleService } from "@medusajs/types"
|
||||
import { IRegionModuleService } from "@medusajs/types"
|
||||
import { ContainerRegistrationKeys } from "@medusajs/utils"
|
||||
import { medusaIntegrationTestRunner } from "medusa-test-utils"
|
||||
import { createAdminUser } from "../../..//helpers/create-admin-user"
|
||||
@@ -15,14 +15,12 @@ medusaIntegrationTestRunner({
|
||||
describe("Remote Query", () => {
|
||||
let appContainer
|
||||
let regionModule: IRegionModuleService
|
||||
let paymentModule: IPaymentModuleService
|
||||
let remoteQuery
|
||||
let remoteLink
|
||||
|
||||
beforeAll(async () => {
|
||||
appContainer = getContainer()
|
||||
regionModule = appContainer.resolve(ModuleRegistrationName.REGION)
|
||||
paymentModule = appContainer.resolve(ModuleRegistrationName.PAYMENT)
|
||||
remoteQuery = appContainer.resolve(
|
||||
ContainerRegistrationKeys.REMOTE_QUERY
|
||||
)
|
||||
@@ -34,7 +32,7 @@ medusaIntegrationTestRunner({
|
||||
})
|
||||
|
||||
it("should fail to retrieve a single non-existing id", async () => {
|
||||
const region = await regionModule.create({
|
||||
const region = await regionModule.createRegions({
|
||||
name: "Test Region",
|
||||
currency_code: "usd",
|
||||
countries: ["us"],
|
||||
@@ -75,19 +73,19 @@ medusaIntegrationTestRunner({
|
||||
})
|
||||
|
||||
it("should fail if a expected relation is not found", async () => {
|
||||
const region = await regionModule.create({
|
||||
const region = await regionModule.createRegions({
|
||||
name: "Test Region",
|
||||
currency_code: "usd",
|
||||
countries: ["us"],
|
||||
})
|
||||
|
||||
const regionWithPayment = await regionModule.create({
|
||||
const regionWithPayment = await regionModule.createRegions({
|
||||
name: "Test W/ Payment",
|
||||
currency_code: "brl",
|
||||
countries: ["br"],
|
||||
})
|
||||
|
||||
const regionNoLink = await regionModule.create({
|
||||
const regionNoLink = await regionModule.createRegions({
|
||||
name: "No link",
|
||||
currency_code: "eur",
|
||||
countries: ["dk"],
|
||||
|
||||
@@ -40,8 +40,8 @@ medusaIntegrationTestRunner({
|
||||
resource_type: "order",
|
||||
} as CreateNotificationDTO
|
||||
|
||||
const result = await service.create(notification)
|
||||
const fromDB = await service.retrieve(result.id)
|
||||
const result = await service.createNotifications(notification)
|
||||
const fromDB = await service.retrieveNotification(result.id)
|
||||
|
||||
expect(result).toEqual(
|
||||
expect.objectContaining({
|
||||
@@ -94,7 +94,9 @@ medusaIntegrationTestRunner({
|
||||
channel: "sms",
|
||||
} as CreateNotificationDTO
|
||||
|
||||
const error = await service.create(notification).catch((e) => e)
|
||||
const error = await service
|
||||
.createNotifications(notification)
|
||||
.catch((e) => e)
|
||||
expect(error.message).toEqual(
|
||||
"Could not find a notification provider for channel: sms"
|
||||
)
|
||||
@@ -113,9 +115,11 @@ medusaIntegrationTestRunner({
|
||||
template: "product-created",
|
||||
} as CreateNotificationDTO
|
||||
|
||||
await service.create([notification1, notification2])
|
||||
await service.createNotifications([notification1, notification2])
|
||||
|
||||
const notifications = await service.list({ channel: "log" })
|
||||
const notifications = await service.listNotifications({
|
||||
channel: "log",
|
||||
})
|
||||
expect(notifications).toHaveLength(1)
|
||||
expect(notifications[0]).toEqual(
|
||||
expect.objectContaining({
|
||||
@@ -139,9 +143,12 @@ medusaIntegrationTestRunner({
|
||||
template: "product-created",
|
||||
} as CreateNotificationDTO
|
||||
|
||||
const [first] = await service.create([notification1, notification2])
|
||||
const [first] = await service.createNotifications([
|
||||
notification1,
|
||||
notification2,
|
||||
])
|
||||
|
||||
const notification = await service.retrieve(first.id)
|
||||
const notification = await service.retrieveNotification(first.id)
|
||||
expect(notification).toEqual(
|
||||
expect.objectContaining({
|
||||
to: "test@medusajs.com",
|
||||
@@ -176,7 +183,7 @@ medusaIntegrationTestRunner({
|
||||
})
|
||||
await subscriberExecution
|
||||
|
||||
const notifications = await service.list()
|
||||
const notifications = await service.listNotifications()
|
||||
|
||||
expect(logSpy).toHaveBeenLastCalledWith(
|
||||
`Attempting to send a notification to: 'test@medusajs.com' on the channel: 'email' with template: 'order-created-template' and data: '{\"order_id\":\"1234\"}'`
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
import { ModuleRegistrationName, Modules } from "@medusajs/modules-sdk"
|
||||
import {
|
||||
ICartModuleService,
|
||||
ICustomerModuleService,
|
||||
IFulfillmentModuleService,
|
||||
IInventoryServiceNext,
|
||||
IPaymentModuleService,
|
||||
IPricingModuleService,
|
||||
IProductModuleService,
|
||||
IRegionModuleService,
|
||||
@@ -31,14 +29,11 @@ medusaIntegrationTestRunner({
|
||||
let cartModuleService: ICartModuleService
|
||||
let regionModuleService: IRegionModuleService
|
||||
let scModuleService: ISalesChannelModuleService
|
||||
let customerModule: ICustomerModuleService
|
||||
let productModule: IProductModuleService
|
||||
let pricingModule: IPricingModuleService
|
||||
let paymentModule: IPaymentModuleService
|
||||
let inventoryModule: IInventoryServiceNext
|
||||
let stockLocationModule: IStockLocationServiceNext
|
||||
let fulfillmentModule: IFulfillmentModuleService
|
||||
let locationModule: IStockLocationServiceNext
|
||||
let taxModule: ITaxModuleService
|
||||
let remoteLink, remoteQuery
|
||||
|
||||
@@ -49,10 +44,8 @@ medusaIntegrationTestRunner({
|
||||
scModuleService = appContainer.resolve(
|
||||
ModuleRegistrationName.SALES_CHANNEL
|
||||
)
|
||||
customerModule = appContainer.resolve(ModuleRegistrationName.CUSTOMER)
|
||||
productModule = appContainer.resolve(ModuleRegistrationName.PRODUCT)
|
||||
pricingModule = appContainer.resolve(ModuleRegistrationName.PRICING)
|
||||
paymentModule = appContainer.resolve(ModuleRegistrationName.PAYMENT)
|
||||
inventoryModule = appContainer.resolve(ModuleRegistrationName.INVENTORY)
|
||||
stockLocationModule = appContainer.resolve(
|
||||
ModuleRegistrationName.STOCK_LOCATION
|
||||
@@ -60,9 +53,6 @@ medusaIntegrationTestRunner({
|
||||
fulfillmentModule = appContainer.resolve(
|
||||
ModuleRegistrationName.FULFILLMENT
|
||||
)
|
||||
locationModule = appContainer.resolve(
|
||||
ModuleRegistrationName.STOCK_LOCATION
|
||||
)
|
||||
taxModule = appContainer.resolve(ModuleRegistrationName.TAX)
|
||||
remoteLink = appContainer.resolve(ContainerRegistrationKeys.REMOTE_LINK)
|
||||
remoteQuery = appContainer.resolve(ContainerRegistrationKeys.REMOTE_QUERY)
|
||||
@@ -74,20 +64,20 @@ medusaIntegrationTestRunner({
|
||||
|
||||
describe("Draft Orders - Admin", () => {
|
||||
it("should create a draft order", async () => {
|
||||
const region = await regionModuleService.create({
|
||||
const region = await regionModuleService.createRegions({
|
||||
name: "US",
|
||||
currency_code: "usd",
|
||||
})
|
||||
|
||||
const salesChannel = await scModuleService.create({
|
||||
const salesChannel = await scModuleService.createSalesChannels({
|
||||
name: "Webshop",
|
||||
})
|
||||
|
||||
const location = await stockLocationModule.create({
|
||||
const location = await stockLocationModule.createStockLocations({
|
||||
name: "Warehouse",
|
||||
})
|
||||
|
||||
const [product, product_2] = await productModule.create([
|
||||
const [product, product_2] = await productModule.createProducts([
|
||||
{
|
||||
title: "Test product",
|
||||
variants: [
|
||||
@@ -107,7 +97,7 @@ medusaIntegrationTestRunner({
|
||||
},
|
||||
])
|
||||
|
||||
const inventoryItem = await inventoryModule.create({
|
||||
const inventoryItem = await inventoryModule.createInventoryItems({
|
||||
sku: "inv-1234",
|
||||
})
|
||||
|
||||
@@ -120,7 +110,7 @@ medusaIntegrationTestRunner({
|
||||
},
|
||||
])
|
||||
|
||||
const [priceSet, priceSet_2] = await pricingModule.create([
|
||||
const [priceSet, priceSet_2] = await pricingModule.createPriceSets([
|
||||
{
|
||||
prices: [
|
||||
{
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { ModuleRegistrationName } from "@medusajs/modules-sdk"
|
||||
import {
|
||||
ICartModuleService,
|
||||
ICustomerModuleService,
|
||||
IFulfillmentModuleService,
|
||||
IInventoryServiceNext,
|
||||
IOrderModuleService,
|
||||
@@ -9,9 +8,7 @@ import {
|
||||
IPricingModuleService,
|
||||
IProductModuleService,
|
||||
IRegionModuleService,
|
||||
ISalesChannelModuleService,
|
||||
IStockLocationServiceNext,
|
||||
ITaxModuleService,
|
||||
} from "@medusajs/types"
|
||||
import { ContainerRegistrationKeys } from "@medusajs/utils"
|
||||
import { medusaIntegrationTestRunner } from "medusa-test-utils"
|
||||
@@ -30,16 +27,12 @@ medusaIntegrationTestRunner({
|
||||
let appContainer
|
||||
let cartModuleService: ICartModuleService
|
||||
let regionModuleService: IRegionModuleService
|
||||
let scModuleService: ISalesChannelModuleService
|
||||
let customerModule: ICustomerModuleService
|
||||
let productModule: IProductModuleService
|
||||
let pricingModule: IPricingModuleService
|
||||
let paymentModule: IPaymentModuleService
|
||||
let pricingModule: IPricingModuleService
|
||||
let inventoryModule: IInventoryServiceNext
|
||||
let stockLocationModule: IStockLocationServiceNext
|
||||
let fulfillmentModule: IFulfillmentModuleService
|
||||
let locationModule: IStockLocationServiceNext
|
||||
let taxModule: ITaxModuleService
|
||||
let orderModule: IOrderModuleService
|
||||
let remoteLink, remoteQuery
|
||||
|
||||
@@ -47,24 +40,12 @@ medusaIntegrationTestRunner({
|
||||
appContainer = getContainer()
|
||||
cartModuleService = appContainer.resolve(ModuleRegistrationName.CART)
|
||||
regionModuleService = appContainer.resolve(ModuleRegistrationName.REGION)
|
||||
scModuleService = appContainer.resolve(
|
||||
ModuleRegistrationName.SALES_CHANNEL
|
||||
)
|
||||
customerModule = appContainer.resolve(ModuleRegistrationName.CUSTOMER)
|
||||
productModule = appContainer.resolve(ModuleRegistrationName.PRODUCT)
|
||||
pricingModule = appContainer.resolve(ModuleRegistrationName.PRICING)
|
||||
paymentModule = appContainer.resolve(ModuleRegistrationName.PAYMENT)
|
||||
inventoryModule = appContainer.resolve(ModuleRegistrationName.INVENTORY)
|
||||
stockLocationModule = appContainer.resolve(
|
||||
ModuleRegistrationName.STOCK_LOCATION
|
||||
)
|
||||
fulfillmentModule = appContainer.resolve(
|
||||
ModuleRegistrationName.FULFILLMENT
|
||||
)
|
||||
locationModule = appContainer.resolve(
|
||||
ModuleRegistrationName.STOCK_LOCATION
|
||||
)
|
||||
taxModule = appContainer.resolve(ModuleRegistrationName.TAX)
|
||||
remoteLink = appContainer.resolve(ContainerRegistrationKeys.REMOTE_LINK)
|
||||
remoteQuery = appContainer.resolve(ContainerRegistrationKeys.REMOTE_QUERY)
|
||||
orderModule = appContainer.resolve(ModuleRegistrationName.ORDER)
|
||||
@@ -76,7 +57,7 @@ medusaIntegrationTestRunner({
|
||||
|
||||
describe("Orders - Admin", () => {
|
||||
it("should get an order", async () => {
|
||||
const created = await orderModule.create({
|
||||
const created = await orderModule.createOrders({
|
||||
region_id: "test_region_idclear",
|
||||
email: "foo@bar.com",
|
||||
items: [
|
||||
|
||||
@@ -9,7 +9,7 @@ import {
|
||||
FulfillmentWorkflow,
|
||||
IOrderModuleService,
|
||||
IRegionModuleService,
|
||||
IStockLocationServiceNext,
|
||||
IStockLocationService,
|
||||
OrderWorkflow,
|
||||
ProductDTO,
|
||||
RegionDTO,
|
||||
@@ -35,7 +35,7 @@ async function prepareDataFixtures({ container }) {
|
||||
const salesChannelService = container.resolve(
|
||||
ModuleRegistrationName.SALES_CHANNEL
|
||||
)
|
||||
const stockLocationModule: IStockLocationServiceNext = container.resolve(
|
||||
const stockLocationModule: IStockLocationService = container.resolve(
|
||||
ModuleRegistrationName.STOCK_LOCATION
|
||||
)
|
||||
const productModule = container.resolve(ModuleRegistrationName.PRODUCT)
|
||||
@@ -46,7 +46,7 @@ async function prepareDataFixtures({ container }) {
|
||||
type: "default",
|
||||
})
|
||||
|
||||
const fulfillmentSet = await fulfillmentService.create({
|
||||
const fulfillmentSet = await fulfillmentService.createFulfillmentSets({
|
||||
name: "Test fulfillment set",
|
||||
type: "manual_test",
|
||||
})
|
||||
@@ -66,7 +66,7 @@ async function prepareDataFixtures({ container }) {
|
||||
ModuleRegistrationName.REGION
|
||||
) as IRegionModuleService
|
||||
|
||||
const [region] = await regionService.create([
|
||||
const [region] = await regionService.createRegions([
|
||||
{
|
||||
name: "Test region",
|
||||
currency_code: "eur",
|
||||
@@ -74,22 +74,23 @@ async function prepareDataFixtures({ container }) {
|
||||
},
|
||||
])
|
||||
|
||||
const salesChannel = await salesChannelService.create({
|
||||
const salesChannel = await salesChannelService.createSalesChannels({
|
||||
name: "Webshop",
|
||||
})
|
||||
|
||||
const location: StockLocationDTO = await stockLocationModule.create({
|
||||
name: "Warehouse",
|
||||
address: {
|
||||
address_1: "Test",
|
||||
city: "Test",
|
||||
country_code: "US",
|
||||
postal_code: "12345",
|
||||
phone: "12345",
|
||||
},
|
||||
})
|
||||
const location: StockLocationDTO =
|
||||
await stockLocationModule.createStockLocations({
|
||||
name: "Warehouse",
|
||||
address: {
|
||||
address_1: "Test",
|
||||
city: "Test",
|
||||
country_code: "US",
|
||||
postal_code: "12345",
|
||||
phone: "12345",
|
||||
},
|
||||
})
|
||||
|
||||
const [product] = await productModule.create([
|
||||
const [product] = await productModule.createProducts([
|
||||
{
|
||||
title: "Test product",
|
||||
variants: [
|
||||
@@ -101,7 +102,7 @@ async function prepareDataFixtures({ container }) {
|
||||
},
|
||||
])
|
||||
|
||||
inventoryItem = await inventoryModule.create({
|
||||
inventoryItem = await inventoryModule.createInventoryItems({
|
||||
sku: "inv-1234",
|
||||
})
|
||||
|
||||
@@ -210,7 +211,7 @@ async function createOrderFixture({ container, product, location }) {
|
||||
const orderService: IOrderModuleService = container.resolve(
|
||||
ModuleRegistrationName.ORDER
|
||||
)
|
||||
let order = await orderService.create({
|
||||
let order = await orderService.createOrders({
|
||||
region_id: "test_region_idclear",
|
||||
email: "foo@bar.com",
|
||||
items: [
|
||||
@@ -292,7 +293,7 @@ async function createOrderFixture({ container, product, location }) {
|
||||
},
|
||||
])
|
||||
|
||||
order = await orderService.retrieve(order.id, {
|
||||
order = await orderService.retrieveOrder(order.id, {
|
||||
relations: ["items"],
|
||||
})
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ import {
|
||||
FulfillmentWorkflow,
|
||||
IOrderModuleService,
|
||||
IRegionModuleService,
|
||||
IStockLocationServiceNext,
|
||||
IStockLocationService,
|
||||
OrderWorkflow,
|
||||
ProductDTO,
|
||||
RegionDTO,
|
||||
@@ -34,7 +34,7 @@ async function prepareDataFixtures({ container }) {
|
||||
const salesChannelService = container.resolve(
|
||||
ModuleRegistrationName.SALES_CHANNEL
|
||||
)
|
||||
const stockLocationModule: IStockLocationServiceNext = container.resolve(
|
||||
const stockLocationModule: IStockLocationService = container.resolve(
|
||||
ModuleRegistrationName.STOCK_LOCATION
|
||||
)
|
||||
const productModule = container.resolve(ModuleRegistrationName.PRODUCT)
|
||||
@@ -45,7 +45,7 @@ async function prepareDataFixtures({ container }) {
|
||||
type: "default",
|
||||
})
|
||||
|
||||
const fulfillmentSet = await fulfillmentService.create({
|
||||
const fulfillmentSet = await fulfillmentService.createFulfillmentSets({
|
||||
name: "Test fulfillment set",
|
||||
type: "manual_test",
|
||||
})
|
||||
@@ -65,7 +65,7 @@ async function prepareDataFixtures({ container }) {
|
||||
ModuleRegistrationName.REGION
|
||||
) as IRegionModuleService
|
||||
|
||||
const [region] = await regionService.create([
|
||||
const [region] = await regionService.createRegions([
|
||||
{
|
||||
name: "Test region",
|
||||
currency_code: "eur",
|
||||
@@ -73,22 +73,23 @@ async function prepareDataFixtures({ container }) {
|
||||
},
|
||||
])
|
||||
|
||||
const salesChannel = await salesChannelService.create({
|
||||
const salesChannel = await salesChannelService.createSalesChannels({
|
||||
name: "Webshop",
|
||||
})
|
||||
|
||||
const location: StockLocationDTO = await stockLocationModule.create({
|
||||
name: "Warehouse",
|
||||
address: {
|
||||
address_1: "Test",
|
||||
city: "Test",
|
||||
country_code: "US",
|
||||
postal_code: "12345",
|
||||
phone: "12345",
|
||||
},
|
||||
})
|
||||
const location: StockLocationDTO =
|
||||
await stockLocationModule.createStockLocations({
|
||||
name: "Warehouse",
|
||||
address: {
|
||||
address_1: "Test",
|
||||
city: "Test",
|
||||
country_code: "US",
|
||||
postal_code: "12345",
|
||||
phone: "12345",
|
||||
},
|
||||
})
|
||||
|
||||
const [product] = await productModule.create([
|
||||
const [product] = await productModule.createProducts([
|
||||
{
|
||||
title: "Test product",
|
||||
variants: [
|
||||
@@ -105,7 +106,7 @@ async function prepareDataFixtures({ container }) {
|
||||
},
|
||||
])
|
||||
|
||||
inventoryItem = await inventoryModule.create({
|
||||
inventoryItem = await inventoryModule.createInventoryItems({
|
||||
sku: "inv-1234",
|
||||
})
|
||||
|
||||
@@ -214,7 +215,7 @@ async function createOrderFixture({ container, product, location }) {
|
||||
const orderService: IOrderModuleService = container.resolve(
|
||||
ModuleRegistrationName.ORDER
|
||||
)
|
||||
let order = await orderService.create({
|
||||
let order = await orderService.createOrders({
|
||||
region_id: "test_region_idclear",
|
||||
email: "foo@bar.com",
|
||||
items: [
|
||||
@@ -305,7 +306,7 @@ async function createOrderFixture({ container, product, location }) {
|
||||
},
|
||||
])
|
||||
|
||||
order = await orderService.retrieve(order.id, {
|
||||
order = await orderService.retrieveOrder(order.id, {
|
||||
relations: ["items"],
|
||||
})
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ import {
|
||||
FulfillmentWorkflow,
|
||||
IOrderModuleService,
|
||||
IRegionModuleService,
|
||||
IStockLocationServiceNext,
|
||||
IStockLocationService,
|
||||
OrderWorkflow,
|
||||
ProductDTO,
|
||||
RegionDTO,
|
||||
@@ -21,8 +21,8 @@ import {
|
||||
} from "@medusajs/types"
|
||||
import {
|
||||
ContainerRegistrationKeys,
|
||||
RuleOperator,
|
||||
remoteQueryObjectFromString,
|
||||
RuleOperator,
|
||||
} from "@medusajs/utils"
|
||||
import { medusaIntegrationTestRunner } from "medusa-test-utils/dist"
|
||||
|
||||
@@ -38,7 +38,7 @@ async function prepareDataFixtures({ container }) {
|
||||
const salesChannelService = container.resolve(
|
||||
ModuleRegistrationName.SALES_CHANNEL
|
||||
)
|
||||
const stockLocationModule: IStockLocationServiceNext = container.resolve(
|
||||
const stockLocationModule: IStockLocationService = container.resolve(
|
||||
ModuleRegistrationName.STOCK_LOCATION
|
||||
)
|
||||
const productModule = container.resolve(ModuleRegistrationName.PRODUCT)
|
||||
@@ -49,7 +49,7 @@ async function prepareDataFixtures({ container }) {
|
||||
type: "default",
|
||||
})
|
||||
|
||||
const fulfillmentSet = await fulfillmentService.create({
|
||||
const fulfillmentSet = await fulfillmentService.createFulfillmentSets({
|
||||
name: "Test fulfillment set",
|
||||
type: "manual_test",
|
||||
})
|
||||
@@ -69,7 +69,7 @@ async function prepareDataFixtures({ container }) {
|
||||
ModuleRegistrationName.REGION
|
||||
) as IRegionModuleService
|
||||
|
||||
const [region] = await regionService.create([
|
||||
const [region] = await regionService.createRegions([
|
||||
{
|
||||
name: "Test region",
|
||||
currency_code: "eur",
|
||||
@@ -77,22 +77,23 @@ async function prepareDataFixtures({ container }) {
|
||||
},
|
||||
])
|
||||
|
||||
const salesChannel = await salesChannelService.create({
|
||||
const salesChannel = await salesChannelService.createSalesChannels({
|
||||
name: "Webshop",
|
||||
})
|
||||
|
||||
const location: StockLocationDTO = await stockLocationModule.create({
|
||||
name: "Warehouse",
|
||||
address: {
|
||||
address_1: "Test",
|
||||
city: "Test",
|
||||
country_code: "US",
|
||||
postal_code: "12345",
|
||||
phone: "12345",
|
||||
},
|
||||
})
|
||||
const location: StockLocationDTO =
|
||||
await stockLocationModule.createStockLocations({
|
||||
name: "Warehouse",
|
||||
address: {
|
||||
address_1: "Test",
|
||||
city: "Test",
|
||||
country_code: "US",
|
||||
postal_code: "12345",
|
||||
phone: "12345",
|
||||
},
|
||||
})
|
||||
|
||||
const [product] = await productModule.create([
|
||||
const [product] = await productModule.createProducts([
|
||||
{
|
||||
title: "Test product",
|
||||
variants: [
|
||||
@@ -104,7 +105,7 @@ async function prepareDataFixtures({ container }) {
|
||||
},
|
||||
])
|
||||
|
||||
const inventoryItem = await inventoryModule.create({
|
||||
const inventoryItem = await inventoryModule.createInventoryItems({
|
||||
sku: "inv-1234",
|
||||
})
|
||||
|
||||
@@ -221,7 +222,7 @@ async function createOrderFixture({ container, product }) {
|
||||
const orderService: IOrderModuleService = container.resolve(
|
||||
ModuleRegistrationName.ORDER
|
||||
)
|
||||
let order = await orderService.create({
|
||||
let order = await orderService.createOrders({
|
||||
region_id: "test_region_idclear",
|
||||
email: "foo@bar.com",
|
||||
items: [
|
||||
@@ -331,7 +332,7 @@ async function createOrderFixture({ container, product }) {
|
||||
|
||||
await orderService.applyPendingOrderActions(order.id)
|
||||
|
||||
order = await orderService.retrieve(order.id, {
|
||||
order = await orderService.retrieveOrder(order.id, {
|
||||
relations: ["items"],
|
||||
})
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ import {
|
||||
FulfillmentWorkflow,
|
||||
IOrderModuleService,
|
||||
IRegionModuleService,
|
||||
IStockLocationServiceNext,
|
||||
IStockLocationService,
|
||||
OrderWorkflow,
|
||||
ProductDTO,
|
||||
RegionDTO,
|
||||
@@ -17,8 +17,8 @@ import {
|
||||
} from "@medusajs/types"
|
||||
import {
|
||||
ContainerRegistrationKeys,
|
||||
RuleOperator,
|
||||
remoteQueryObjectFromString,
|
||||
RuleOperator,
|
||||
} from "@medusajs/utils"
|
||||
import { medusaIntegrationTestRunner } from "medusa-test-utils/dist"
|
||||
|
||||
@@ -35,7 +35,7 @@ async function prepareDataFixtures({ container }) {
|
||||
const salesChannelService = container.resolve(
|
||||
ModuleRegistrationName.SALES_CHANNEL
|
||||
)
|
||||
const stockLocationModule: IStockLocationServiceNext = container.resolve(
|
||||
const stockLocationModule: IStockLocationService = container.resolve(
|
||||
ModuleRegistrationName.STOCK_LOCATION
|
||||
)
|
||||
const productModule = container.resolve(ModuleRegistrationName.PRODUCT)
|
||||
@@ -46,7 +46,7 @@ async function prepareDataFixtures({ container }) {
|
||||
type: "default",
|
||||
})
|
||||
|
||||
const fulfillmentSet = await fulfillmentService.create({
|
||||
const fulfillmentSet = await fulfillmentService.createFulfillmentSets({
|
||||
name: "Test fulfillment set",
|
||||
type: "manual_test",
|
||||
})
|
||||
@@ -66,7 +66,7 @@ async function prepareDataFixtures({ container }) {
|
||||
ModuleRegistrationName.REGION
|
||||
) as IRegionModuleService
|
||||
|
||||
const [region] = await regionService.create([
|
||||
const [region] = await regionService.createRegions([
|
||||
{
|
||||
name: "Test region",
|
||||
currency_code: "eur",
|
||||
@@ -74,22 +74,23 @@ async function prepareDataFixtures({ container }) {
|
||||
},
|
||||
])
|
||||
|
||||
const salesChannel = await salesChannelService.create({
|
||||
const salesChannel = await salesChannelService.createSalesChannels({
|
||||
name: "Webshop",
|
||||
})
|
||||
|
||||
const location: StockLocationDTO = await stockLocationModule.create({
|
||||
name: "Warehouse",
|
||||
address: {
|
||||
address_1: "Test",
|
||||
city: "Test",
|
||||
country_code: "US",
|
||||
postal_code: "12345",
|
||||
phone: "12345",
|
||||
},
|
||||
})
|
||||
const location: StockLocationDTO =
|
||||
await stockLocationModule.createStockLocations({
|
||||
name: "Warehouse",
|
||||
address: {
|
||||
address_1: "Test",
|
||||
city: "Test",
|
||||
country_code: "US",
|
||||
postal_code: "12345",
|
||||
phone: "12345",
|
||||
},
|
||||
})
|
||||
|
||||
const [product] = await productModule.create([
|
||||
const [product] = await productModule.createProducts([
|
||||
{
|
||||
title: "Test product",
|
||||
variants: [
|
||||
@@ -101,7 +102,7 @@ async function prepareDataFixtures({ container }) {
|
||||
},
|
||||
])
|
||||
|
||||
inventoryItem = await inventoryModule.create({
|
||||
inventoryItem = await inventoryModule.createInventoryItems({
|
||||
sku: "inv-1234",
|
||||
})
|
||||
|
||||
@@ -217,7 +218,7 @@ async function createOrderFixture({ container, product, location }) {
|
||||
const orderService: IOrderModuleService = container.resolve(
|
||||
ModuleRegistrationName.ORDER
|
||||
)
|
||||
let order = await orderService.create({
|
||||
let order = await orderService.createOrders({
|
||||
region_id: "test_region_idclear",
|
||||
email: "foo@bar.com",
|
||||
items: [
|
||||
@@ -299,7 +300,7 @@ async function createOrderFixture({ container, product, location }) {
|
||||
},
|
||||
])
|
||||
|
||||
order = await orderService.retrieve(order.id, {
|
||||
order = await orderService.retrieveOrder(order.id, {
|
||||
relations: ["items"],
|
||||
})
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ medusaIntegrationTestRunner({
|
||||
let paymentCollection
|
||||
|
||||
beforeEach(async () => {
|
||||
region = await regionModule.create({
|
||||
region = await regionModule.createRegions({
|
||||
currency_code: "usd",
|
||||
name: "US",
|
||||
})
|
||||
@@ -130,7 +130,7 @@ medusaIntegrationTestRunner({
|
||||
},
|
||||
})
|
||||
|
||||
const region = await regionModule.create({
|
||||
const region = await regionModule.createRegions({
|
||||
currency_code: "usd",
|
||||
name: "US",
|
||||
})
|
||||
|
||||
@@ -32,7 +32,7 @@ medusaIntegrationTestRunner({
|
||||
|
||||
// TODO: Test should move to `integration-tests/api`
|
||||
it("should list payment providers", async () => {
|
||||
const region = await regionService.create({
|
||||
const region = await regionService.createRegions({
|
||||
name: "Test Region",
|
||||
currency_code: "usd",
|
||||
})
|
||||
|
||||
@@ -43,11 +43,14 @@ medusaIntegrationTestRunner({
|
||||
beforeEach(async () => {
|
||||
await createAdminUser(dbConnection, adminHeaders, appContainer)
|
||||
|
||||
customerGroup = await customerModule.createCustomerGroup({
|
||||
customerGroup = await customerModule.createCustomerGroups({
|
||||
name: "VIP",
|
||||
})
|
||||
region = await regionModule.create({ name: "US", currency_code: "USD" })
|
||||
;[product] = await productModule.create([
|
||||
region = await regionModule.createRegions({
|
||||
name: "US",
|
||||
currency_code: "USD",
|
||||
})
|
||||
;[product] = await productModule.createProducts([
|
||||
{
|
||||
title: "test product",
|
||||
variants: [
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import { IPricingModuleService } from "@medusajs/types"
|
||||
import { PriceListStatus, PriceListType } from "@medusajs/utils"
|
||||
import { medusaIntegrationTestRunner } from "medusa-test-utils"
|
||||
import {
|
||||
@@ -31,11 +30,9 @@ medusaIntegrationTestRunner({
|
||||
let product
|
||||
let variant
|
||||
let priceSetId
|
||||
let pricingModuleService: IPricingModuleService
|
||||
|
||||
beforeAll(async () => {
|
||||
appContainer = getContainer()
|
||||
pricingModuleService = appContainer.resolve("pricingModuleService")
|
||||
})
|
||||
|
||||
beforeEach(async () => {
|
||||
|
||||
@@ -82,7 +82,7 @@ medusaIntegrationTestRunner({
|
||||
{ name: "region_id", rule_attribute: "region_id" },
|
||||
])
|
||||
|
||||
priceSet = await pricingModuleService.create({
|
||||
priceSet = await pricingModuleService.createPriceSets({
|
||||
rules: [{ rule_attribute: "region_id" }],
|
||||
prices: [
|
||||
{
|
||||
|
||||
@@ -22,14 +22,14 @@ async function createProductsWithVariants(
|
||||
): Promise<[ProductDTO, ProductVariantDTO[]]> {
|
||||
const { variants: variantsData, ...productData } = productsData
|
||||
|
||||
const [product] = await productModule.create([productData])
|
||||
const [product] = await productModule.createProducts([productData])
|
||||
|
||||
const variantsDataWithProductId = variantsData?.map((variantData) => {
|
||||
return { ...variantData, product_id: product.id }
|
||||
})
|
||||
|
||||
const variants = variantsDataWithProductId
|
||||
? await productModule.createVariants(variantsDataWithProductId)
|
||||
? await productModule.createProductVariants(variantsDataWithProductId)
|
||||
: []
|
||||
|
||||
return [product, variants]
|
||||
|
||||
@@ -35,8 +35,8 @@ medusaIntegrationTestRunner({
|
||||
},
|
||||
})
|
||||
|
||||
const product1 = await service.create({ title: "test1" })
|
||||
const product2 = await service.create({ title: "test2" })
|
||||
const product1 = await service.createProducts({ title: "test1" })
|
||||
const product2 = await service.createProducts({ title: "test2" })
|
||||
|
||||
const { errors } = await workflow.run({
|
||||
input: {
|
||||
@@ -57,7 +57,7 @@ medusaIntegrationTestRunner({
|
||||
},
|
||||
])
|
||||
|
||||
const products = await service.list()
|
||||
const products = await service.listProducts()
|
||||
|
||||
expect(products).toHaveLength(2)
|
||||
expect(products).toEqual([
|
||||
@@ -135,7 +135,7 @@ medusaIntegrationTestRunner({
|
||||
},
|
||||
])
|
||||
|
||||
const product = await service.retrieve(product1.id, {
|
||||
const product = await service.retrieveProduct(product1.id, {
|
||||
relations: ["variants"],
|
||||
})
|
||||
|
||||
|
||||
@@ -16,13 +16,8 @@ medusaIntegrationTestRunner({
|
||||
testSuite: ({ dbConnection, getContainer, api }) => {
|
||||
describe("POST /admin/promotions", () => {
|
||||
let appContainer
|
||||
let promotionModuleService: IPromotionModuleService
|
||||
|
||||
beforeAll(async () => {
|
||||
appContainer = getContainer()
|
||||
promotionModuleService = appContainer.resolve(
|
||||
ModuleRegistrationName.PROMOTION
|
||||
)
|
||||
})
|
||||
|
||||
beforeEach(async () => {
|
||||
|
||||
@@ -29,7 +29,7 @@ medusaIntegrationTestRunner({
|
||||
})
|
||||
|
||||
it("should delete promotion successfully", async () => {
|
||||
const createdPromotion = await promotionModuleService.create({
|
||||
const createdPromotion = await promotionModuleService.createPromotions({
|
||||
code: "TEST",
|
||||
type: "standard",
|
||||
application_method: {
|
||||
@@ -47,7 +47,7 @@ medusaIntegrationTestRunner({
|
||||
|
||||
expect(deleteRes.status).toEqual(200)
|
||||
|
||||
const promotions = await promotionModuleService.list({
|
||||
const promotions = await promotionModuleService.listPromotions({
|
||||
id: [createdPromotion.id],
|
||||
})
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ medusaIntegrationTestRunner({
|
||||
})
|
||||
|
||||
it("should get all promotions and its count", async () => {
|
||||
await promotionModuleService.create([
|
||||
await promotionModuleService.createPromotions([
|
||||
{
|
||||
code: "TEST",
|
||||
type: PromotionType.STANDARD,
|
||||
@@ -69,7 +69,7 @@ medusaIntegrationTestRunner({
|
||||
})
|
||||
|
||||
it("should support search of promotions", async () => {
|
||||
await promotionModuleService.create([
|
||||
await promotionModuleService.createPromotions([
|
||||
{
|
||||
code: "first",
|
||||
type: PromotionType.STANDARD,
|
||||
@@ -103,7 +103,7 @@ medusaIntegrationTestRunner({
|
||||
})
|
||||
|
||||
it("should get all promotions and its count filtered", async () => {
|
||||
await promotionModuleService.create([
|
||||
await promotionModuleService.createPromotions([
|
||||
{
|
||||
code: "TEST",
|
||||
type: PromotionType.STANDARD,
|
||||
|
||||
@@ -47,7 +47,7 @@ medusaIntegrationTestRunner({
|
||||
beforeEach(async () => {
|
||||
await createAdminUser(dbConnection, adminHeaders, appContainer)
|
||||
|
||||
standardPromotion = await promotionModule.create({
|
||||
standardPromotion = await promotionModule.createPromotions({
|
||||
code: "TEST_ACROSS",
|
||||
type: PromotionType.STANDARD,
|
||||
application_method: {
|
||||
@@ -322,7 +322,7 @@ medusaIntegrationTestRunner({
|
||||
})
|
||||
|
||||
it("should add buy rules to a buyget promotion successfully", async () => {
|
||||
const buyGetPromotion = await promotionModule.create({
|
||||
const buyGetPromotion = await promotionModule.createPromotions({
|
||||
code: "TEST_BUYGET",
|
||||
type: PromotionType.BUYGET,
|
||||
application_method: {
|
||||
@@ -414,7 +414,7 @@ medusaIntegrationTestRunner({
|
||||
deleted: true,
|
||||
})
|
||||
|
||||
const promotion = await promotionModule.retrieve(
|
||||
const promotion = await promotionModule.retrievePromotion(
|
||||
standardPromotion.id,
|
||||
{ relations: ["rules"] }
|
||||
)
|
||||
@@ -455,7 +455,7 @@ medusaIntegrationTestRunner({
|
||||
deleted: true,
|
||||
})
|
||||
|
||||
const promotion = await promotionModule.retrieve(
|
||||
const promotion = await promotionModule.retrievePromotion(
|
||||
standardPromotion.id,
|
||||
{ relations: ["application_method.target_rules"] }
|
||||
)
|
||||
@@ -482,7 +482,7 @@ medusaIntegrationTestRunner({
|
||||
})
|
||||
|
||||
it("should remove buy rules from a promotion successfully", async () => {
|
||||
const buyGetPromotion = await promotionModule.create({
|
||||
const buyGetPromotion = await promotionModule.createPromotions({
|
||||
code: "TEST_BUYGET",
|
||||
type: PromotionType.BUYGET,
|
||||
application_method: {
|
||||
@@ -513,9 +513,12 @@ medusaIntegrationTestRunner({
|
||||
deleted: true,
|
||||
})
|
||||
|
||||
const promotion = await promotionModule.retrieve(buyGetPromotion.id, {
|
||||
relations: ["application_method.buy_rules"],
|
||||
})
|
||||
const promotion = await promotionModule.retrievePromotion(
|
||||
buyGetPromotion.id,
|
||||
{
|
||||
relations: ["application_method.buy_rules"],
|
||||
}
|
||||
)
|
||||
|
||||
expect(promotion.application_method!.buy_rules!.length).toEqual(0)
|
||||
})
|
||||
@@ -731,7 +734,7 @@ medusaIntegrationTestRunner({
|
||||
})
|
||||
|
||||
it("should return all values based on rule types", async () => {
|
||||
const [region1, region2] = await regionService.create([
|
||||
const [region1, region2] = await regionService.createRegions([
|
||||
{ name: "North America", currency_code: "usd" },
|
||||
{ name: "Europe", currency_code: "eur" },
|
||||
])
|
||||
@@ -770,7 +773,7 @@ medusaIntegrationTestRunner({
|
||||
])
|
||||
)
|
||||
|
||||
const group = await customerService.createCustomerGroup({
|
||||
const group = await customerService.createCustomerGroups({
|
||||
name: "VIP",
|
||||
})
|
||||
|
||||
@@ -787,7 +790,7 @@ medusaIntegrationTestRunner({
|
||||
},
|
||||
])
|
||||
|
||||
const salesChannel = await salesChannelService.create({
|
||||
const salesChannel = await salesChannelService.createSalesChannels({
|
||||
name: "Instagram",
|
||||
})
|
||||
|
||||
@@ -826,7 +829,7 @@ medusaIntegrationTestRunner({
|
||||
])
|
||||
)
|
||||
|
||||
const [product1, product2] = await productService.create([
|
||||
const [product1, product2] = await productService.createProducts([
|
||||
{ title: "test product 1" },
|
||||
{ title: "test product 2" },
|
||||
])
|
||||
@@ -845,7 +848,7 @@ medusaIntegrationTestRunner({
|
||||
])
|
||||
)
|
||||
|
||||
const category = await productService.createCategory({
|
||||
const category = await productService.createProductCategories({
|
||||
name: "test category 1",
|
||||
parent_category_id: null,
|
||||
})
|
||||
@@ -860,7 +863,7 @@ medusaIntegrationTestRunner({
|
||||
{ label: "test category 1", value: category.id },
|
||||
])
|
||||
|
||||
const collection = await productService.createCollections({
|
||||
const collection = await productService.createProductCollections({
|
||||
title: "test collection 1",
|
||||
})
|
||||
|
||||
@@ -874,7 +877,7 @@ medusaIntegrationTestRunner({
|
||||
{ label: "test collection 1", value: collection.id },
|
||||
])
|
||||
|
||||
const type = await productService.createTypes({
|
||||
const type = await productService.createProductTypes({
|
||||
value: "test type",
|
||||
})
|
||||
|
||||
@@ -888,7 +891,7 @@ medusaIntegrationTestRunner({
|
||||
{ label: "test type", value: type.id },
|
||||
])
|
||||
|
||||
const [tag1, tag2] = await productService.createTags([
|
||||
const [tag1, tag2] = await productService.createProductTags([
|
||||
{ value: "test tag 1" },
|
||||
{ value: "test tag 2" },
|
||||
])
|
||||
|
||||
@@ -41,7 +41,7 @@ medusaIntegrationTestRunner({
|
||||
})
|
||||
|
||||
it("should get the requested promotion by id or codde", async () => {
|
||||
const createdPromotion = await promotionModuleService.create({
|
||||
const createdPromotion = await promotionModuleService.createPromotions({
|
||||
code: "TEST",
|
||||
type: PromotionType.STANDARD,
|
||||
application_method: {
|
||||
@@ -78,7 +78,7 @@ medusaIntegrationTestRunner({
|
||||
})
|
||||
|
||||
it("should get the requested promotion with filtered fields and relations", async () => {
|
||||
const createdPromotion = await promotionModuleService.create({
|
||||
const createdPromotion = await promotionModuleService.createPromotions({
|
||||
code: "TEST",
|
||||
type: PromotionType.STANDARD,
|
||||
application_method: {
|
||||
|
||||
@@ -45,7 +45,7 @@ medusaIntegrationTestRunner({
|
||||
})
|
||||
|
||||
it("should throw an error when both campaign and campaign_id params are passed", async () => {
|
||||
const createdPromotion = await promotionModuleService.create({
|
||||
const createdPromotion = await promotionModuleService.createPromotions({
|
||||
code: "TEST",
|
||||
type: PromotionType.STANDARD,
|
||||
is_automatic: true,
|
||||
@@ -79,7 +79,7 @@ medusaIntegrationTestRunner({
|
||||
})
|
||||
|
||||
it("should update a promotion successfully", async () => {
|
||||
const createdPromotion = await promotionModuleService.create({
|
||||
const createdPromotion = await promotionModuleService.createPromotions({
|
||||
code: "TEST",
|
||||
type: PromotionType.STANDARD,
|
||||
is_automatic: true,
|
||||
@@ -117,7 +117,7 @@ medusaIntegrationTestRunner({
|
||||
})
|
||||
|
||||
it("should update a buyget promotion successfully", async () => {
|
||||
const createdPromotion = await promotionModuleService.create({
|
||||
const createdPromotion = await promotionModuleService.createPromotions({
|
||||
code: "PROMOTION_TEST",
|
||||
type: PromotionType.BUYGET,
|
||||
application_method: {
|
||||
|
||||
@@ -87,9 +87,12 @@ medusaIntegrationTestRunner({
|
||||
deleted: true,
|
||||
})
|
||||
|
||||
const deletedRegion = await service.retrieve(updated.data.region.id, {
|
||||
withDeleted: true,
|
||||
})
|
||||
const deletedRegion = await service.retrieveRegion(
|
||||
updated.data.region.id,
|
||||
{
|
||||
withDeleted: true,
|
||||
}
|
||||
)
|
||||
|
||||
// @ts-ignore
|
||||
expect(deletedRegion.deleted_at).toBeTruthy()
|
||||
@@ -294,7 +297,7 @@ medusaIntegrationTestRunner({
|
||||
})
|
||||
|
||||
it("should throw on unknown properties in update", async () => {
|
||||
const created = await service.create({
|
||||
const created = await service.createRegions({
|
||||
name: "Test Region",
|
||||
currency_code: "usd",
|
||||
})
|
||||
@@ -318,7 +321,7 @@ medusaIntegrationTestRunner({
|
||||
})
|
||||
|
||||
it("should get all regions and count", async () => {
|
||||
await service.create([
|
||||
await service.createRegions([
|
||||
{
|
||||
name: "Test",
|
||||
currency_code: "usd",
|
||||
@@ -344,7 +347,7 @@ medusaIntegrationTestRunner({
|
||||
})
|
||||
|
||||
it("should support searching of regions", async () => {
|
||||
await service.create([
|
||||
await service.createRegions([
|
||||
{
|
||||
name: "APAC",
|
||||
currency_code: "usd",
|
||||
@@ -369,7 +372,7 @@ medusaIntegrationTestRunner({
|
||||
})
|
||||
|
||||
it("should get a region", async () => {
|
||||
const [region] = await service.create([
|
||||
const [region] = await service.createRegions([
|
||||
{
|
||||
name: "Test",
|
||||
currency_code: "usd",
|
||||
|
||||
@@ -43,7 +43,7 @@ medusaIntegrationTestRunner({
|
||||
ContainerRegistrationKeys.REMOTE_LINK
|
||||
)
|
||||
|
||||
region = await regionService.create({
|
||||
region = await regionService.createRegions({
|
||||
name: "Test region",
|
||||
countries: ["US"],
|
||||
currency_code: "usd",
|
||||
@@ -103,7 +103,7 @@ medusaIntegrationTestRunner({
|
||||
type: "default",
|
||||
})
|
||||
|
||||
fulfillmentSet = await fulfillmentModule.create({
|
||||
fulfillmentSet = await fulfillmentModule.createFulfillmentSets({
|
||||
name: "Test",
|
||||
type: "test-type",
|
||||
service_zones: [
|
||||
@@ -184,7 +184,9 @@ medusaIntegrationTestRunner({
|
||||
|
||||
describe("GET /admin/shipping-options?cart_id=", () => {
|
||||
it("should get all shipping options for a cart successfully", async () => {
|
||||
const resp = await api.get(`/store/shipping-options?cart_id=${cart.id}`)
|
||||
const resp = await api.get(
|
||||
`/store/shipping-options?cart_id=${cart.id}`
|
||||
)
|
||||
|
||||
const shippingOptions = resp.data.shipping_options
|
||||
expect(shippingOptions).toHaveLength(1)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { ModuleRegistrationName } from "@medusajs/modules-sdk"
|
||||
import {ModuleRegistrationName} from "@medusajs/modules-sdk"
|
||||
import {
|
||||
BatchWorkflowInput,
|
||||
CreateShippingOptionRuleDTO,
|
||||
@@ -10,7 +10,7 @@ import {
|
||||
ShippingProfileDTO,
|
||||
UpdateShippingOptionRuleDTO,
|
||||
} from "@medusajs/types"
|
||||
import { medusaIntegrationTestRunner } from "medusa-test-utils/dist"
|
||||
import {medusaIntegrationTestRunner} from "medusa-test-utils/dist"
|
||||
import {
|
||||
batchShippingOptionRulesWorkflow,
|
||||
createShippingOptionsWorkflow,
|
||||
@@ -35,7 +35,7 @@ async function createShippingOptionFixture({
|
||||
ModuleRegistrationName.REGION
|
||||
) as IRegionModuleService
|
||||
|
||||
const [region] = await regionService.create([
|
||||
const [region] = await regionService.createRegions([
|
||||
{
|
||||
name: "Test region",
|
||||
currency_code: "eur",
|
||||
@@ -136,7 +136,7 @@ medusaIntegrationTestRunner({
|
||||
type: "default",
|
||||
})
|
||||
|
||||
fulfillmentSet = await service.create({
|
||||
fulfillmentSet = await service.createFulfillmentSets({
|
||||
name: "Test fulfillment set",
|
||||
type: "manual_test",
|
||||
})
|
||||
|
||||
@@ -42,7 +42,7 @@ medusaIntegrationTestRunner({
|
||||
type: "default",
|
||||
})
|
||||
|
||||
fulfillmentSet = await service.create({
|
||||
fulfillmentSet = await service.createFulfillmentSets({
|
||||
name: "Test fulfillment set",
|
||||
type: "manual_test",
|
||||
})
|
||||
@@ -64,7 +64,7 @@ medusaIntegrationTestRunner({
|
||||
ModuleRegistrationName.REGION
|
||||
) as IRegionModuleService
|
||||
|
||||
const [region] = await regionService.create([
|
||||
const [region] = await regionService.createRegions([
|
||||
{
|
||||
name: "Test region",
|
||||
currency_code: "eur",
|
||||
@@ -180,7 +180,7 @@ medusaIntegrationTestRunner({
|
||||
ModuleRegistrationName.REGION
|
||||
) as IRegionModuleService
|
||||
|
||||
const [region] = await regionService.create([
|
||||
const [region] = await regionService.createRegions([
|
||||
{
|
||||
name: "Test region",
|
||||
currency_code: "eur",
|
||||
|
||||
@@ -45,7 +45,7 @@ medusaIntegrationTestRunner({
|
||||
type: "default",
|
||||
})
|
||||
|
||||
fulfillmentSet = await service.create({
|
||||
fulfillmentSet = await service.createFulfillmentSets({
|
||||
name: "Test fulfillment set",
|
||||
type: "manual_test",
|
||||
})
|
||||
@@ -67,7 +67,7 @@ medusaIntegrationTestRunner({
|
||||
ModuleRegistrationName.REGION
|
||||
) as IRegionModuleService
|
||||
|
||||
const [region] = await regionService.create([
|
||||
const [region] = await regionService.createRegions([
|
||||
{
|
||||
name: "Test region",
|
||||
currency_code: "eur",
|
||||
@@ -150,7 +150,7 @@ medusaIntegrationTestRunner({
|
||||
ModuleRegistrationName.REGION
|
||||
) as IRegionModuleService
|
||||
|
||||
const [region] = await regionService.create([
|
||||
const [region] = await regionService.createRegions([
|
||||
{
|
||||
name: "Test region",
|
||||
currency_code: "eur",
|
||||
|
||||
@@ -46,7 +46,7 @@ medusaIntegrationTestRunner({
|
||||
type: "default",
|
||||
})
|
||||
|
||||
fulfillmentSet = await service.create({
|
||||
fulfillmentSet = await service.createFulfillmentSets({
|
||||
name: "Test fulfillment set",
|
||||
type: "manual_test",
|
||||
})
|
||||
@@ -68,7 +68,7 @@ medusaIntegrationTestRunner({
|
||||
ModuleRegistrationName.REGION
|
||||
) as IRegionModuleService
|
||||
|
||||
const [region] = await regionService.create([
|
||||
const [region] = await regionService.createRegions([
|
||||
{
|
||||
name: "Test region",
|
||||
currency_code: "eur",
|
||||
@@ -233,7 +233,7 @@ medusaIntegrationTestRunner({
|
||||
ModuleRegistrationName.REGION
|
||||
) as IRegionModuleService
|
||||
|
||||
const [region] = await regionService.create([
|
||||
const [region] = await regionService.createRegions([
|
||||
{
|
||||
name: "Test region",
|
||||
currency_code: "eur",
|
||||
|
||||
@@ -27,7 +27,7 @@ medusaIntegrationTestRunner({
|
||||
})
|
||||
|
||||
it("should correctly implement the entire lifecycle of a store", async () => {
|
||||
const createdStore = await service.create({
|
||||
const createdStore = await service.createStores({
|
||||
name: "Test store",
|
||||
supported_currency_codes: ["usd"],
|
||||
})
|
||||
@@ -56,8 +56,11 @@ medusaIntegrationTestRunner({
|
||||
})
|
||||
)
|
||||
|
||||
await service.delete(createdStore.id)
|
||||
const listedStores = await api.get(`/admin/stores?id=${createdStore.id}`, adminHeaders)
|
||||
await service.deleteStores(createdStore.id)
|
||||
const listedStores = await api.get(
|
||||
`/admin/stores?id=${createdStore.id}`,
|
||||
adminHeaders
|
||||
)
|
||||
expect(listedStores.data.stores).toHaveLength(0)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -31,7 +31,7 @@ medusaIntegrationTestRunner({
|
||||
const region = await service.createTaxRegions({
|
||||
country_code: "us",
|
||||
})
|
||||
const rate = await service.create({
|
||||
const rate = await service.createTaxRates({
|
||||
tax_region_id: region.id,
|
||||
code: "test",
|
||||
rate: 2.5,
|
||||
@@ -69,14 +69,14 @@ medusaIntegrationTestRunner({
|
||||
country_code: "us",
|
||||
})
|
||||
|
||||
await service.create({
|
||||
await service.createTaxRates({
|
||||
tax_region_id: region.id,
|
||||
code: "low",
|
||||
rate: 2.5,
|
||||
name: "low rate",
|
||||
})
|
||||
|
||||
await service.create({
|
||||
await service.createTaxRates({
|
||||
tax_region_id: region.id,
|
||||
code: "high",
|
||||
rate: 5,
|
||||
@@ -384,7 +384,7 @@ medusaIntegrationTestRunner({
|
||||
deleted: true,
|
||||
})
|
||||
|
||||
const rates = await service.list(
|
||||
const rates = await service.listTaxRates(
|
||||
{ id: rateRes.data.tax_rate.id },
|
||||
{ withDeleted: true }
|
||||
)
|
||||
@@ -397,7 +397,7 @@ medusaIntegrationTestRunner({
|
||||
country_code: "us",
|
||||
})
|
||||
|
||||
const rate = await service.create({
|
||||
const rate = await service.createTaxRates({
|
||||
tax_region_id: region.id,
|
||||
code: "test",
|
||||
rate: 2.5,
|
||||
|
||||
@@ -36,7 +36,7 @@ medusaIntegrationTestRunner({
|
||||
country_code: "us",
|
||||
})
|
||||
|
||||
const [rateOne, rateTwo] = await service.create([
|
||||
const [rateOne, rateTwo] = await service.createTaxRates([
|
||||
{
|
||||
tax_region_id: taxRegion.id,
|
||||
rate: 10,
|
||||
@@ -123,7 +123,7 @@ medusaIntegrationTestRunner({
|
||||
country_code: "us",
|
||||
})
|
||||
|
||||
const [rateOne, rateTwo] = await service.create([
|
||||
const [rateOne, rateTwo] = await service.createTaxRates([
|
||||
{
|
||||
tax_region_id: taxRegion.id,
|
||||
rate: 10,
|
||||
|
||||
@@ -27,7 +27,7 @@ medusaIntegrationTestRunner({
|
||||
})
|
||||
|
||||
it("should delete a single user", async () => {
|
||||
const user = await userModuleService.create({
|
||||
const user = await userModuleService.createUsers({
|
||||
email: "member@test.com",
|
||||
})
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ medusaIntegrationTestRunner({
|
||||
})
|
||||
|
||||
it("should list users", async () => {
|
||||
await userModuleService.create([
|
||||
await userModuleService.createUsers([
|
||||
{
|
||||
email: "member@test.com",
|
||||
},
|
||||
|
||||
@@ -27,7 +27,7 @@ medusaIntegrationTestRunner({
|
||||
})
|
||||
|
||||
it("should retrieve a single user", async () => {
|
||||
const user = await userModuleService.create({
|
||||
const user = await userModuleService.createUsers({
|
||||
email: "member@test.com",
|
||||
})
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ medusaIntegrationTestRunner({
|
||||
})
|
||||
|
||||
it("should update a single user", async () => {
|
||||
const user = await userModuleService.create({
|
||||
const user = await userModuleService.createUsers({
|
||||
email: "member@test.com",
|
||||
})
|
||||
|
||||
|
||||
@@ -13,16 +13,20 @@ export const createAuthenticatedCustomer = async (
|
||||
ModuleRegistrationName.CUSTOMER
|
||||
)
|
||||
|
||||
const customer = await customerModuleService.create({
|
||||
const customer = await customerModuleService.createCustomers({
|
||||
first_name: "John",
|
||||
last_name: "Doe",
|
||||
email: "john@me.com",
|
||||
...customerData,
|
||||
})
|
||||
|
||||
const authIdentity = await authService.create({
|
||||
entity_id: "store_user",
|
||||
provider: "emailpass",
|
||||
const authIdentity = await authService.createAuthIdentities({
|
||||
provider_identities: [
|
||||
{
|
||||
entity_id: "store_user",
|
||||
provider: "emailpass",
|
||||
},
|
||||
],
|
||||
app_metadata: {
|
||||
customer_id: customer.id,
|
||||
},
|
||||
|
||||
@@ -5,7 +5,7 @@ export const createDefaultRuleTypes = async (container) => {
|
||||
"pricingModuleService"
|
||||
)
|
||||
|
||||
return pricingModuleService.createRuleTypes([
|
||||
return await pricingModuleService.createRuleTypes([
|
||||
{
|
||||
name: "region_id",
|
||||
rule_attribute: "region_id",
|
||||
|
||||
@@ -30,7 +30,7 @@ export const createVariantPriceSet = async ({
|
||||
"pricingModuleService"
|
||||
)
|
||||
|
||||
const priceSet = await pricingModuleService.create({
|
||||
const priceSet = await pricingModuleService.createPriceSets({
|
||||
rules,
|
||||
prices,
|
||||
})
|
||||
@@ -40,7 +40,7 @@ export const createVariantPriceSet = async ({
|
||||
[Modules.PRICING]: { price_set_id: priceSet.id },
|
||||
})
|
||||
|
||||
return await pricingModuleService.retrieve(priceSet.id, {
|
||||
return await pricingModuleService.retrievePriceSet(priceSet.id, {
|
||||
relations: ["prices"],
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user