mirror of
https://github.com/stablyai/orca.git
synced 2026-11-15 10:27:33 +00:00
test(github): format queued refresh deadline cases
This commit is contained in:
@@ -3,40 +3,43 @@ import type { PRRefreshOutcome } from '../../../../shared/github/pull-requests/r
|
||||
import { makeCandidate } from '../../../github/pull-requests/refresh/pr-refresh-coordinator-test-harness'
|
||||
import { fixture, found, mocks, read, rpcRead } from './runtime-hosted-pr-snapshot-test-harness'
|
||||
|
||||
it.each([false, true])('delivers post-push data while another row waits for a later rate-limit reset (clock jump: %s)', async (clockJump) => {
|
||||
const coordinator = await import('../../../github/pull-requests/refresh/pr-refresh-coordinator')
|
||||
const delivered: PRRefreshOutcome[] = []
|
||||
const remove = coordinator.addPRRefreshOutcomeObserver((_candidate, outcome) =>
|
||||
delivered.push(outcome)
|
||||
)
|
||||
const candidate = (branch: string) =>
|
||||
makeCandidate({
|
||||
branch,
|
||||
cacheKey: `/repo::${branch}`,
|
||||
currentHeadOid: 'head-a'
|
||||
})
|
||||
try {
|
||||
fixture.title = 'after push'
|
||||
mocks.gate.mockImplementation(async (row) => (row.branch === 'later' ? 61_000 : null))
|
||||
if (clockJump) {
|
||||
await coordinator.refreshPRNow(candidate('later'))
|
||||
vi.setSystemTime(301_000)
|
||||
it.each([false, true])(
|
||||
'delivers post-push data while another row waits for a later rate-limit reset (clock jump: %s)',
|
||||
async (clockJump) => {
|
||||
const coordinator = await import('../../../github/pull-requests/refresh/pr-refresh-coordinator')
|
||||
const delivered: PRRefreshOutcome[] = []
|
||||
const remove = coordinator.addPRRefreshOutcomeObserver((_candidate, outcome) =>
|
||||
delivered.push(outcome)
|
||||
)
|
||||
const candidate = (branch: string) =>
|
||||
makeCandidate({
|
||||
branch,
|
||||
cacheKey: `/repo::${branch}`,
|
||||
currentHeadOid: 'head-a'
|
||||
})
|
||||
try {
|
||||
fixture.title = 'after push'
|
||||
mocks.gate.mockImplementation(async (row) => (row.branch === 'later' ? 61_000 : null))
|
||||
if (clockJump) {
|
||||
await coordinator.refreshPRNow(candidate('later'))
|
||||
vi.setSystemTime(301_000)
|
||||
}
|
||||
coordinator.enqueuePRRefresh(candidate('pushed'), 'post-push')
|
||||
await vi.advanceTimersByTimeAsync(0)
|
||||
if (!clockJump) {
|
||||
await coordinator.refreshPRNow(candidate('later'))
|
||||
}
|
||||
await vi.advanceTimersByTimeAsync(2_500)
|
||||
expect(delivered).toContainEqual({
|
||||
kind: 'found',
|
||||
fetchedAt: clockJump ? 303_500 : 3_500,
|
||||
pr: expect.objectContaining({ title: 'after push' })
|
||||
})
|
||||
} finally {
|
||||
remove()
|
||||
}
|
||||
coordinator.enqueuePRRefresh(candidate('pushed'), 'post-push')
|
||||
await vi.advanceTimersByTimeAsync(0)
|
||||
if (!clockJump) {
|
||||
await coordinator.refreshPRNow(candidate('later'))
|
||||
}
|
||||
await vi.advanceTimersByTimeAsync(2_500)
|
||||
expect(delivered).toContainEqual({
|
||||
kind: 'found',
|
||||
fetchedAt: clockJump ? 303_500 : 3_500,
|
||||
pr: expect.objectContaining({ title: 'after push' })
|
||||
})
|
||||
} finally {
|
||||
remove()
|
||||
}
|
||||
})
|
||||
)
|
||||
|
||||
it.each(['deadline', 'abort'] as const)(
|
||||
'detaches an automatic cold-read waiter on %s while its producer completes for another client',
|
||||
|
||||
Reference in New Issue
Block a user