fix: restore cleaner history in postgresql
This commit is contained in:
29
tests/unit/cleaner-history-load-state.test.ts
Normal file
29
tests/unit/cleaner-history-load-state.test.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import {
|
||||
canStartHistoryLoad,
|
||||
getNextHistoryLoadState
|
||||
} from '../../src/renderer/src/components/cleaner-history-load-state'
|
||||
|
||||
describe('cleaner history load state helpers', () => {
|
||||
it('allows initial and failed loads to retry', () => {
|
||||
expect(canStartHistoryLoad('idle')).toBe(true)
|
||||
expect(canStartHistoryLoad('error')).toBe(true)
|
||||
})
|
||||
|
||||
it('prevents duplicate requests after loading starts or succeeds', () => {
|
||||
expect(canStartHistoryLoad('loading')).toBe(false)
|
||||
expect(canStartHistoryLoad('success')).toBe(false)
|
||||
})
|
||||
|
||||
it('retries after an error but keeps successful loads cached', () => {
|
||||
const failedState = getNextHistoryLoadState('loading', 'error')
|
||||
const retryState = getNextHistoryLoadState(failedState, 'start')
|
||||
const successState = getNextHistoryLoadState(retryState, 'success')
|
||||
const blockedState = getNextHistoryLoadState(successState, 'start')
|
||||
|
||||
expect(failedState).toBe('error')
|
||||
expect(retryState).toBe('loading')
|
||||
expect(successState).toBe('success')
|
||||
expect(blockedState).toBe('success')
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user