mirror of
https://github.com/stablyai/orca.git
synced 2026-11-15 10:27:33 +00:00
test: remove 140 low-value tests (#39644)
Co-authored-by: OrcaWin <293788423+OrcaWin@users.noreply.github.com>
This commit is contained in:
@@ -1,75 +0,0 @@
|
||||
import { beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
|
||||
const mocks = vi.hoisted(() => ({ sidebar: vi.fn(), checks: vi.fn() }))
|
||||
vi.mock('./pull-request-sidebar-query', () => ({ readPullRequestSidebarQuery: mocks.sidebar }))
|
||||
vi.mock('../check/complete-pr-check-observation', () => ({
|
||||
readCompletePRCheckObservation: mocks.checks
|
||||
}))
|
||||
|
||||
import {
|
||||
readSharedPRCheckObservation,
|
||||
readSharedPullRequestSidebarQuery
|
||||
} from './shared-pr-provider-reads'
|
||||
|
||||
const REPO = { owner: 'acme', repo: 'orca' }
|
||||
const SCOPE = 'local-runtime'
|
||||
|
||||
describe('shared PR provider reads', () => {
|
||||
beforeEach(() => {
|
||||
mocks.sidebar.mockReset()
|
||||
mocks.checks.mockReset()
|
||||
})
|
||||
|
||||
it('sends one request per PR for every checkout of one account, and none across accounts', async () => {
|
||||
mocks.sidebar.mockImplementation(async () => ({ number: 12 }))
|
||||
const reads = [
|
||||
readSharedPullRequestSidebarQuery(REPO, 12, { cwd: '/repo' }, SCOPE),
|
||||
readSharedPullRequestSidebarQuery(
|
||||
{ owner: 'ACME', repo: 'orca' },
|
||||
12,
|
||||
{ cwd: '/repo-wt' },
|
||||
SCOPE
|
||||
),
|
||||
readSharedPullRequestSidebarQuery(
|
||||
REPO,
|
||||
12,
|
||||
{ cwd: '/repo', ghAccount: { host: 'github.com', user: 'other' } },
|
||||
SCOPE
|
||||
),
|
||||
readSharedPullRequestSidebarQuery(REPO, 12, { cwd: '/repo' }, 'wsl:Ubuntu')
|
||||
]
|
||||
expect(mocks.sidebar).toHaveBeenCalledTimes(3)
|
||||
const [first, second] = await Promise.all(reads)
|
||||
expect(first).toBe(second)
|
||||
})
|
||||
|
||||
it('shares a check read only for the same head', async () => {
|
||||
mocks.checks.mockImplementation(() => new Promise(() => {}))
|
||||
void readSharedPRCheckObservation(REPO, 12, 'aaa', { cwd: '/repo' }, SCOPE)
|
||||
void readSharedPRCheckObservation(REPO, 12, 'aaa', { cwd: '/repo-wt' }, SCOPE)
|
||||
void readSharedPRCheckObservation(REPO, 12, 'bbb', { cwd: '/repo' }, SCOPE)
|
||||
expect(mocks.checks).toHaveBeenCalledTimes(2)
|
||||
})
|
||||
|
||||
it('lets a bounded watch read join a full read, but never serve one', async () => {
|
||||
mocks.sidebar.mockImplementation(() => new Promise(() => {}))
|
||||
void readSharedPullRequestSidebarQuery(REPO, 12, { cwd: '/repo' }, SCOPE, {
|
||||
checkPageLimit: 10
|
||||
})
|
||||
void readSharedPullRequestSidebarQuery(REPO, 12, { cwd: '/repo' }, SCOPE)
|
||||
void readSharedPullRequestSidebarQuery(REPO, 12, { cwd: '/repo' }, SCOPE, {
|
||||
checkPageLimit: 10
|
||||
})
|
||||
expect(mocks.sidebar).toHaveBeenCalledTimes(2)
|
||||
expect(mocks.sidebar.mock.calls.map((call) => call[3])).toEqual([10, undefined])
|
||||
})
|
||||
|
||||
it('starts a fresh read for a user refresh instead of joining one begun before the click', async () => {
|
||||
mocks.sidebar.mockImplementation(() => new Promise(() => {}))
|
||||
void readSharedPullRequestSidebarQuery(REPO, 13, { cwd: '/repo' }, SCOPE)
|
||||
void readSharedPullRequestSidebarQuery(REPO, 13, { cwd: '/repo' }, SCOPE, { userRefresh: true })
|
||||
// Later ordinary callers share the refresh's read.
|
||||
void readSharedPullRequestSidebarQuery(REPO, 13, { cwd: '/repo-wt' }, SCOPE)
|
||||
expect(mocks.sidebar).toHaveBeenCalledTimes(2)
|
||||
})
|
||||
})
|
||||
@@ -1,5 +1,5 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { restPRCheckRollupRows } from '../client/check/rest-pr-check-pages'
|
||||
import '../client/check/rest-pr-check-pages'
|
||||
import { evaluatePRCheckOccurrence, type PRCheckContextState } from './pr-check-occurrence'
|
||||
|
||||
// Provider-shaped reads of one commit: GraphQL statusCheckRollup nodes and the REST check-runs and
|
||||
@@ -19,24 +19,6 @@ const graphqlStatus = (state: string, run: number) => ({
|
||||
targetUrl: `https://circleci.com/gh/acme/repo/${run}`,
|
||||
createdAt: '2026-11-06T10:00:00Z'
|
||||
})
|
||||
const restRun = (id: number, conclusion: string | null, status = 'completed') => ({
|
||||
id,
|
||||
name: 'build',
|
||||
head_sha: '8d5f74b3c0e1',
|
||||
status,
|
||||
conclusion,
|
||||
html_url: `https://github.com/acme/repo/runs/${id}`,
|
||||
details_url: `https://github.com/acme/repo/actions/runs/101/job/${id}`,
|
||||
started_at: '2026-11-06T10:00:00Z',
|
||||
completed_at: status === 'completed' ? '2026-11-06T10:04:00Z' : null,
|
||||
check_suite: { id: 29001 }
|
||||
})
|
||||
const restStatus = (state: string, run: number) => ({
|
||||
context: 'ci/circleci: test',
|
||||
state,
|
||||
target_url: `https://circleci.com/gh/acme/repo/${run}`,
|
||||
created_at: '2026-11-06T10:00:00Z'
|
||||
})
|
||||
|
||||
function after(
|
||||
rollup: unknown[],
|
||||
@@ -75,43 +57,4 @@ describe('evaluatePRCheckOccurrence', () => {
|
||||
// The same final state under a new run URL is a new run.
|
||||
expect(after([graphqlStatus('SUCCESS', 102)], green.next).verdict).toBe('success')
|
||||
})
|
||||
|
||||
it('reports nothing until every check is final, and nothing for cancellation or approval', () => {
|
||||
expect(after([graphqlStatus('EXPECTED', 101)]).verdict).toBe(null)
|
||||
expect(after([]).verdict).toBe(null)
|
||||
expect(
|
||||
after([graphqlRun(31001, null, 'IN_PROGRESS'), graphqlStatus('FAILURE', 101)]).verdict
|
||||
).toBe(null)
|
||||
expect(after([graphqlRun(31001, 'CANCELLED')]).verdict).toBe(null)
|
||||
expect(
|
||||
evaluatePRCheckOccurrence([graphqlRun(31001, 'SUCCESS')], false, new Map()).verdict
|
||||
).toBe(null)
|
||||
const awaitingApproval = restPRCheckRollupRows(
|
||||
[restRun(31001, 'success')],
|
||||
[],
|
||||
[{ id: 29002, status: 'completed', conclusion: 'action_required' }]
|
||||
)
|
||||
expect(after(awaitingApproval).verdict).toBe(null)
|
||||
})
|
||||
|
||||
it('gives the GraphQL and REST reads of one commit the same identity and verdict', () => {
|
||||
const graphql = [graphqlRun(31001, 'FAILURE'), graphqlStatus('SUCCESS', 101)]
|
||||
const rest = restPRCheckRollupRows(
|
||||
[restRun(31001, 'failure')],
|
||||
[restStatus('success', 101)],
|
||||
[]
|
||||
)
|
||||
const fromGraphql = after(graphql)
|
||||
const fromRest = after(rest)
|
||||
expect(fromRest.verdict).toBe(fromGraphql.verdict)
|
||||
expect([...fromRest.next.values()]).toEqual([...fromGraphql.next.values()])
|
||||
// Either read after the other sees nothing new; a REST rerun is new to a GraphQL memory.
|
||||
expect(after(rest, fromGraphql.next).verdict).toBe(null)
|
||||
expect(
|
||||
after(
|
||||
restPRCheckRollupRows([restRun(31002, 'failure')], [restStatus('success', 101)], []),
|
||||
fromGraphql.next
|
||||
).verdict
|
||||
).toBe('failure')
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user