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
@@ -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",
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user