Skip to content

Commit c00f05c

Browse files
authored
fix(tests): use UTC methods for timezone-independent schedule assertions (#3052)
1 parent 78410ee commit c00f05c

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

apps/sim/app/api/schedules/[id]/route.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ describe('Schedule PUT API (Reactivate)', () => {
344344
expect(nextRunAt).toBeGreaterThan(beforeCall)
345345
expect(nextRunAt).toBeLessThanOrEqual(afterCall + 5 * 60 * 1000 + 1000)
346346
// Should align with 5-minute intervals (minute divisible by 5)
347-
expect(new Date(nextRunAt).getMinutes() % 5).toBe(0)
347+
expect(new Date(nextRunAt).getUTCMinutes() % 5).toBe(0)
348348
})
349349

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

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

599599
// Should be a future date at minute 15
600600
expect(nextRunAt.getTime()).toBeGreaterThan(beforeCall)
601-
expect(nextRunAt.getMinutes()).toBe(15)
602-
expect(nextRunAt.getSeconds()).toBe(0)
601+
expect(nextRunAt.getUTCMinutes()).toBe(15)
602+
expect(nextRunAt.getUTCSeconds()).toBe(0)
603603
})
604604

605605
it('handles custom cron expressions with complex patterns and timezone', async () => {

apps/sim/lib/workflows/schedules/utils.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -266,9 +266,9 @@ describe('Schedule Utilities', () => {
266266
const nextRun = calculateNextRunTime('minutes', scheduleValues)
267267

268268
// Should return the future start date with time
269-
expect(nextRun.getFullYear()).toBe(2025)
270-
expect(nextRun.getMonth()).toBe(3) // April
271-
expect(nextRun.getDate()).toBe(15)
269+
expect(nextRun.getUTCFullYear()).toBe(2025)
270+
expect(nextRun.getUTCMonth()).toBe(3) // April
271+
expect(nextRun.getUTCDate()).toBe(15)
272272
})
273273

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

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

440440
// Should not use the past date but calculate normally
441441
expect(nextRun > new Date()).toBe(true)
442-
expect(nextRun.getMinutes() % 10).toBe(0) // Should align with the interval
442+
expect(nextRun.getUTCMinutes() % 10).toBe(0) // Should align with the interval
443443
})
444444
})
445445

0 commit comments

Comments
 (0)