Skip to content
Open
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
2 changes: 1 addition & 1 deletion apps/sim/lib/workflows/schedules/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ export function getScheduleTimeValues(starterBlock: BlockState): {

// Get weekly config
const weeklyDayStr = getSubBlockValue(starterBlock, 'weeklyDay') || 'MON'
const weeklyDay = DAY_MAP[weeklyDayStr] || 1
const weeklyDay = DAY_MAP[weeklyDayStr] ?? 1
const weeklyTime = parseTimeString(getSubBlockValue(starterBlock, 'weeklyDayTime'))

// Get monthly config
Expand Down
16 changes: 16 additions & 0 deletions apps/sim/lib/workflows/schedules/validation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,19 @@ describe('validateScheduleBlock reason', () => {
expect(result.reason).toBe('invalid')
})
})

describe('validateScheduleBlock weekly day', () => {
it('schedules a Sunday run for Sunday instead of falling back to Monday', () => {
const result = validateScheduleBlock({
type: 'schedule',
subBlocks: {
scheduleType: { value: 'weekly' },
weeklyDay: { value: 'SUN' },
weeklyDayTime: { value: '09:00' },
timezone: { value: 'UTC' },
},
})
expect(result.cronExpression).toBe('0 9 * * 0')
expect(result.nextRunAt?.getUTCDay()).toBe(0)
})
})