Files
medusa-store/integration-tests/modules/helpers/create-authenticated-customer.ts
Riqwan Thamir b7044bb3b0 feat(core-flows,medusa): Add API to update cart's customer (#10151)
what:

- adds an endpoint that updates a cart's customer

RESOLVES CMRC-718
2024-11-19 11:44:25 +00:00

40 lines
870 B
TypeScript

import { CreateCustomerDTO } from "@medusajs/types"
export const createAuthenticatedCustomer = async (
api: any,
storeHeaders: Record<any, any>,
customerData: Partial<CreateCustomerDTO> = {}
) => {
const email = customerData.email ?? "tony@start.com"
const signup = await api.post("/auth/customer/emailpass/register", {
email,
password: "secret_password",
})
const {
data: { customer },
} = await api.post(
"/store/customers",
{
email,
first_name: "John",
last_name: "Doe",
metadata: {},
...customerData,
},
{
headers: {
authorization: `Bearer ${signup.data.token}`,
...storeHeaders.headers,
},
}
)
const signin = await api.post("/auth/customer/emailpass", {
email,
password: "secret_password",
})
return { customer, jwt: signin.data.token }
}