Skip to content

Commit dfa9e7f

Browse files
fix(server): daily workflows with no weekday restriction drop the dangling on (#45281)
Co-authored-by: SAPHID <saphid@users.noreply.github.com> Co-authored-by: Julius Marminge <julius0216@outlook.com>
1 parent 8410595 commit dfa9e7f

2 files changed

Lines changed: 31 additions & 1 deletion

File tree

‎apps/server/src/workflows/WorkflowEngine.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -910,7 +910,7 @@ const make = Effect.fn("WorkflowEngine.make")(function* (
910910
}
911911
const days = trigger.schedule.weekdays;
912912
return `daily at ${trigger.schedule.timeOfDay}${
913-
days === undefined ? "" : ` on ${days.map((day) => WEEKDAYS[day] ?? day).join(", ")}`
913+
days?.length ? ` on ${days.map((day) => WEEKDAYS[day] ?? day).join(", ")}` : ""
914914
}`;
915915
};
916916
const summaries = [...new Set(registered.map(([definition]) => definition.name))].flatMap(

‎apps/server/src/workflows/Workflows.test.ts‎

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2448,6 +2448,36 @@ it("a workflow refuses two daily schedules that fire at the same times", () => {
24482448
checkTriggers("standup", [daily("09:00", { weekdays: [1] }), daily("09:00")]);
24492449
});
24502450

2451+
it.effect("a daily workflow summary lists weekdays only when restricted", () =>
2452+
Effect.gen(function* () {
2453+
const { boot } = yield* harness();
2454+
const definitions = [
2455+
["empty", daily("09:00", { weekdays: [] })],
2456+
["omitted", daily("09:00")],
2457+
["restricted", daily("09:00", { weekdays: [1, 3] })],
2458+
] as const;
2459+
yield* boot(
2460+
Effect.gen(function* () {
2461+
const workflows = yield* Workflows.Workflows;
2462+
const snapshot = Option.getOrThrow(
2463+
yield* Stream.runHead(Workflows.wholeLists(workflows.watch)),
2464+
);
2465+
const summaries = Object.fromEntries(
2466+
snapshot.workflows.map(({ name, triggers }) => [name, triggers]),
2467+
);
2468+
assert.deepStrictEqual(summaries, {
2469+
empty: ["daily at 09:00"],
2470+
omitted: ["daily at 09:00"],
2471+
restricted: ["daily at 09:00 on Mon, Wed"],
2472+
});
2473+
}),
2474+
definitions.map(([name, trigger]) =>
2475+
workflow(name, { version: 1, payload: Tick, triggers: [trigger] }, () => Effect.void),
2476+
),
2477+
);
2478+
}).pipe(Effect.provide(NodeServices.layer), Effect.scoped),
2479+
);
2480+
24512481
it("a workflow refuses two issue triggers whose labels differ only by repetition", () => {
24522482
assert.throws(
24532483
() =>

0 commit comments

Comments
 (0)