Chore/rm main entity concept (#7709)
**What** Update the `MedusaService` class, factory and types to remove the concept of main modules. The idea being that all method will be explicitly named and suffixes to represent the object you are trying to manipulate. This pr also includes various fixes in different modules Co-authored-by: Stevche Radevski <4820812+sradevski@users.noreply.github.com> Co-authored-by: Oli Juhl <59018053+olivermrbl@users.noreply.github.com>
This commit is contained in:
co-authored by
Stevche Radevski
Oli Juhl
parent
2895ccfba8
commit
48963f55ef
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user