Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions apps/sim/app/api/schedules/[id]/route.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ describe('Schedule PUT API (Reactivate)', () => {
expect(nextRunAt).toBeGreaterThan(beforeCall)
expect(nextRunAt).toBeLessThanOrEqual(afterCall + 5 * 60 * 1000 + 1000)
// Should align with 5-minute intervals (minute divisible by 5)
expect(new Date(nextRunAt).getMinutes() % 5).toBe(0)
expect(new Date(nextRunAt).getUTCMinutes() % 5).toBe(0)
})

it('calculates nextRunAt from daily cron expression', async () => {
Expand Down Expand Up @@ -572,7 +572,7 @@ describe('Schedule PUT API (Reactivate)', () => {
expect(nextRunAt.getTime()).toBeGreaterThan(beforeCall)
expect(nextRunAt.getTime()).toBeLessThanOrEqual(beforeCall + 10 * 60 * 1000 + 1000)
// Should align with 10-minute intervals
expect(nextRunAt.getMinutes() % 10).toBe(0)
expect(nextRunAt.getUTCMinutes() % 10).toBe(0)
})

it('handles hourly schedules with timezone correctly', async () => {
Expand All @@ -598,8 +598,8 @@ describe('Schedule PUT API (Reactivate)', () => {

// Should be a future date at minute 15
expect(nextRunAt.getTime()).toBeGreaterThan(beforeCall)
expect(nextRunAt.getMinutes()).toBe(15)
expect(nextRunAt.getSeconds()).toBe(0)
expect(nextRunAt.getUTCMinutes()).toBe(15)
expect(nextRunAt.getUTCSeconds()).toBe(0)
})

it('handles custom cron expressions with complex patterns and timezone', async () => {
Expand Down
10 changes: 5 additions & 5 deletions apps/sim/lib/workflows/schedules/utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -266,9 +266,9 @@ describe('Schedule Utilities', () => {
const nextRun = calculateNextRunTime('minutes', scheduleValues)

// Should return the future start date with time
expect(nextRun.getFullYear()).toBe(2025)
expect(nextRun.getMonth()).toBe(3) // April
expect(nextRun.getDate()).toBe(15)
expect(nextRun.getUTCFullYear()).toBe(2025)
expect(nextRun.getUTCMonth()).toBe(3) // April
expect(nextRun.getUTCDate()).toBe(15)
})

it.concurrent('should calculate next run for hourly schedule using Croner', () => {
Expand All @@ -292,7 +292,7 @@ describe('Schedule Utilities', () => {
expect(nextRun instanceof Date).toBe(true)
expect(nextRun > new Date()).toBe(true)
// Croner calculates based on cron "30 * * * *"
expect(nextRun.getMinutes()).toBe(30)
expect(nextRun.getUTCMinutes()).toBe(30)
})

it.concurrent('should calculate next run for daily schedule using Croner with timezone', () => {
Expand Down Expand Up @@ -439,7 +439,7 @@ describe('Schedule Utilities', () => {

// Should not use the past date but calculate normally
expect(nextRun > new Date()).toBe(true)
expect(nextRun.getMinutes() % 10).toBe(0) // Should align with the interval
expect(nextRun.getUTCMinutes() % 10).toBe(0) // Should align with the interval
})
})

Expand Down