From ad21bd30b16a8c53d3905a0f71303728ed757fff Mon Sep 17 00:00:00 2001 From: Oli Juhl <59018053+olivermrbl@users.noreply.github.com> Date: Tue, 28 May 2024 08:44:33 +0200 Subject: [PATCH] fix: errors thrown in transformer (#7480) * chore: wup * throw on error * add back test --------- Co-authored-by: Carlos R. L. Rodrigues --- .../shipping-options/store/shipping-options.spec.ts | 9 ++++----- .../core/workflows-sdk/src/helper/workflow-export.ts | 6 +++++- packages/medusa/src/api/store/shipping-options/route.ts | 2 +- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/integration-tests/modules/__tests__/shipping-options/store/shipping-options.spec.ts b/integration-tests/modules/__tests__/shipping-options/store/shipping-options.spec.ts index b7b2095ffba18..aef2300f64997 100644 --- a/integration-tests/modules/__tests__/shipping-options/store/shipping-options.spec.ts +++ b/integration-tests/modules/__tests__/shipping-options/store/shipping-options.spec.ts @@ -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) diff --git a/packages/core/workflows-sdk/src/helper/workflow-export.ts b/packages/core/workflows-sdk/src/helper/workflow-export.ts index a8cc2261ae6ea..c5fa4dde67d4b 100644 --- a/packages/core/workflows-sdk/src/helper/workflow-export.ts +++ b/packages/core/workflows-sdk/src/helper/workflow-export.ts @@ -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) }) diff --git a/packages/medusa/src/api/store/shipping-options/route.ts b/packages/medusa/src/api/store/shipping-options/route.ts index 222bb708167e5..8c6351672f9a3 100644 --- a/packages/medusa/src/api/store/shipping-options/route.ts +++ b/packages/medusa/src/api/store/shipping-options/route.ts @@ -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 }