diff --git a/integration-tests/http/__tests__/customer/store/customer.spec.ts b/integration-tests/http/__tests__/customer/store/customer.spec.ts index 4fade4635f749..1e94b32b9992c 100644 --- a/integration-tests/http/__tests__/customer/store/customer.spec.ts +++ b/integration-tests/http/__tests__/customer/store/customer.spec.ts @@ -6,6 +6,7 @@ import { generatePublishableKey, generateStoreHeaders, } from "../../../../helpers/create-admin-user" +import { createAuthenticatedCustomer } from "../../../../modules/helpers/create-authenticated-customer" jest.setTimeout(50000) @@ -265,5 +266,38 @@ medusaIntegrationTestRunner({ }) }) }) + + describe("POST /store/customers/me", () => { + it("should successfully update a customer", async () => { + const { customer, jwt } = await createAuthenticatedCustomer( + api, + storeHeaders + ) + + const response = await api.post( + `/store/customers/me`, + { + first_name: "John2", + last_name: "Doe2", + }, + { + headers: { + authorization: `Bearer ${jwt}`, + ...storeHeaders.headers, + }, + } + ) + + expect(response.status).toEqual(200) + expect(response.data).toEqual({ + customer: expect.objectContaining({ + id: customer.id, + first_name: "John2", + last_name: "Doe2", + email: "tony@start.com", + }), + }) + }) + }) }, }) diff --git a/packages/medusa/src/api/store/customers/me/route.ts b/packages/medusa/src/api/store/customers/me/route.ts index d7488876fad68..40ba3357fcd13 100644 --- a/packages/medusa/src/api/store/customers/me/route.ts +++ b/packages/medusa/src/api/store/customers/me/route.ts @@ -46,7 +46,7 @@ export const POST = async ( }) const customer = await refetchCustomer( - req.params.id, + customerId, req.scope, req.remoteQueryConfig.fields )