fix: Switch to zod for customer endpoints, fix inconsistencies (#7094)
This commit is contained in:
@@ -13,7 +13,7 @@ const adminHeaders = {
|
||||
medusaIntegrationTestRunner({
|
||||
env,
|
||||
testSuite: ({ dbConnection, getContainer, api }) => {
|
||||
describe("POST /admin/customer-groups/:id/customers/batch/add", () => {
|
||||
describe("POST /admin/customer-groups/:id/customers/batch", () => {
|
||||
let appContainer
|
||||
let customerModuleService: ICustomerModuleService
|
||||
|
||||
@@ -48,9 +48,9 @@ medusaIntegrationTestRunner({
|
||||
])
|
||||
|
||||
const response = await api.post(
|
||||
`/admin/customer-groups/${group.id}/customers/batch/add`,
|
||||
`/admin/customer-groups/${group.id}/customers/batch`,
|
||||
{
|
||||
customer_ids: customers.map((c) => ({ id: c.id })),
|
||||
create: customers.map((c) => c.id),
|
||||
},
|
||||
adminHeaders
|
||||
)
|
||||
|
||||
@@ -13,7 +13,7 @@ const adminHeaders = {
|
||||
medusaIntegrationTestRunner({
|
||||
env,
|
||||
testSuite: ({ dbConnection, getContainer, api }) => {
|
||||
describe("POST /admin/customer-groups/:id/customers/batch/remove", () => {
|
||||
describe("POST /admin/customer-groups/:id/customers/batch", () => {
|
||||
let appContainer
|
||||
let customerModuleService: ICustomerModuleService
|
||||
|
||||
@@ -55,9 +55,9 @@ medusaIntegrationTestRunner({
|
||||
)
|
||||
|
||||
const response = await api.post(
|
||||
`/admin/customer-groups/${group.id}/customers/batch/remove`,
|
||||
`/admin/customer-groups/${group.id}/customers/batch`,
|
||||
{
|
||||
customer_ids: customers.map((c) => ({ id: c.id })),
|
||||
delete: customers.map((c) => c.id),
|
||||
},
|
||||
adminHeaders
|
||||
)
|
||||
|
||||
@@ -13,7 +13,7 @@ const adminHeaders = {
|
||||
medusaIntegrationTestRunner({
|
||||
env,
|
||||
testSuite: ({ dbConnection, getContainer, api }) => {
|
||||
describe("GET /admin/customer-groups/:id/customers", () => {
|
||||
describe("GET customer group customers", () => {
|
||||
let appContainer
|
||||
let customerModuleService: ICustomerModuleService
|
||||
|
||||
@@ -54,7 +54,7 @@ medusaIntegrationTestRunner({
|
||||
)
|
||||
|
||||
const response = await api.get(
|
||||
`/admin/customer-groups/${group.id}/customers`,
|
||||
`/admin/customers?groups[]=${group.id}`,
|
||||
adminHeaders
|
||||
)
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ medusaIntegrationTestRunner({
|
||||
})
|
||||
|
||||
const response = await api.post(
|
||||
`/admin/customers/${customer.id}/addresses`,
|
||||
`/admin/customers/${customer.id}/addresses?fields=*addresses`,
|
||||
{
|
||||
first_name: "John",
|
||||
last_name: "Doe",
|
||||
@@ -45,13 +45,15 @@ medusaIntegrationTestRunner({
|
||||
)
|
||||
|
||||
expect(response.status).toEqual(200)
|
||||
expect(response.data.address).toEqual(
|
||||
expect.objectContaining({
|
||||
id: expect.any(String),
|
||||
first_name: "John",
|
||||
last_name: "Doe",
|
||||
address_1: "Test street 1",
|
||||
})
|
||||
expect(response.data.customer.addresses).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
id: expect.any(String),
|
||||
first_name: "John",
|
||||
last_name: "Doe",
|
||||
address_1: "Test street 1",
|
||||
}),
|
||||
])
|
||||
)
|
||||
|
||||
const customerWithAddresses = await customerModuleService.retrieve(
|
||||
|
||||
@@ -42,7 +42,7 @@ medusaIntegrationTestRunner({
|
||||
})
|
||||
|
||||
const response = await api.post(
|
||||
`/admin/customers/${customer.id}/addresses/${address.id}`,
|
||||
`/admin/customers/${customer.id}/addresses/${address.id}?fields=*addresses`,
|
||||
{
|
||||
first_name: "Jane",
|
||||
},
|
||||
@@ -50,12 +50,14 @@ medusaIntegrationTestRunner({
|
||||
)
|
||||
|
||||
expect(response.status).toEqual(200)
|
||||
expect(response.data.address).toEqual(
|
||||
expect.objectContaining({
|
||||
id: expect.any(String),
|
||||
first_name: "Jane",
|
||||
last_name: "Doe",
|
||||
})
|
||||
expect(response.data.customer.addresses).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
id: expect.any(String),
|
||||
first_name: "Jane",
|
||||
last_name: "Doe",
|
||||
}),
|
||||
])
|
||||
)
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user