Skip to content

Commit

Permalink
Merge branch 'develop' into fix/utils-object-from-string-path
Browse files Browse the repository at this point in the history
  • Loading branch information
adrien2p authored Dec 21, 2023
2 parents d791864 + 29bb2e4 commit bbd4b6a
Show file tree
Hide file tree
Showing 228 changed files with 7,125 additions and 765 deletions.
6 changes: 6 additions & 0 deletions .changeset/angry-pigs-shop.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@medusajs/modules-sdk": patch
"@medusajs/types": patch
---

feat(modules-sdk, types): add initial authentication module configuration
8 changes: 8 additions & 0 deletions .changeset/bright-coins-kneel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
"@medusajs/medusa": patch
"medusa-fulfillment-webshipper": patch
"medusa-interfaces": patch
"@medusajs/utils": patch
---

chore(medusa, interfaces, utils, webshiper): Uniformise class checks
5 changes: 5 additions & 0 deletions .changeset/cyan-chicken-roll.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@medusajs/admin-ui": patch
---

feat(admin-ui): Add Czech translation
7 changes: 7 additions & 0 deletions .changeset/eleven-jokes-tan.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@medusajs/orchestration": patch
"@medusajs/utils": patch
"@medusajs/workflows-sdk": patch
---

feat(workflows-sdk): Configurable retries upon step creation
6 changes: 6 additions & 0 deletions .changeset/itchy-knives-stare.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@medusajs/modules-sdk": patch
"@medusajs/types": patch
---

feat(types,modules-sdk): basic module setup for promotions
6 changes: 6 additions & 0 deletions .changeset/old-meals-run.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@medusajs/medusa": patch
"@medusajs/medusa-js": patch
---

fix(medusa, medusa-js): publishable api key bugs
6 changes: 6 additions & 0 deletions .changeset/small-kangaroos-camp.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@medusajs/pricing": patch
"@medusajs/types": patch
---

feat(types, pricing): separate internal pricing module types from types module
5 changes: 5 additions & 0 deletions .changeset/smooth-days-dress.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@medusajs/medusa": patch
---

Feat/cart completion conflict fixes
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ describe("POST /admin/price-lists", () => {
type: "override",
customer_groups: [{ id: "customer-group-1" }],
status: "active",
starts_at: new Date(),
prices: [
{
amount: 400,
Expand Down Expand Up @@ -132,7 +133,7 @@ describe("POST /admin/price-lists", () => {
description: "test",
type: "override",
status: "active",
starts_at: null,
starts_at: expect.any(String),
ends_at: null,
customer_groups: [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,40 @@ describe("Workflow composer", function () {
jest.clearAllMocks()
})

it("should compose a new workflow composed retryable steps", async () => {
const maxRetries = 1

const mockStep1Fn = jest.fn().mockImplementation((input, context) => {
const attempt = context.metadata.attempt || 0
if (attempt <= maxRetries) {
throw new Error("test error")
}

return { inputs: [input], obj: "return from 1" }
})

const step1 = createStep({ name: "step1", maxRetries }, mockStep1Fn)

const workflow = createWorkflow("workflow1", function (input) {
return step1(input)
})

const workflowInput = { test: "payload1" }
const { result: workflowResult } = await workflow().run({
input: workflowInput,
})

expect(mockStep1Fn).toHaveBeenCalledTimes(2)
expect(mockStep1Fn.mock.calls[0]).toHaveLength(2)
expect(mockStep1Fn.mock.calls[0][0]).toEqual(workflowInput)
expect(mockStep1Fn.mock.calls[1][0]).toEqual(workflowInput)

expect(workflowResult).toEqual({
inputs: [{ test: "payload1" }],
obj: "return from 1",
})
})

it("should compose a new workflow and execute it", async () => {
const mockStep1Fn = jest.fn().mockImplementation((input) => {
return { inputs: [input], obj: "return from 1" }
Expand Down Expand Up @@ -928,6 +962,73 @@ describe("Workflow composer", function () {
jest.clearAllMocks()
})

it("should compose a new workflow composed of retryable steps", async () => {
const maxRetries = 1

const mockStep1Fn = jest.fn().mockImplementation((input, context) => {
const attempt = context.metadata.attempt || 0
if (attempt <= maxRetries) {
throw new Error("test error")
}

return new StepResponse({ inputs: [input], obj: "return from 1" })
})

const step1 = createStep({ name: "step1", maxRetries }, mockStep1Fn)

const workflow = createWorkflow("workflow1", function (input) {
return step1(input)
})

const workflowInput = { test: "payload1" }
const { result: workflowResult } = await workflow().run({
input: workflowInput,
})

expect(mockStep1Fn).toHaveBeenCalledTimes(2)
expect(mockStep1Fn.mock.calls[0]).toHaveLength(2)
expect(mockStep1Fn.mock.calls[0][0]).toEqual(workflowInput)
expect(mockStep1Fn.mock.calls[1][0]).toEqual(workflowInput)

expect(workflowResult).toEqual({
inputs: [{ test: "payload1" }],
obj: "return from 1",
})
})

it("should compose a new workflow composed of retryable steps that should stop retries on permanent failure", async () => {
const maxRetries = 1

const mockStep1Fn = jest.fn().mockImplementation((input, context) => {
return StepResponse.permanentFailure("fail permanently")
})

const step1 = createStep({ name: "step1", maxRetries }, mockStep1Fn)

const workflow = createWorkflow("workflow1", function (input) {
return step1(input)
})

const workflowInput = { test: "payload1" }
const { errors } = await workflow().run({
input: workflowInput,
throwOnError: false,
})

expect(mockStep1Fn).toHaveBeenCalledTimes(1)
expect(mockStep1Fn.mock.calls[0]).toHaveLength(2)
expect(mockStep1Fn.mock.calls[0][0]).toEqual(workflowInput)

expect(errors).toHaveLength(1)
expect(errors[0]).toEqual({
action: "step1",
handlerType: "invoke",
error: expect.objectContaining({
message: "fail permanently",
}),
})
})

it("should compose a new workflow and execute it", async () => {
const mockStep1Fn = jest.fn().mockImplementation((input) => {
return new StepResponse({ inputs: [input], obj: "return from 1" })
Expand Down
Loading

0 comments on commit bbd4b6a

Please sign in to comment.