Default new workflows to schedules

Signed-off-by: Taylor Ho <taylorkmho@gmail.com>
This commit is contained in:
Taylor Ho
2026-08-14 15:27:30 -07:00
parent 87cdc413aa
commit b89f435321
2 changed files with 17 additions and 3 deletions
@@ -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
@@ -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: [],
};