diff --git a/desktop/src/features/workflows/ui/workflowFormTypes.test.mjs b/desktop/src/features/workflows/ui/workflowFormTypes.test.mjs index 0e78e70d2..133d2ce59 100644 --- a/desktop/src/features/workflows/ui/workflowFormTypes.test.mjs +++ b/desktop/src/features/workflows/ui/workflowFormTypes.test.mjs @@ -1,7 +1,20 @@ import assert from "node:assert/strict"; import test from "node:test"; -import { formStateToYaml, yamlToFormState } from "./workflowFormTypes.ts"; +import { + DEFAULT_FORM_STATE, + formStateToYaml, + TRIGGER_TYPES, + yamlToFormState, +} from "./workflowFormTypes.ts"; + +test("defaults new workflows to the first-listed schedule trigger", () => { + assert.equal(TRIGGER_TYPES[0], "schedule"); + assert.deepEqual(DEFAULT_FORM_STATE.trigger, { + on: "schedule", + cron: "0 9 * * *", + }); +}); test("keeps workflows with step conditions in the YAML editor", () => { const result = yamlToFormState(`name: conditional_step diff --git a/desktop/src/features/workflows/ui/workflowFormTypes.ts b/desktop/src/features/workflows/ui/workflowFormTypes.ts index c7c34b4fc..131d86239 100644 --- a/desktop/src/features/workflows/ui/workflowFormTypes.ts +++ b/desktop/src/features/workflows/ui/workflowFormTypes.ts @@ -3,13 +3,14 @@ import { formatDurationSeconds, parseDurationSeconds, } from "./workflowDuration"; +import { defaultScheduleTrigger } from "./workflowSchedule"; export const TRIGGER_TYPES = [ + "schedule", "message_posted", "reaction_added", "diff_posted", "webhook", - "schedule", ] as const; export type TriggerType = (typeof TRIGGER_TYPES)[number]; @@ -78,7 +79,7 @@ export const DEFAULT_FORM_STATE: WorkflowFormState = { name: "", description: "", enabled: true, - trigger: { on: "message_posted" }, + trigger: defaultScheduleTrigger(), steps: [], };