diff --git a/packages/core/src/schedule/check.ts b/packages/core/src/schedule/check.ts index 816422d13de..18c2a0c31bf 100644 --- a/packages/core/src/schedule/check.ts +++ b/packages/core/src/schedule/check.ts @@ -71,10 +71,11 @@ export function validate(condition: ScheduleSchema.Condition): Result.Result 1) return Result.fail("Choose at most one of is, matches or changes") if (condition.matches === undefined) return Result.succeed(undefined) diff --git a/packages/core/test/schedule.test.ts b/packages/core/test/schedule.test.ts index 391e92dab92..39802f04043 100644 --- a/packages/core/test/schedule.test.ts +++ b/packages/core/test/schedule.test.ts @@ -1229,6 +1229,26 @@ describe("Schedule", () => { ).toMatchObject({ _tag: "Schedule.InvalidError" }) }), ) + + it.effect("counts only a changes predicate that is turned on", () => + Effect.gen(function* () { + const schedules = yield* setup() + const create = (check: NonNullable[0]["if"]>) => + schedules.create({ + sessionID, + when: { type: "every", every: "15 seconds" }, + if: check, + action: { type: "prompt", prompt: "x" }, + }) + // `changes: false` opts out, so it does not compete with another predicate. + expect(yield* create({ type: "shell", run: "echo hi", is: "hi", changes: false })).toMatchObject({ + if: { type: "shell", run: "echo hi", is: "hi", changes: false }, + }) + expect( + yield* Effect.flip(create({ type: "shell", run: "echo hi", is: "hi", changes: true })), + ).toMatchObject({ reason: "Choose at most one of is, matches or changes" }) + }), + ) }) describe("code checks", () => {