feat: add scoped manual usage cleanup

This commit is contained in:
HsungKayphoon
2026-05-16 15:23:44 +08:00
parent 75b7319465
commit 74a1e5ad7d
17 changed files with 1746 additions and 305 deletions
@@ -1,8 +1,11 @@
import { describe, expect, it } from 'vitest'
import {
allowedTargetsForMode,
defaultManualCleanupTargets,
MANUAL_USAGE_CLEANUP_CONFIRM_PHRASE,
isConfirmPhraseMatched,
normalizeManualCleanupTargets,
normalizeConfirmPhraseInput,
normalizeOlderThanDaysInput,
} from '../manualCleanupForm'
@@ -61,4 +64,34 @@ describe('manualCleanupForm', () => {
expect(normalizeOlderThanDaysInput('abc')).toBeNull()
})
})
describe('cleanup targets', () => {
it('keeps all ranges available for policy cleanup', () => {
expect(allowedTargetsForMode('policy')).toEqual([
'detail_body',
'compressed_body',
'headers',
'records',
])
expect(defaultManualCleanupTargets('older_than_days')).toEqual([
'detail_body',
'compressed_body',
'headers',
'records',
])
})
it('limits before-now cleanup to body targets', () => {
expect(allowedTargetsForMode('before_now')).toEqual([
'detail_body',
'compressed_body',
])
expect(normalizeManualCleanupTargets('before_now', [
'detail_body',
'headers',
'compressed_body',
'records',
])).toEqual(['detail_body', 'compressed_body'])
})
})
})