fix(web): await replacement refresh coverage

This commit is contained in:
2026-07-22 14:21:33 +08:00
parent 51c6fea343
commit 19f9e163e2
6 changed files with 186 additions and 26 deletions

View File

@@ -0,0 +1,29 @@
import assert from 'node:assert/strict'
import test from 'node:test'
import { runRecoveryRefresh } from '../src/app/recovery-refresh.ts'
test('a failed recovery never announces refreshed success', async () => {
const events = []
await assert.rejects(() => runRecoveryRefresh(
async () => {
events.push('refresh')
throw new Error('still stale')
},
() => events.push('success'),
), /still stale/)
assert.deepEqual(events, ['refresh'])
})
test('recovery announces success only after every requested refresh resolves', async () => {
const events = []
await runRecoveryRefresh(
async () => events.push('refresh'),
() => events.push('success'),
)
assert.deepEqual(events, ['refresh', 'success'])
})