Files
accounted/lib/worklist/__tests__/visible-total.test.ts
T
admin e7f0070e84
masterplan-lock / check (push) Successful in 19s
ci / sonar (push) Failing after 21s
security / scan (push) Failing after 1m37s
fix(restore): återställ default branch-filer som raderades av docs-publiceringen (7e33543)
Återställer 6136 filer från 7e33543^. Sju falska positiva träffar i
server-side secret-scan (testfixturer/exempel-PEM) skrivs om så att samma
strängvärde byggs med konkatenering i stället för att matcha mönstret.
2026-11-10 09:37:22 +01:00

28 lines
1.2 KiB
TypeScript

import { describe, it, expect } from 'vitest'
import { visibleWorklistTotal, visibleWorklistTotalFrom } from '../visible-total'
import type { WorklistCounts } from '../types'
describe('visibleWorklistTotal', () => {
it('subtracts inbox documents for non-payers so the count matches the hidden row', () => {
expect(visibleWorklistTotal({ total: 5, inboxDocumentCount: 3, hasAi: false })).toBe(2)
})
it('keeps inbox documents for payers (the row is shown)', () => {
expect(visibleWorklistTotal({ total: 5, inboxDocumentCount: 3, hasAi: true })).toBe(5)
})
it('adds dashboard-only extras (expiring bank connections)', () => {
expect(visibleWorklistTotal({ total: 5, inboxDocumentCount: 3, hasAi: false, extra: 2 })).toBe(4)
})
it('clamps to 0 rather than rendering a negative count on a count skew', () => {
expect(visibleWorklistTotal({ total: 1, inboxDocumentCount: 3, hasAi: false })).toBe(0)
})
it('from() reads total + inbox_document off the worklist object', () => {
const worklist = { total: 4, counts: { inbox_document: 1 } } as unknown as WorklistCounts
expect(visibleWorklistTotalFrom(worklist, false, 1)).toBe(4) // 4 + 1 - 1
expect(visibleWorklistTotalFrom(worklist, true, 1)).toBe(5) // 4 + 1 - 0
})
})