Skip to content

Commit

Permalink
fix: errors thrown in transformer (#7480)
Browse files Browse the repository at this point in the history
* chore: wup

* throw on error

* add back test

---------

Co-authored-by: Carlos R. L. Rodrigues <rodrigolr@gmail.com>
  • Loading branch information
olivermrbl and carlos-r-l-rodrigues authored May 28, 2024
1 parent 2f20dbd commit ad21bd3
Showing 3 changed files with 10 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -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)
6 changes: 5 additions & 1 deletion packages/core/workflows-sdk/src/helper/workflow-export.ts
Original file line number Diff line number Diff line change
@@ -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)
})
2 changes: 1 addition & 1 deletion packages/medusa/src/api/store/shipping-options/route.ts
Original file line number Diff line number Diff line change
@@ -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 }

0 comments on commit ad21bd3

Please sign in to comment.