From 7e767e408955687f8841acb6fb68e9b34e44efd7 Mon Sep 17 00:00:00 2001 From: Peter Clement Date: Fri, 13 Sep 2024 12:25:39 +0100 Subject: [PATCH] some pr comments --- .../tests/scenarios/looping.spec.ts | 9 +++-- .../tests/scenarios/scenarios.spec.ts | 2 +- .../tests/utilities/AutomationTestBuilder.ts | 38 +++++++++++-------- .../documents/app/automation/automation.ts | 1 + 4 files changed, 30 insertions(+), 20 deletions(-) diff --git a/packages/server/src/automations/tests/scenarios/looping.spec.ts b/packages/server/src/automations/tests/scenarios/looping.spec.ts index f229610542..6dde05ddb8 100644 --- a/packages/server/src/automations/tests/scenarios/looping.spec.ts +++ b/packages/server/src/automations/tests/scenarios/looping.spec.ts @@ -255,12 +255,15 @@ describe("Loop automations", () => { option: LoopStepType.ARRAY, binding: [1, 2, 3], }, - "FirstLoopStep" + { stepName: "FirstLoopStep" } + ) + .serverLog( + { text: "Message {{loop.currentItem}}" }, + { stepName: "FirstLoopLog" } ) - .serverLog({ text: "Message {{loop.currentItem}}" }, "FirstLoopLog") .serverLog( { text: "{{steps.FirstLoopLog.iterations}}" }, - "FirstLoopIterationLog" + { stepName: "FirstLoopIterationLog" } ) .run() diff --git a/packages/server/src/automations/tests/scenarios/scenarios.spec.ts b/packages/server/src/automations/tests/scenarios/scenarios.spec.ts index 398ef20100..49c05984fe 100644 --- a/packages/server/src/automations/tests/scenarios/scenarios.spec.ts +++ b/packages/server/src/automations/tests/scenarios/scenarios.spec.ts @@ -217,7 +217,7 @@ describe("Automation Scenarios", () => { { tableId: table._id!, }, - "InitialQueryStep" + { stepName: "InitialQueryStep" } ) .deleteRow({ tableId: table._id!, diff --git a/packages/server/src/automations/tests/utilities/AutomationTestBuilder.ts b/packages/server/src/automations/tests/utilities/AutomationTestBuilder.ts index 34c25d7004..7528ea0f2e 100644 --- a/packages/server/src/automations/tests/utilities/AutomationTestBuilder.ts +++ b/packages/server/src/automations/tests/utilities/AutomationTestBuilder.ts @@ -105,74 +105,80 @@ class BaseStepBuilder { } // STEPS - createRow(inputs: CreateRowStepInputs, stepName?: string): this { + createRow(inputs: CreateRowStepInputs, opts?: { stepName?: string }): this { return this.step( AutomationActionStepId.CREATE_ROW, BUILTIN_ACTION_DEFINITIONS.CREATE_ROW, inputs, - stepName + opts?.stepName ) } - updateRow(inputs: UpdateRowStepInputs, stepName?: string): this { + updateRow(inputs: UpdateRowStepInputs, opts?: { stepName?: string }): this { return this.step( AutomationActionStepId.UPDATE_ROW, BUILTIN_ACTION_DEFINITIONS.UPDATE_ROW, inputs, - stepName + opts?.stepName ) } - deleteRow(inputs: DeleteRowStepInputs, stepName?: string): this { + deleteRow(inputs: DeleteRowStepInputs, opts?: { stepName?: string }): this { return this.step( AutomationActionStepId.DELETE_ROW, BUILTIN_ACTION_DEFINITIONS.DELETE_ROW, inputs, - stepName + opts?.stepName ) } - sendSmtpEmail(inputs: SmtpEmailStepInputs, stepName?: string): this { + sendSmtpEmail( + inputs: SmtpEmailStepInputs, + opts?: { stepName?: string } + ): this { return this.step( AutomationActionStepId.SEND_EMAIL_SMTP, BUILTIN_ACTION_DEFINITIONS.SEND_EMAIL_SMTP, inputs, - stepName + opts?.stepName ) } - executeQuery(inputs: ExecuteQueryStepInputs, stepName?: string): this { + executeQuery( + inputs: ExecuteQueryStepInputs, + opts?: { stepName?: string } + ): this { return this.step( AutomationActionStepId.EXECUTE_QUERY, BUILTIN_ACTION_DEFINITIONS.EXECUTE_QUERY, inputs, - stepName + opts?.stepName ) } - queryRows(inputs: QueryRowsStepInputs, stepName?: string): this { + queryRows(inputs: QueryRowsStepInputs, opts?: { stepName?: string }): this { return this.step( AutomationActionStepId.QUERY_ROWS, BUILTIN_ACTION_DEFINITIONS.QUERY_ROWS, inputs, - stepName + opts?.stepName ) } - loop(inputs: LoopStepInputs, stepName?: string): this { + loop(inputs: LoopStepInputs, opts?: { stepName?: string }): this { return this.step( AutomationActionStepId.LOOP, BUILTIN_ACTION_DEFINITIONS.LOOP, inputs, - stepName + opts?.stepName ) } - serverLog(input: ServerLogStepInputs, stepName?: string): this { + serverLog(input: ServerLogStepInputs, opts?: { stepName?: string }): this { return this.step( AutomationActionStepId.SERVER_LOG, BUILTIN_ACTION_DEFINITIONS.SERVER_LOG, input, - stepName + opts?.stepName ) } } diff --git a/packages/types/src/documents/app/automation/automation.ts b/packages/types/src/documents/app/automation/automation.ts index 78d22c787f..effe99a328 100644 --- a/packages/types/src/documents/app/automation/automation.ts +++ b/packages/types/src/documents/app/automation/automation.ts @@ -124,6 +124,7 @@ export interface Automation extends Document { definition: { steps: AutomationStep[] trigger: AutomationTrigger + // stepNames is used to lookup step names from their correspnding step ID. stepNames?: Record } screenId?: string