fix: calendar recurrence tz/overrides, today habits schedule, list archive mobile access
ci / docker (push) Successful in 3m23s
ci / docker (push) Successful in 3m23s
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { dateKey, defaultView, habitWeek, isHabitComplete, isTaskView, nextHabitSwipeValue, numericHabitInputValue, previousHabitSwipeValue, shouldToggleRowSwipe } from './mvp-utils'
|
||||
import { dateKey, defaultView, habitWeek, isHabitComplete, isHabitScheduledToday, isTaskView, nextHabitSwipeValue, numericHabitInputValue, previousHabitSwipeValue, shouldToggleRowSwipe } from './mvp-utils'
|
||||
|
||||
describe('MVP view utilities', () => {
|
||||
it('formats a local date as YYYY-MM-DD', () => {
|
||||
@@ -33,6 +33,15 @@ describe('MVP view utilities', () => {
|
||||
expect(defaultView()).toBe('today')
|
||||
})
|
||||
|
||||
it('only includes scheduled, unpaused habits today regardless of kind or completion', () => {
|
||||
const day = '2026-09-06'
|
||||
expect(isHabitScheduledToday({ kind: 'boolean', cells: [{ day, scheduled: true, paused: false, value: true }] }, day)).toBe(true)
|
||||
expect(isHabitScheduledToday({ kind: 'numeric', cells: [{ day, scheduled: true, paused: false, value: 5 }] }, day)).toBe(true)
|
||||
expect(isHabitScheduledToday({ kind: 'boolean', cells: [{ day, scheduled: false, paused: false, value: true }] }, day)).toBe(false)
|
||||
expect(isHabitScheduledToday({ kind: 'numeric', cells: [{ day, scheduled: true, paused: true, value: 0 }] }, day)).toBe(false)
|
||||
expect(isHabitScheduledToday({ kind: 'boolean', cells: [] }, day)).toBe(false)
|
||||
})
|
||||
|
||||
it('increments count habits one swipe at a time and caps at target', () => {
|
||||
expect(nextHabitSwipeValue('numeric', 2, 5)).toBe(3)
|
||||
expect(nextHabitSwipeValue('numeric', 5, 5)).toBe(5)
|
||||
|
||||
@@ -33,6 +33,16 @@ export function isHabitComplete(kind: string | undefined, value: number | boolea
|
||||
return Boolean(value)
|
||||
}
|
||||
|
||||
type HabitSchedule = {
|
||||
kind?: string
|
||||
cells?: Array<{ day: string; scheduled?: boolean; paused?: boolean; value?: number | boolean }>
|
||||
}
|
||||
|
||||
export function isHabitScheduledToday(habit: HabitSchedule, day: string) {
|
||||
const cell = (habit.cells ?? []).find((item) => item.day === day)
|
||||
return Boolean(cell?.scheduled && !cell.paused)
|
||||
}
|
||||
|
||||
export function nextHabitSwipeValue(kind: string | undefined, current: number | boolean | undefined, target = 1) {
|
||||
const value = Number(current ?? 0)
|
||||
if (kind === 'numeric') return Math.min(value + 1, target)
|
||||
|
||||
Reference in New Issue
Block a user