opsdash-app/opsdash/test/targetsProgress.test.ts
blade34242 d7efcba67c
All checks were successful
Nextcloud Server Tests / version-consistency (push) Successful in 32s
Nextcloud Server Tests / matrix-config (push) Successful in 26s
Nextcloud Server Tests / Nextcloud stable30 / PHP 8.2 (stable30, 8.2) (push) Successful in 4m44s
Nextcloud Server Tests / Nextcloud stable31 / PHP 8.2 (stable31, 8.2) (push) Successful in 4m41s
Nextcloud Server Tests / Nextcloud stable31 / PHP 8.3 (stable31, 8.3) (push) Successful in 4m29s
Nextcloud Server Tests / Nextcloud stable32 / PHP 8.2 (stable32, 8.2) (push) Successful in 4m34s
Nextcloud Server Tests / Nextcloud stable32 / PHP 8.3 (stable32, 8.3) (push) Successful in 4m43s
Nextcloud Server Tests / Nextcloud stable33 / PHP 8.2 (stable33, 8.2) (push) Successful in 4m51s
Nextcloud Server Tests / Nextcloud stable33 / PHP 8.3 (stable33, 8.3) (push) Successful in 4m52s
Build And Publish Appstore Package / build_and_publish (push) Successful in 3m3s
fix: stabilize release notes and target progress
2026-04-28 11:51:14 +07:00

42 lines
1.1 KiB
TypeScript

import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest'
import { computePaceInfo, progressPercent } from '../src/services/targets/progress'
describe('targets progress helpers', () => {
beforeEach(() => {
vi.useFakeTimers()
vi.setSystemTime(new Date('2025-03-05T12:00:00Z'))
})
afterEach(() => {
vi.useRealTimers()
})
it('skips zero-hour days when includeZeroDays=false', () => {
const start = new Date('2025-03-03T00:00:00Z')
const end = new Date('2025-03-09T23:59:59Z')
const dailyHours = new Map<string, number>([
['2025-03-03', 0],
['2025-03-04', 2],
['2025-03-05', 0],
])
const pace = computePaceInfo({
includeWeekend: false,
mode: 'days_only',
includeZeroDays: false,
start,
end,
dailyHours,
})
expect(pace.totalEligible).toBe(5)
expect(pace.elapsedEligible).toBeCloseTo(1, 4)
expect(pace.daysLeft).toBeCloseTo(4, 4)
expect(pace.calendarPercent).toBeCloseTo(20, 2)
})
it('keeps over-target percentages above 200%', () => {
expect(progressPercent(25, 10)).toBe(250)
})
})