fix: persist completed item visibility
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { calendarModeLabel, clampFabPosition, countdownDayText, countdownKindLabel, dateKey, defaultView, habitButtonNotice, habitButtonValue, habitWeek, isFabDrag, isHabitComplete, isHabitScheduledToday, isTaskView, nextHabitSwipeValue, nextTotalAfterLocalTaskAdd, numericHabitInputValue, previousHabitSwipeValue, quickTaskFields, readCountdownCache, readHabitGridCache, shouldToggleRowSwipe, writeCountdownCache, writeHabitGridCache } from './mvp-utils'
|
||||
import { calendarModeLabel, clampFabPosition, countdownDayText, countdownKindLabel, dateKey, defaultView, habitButtonNotice, habitButtonValue, habitWeek, isFabDrag, isHabitComplete, isHabitScheduledToday, isTaskView, nextHabitSwipeValue, nextTotalAfterLocalTaskAdd, numericHabitInputValue, previousHabitSwipeValue, quickTaskFields, readCountdownCache, readHabitGridCache, readStoredBoolean, shouldToggleRowSwipe, writeCountdownCache, writeHabitGridCache, writeStoredBoolean } from './mvp-utils'
|
||||
|
||||
describe('MVP view utilities', () => {
|
||||
it('formats a local date as YYYY-MM-DD', () => {
|
||||
@@ -77,6 +77,19 @@ describe('MVP view utilities', () => {
|
||||
expect(habitButtonNotice('boolean', 1, 0)).toBe('已取消完成')
|
||||
})
|
||||
|
||||
it('persists boolean display preferences across page refreshes', () => {
|
||||
const storage = new Map<string, string>()
|
||||
const fakeStorage = {
|
||||
getItem: (key: string) => storage.get(key) ?? null,
|
||||
setItem: (key: string, value: string) => storage.set(key, value),
|
||||
}
|
||||
expect(readStoredBoolean(fakeStorage, 'dodo.show-completed', true)).toBe(true)
|
||||
writeStoredBoolean(fakeStorage, 'dodo.show-completed', false)
|
||||
expect(readStoredBoolean(fakeStorage, 'dodo.show-completed', true)).toBe(false)
|
||||
storage.set('dodo.show-completed', 'invalid')
|
||||
expect(readStoredBoolean(fakeStorage, 'dodo.show-completed', true)).toBe(true)
|
||||
})
|
||||
|
||||
it('reuses the current week habit grid while refreshing in the background', () => {
|
||||
const habits = [{ id: 'habit-1', name: '喝水' }]
|
||||
writeHabitGridCache('2026-09-07', habits)
|
||||
|
||||
Reference in New Issue
Block a user