Files
dodo/frontend/src/lib/ui-bugfixes.test.ts
T
bboysoul ec90e9155e
ci / docker (push) Successful in 3m30s
fix: resolve ui audit bugs
2026-09-07 09:08:22 +08:00

21 lines
1001 B
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { describe, expect, it } from 'vitest'
import { formatApiErrorDetail, nextTotalAfterLocalTaskAdd } from './mvp-utils'
describe('UI bugfix helpers', () => {
it('formats FastAPI validation arrays into readable messages', () => {
expect(formatApiErrorDetail([
{ loc: ['body', 'lunar_day'], msg: 'Input should be less than or equal to 30' },
{ loc: ['body', 'title'], msg: 'String should have at least 1 character' },
])).toBe('lunar_dayInput should be less than or equal to 30titleString should have at least 1 character')
})
it('formats nested API detail objects instead of [object Object]', () => {
expect(formatApiErrorDetail({ detail: [{ loc: ['body', 'event_date'], msg: 'Input should be a valid date' }] })).toBe('event_dateInput should be a valid date')
})
it('increments the visible total after a local quick-add insert', () => {
expect(nextTotalAfterLocalTaskAdd(0)).toBe(1)
expect(nextTotalAfterLocalTaskAdd(49)).toBe(50)
})
})