fix: errors thrown in transformer (#7480)

* chore: wup

* throw on error

* add back test

---------

Co-authored-by: Carlos R. L. Rodrigues <rodrigolr@gmail.com>
This commit is contained in:
Oli Juhl
2024-05-28 08:44:33 +02:00
committed by GitHub
co-authored by Carlos R. L. Rodrigues
parent 2f20dbd50d
commit ad21bd30b1
3 changed files with 10 additions and 7 deletions
@@ -70,7 +70,7 @@ medusaIntegrationTestRunner({
variants: [
{
title: "Test variant",
inventory_quantity: 10,
manage_inventory: false,
prices: [
{
currency_code: "usd",
@@ -182,10 +182,9 @@ medusaIntegrationTestRunner({
).data.cart
})
describe("GET /admin/shipping-options/:cart_id", () => {
// TODO: Enable it when product workflows manage inventory items
it.skip("should get all shipping options for a cart successfully", async () => {
const resp = await api.get(`/store/shipping-options/${cart.id}`)
describe("GET /admin/shipping-options?cart_id=", () => {
it("should get all shipping options for a cart successfully", async () => {
const resp = await api.get(`/store/shipping-options?cart_id=${cart.id}`)
const shippingOptions = resp.data.shipping_options
expect(shippingOptions).toHaveLength(1)
@@ -5,7 +5,7 @@ import {
TransactionState,
} from "@medusajs/orchestration"
import { LoadedModule, MedusaContainer } from "@medusajs/types"
import { isPresent, MedusaContextType } from "@medusajs/utils"
import { MedusaContextType, isPresent } from "@medusajs/utils"
import { EOL } from "os"
import { ulid } from "ulid"
import { MedusaWorkflow } from "../medusa-workflow"
@@ -99,6 +99,10 @@ function createContextualWorkflowRunner<
result = resolveValue(resultFrom, transaction.getContext())
if (result instanceof Promise) {
result = await result.catch((e) => {
if (throwOnError) {
throw e
}
errors ??= []
errors.push(e)
})
@@ -1,8 +1,8 @@
import { listShippingOptionsForCartWorkflow } from "@medusajs/core-flows"
import { ModuleRegistrationName } from "@medusajs/modules-sdk"
import { ICartModuleService } from "@medusajs/types"
import { MedusaRequest, MedusaResponse } from "../../../types/routing"
import { MedusaError } from "@medusajs/utils"
import { MedusaRequest, MedusaResponse } from "../../../types/routing"
export const GET = async (req: MedusaRequest, res: MedusaResponse) => {
const { cart_id } = req.filterableFields as { cart_id: string }