fix: align task due dates to the right
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { archivePanelFlags, calendarModeLabel, changedHabitFields, clampFabPosition, countdownDayText, countdownKindLabel, dateKey, defaultView, formatArchivedAt, formatAuditAction, formatAuditEntity, formatHabitApiError, formatLocalShortDateTime, formatUserAgent, habitActionState, habitButtonNotice, habitButtonValue, habitWeek, invalidateHabitGridCache, isFabDrag, isHabitComplete, isHabitScheduledToday, isTaskView, nextHabitSwipeValue, nextTotalAfterLocalTaskAdd, normalizeRequiredName, numericHabitInputValue, performHabitRestore, previousHabitSwipeValue, quickTaskFields, readCountdownCache, readHabitGridCache, readStoredBoolean, readStoredNavigation, shouldToggleRowSwipe, validateHabitForm, writeCountdownCache, writeHabitGridCache, writeStoredBoolean, writeStoredNavigation } from './mvp-utils'
|
||||
import { archivePanelFlags, calendarModeLabel, changedHabitFields, clampFabPosition, countdownDayText, countdownKindLabel, dateKey, defaultView, formatArchivedAt, formatAuditAction, formatAuditEntity, formatHabitApiError, formatLocalShortDateTime, formatUserAgent, habitActionState, habitButtonNotice, habitButtonValue, habitWeek, invalidateHabitGridCache, isFabDrag, isHabitComplete, isHabitScheduledToday, isTaskView, nextHabitSwipeValue, nextTotalAfterLocalTaskAdd, nextTotalAfterLocalTaskRemoval, normalizeRequiredName, numericHabitInputValue, performHabitRestore, performTrashMutation, previousHabitSwipeValue, quickTaskFields, readCountdownCache, readHabitGridCache, readStoredBoolean, readStoredNavigation, shouldToggleRowSwipe, validateHabitForm, writeCountdownCache, writeHabitGridCache, writeStoredBoolean, writeStoredNavigation } from './mvp-utils'
|
||||
|
||||
describe('MVP view utilities', () => {
|
||||
it('formats a local date as YYYY-MM-DD', () => {
|
||||
@@ -17,6 +17,45 @@ describe('MVP view utilities', () => {
|
||||
expect(['habits', 'settings', 'trash'].filter(isTaskView)).toEqual([])
|
||||
})
|
||||
|
||||
it('keeps Trash totals aligned after restoring or purging visible rows', () => {
|
||||
expect(nextTotalAfterLocalTaskRemoval(2, 1)).toBe(1)
|
||||
expect(nextTotalAfterLocalTaskRemoval(0, 1)).toBe(0)
|
||||
expect(nextTotalAfterLocalTaskRemoval(Number.NaN, 1)).toBe(0)
|
||||
})
|
||||
|
||||
it('does not reconcile Trash state when the mutation fails', async () => {
|
||||
let reconciled = 0
|
||||
const result = await performTrashMutation(
|
||||
async () => { throw new Error('mutation failed') },
|
||||
() => { reconciled += 1 },
|
||||
async () => true,
|
||||
)
|
||||
expect(result).toEqual({ mutated: false, refreshed: false, error: expect.any(Error) })
|
||||
expect(reconciled).toBe(0)
|
||||
})
|
||||
|
||||
it('keeps confirmed Trash reconciliation when the refresh fails', async () => {
|
||||
let reconciled = 0
|
||||
const result = await performTrashMutation(
|
||||
async () => undefined,
|
||||
() => { reconciled += 1 },
|
||||
async () => false,
|
||||
)
|
||||
expect(result).toEqual({ mutated: true, refreshed: false })
|
||||
expect(reconciled).toBe(1)
|
||||
})
|
||||
|
||||
it('reports a fully reconciled Trash mutation after refresh succeeds', async () => {
|
||||
let reconciled = 0
|
||||
const result = await performTrashMutation(
|
||||
async () => undefined,
|
||||
() => { reconciled += 1 },
|
||||
async () => true,
|
||||
)
|
||||
expect(result).toEqual({ mutated: true, refreshed: true })
|
||||
expect(reconciled).toBe(1)
|
||||
})
|
||||
|
||||
it('restores the last page and selected task list after refresh', () => {
|
||||
const storage = new Map<string, string>()
|
||||
const fakeStorage = {
|
||||
|
||||
Reference in New Issue
Block a user