Skip to content

Commit

Permalink
chore: joiner config entity property (medusajs#9084)
Browse files Browse the repository at this point in the history
  • Loading branch information
carlos-r-l-rodrigues authored Sep 11, 2024
1 parent 28dc8d4 commit fdd0543
Show file tree
Hide file tree
Showing 80 changed files with 464 additions and 294 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ medusaIntegrationTestRunner({

expect(response.status).toEqual(200)

const [address] = await customerModuleService.listAddresses({
const [address] = await customerModuleService.listCustomerAddresses({
customer_id: customer.id,
is_default_shipping: true,
})
Expand Down Expand Up @@ -126,7 +126,7 @@ medusaIntegrationTestRunner({

expect(response.status).toEqual(200)

const [address] = await customerModuleService.listAddresses({
const [address] = await customerModuleService.listCustomerAddresses({
customer_id: customer.id,
is_default_billing: true,
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ medusaIntegrationTestRunner({
last_name: "Doe",
})

const address = await customerModuleService.createAddresses({
const address = await customerModuleService.createCustomerAddresses({
customer_id: customer.id,
first_name: "John",
last_name: "Doe",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ medusaIntegrationTestRunner({
last_name: "Doe",
})

const address = await customerModuleService.createAddresses({
const address = await customerModuleService.createCustomerAddresses({
customer_id: customer.id,
first_name: "John",
last_name: "Doe",
Expand Down Expand Up @@ -66,21 +66,23 @@ medusaIntegrationTestRunner({
first_name: "John",
last_name: "Doe",
})
const [, address] = await customerModuleService.createAddresses([
{
customer_id: customer.id,
first_name: "John",
last_name: "Doe",
address_1: "Test street 1",
is_default_shipping: true,
},
{
customer_id: customer.id,
first_name: "John",
last_name: "Doe",
address_1: "Test street 2",
},
])
const [, address] = await customerModuleService.createCustomerAddresses(
[
{
customer_id: customer.id,
first_name: "John",
last_name: "Doe",
address_1: "Test street 1",
is_default_shipping: true,
},
{
customer_id: customer.id,
first_name: "John",
last_name: "Doe",
address_1: "Test street 2",
},
]
)

const response = await api.post(
`/admin/customers/${customer.id}/addresses/${address.id}`,
Expand All @@ -93,10 +95,11 @@ medusaIntegrationTestRunner({

expect(response.status).toEqual(200)

const [defaultAddress] = await customerModuleService.listAddresses({
customer_id: customer.id,
is_default_shipping: true,
})
const [defaultAddress] =
await customerModuleService.listCustomerAddresses({
customer_id: customer.id,
is_default_shipping: true,
})

expect(defaultAddress.first_name).toEqual("jane")
expect(defaultAddress.address_1).toEqual("Test street 2")
Expand All @@ -108,21 +111,23 @@ medusaIntegrationTestRunner({
first_name: "John",
last_name: "Doe",
})
const [, address] = await customerModuleService.createAddresses([
{
customer_id: customer.id,
first_name: "John",
last_name: "Doe",
address_1: "Test street 1",
is_default_billing: true,
},
{
customer_id: customer.id,
first_name: "John",
last_name: "Doe",
address_1: "Test street 2",
},
])
const [, address] = await customerModuleService.createCustomerAddresses(
[
{
customer_id: customer.id,
first_name: "John",
last_name: "Doe",
address_1: "Test street 1",
is_default_billing: true,
},
{
customer_id: customer.id,
first_name: "John",
last_name: "Doe",
address_1: "Test street 2",
},
]
)

const response = await api.post(
`/admin/customers/${customer.id}/addresses/${address.id}`,
Expand All @@ -135,10 +140,11 @@ medusaIntegrationTestRunner({

expect(response.status).toEqual(200)

const [defaultAddress] = await customerModuleService.listAddresses({
customer_id: customer.id,
is_default_billing: true,
})
const [defaultAddress] =
await customerModuleService.listCustomerAddresses({
customer_id: customer.id,
is_default_billing: true,
})

expect(defaultAddress.first_name).toEqual("jane")
expect(defaultAddress.address_1).toEqual("Test street 2")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ medusaIntegrationTestRunner({
appContainer
)

const address = await customerModuleService.createAddresses({
const address = await customerModuleService.createCustomerAddresses({
customer_id: customer.id,
first_name: "John",
last_name: "Doe",
Expand Down Expand Up @@ -57,7 +57,7 @@ medusaIntegrationTestRunner({
first_name: "Jane",
last_name: "Doe",
})
const address = await customerModuleService.createAddresses({
const address = await customerModuleService.createCustomerAddresses({
customer_id: otherCustomer.id,
first_name: "John",
last_name: "Doe",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ medusaIntegrationTestRunner({
appContainer
)

await customerModuleService.createAddresses([
await customerModuleService.createCustomerAddresses([
{
first_name: "Test",
last_name: "Test",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ medusaIntegrationTestRunner({
appContainer
)

const address = await customerModuleService.createAddresses({
const address = await customerModuleService.createCustomerAddresses({
customer_id: customer.id,
first_name: "John",
last_name: "Doe",
Expand Down Expand Up @@ -59,7 +59,7 @@ medusaIntegrationTestRunner({
last_name: "Doe",
})

const address = await customerModuleService.createAddresses({
const address = await customerModuleService.createCustomerAddresses({
customer_id: otherCustomer.id,
first_name: "John",
last_name: "Doe",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { medusaIntegrationTestRunner } from "medusa-test-utils"

import CurrencyModule from "@medusajs/currency"
import { MedusaModule } from "@medusajs/modules-sdk"
import RegionModule from "@medusajs/region"
import ProductModule from "@medusajs/product"
import RegionModule from "@medusajs/region"
import { defineLink } from "@medusajs/utils"

jest.setTimeout(50000)
Expand Down Expand Up @@ -43,6 +43,7 @@ medusaIntegrationTestRunner({
relationships: [
{
serviceName: "currency",
entity: "Currency",
primaryKey: "code",
foreignKey: "currency_code",
alias: "currency",
Expand All @@ -53,6 +54,7 @@ medusaIntegrationTestRunner({
},
{
serviceName: "region",
entity: "Region",
primaryKey: "id",
foreignKey: "region_id",
alias: "region",
Expand All @@ -69,6 +71,7 @@ medusaIntegrationTestRunner({
region: {
path: "region_link.region",
isList: false,
forwardArgumentsOnPath: ["region_link.region"],
},
},
relationship: {
Expand All @@ -85,6 +88,7 @@ medusaIntegrationTestRunner({
currency: {
path: "currency_link.currency",
isList: false,
forwardArgumentsOnPath: ["currency_link.currency"],
},
},
relationship: {
Expand Down Expand Up @@ -134,6 +138,7 @@ medusaIntegrationTestRunner({
relationships: [
{
serviceName: "productService",
entity: "ProductVariant",
primaryKey: "id",
foreignKey: "product_variant_id",
alias: "product_variant",
Expand All @@ -144,6 +149,7 @@ medusaIntegrationTestRunner({
},
{
serviceName: "region",
entity: "Region",
primaryKey: "id",
foreignKey: "region_id",
alias: "region",
Expand All @@ -160,6 +166,7 @@ medusaIntegrationTestRunner({
region: {
path: "region_link.region",
isList: false,
forwardArgumentsOnPath: ["region_link.region"],
},
},
relationship: {
Expand All @@ -176,6 +183,9 @@ medusaIntegrationTestRunner({
product_variant: {
path: "product_variant_link.product_variant",
isList: false,
forwardArgumentsOnPath: [
"product_variant_link.product_variant",
],
},
},
relationship: {
Expand Down Expand Up @@ -228,6 +238,7 @@ medusaIntegrationTestRunner({
relationships: [
{
serviceName: "currency",
entity: "Currency",
primaryKey: "code",
foreignKey: "currency_code",
alias: "currency",
Expand All @@ -238,6 +249,7 @@ medusaIntegrationTestRunner({
},
{
serviceName: "region",
entity: "Region",
primaryKey: "id",
foreignKey: "region_id",
alias: "region",
Expand All @@ -254,6 +266,7 @@ medusaIntegrationTestRunner({
region: {
path: "region_link.region",
isList: false,
forwardArgumentsOnPath: ["region_link.region"],
},
},
relationship: {
Expand All @@ -270,6 +283,7 @@ medusaIntegrationTestRunner({
currency: {
path: "currency_link.currency",
isList: false,
forwardArgumentsOnPath: ["currency_link.currency"],
},
},
relationship: {
Expand Down Expand Up @@ -318,6 +332,7 @@ medusaIntegrationTestRunner({
relationships: [
{
serviceName: "currency",
entity: "Currency",
primaryKey: "code",
foreignKey: "currency_code",
alias: "currency",
Expand All @@ -328,6 +343,7 @@ medusaIntegrationTestRunner({
},
{
serviceName: "region",
entity: "Region",
primaryKey: "id",
foreignKey: "region_id",
alias: "region",
Expand All @@ -344,6 +360,7 @@ medusaIntegrationTestRunner({
regions: {
path: "region_link.region",
isList: true,
forwardArgumentsOnPath: ["region_link.region"],
},
},
relationship: {
Expand All @@ -360,6 +377,7 @@ medusaIntegrationTestRunner({
currency: {
path: "currency_link.currency",
isList: false,
forwardArgumentsOnPath: ["currency_link.currency"],
},
},
relationship: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export const createCustomerAddressesStep = createStep(
ModuleRegistrationName.CUSTOMER
)

const addresses = await service.createAddresses(data)
const addresses = await service.createCustomerAddresses(data)

return new StepResponse(
addresses,
Expand All @@ -32,6 +32,6 @@ export const createCustomerAddressesStep = createStep(
ModuleRegistrationName.CUSTOMER
)

await service.deleteAddresses(ids)
await service.deleteCustomerAddresses(ids)
}
)
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ export const deleteCustomerAddressesStep = createStep(
ModuleRegistrationName.CUSTOMER
)

const existing = await service.listAddresses({
const existing = await service.listCustomerAddresses({
id: ids,
})
await service.deleteAddresses(ids)
await service.deleteCustomerAddresses(ids)

return new StepResponse(void 0, existing)
},
Expand All @@ -29,6 +29,6 @@ export const deleteCustomerAddressesStep = createStep(
ModuleRegistrationName.CUSTOMER
)

await service.createAddresses(prevAddresses)
await service.createCustomerAddresses(prevAddresses)
}
)
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export const maybeUnsetDefaultBillingAddressesStep = createStep(
ModuleRegistrationName.CUSTOMER
)

await customerModuleService.updateAddresses(
await customerModuleService.updateCustomerAddresses(
{ id: addressesToSet },
{ is_default_billing: true }
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export const maybeUnsetDefaultShippingAddressesStep = createStep(
ModuleRegistrationName.CUSTOMER
)

await customerModuleService.updateAddresses(
await customerModuleService.updateCustomerAddresses(
{ id: addressesToSet },
{ is_default_shipping: true }
)
Expand Down
Loading

0 comments on commit fdd0543

Please sign in to comment.