mirror of
https://github.com/block/buzz.git
synced 2026-08-18 06:50:31 +02:00
Default new workflows to schedules
Signed-off-by: Taylor Ho <taylorkmho@gmail.com>
This commit is contained in:
@@ -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: [],
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user