fix: tests

This commit is contained in:
zakariaelas committed 2021-10-01 16:41:27 +01:00
1 parent 632ad17e3f
commit db83448d18
15 files changed
+793 -1061

No files matched your search

+1 -1
View File
@@ -88,4 +88,4 @@
"winston": "^3.2.1"
},
"gitHead": "41a5425405aea5045a26def95c0dc00cf4a5a44d"
}
}
@@ -81,12 +81,14 @@ export default async (req, res) => {
.optional(),
})
.optional(),
rma_shipping_options: Validator.array().items({
option_id: Validator.string().optional(),
price: Validator.number()
.integer()
.optional(),
}),
rma_shipping_options: Validator.array()
.items({
option_id: Validator.string().optional(),
price: Validator.number()
.integer()
.optional(),
})
.default([]),
additional_items: Validator.array().items({
variant_id: Validator.string().required(),
quantity: Validator.number().required(),
@@ -1,7 +1,6 @@
import _ from "lodash"
import { Validator, MedusaError } from "medusa-core-utils"
import { defaultFields, defaultRelations } from "./"
import { CartType } from "../../../../models/cart"
/**
* @oas [post] /carts/{id}/shipping-methods
@@ -1,5 +1,4 @@
import { Validator, MedusaError } from "medusa-core-utils"
import { CartType } from "../../../../models/cart"
/**
* @oas [get] /shipping-options/{cart_id}
@@ -42,7 +41,7 @@ export default async (req, res) => {
})
let options
if (cart.type === CartType.SWAP || cart.type === CartType.CLAIM) {
if (cart.type === "swap" || cart.type === "claim") {
options = await shippingProfileService.fetchRMAOptions(cart)
} else {
options = await shippingProfileService.fetchCartOptions(cart)
@@ -108,7 +108,7 @@ export default async (req, res) => {
case "started": {
const { key, error } = await idempotencyKeyService.workStage(
idempotencyKey.idempotency_key,
async (manager) => {
async manager => {
const order = await orderService
.withTransaction(manager)
.retrieve(value.order_id, {
@@ -130,6 +130,7 @@ export default async (req, res) => {
value.return_items,
value.additional_items,
returnShipping,
[],
{
idempotency_key: idempotencyKey.idempotency_key,
no_notification: true,
@@ -163,7 +164,7 @@ export default async (req, res) => {
case "swap_created": {
const { key, error } = await idempotencyKeyService.workStage(
idempotencyKey.idempotency_key,
async (manager) => {
async manager => {
const swaps = await swapService.list({
idempotency_key: idempotencyKey.idempotency_key,
})
+1 -1
View File
@@ -1327,7 +1327,7 @@ class CartService extends BaseService {
})
const { shipping_methods } = cart
const customPrice = data.price ? { price: data.price } : {}
const customPrice = data && data.price ? { price: data.price } : {}
const newMethod = await this.shippingOptionService_
.withTransaction(manager)
.createShippingMethod(optionId, data, {
@@ -2,7 +2,6 @@ import _ from "lodash"
import { MedusaError } from "medusa-core-utils"
import { BaseService } from "medusa-interfaces"
import { Any, In } from "typeorm"
import { CartType } from "../models/cart"
/**
* Provides layer to manipulate profiles.
@@ -449,7 +448,7 @@ class ShippingProfileService extends BaseService {
* @return {[RMAShippingOptions | ShippingOptions]} a list of the available rma or normal shipping options
*/
async fetchRMAOptions(cart) {
if (cart.type === CartType.DEFAULT) {
if (cart.type === "default") {
throw new MedusaError(MedusaError.Types.INVALID_DATA, "error")
}
@@ -457,7 +456,7 @@ class ShippingProfileService extends BaseService {
this.swapRepository_
)
if (cart.type === CartType.SWAP) {
if (cart.type === "swap") {
const swap = await swapRepo.findOne({
where: { cart_id: cart.id },
relations: ["rma_shipping_options"],
+700 -968
View File
File diff suppressed because it is too large. Load diff