Skip to content

Commit

Permalink
Revert "remove validation for empty conditions"
Browse files Browse the repository at this point in the history
This reverts commit d37c3ab.
  • Loading branch information
PClmnt committed Oct 31, 2024
1 parent 5a9c586 commit 9023864
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
24 changes: 24 additions & 0 deletions packages/server/src/api/routes/tests/automation.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,30 @@ describe("/automations", () => {
})
})

it("Should check validation on a branch step with empty conditions", async () => {
const automation = createAutomationBuilder({
name: "String Equality Branching",
appId: config.getAppId(),
})
.appAction({ fields: { status: "active" } })
.branch({
activeBranch: {
steps: stepBuilder =>
stepBuilder.serverLog({ text: "Active user" }),
condition: {},
},
})
.build()

await config.api.automation.post(automation, {
status: 400,
body: {
message:
'Invalid body - "definition.steps[0].inputs.branches[0].condition" must have at least 1 key',
},
})
})

it("Should check validation on an branch that has a condition that is not valid", async () => {
const automation = createAutomationBuilder({
name: "String Equality Branching",
Expand Down
4 changes: 2 additions & 2 deletions packages/server/src/api/routes/utils/validators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -280,8 +280,8 @@ function generateStepSchema(allowStepTypes: string[]) {
const branchSchema = Joi.object({
id: Joi.string().required(),
name: Joi.string().required(),
condition: filterObject({ unknown: false }).required().allow(null),
conditionUI: Joi.object().allow(null),
condition: filterObject({ unknown: false }).required().min(1),
conditionUI: Joi.object(),
})

return Joi.object({
Expand Down

0 comments on commit 9023864

Please sign in to comment.