fix: failing integration tests
This commit is contained in:
@@ -19,12 +19,12 @@ Object {
|
||||
"mid_code": null,
|
||||
"options": Array [
|
||||
Object {
|
||||
"created_at": "2021-10-13T08:02:41.668Z",
|
||||
"created_at": Any<String>,
|
||||
"deleted_at": null,
|
||||
"id": "test-variant-option",
|
||||
"metadata": null,
|
||||
"option_id": "test-option",
|
||||
"updated_at": "2021-10-13T08:02:41.668Z",
|
||||
"updated_at": Any<String>,
|
||||
"value": "Default variant",
|
||||
"variant_id": "test-variant",
|
||||
},
|
||||
@@ -75,12 +75,12 @@ Object {
|
||||
"mid_code": null,
|
||||
"options": Array [
|
||||
Object {
|
||||
"created_at": "2021-10-13T08:02:41.493Z",
|
||||
"created_at": Any<String>,
|
||||
"deleted_at": null,
|
||||
"id": "test-variant-option",
|
||||
"metadata": null,
|
||||
"option_id": "test-option",
|
||||
"updated_at": "2021-10-13T08:02:41.493Z",
|
||||
"updated_at": Any<String>,
|
||||
"value": "Default variant",
|
||||
"variant_id": "test-variant",
|
||||
},
|
||||
|
||||
@@ -65,6 +65,12 @@ describe("/store/variants", () => {
|
||||
updated_at: expect.any(String),
|
||||
weight: null,
|
||||
width: null,
|
||||
options: [
|
||||
{
|
||||
created_at: expect.any(String),
|
||||
updated_at: expect.any(String),
|
||||
},
|
||||
],
|
||||
prices: [
|
||||
{
|
||||
created_at: expect.any(String),
|
||||
@@ -113,6 +119,12 @@ describe("/store/variants", () => {
|
||||
updated_at: expect.any(String),
|
||||
weight: null,
|
||||
width: null,
|
||||
options: [
|
||||
{
|
||||
created_at: expect.any(String),
|
||||
updated_at: expect.any(String),
|
||||
},
|
||||
],
|
||||
prices: [
|
||||
{
|
||||
created_at: expect.any(String),
|
||||
|
||||
@@ -66,9 +66,9 @@ export default async (req, res) => {
|
||||
|
||||
try {
|
||||
const customerService = req.scope.resolve("customerService")
|
||||
let customer = await customerService.update(id, value)
|
||||
await customerService.update(id, value)
|
||||
|
||||
customer = await customerService.retrieve(customer.id, {
|
||||
const customer = await customerService.retrieve(id, {
|
||||
relations: defaultRelations,
|
||||
select: defaultFields,
|
||||
})
|
||||
|
||||
@@ -224,7 +224,6 @@ class CustomerService extends BaseService {
|
||||
const query = this.buildQuery_({ id: validatedId }, config)
|
||||
|
||||
const customer = await customerRepo.findOne(query)
|
||||
|
||||
if (!customer) {
|
||||
throw new MedusaError(
|
||||
MedusaError.Types.NOT_FOUND,
|
||||
@@ -286,7 +285,7 @@ class CustomerService extends BaseService {
|
||||
/**
|
||||
* Hashes a password
|
||||
* @param {string} password - the value to hash
|
||||
* @return {string} hashed password
|
||||
* @return {Promise<string>} hashed password
|
||||
*/
|
||||
async hashPassword_(password) {
|
||||
const buf = await Scrypt.kdf(password, { logN: 1, r: 1, p: 1 })
|
||||
@@ -371,7 +370,14 @@ class CustomerService extends BaseService {
|
||||
|
||||
const customer = await this.retrieve(customerId)
|
||||
|
||||
const { email, password, metadata, ...rest } = update
|
||||
const {
|
||||
email,
|
||||
password,
|
||||
metadata,
|
||||
billing_address,
|
||||
billing_address_id,
|
||||
...rest
|
||||
} = update
|
||||
|
||||
if (metadata) {
|
||||
customer.metadata = this.setMetadata_(customer, metadata)
|
||||
@@ -381,7 +387,7 @@ class CustomerService extends BaseService {
|
||||
customer.email = this.validateEmail_(email)
|
||||
}
|
||||
|
||||
if ("billing_address_id" in update || "billing_address" in update) {
|
||||
if (billing_address_id || billing_address) {
|
||||
const address = update.billing_address_id || update.billing_address
|
||||
await this.updateBillingAddress_(customer, address, addrRepo)
|
||||
}
|
||||
@@ -421,7 +427,6 @@ class CustomerService extends BaseService {
|
||||
|
||||
if (addressOrId.id) {
|
||||
customer.billing_address_id = addressOrId.id
|
||||
customer.billing_address = addressOrId
|
||||
} else {
|
||||
if (customer.billing_address_id) {
|
||||
const addr = await addrRepo.findOne({
|
||||
|
||||
Reference in New Issue
Block a user