mirror of
https://github.com/stablyai/orca.git
synced 2026-11-18 20:06:10 +00:00
test: remove 559 low-value tests (#39661)
* test: remove 247 low-value tests * test: remove 559 low-value tests --------- Co-authored-by: OrcaWin <293788423+OrcaWin@users.noreply.github.com>
This commit is contained in:
@@ -1,159 +0,0 @@
|
||||
import { beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
|
||||
const { coordinatorMocks, moduleMocks } = await vi.hoisted(async () => {
|
||||
const moduleMocks = await import('./pr-refresh-coordinator-test-mocks')
|
||||
return { coordinatorMocks: moduleMocks.createPRRefreshCoordinatorMocks(), moduleMocks }
|
||||
})
|
||||
|
||||
vi.mock('./pr-refresh-renderer-port', () => moduleMocks.rendererPortModuleMock(coordinatorMocks))
|
||||
vi.mock('./client', () => moduleMocks.clientModuleMock(coordinatorMocks))
|
||||
vi.mock('./github-api-repository', () =>
|
||||
moduleMocks.githubApiRepositoryModuleMock(coordinatorMocks)
|
||||
)
|
||||
vi.mock('./rate-limit', () => moduleMocks.rateLimitModuleMock(coordinatorMocks))
|
||||
|
||||
import { makeCandidate, makePR } from './pr-refresh-coordinator-test-harness'
|
||||
|
||||
const { getPRForBranchOutcomeMock } = coordinatorMocks
|
||||
const WATCHED = '/watched-repo'
|
||||
// Fake time starts here; reads stamp `fetchedAt` from the fake clock as it advances.
|
||||
const START_AT = 1_000
|
||||
|
||||
function watchReads(): number {
|
||||
return getPRForBranchOutcomeMock.mock.calls.filter(([repoPath]) => repoPath === WATCHED).length
|
||||
}
|
||||
|
||||
async function startWatch(): Promise<void> {
|
||||
const { schedulePRWatchRead, setPRWatchJobHooks } = await import('./pr-refresh-coordinator')
|
||||
setPRWatchJobHooks({ isWatched: () => true, readHeadChecks: async () => null })
|
||||
schedulePRWatchRead(
|
||||
{ prKey: 'github.com/acme/watched#7' },
|
||||
makeCandidate({ repoPath: WATCHED, cacheKey: 'watch', linkedPRNumber: 7 }),
|
||||
START_AT
|
||||
)
|
||||
}
|
||||
|
||||
describe('pr-refresh watch jobs', () => {
|
||||
beforeEach(() => {
|
||||
moduleMocks.resetPRRefreshCoordinatorMocks(coordinatorMocks)
|
||||
vi.setSystemTime(START_AT)
|
||||
getPRForBranchOutcomeMock.mockImplementation(async () => ({
|
||||
kind: 'found',
|
||||
pr: makePR({ checksStatus: 'pending' }),
|
||||
fetchedAt: Date.now()
|
||||
}))
|
||||
})
|
||||
|
||||
it('re-reads an open PR every background interval with no window showing it', async () => {
|
||||
await startWatch()
|
||||
await vi.advanceTimersByTimeAsync(0)
|
||||
expect(watchReads()).toBe(1)
|
||||
await vi.advanceTimersByTimeAsync(119_000)
|
||||
expect(watchReads()).toBe(1)
|
||||
await vi.advanceTimersByTimeAsync(2_000)
|
||||
expect(watchReads()).toBe(2)
|
||||
await vi.advanceTimersByTimeAsync(10 * 120_000)
|
||||
expect(watchReads()).toBe(12)
|
||||
})
|
||||
|
||||
it('stops once the PR is merged with its checks settled', async () => {
|
||||
getPRForBranchOutcomeMock.mockImplementation(async () => ({
|
||||
kind: 'found',
|
||||
pr: makePR({
|
||||
state: 'merged',
|
||||
checksStatus: 'success',
|
||||
checksReadComplete: true,
|
||||
checksFinal: true
|
||||
}),
|
||||
fetchedAt: Date.now()
|
||||
}))
|
||||
await startWatch()
|
||||
await vi.advanceTimersByTimeAsync(60 * 60_000)
|
||||
expect(watchReads()).toBe(1)
|
||||
})
|
||||
|
||||
it('keeps reading a merged PR whose failure sits beside a check still running', async () => {
|
||||
getPRForBranchOutcomeMock.mockImplementation(async () => ({
|
||||
kind: 'found',
|
||||
pr: makePR({
|
||||
state: 'merged',
|
||||
checksStatus: 'failure',
|
||||
checksReadComplete: true,
|
||||
checksFinal: false
|
||||
}),
|
||||
fetchedAt: Date.now()
|
||||
}))
|
||||
await startWatch()
|
||||
await vi.advanceTimersByTimeAsync(5 * 60_000)
|
||||
expect(watchReads()).toBeGreaterThan(1)
|
||||
})
|
||||
|
||||
it('gives saturating watches and visible rows each a share of the budget', async () => {
|
||||
const { reportVisiblePRRefreshCandidates, schedulePRWatchRead, setPRWatchJobHooks } =
|
||||
await import('./pr-refresh-coordinator')
|
||||
setPRWatchJobHooks({ isWatched: () => true, readHeadChecks: async () => null })
|
||||
for (let index = 0; index < 25; index++) {
|
||||
schedulePRWatchRead(
|
||||
{ prKey: `github.com/acme/watched#${index}` },
|
||||
makeCandidate({ repoPath: `${WATCHED}-${index}`, cacheKey: `watch-${index}` }),
|
||||
START_AT
|
||||
)
|
||||
}
|
||||
reportVisiblePRRefreshCandidates(
|
||||
Array.from({ length: 25 }, (_, index) =>
|
||||
makeCandidate({
|
||||
repoPath: `/visible-${index}`,
|
||||
cacheKey: `visible-${index}`,
|
||||
worktreeId: `wt-${index}`
|
||||
})
|
||||
),
|
||||
1,
|
||||
1
|
||||
)
|
||||
const counts = () => {
|
||||
const paths = getPRForBranchOutcomeMock.mock.calls.map(([path]) => String(path))
|
||||
return {
|
||||
watch: paths.filter((path) => path.startsWith(WATCHED)).length,
|
||||
visible: paths.filter((path) => path.startsWith('/visible-')).length
|
||||
}
|
||||
}
|
||||
await vi.advanceTimersByTimeAsync(15 * 60_000)
|
||||
const early = counts()
|
||||
await vi.advanceTimersByTimeAsync(30 * 60_000)
|
||||
const late = counts()
|
||||
// Past the first passes both kinds stay overdue; each must still get starts.
|
||||
expect(late.watch - early.watch).toBeGreaterThanOrEqual(20)
|
||||
expect(late.visible - early.visible).toBeGreaterThanOrEqual(20)
|
||||
})
|
||||
|
||||
it('shares the background budget and still reads a watch while visible rows saturate it', async () => {
|
||||
const { reportVisiblePRRefreshCandidates } = await import('./pr-refresh-coordinator')
|
||||
const visible = Array.from({ length: 30 }, (_, index) =>
|
||||
makeCandidate({
|
||||
repoPath: `/visible-${index}`,
|
||||
cacheKey: `visible-${index}`,
|
||||
worktreeId: `wt-${index}`
|
||||
})
|
||||
)
|
||||
reportVisiblePRRefreshCandidates(visible, 1, 1)
|
||||
await startWatch()
|
||||
await vi.advanceTimersByTimeAsync(5 * 60_000 - 1_000)
|
||||
// Twenty background starts per five minutes, watch reads included.
|
||||
expect(getPRForBranchOutcomeMock.mock.calls.length).toBeLessThanOrEqual(20)
|
||||
await vi.advanceTimersByTimeAsync(10 * 60_000)
|
||||
// Aged past one interval, the watch outranks the visible rows that keep the budget full.
|
||||
expect(watchReads()).toBeGreaterThanOrEqual(2)
|
||||
})
|
||||
|
||||
it('bounds the check pages of watch reads only, never a visible read', async () => {
|
||||
const { reportVisiblePRRefreshCandidates } = await import('./pr-refresh-coordinator')
|
||||
await startWatch()
|
||||
reportVisiblePRRefreshCandidates([makeCandidate()], 1, 1)
|
||||
await vi.advanceTimersByTimeAsync(30_000)
|
||||
const options = (repoPath: string) =>
|
||||
getPRForBranchOutcomeMock.mock.calls.find(([path]) => path === repoPath)?.[5]
|
||||
expect(watchReads()).toBe(1)
|
||||
expect(options(WATCHED)).toMatchObject({ checkPageLimit: 10 })
|
||||
expect(options('/repo')?.checkPageLimit).toBeUndefined()
|
||||
})
|
||||
})
|
||||
@@ -64,36 +64,11 @@ describe('push updates from recorded tool calls', () => {
|
||||
expect(pushedBranches(codex)).toEqual([{ branch: 'ci-lines', newSha: '5d6e7f8' }])
|
||||
})
|
||||
|
||||
it('reads a push that merges its stderr into the output, and still skips a dry run', () => {
|
||||
expect(pushBy('git push -u origin HEAD 2>&1', REVIEW_PUSHED)).toEqual([REVIEW_UPDATE])
|
||||
expect(pushBy('git push --dry-run 2>&1', REVIEW_PUSHED)).toEqual([])
|
||||
})
|
||||
|
||||
it("reads a push after a heredoc's declaration, past `;`", () => {
|
||||
const command = "cat <<'EOF' > notes.md; git push -u origin HEAD 2>&1\nnotes\nEOF"
|
||||
expect(pushBy(command, REVIEW_PUSHED)).toEqual([REVIEW_UPDATE])
|
||||
})
|
||||
|
||||
it("reads a push after a heredoc's declaration, past `&&`", () => {
|
||||
const command = "cat <<'EOF' > notes.md && git push -u origin HEAD 2>&1\nnotes\nEOF"
|
||||
expect(pushBy(command, REVIEW_PUSHED)).toEqual([REVIEW_UPDATE])
|
||||
})
|
||||
|
||||
it("reads an unredirected push after a heredoc's declaration", () => {
|
||||
const command = "cat <<'EOF' > notes.md; git push -u origin HEAD\nnotes\nEOF"
|
||||
expect(pushBy(command, REVIEW_PUSHED)).toEqual([REVIEW_UPDATE])
|
||||
})
|
||||
|
||||
it("reads a piped push after a heredoc's declaration", () => {
|
||||
const command = "cat <<'EOF' > notes.md && git push -u origin HEAD 2>&1 | tail -5\nnotes\nEOF"
|
||||
expect(pushBy(command, REVIEW_PUSHED)).toEqual([REVIEW_UPDATE])
|
||||
})
|
||||
|
||||
it("skips a quoted dry run after a heredoc's declaration", () => {
|
||||
const command = "cat <<'EOF' > notes.md; git push '--dry-run' -u origin HEAD 2>&1\nnotes\nEOF"
|
||||
expect(pushBy(command, REVIEW_PUSHED)).toEqual([])
|
||||
})
|
||||
|
||||
it('takes nothing from a heredoc that prints a push and its update lines', () => {
|
||||
const printed =
|
||||
'git push -u origin HEAD 2>&1\nTo github.com:acme/repo.git\n 1234567..89abcde HEAD -> review\n'
|
||||
@@ -104,55 +79,9 @@ describe('push updates from recorded tool calls', () => {
|
||||
expect(pushBy(`cat <<-EOF\n${indented}\tEOF`, printed)).toEqual([])
|
||||
})
|
||||
|
||||
it("reads a push after a heredoc's delimiter", () => {
|
||||
const command = "cat <<'EOF' > notes.md\nnotes\nEOF\ngit push -u origin HEAD 2>&1"
|
||||
expect(pushBy(command, REVIEW_PUSHED)).toEqual([REVIEW_UPDATE])
|
||||
})
|
||||
|
||||
it("doesn't let an escaped `>` before a real pipe hide the push after it", () => {
|
||||
expect(pushBy('printf x \\>|git push origin HEAD', REVIEW_PUSHED)).toEqual([REVIEW_UPDATE])
|
||||
})
|
||||
|
||||
it('takes new branches and porcelain lines, and nothing from pushes that updated nothing', () => {
|
||||
const push = (command: string, output: string) =>
|
||||
pushedBranches(toolCallRow({ name: 'Bash', input: { command }, output }))
|
||||
expect(
|
||||
push(
|
||||
'git push -u origin feature',
|
||||
"remote: Create a pull request for 'feature' on GitHub by visiting:\nTo github.com:acme/repo.git\n * [new branch] feature -> feature\n"
|
||||
)
|
||||
).toEqual([{ branch: 'feature', newSha: null }])
|
||||
expect(
|
||||
push(
|
||||
'git push --porcelain',
|
||||
'To github.com:acme/repo.git\n \trefs/heads/feature:refs/heads/feature\t8d5f74b..c512e75\nDone\n'
|
||||
)
|
||||
).toEqual([{ branch: 'feature', newSha: 'c512e75' }])
|
||||
expect(
|
||||
push(
|
||||
'git push',
|
||||
'To github.com:acme/repo.git\n ! [rejected] feature -> feature (fetch first)\n'
|
||||
)
|
||||
).toEqual([])
|
||||
expect(push('git push', 'Everything up-to-date\n')).toEqual([])
|
||||
expect(push('git push -q', '')).toEqual([])
|
||||
// Dry runs print real-looking updates however the option is written.
|
||||
for (const command of ["git push origin feature '--dry-run'", 'git push -nv origin feature']) {
|
||||
expect(push(command, `${TO_ORIGIN} 8d5f74b..c512e75 feature -> feature\n`)).toEqual([])
|
||||
}
|
||||
expect(
|
||||
push(
|
||||
'git push --dry-run',
|
||||
'To github.com:acme/repo.git\n 8d5f74b..c512e75 feature -> feature\n'
|
||||
)
|
||||
).toEqual([])
|
||||
expect(
|
||||
push(
|
||||
'echo "git push"',
|
||||
'To github.com:acme/repo.git\n 8d5f74b..c512e75 feature -> feature\n'
|
||||
)
|
||||
).toEqual([])
|
||||
})
|
||||
})
|
||||
|
||||
describe('pushedPullRequestHead', () => {
|
||||
|
||||
@@ -15,7 +15,7 @@ import {
|
||||
} from './pr-head-evaluation'
|
||||
import { PRPendingActionResume } from './pr-pending-action-resume'
|
||||
import { capturePRPendingActions } from './pr-pending-actions'
|
||||
import { deletePRWatchChats } from './pr-watch-tables'
|
||||
import './pr-watch-tables'
|
||||
import { prInfoFixture, shellCallRow } from './pr-watch-test-fixtures'
|
||||
import { prWatchCandidate } from './pr-watch-types'
|
||||
|
||||
@@ -77,15 +77,6 @@ describe('recordPRHeadObservation over saved state', () => {
|
||||
expect(read(HEAD_B, green(31002), 30)).toEqual(['chat-1'])
|
||||
expect(read(HEAD_A, green(31001), 40)).toEqual([])
|
||||
})
|
||||
|
||||
it('drops heads and context memory with the PR’s last owning chat', () => {
|
||||
read(HEAD_A, [{ ...green(31001)[0], status: 'IN_PROGRESS', conclusion: null }])
|
||||
expect(readPRPendingHeads(database.db, PR_KEY)).toHaveLength(1)
|
||||
database.transaction((db) => deletePRWatchChats(db, ['chat-1']))
|
||||
expect(readPRPendingHeads(database.db, PR_KEY)).toEqual([])
|
||||
const contexts = database.db.prepare('SELECT COUNT(*) AS n FROM pr_check_contexts').get()
|
||||
expect(contexts?.n).toBe(0)
|
||||
})
|
||||
})
|
||||
|
||||
const FULL_A = '89abcde0000000000000000000000000000000ff'
|
||||
|
||||
@@ -14,11 +14,7 @@ import {
|
||||
} from '../../native-chat/agent-session-journal/store-lifecycle/journal-host-database-test-support'
|
||||
import { assemblePRRefreshFoundOutcome } from '../client/lookup/pr-refresh-outcome-assembly'
|
||||
import type { PRWatchJob } from '../pr-refresh-watch-jobs'
|
||||
import {
|
||||
readPRPendingDeliveryChatIds,
|
||||
readPRPendingHeads,
|
||||
upsertPRPendingHead
|
||||
} from './pr-check-event-tables'
|
||||
import { readPRPendingDeliveryChatIds, readPRPendingHeads } from './pr-check-event-tables'
|
||||
import { readPRHeadCheckRollup } from './pr-head-check-read'
|
||||
import { capturePRPendingActions } from './pr-pending-actions'
|
||||
import { shellCallRow } from './pr-watch-test-fixtures'
|
||||
@@ -233,31 +229,4 @@ describe('PRWatchService startup retirement', () => {
|
||||
])
|
||||
next.stop()
|
||||
})
|
||||
|
||||
it('starts nothing from a workspace that resolves after the service stopped', async () => {
|
||||
// R's action is past the action window, so retirement, had it run, would delete R's head.
|
||||
vi.setSystemTime(1_800_000_000_000 - 30 * 24 * 60 * 60_000)
|
||||
await seedOpenedPR('chat-r', 9)
|
||||
vi.setSystemTime(1_800_000_000_000)
|
||||
const database = await seedOpenedPR()
|
||||
const STALE_KEY = 'github.com/acme/repo#9'
|
||||
database.transaction((db) =>
|
||||
upsertPRPendingHead(db, {
|
||||
prKey: STALE_KEY,
|
||||
headSha: HEAD_A,
|
||||
now: Date.now(),
|
||||
movedAt: null,
|
||||
ttlMs: 60_000
|
||||
})
|
||||
)
|
||||
let releaseQ = (_workspace: PRWatchWorkspace) => {}
|
||||
const qWorkspace = new Promise<PRWatchWorkspace>((resolve) => (releaseQ = resolve))
|
||||
const stopping = service(() => qWorkspace)
|
||||
const starting = stopping.start()
|
||||
stopping.stop()
|
||||
releaseQ(WORKSPACE)
|
||||
await starting
|
||||
expect(queue.scheduled).toEqual([])
|
||||
expect(readPRPendingHeads(database.db, STALE_KEY)).toHaveLength(1)
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user