Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions __tests__/cronJobTest/sweepDelayGuards.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,10 @@ function json(body: unknown, status = 200) {
return new Response(JSON.stringify(body), { status, headers: { 'Content-Type': 'application/json' } })
}

// Pins three guards of `requestReviewersIfDue` (src/cronJobs/sweep.ts) that
// Pins four guards of `requestReviewersIfDue` (src/cronJobs/sweep.ts) that
// the other delayed-blunderbuss suites reach but never distinguish: the
// `ready_for_review` filter on the timeline, the draft skip before any
// `ready_for_review` filter on the timeline, a timeline without one leaving
// the creation time as the review clock, the draft skip before any
// timeline read, and `explicit: false` carrying `ignore_authors` into the
// delayed path.
describe('sweep with blunderbuss.delay: guards of requestReviewersIfDue', () => {
Expand Down Expand Up @@ -130,6 +131,18 @@ describe('sweep with blunderbuss.delay: guards of requestReviewersIfDue', () =>
expect(requested).toEqual([1])
})

it('keeps the creation time as the review clock when the timeline has no ready_for_review', async () => {
// opened long before the due window and touched inside it; with nothing on the
// timeline to move the clock, the pull request was due an hour after it opened
// and is not due again now
servePulls([pull({ number: 1, createdMinutesAgo: 5 * 60, updatedMinutesAgo: 70 })])
timeline[1] = [{ event: 'labeled', created_at: ago(10) }]

await expect(sweep(context)).resolves.toEqual({ candidates: [], merged: [], enqueued: [], failures: [] })
expect(timelineReads).toEqual([1])
expect(requested).toEqual([])
})

it('leaves a draft alone before reading its timeline when ignore_drafts is on', async () => {
servePulls([pull({ number: 1, createdMinutesAgo: 70, draft: true })])
timeline[1] = [{ event: 'ready_for_review', created_at: ago(70) }]
Expand Down
Loading