mirror of
https://github.com/stablyai/orca.git
synced 2026-11-19 04:23:57 +00:00
test(github): place host and renderer loops in cross-layer suite
This commit is contained in:
+10
-11
@@ -5,8 +5,8 @@ import {
|
|||||||
found,
|
found,
|
||||||
mocks,
|
mocks,
|
||||||
rpcRead
|
rpcRead
|
||||||
} from '../../../../../main/runtime/integrations/reviews/runtime-hosted-pr-snapshot-test-harness'
|
} from '../../src/main/runtime/integrations/reviews/runtime-hosted-pr-snapshot-test-harness'
|
||||||
import type { PRRefreshOutcome } from '../../../../../shared/github/pull-requests/refresh/pull-request-refresh-types'
|
import type { PRRefreshOutcome } from '../../src/shared/github/pull-requests/refresh/pull-request-refresh-types'
|
||||||
|
|
||||||
describe('hosted PR receipt delivery', () => {
|
describe('hosted PR receipt delivery', () => {
|
||||||
it('carries a real deferred reply through the visible target, store and scheduler to its completion', async () => {
|
it('carries a real deferred reply through the visible target, store and scheduler to its completion', async () => {
|
||||||
@@ -15,13 +15,12 @@ describe('hosted PR receipt delivery', () => {
|
|||||||
makePRRefreshWorktree,
|
makePRRefreshWorktree,
|
||||||
resetRemoteRuntimeMocks,
|
resetRemoteRuntimeMocks,
|
||||||
runtimeEnvironmentCall
|
runtimeEnvironmentCall
|
||||||
} = await import('../github-slice-test-harness')
|
} = await import('../../src/renderer/src/store/github/github-slice-test-harness')
|
||||||
const { getVisibleHostedReviewRefreshTargets } =
|
const { getVisibleHostedReviewRefreshTargets } =
|
||||||
await import('../../slices/hosted-review/refresh/visible-hosted-review-refresh-targets')
|
await import('../../src/renderer/src/store/slices/hosted-review/refresh/visible-hosted-review-refresh-targets')
|
||||||
const { createVisibleHostedReviewRefreshScheduler } =
|
const { createVisibleHostedReviewRefreshScheduler } =
|
||||||
await import('../../slices/hosted-review/refresh/visible-hosted-review-refresh-scheduler')
|
await import('../../src/renderer/src/store/slices/hosted-review/refresh/visible-hosted-review-refresh-scheduler')
|
||||||
const { PrForBranch } =
|
const { PrForBranch } = await import('../../src/shared/rpc-contract/github-pull-request-params')
|
||||||
await import('../../../../../shared/rpc-contract/github-pull-request-params')
|
|
||||||
const readReceipt = (reason: 'active' | 'swr') =>
|
const readReceipt = (reason: 'active' | 'swr') =>
|
||||||
commands.getRepoPRForBranch(
|
commands.getRepoPRForBranch(
|
||||||
'repo',
|
'repo',
|
||||||
@@ -171,18 +170,18 @@ it('applies data-bearing retry replies to both clients and sends selection after
|
|||||||
makePRRefreshWorktree,
|
makePRRefreshWorktree,
|
||||||
resetRemoteRuntimeMocks,
|
resetRemoteRuntimeMocks,
|
||||||
runtimeEnvironmentCall
|
runtimeEnvironmentCall
|
||||||
} = await import('../github-slice-test-harness')
|
} = await import('../../src/renderer/src/store/github/github-slice-test-harness')
|
||||||
const { getVisibleHostedReviewRefreshTargets } =
|
const { getVisibleHostedReviewRefreshTargets } =
|
||||||
await import('../../slices/hosted-review/refresh/visible-hosted-review-refresh-targets')
|
await import('../../src/renderer/src/store/slices/hosted-review/refresh/visible-hosted-review-refresh-targets')
|
||||||
const { createVisibleHostedReviewRefreshScheduler } =
|
const { createVisibleHostedReviewRefreshScheduler } =
|
||||||
await import('../../slices/hosted-review/refresh/visible-hosted-review-refresh-scheduler')
|
await import('../../src/renderer/src/store/slices/hosted-review/refresh/visible-hosted-review-refresh-scheduler')
|
||||||
resetRemoteRuntimeMocks()
|
resetRemoteRuntimeMocks()
|
||||||
runtimeEnvironmentCall.mockImplementation(async (args) => {
|
runtimeEnvironmentCall.mockImplementation(async (args) => {
|
||||||
if (args.method !== 'github.prForBranch') {
|
if (args.method !== 'github.prForBranch') {
|
||||||
throw new Error('unexpected fixture RPC')
|
throw new Error('unexpected fixture RPC')
|
||||||
}
|
}
|
||||||
const { PrForBranch } =
|
const { PrForBranch } =
|
||||||
await import('../../../../../shared/rpc-contract/github-pull-request-params')
|
await import('../../src/shared/rpc-contract/github-pull-request-params')
|
||||||
const params = PrForBranch.parse(args.params)
|
const params = PrForBranch.parse(args.params)
|
||||||
const requestClient = 'selector' in args && args.selector === 'env-client-0' ? 0 : 1
|
const requestClient = 'selector' in args && args.selector === 'env-client-0' ? 0 : 1
|
||||||
reasons.push(params.reason ?? 'missing')
|
reasons.push(params.reason ?? 'missing')
|
||||||
+11
-10
@@ -1,22 +1,22 @@
|
|||||||
import { afterEach, beforeEach, expect, it, vi } from 'vitest'
|
import { afterEach, beforeEach, expect, it, vi } from 'vitest'
|
||||||
import { makePR } from '../../../github/pull-requests/refresh/pr-refresh-coordinator-test-harness'
|
import { makePR } from '../../src/main/github/pull-requests/refresh/pr-refresh-coordinator-test-harness'
|
||||||
import type { PRRefreshOutcome } from '../../../../shared/github/pull-requests/refresh/pull-request-refresh-types'
|
import type { PRRefreshOutcome } from '../../src/shared/github/pull-requests/refresh/pull-request-refresh-types'
|
||||||
import type { VisibleHostedReviewRefreshTarget as Target } from '../../../../renderer/src/store/slices/hosted-review/refresh/visible-hosted-review-refresh-scheduler'
|
import type { VisibleHostedReviewRefreshTarget as Target } from '../../src/renderer/src/store/slices/hosted-review/refresh/visible-hosted-review-refresh-scheduler'
|
||||||
import type { RuntimeHostedReviewCommands } from './runtime-hosted-review-commands'
|
import type { RuntimeHostedReviewCommands } from '../../src/main/runtime/integrations/reviews/runtime-hosted-review-commands'
|
||||||
|
|
||||||
const mocks = vi.hoisted(() => ({ resolve: vi.fn(), account: vi.fn(), gate: vi.fn() }))
|
const mocks = vi.hoisted(() => ({ resolve: vi.fn(), account: vi.fn(), gate: vi.fn() }))
|
||||||
vi.mock('../../../github/accounts/github-project-account', () => ({
|
vi.mock('../../src/main/github/accounts/github-project-account', () => ({
|
||||||
githubPRPolicyProjects: () => ({ source: null, selection: String(mocks.account()) }),
|
githubPRPolicyProjects: () => ({ source: null, selection: String(mocks.account()) }),
|
||||||
resolveGitHubProjectAccount: mocks.account
|
resolveGitHubProjectAccount: mocks.account
|
||||||
}))
|
}))
|
||||||
vi.mock('../../../github/execution/github-operation-slots', () => ({
|
vi.mock('../../src/main/github/execution/github-operation-slots', () => ({
|
||||||
acquire: async () => {},
|
acquire: async () => {},
|
||||||
release: () => {}
|
release: () => {}
|
||||||
}))
|
}))
|
||||||
vi.mock('../../../github/client/lookup/branch-lookup-resolution', () => ({
|
vi.mock('../../src/main/github/client/lookup/branch-lookup-resolution', () => ({
|
||||||
resolvePRForBranchOutcome: mocks.resolve
|
resolvePRForBranchOutcome: mocks.resolve
|
||||||
}))
|
}))
|
||||||
vi.mock('../../../github/pull-requests/refresh/pr-refresh-rate-limit-gate', () => ({
|
vi.mock('../../src/main/github/pull-requests/refresh/pr-refresh-rate-limit-gate', () => ({
|
||||||
prRefreshRateLimitPausedUntil: mocks.gate
|
prRefreshRateLimitPausedUntil: mocks.gate
|
||||||
}))
|
}))
|
||||||
|
|
||||||
@@ -67,7 +67,8 @@ beforeEach(async () => {
|
|||||||
mocks.resolve.mockReset().mockImplementation(async () => found())
|
mocks.resolve.mockReset().mockImplementation(async () => found())
|
||||||
mocks.account.mockReset().mockReturnValue(null)
|
mocks.account.mockReset().mockReturnValue(null)
|
||||||
mocks.gate.mockReset().mockResolvedValue(null)
|
mocks.gate.mockReset().mockResolvedValue(null)
|
||||||
const { RuntimeHostedReviewCommands: Commands } = await import('./runtime-hosted-review-commands')
|
const { RuntimeHostedReviewCommands: Commands } =
|
||||||
|
await import('../../src/main/runtime/integrations/reviews/runtime-hosted-review-commands')
|
||||||
const repo = {
|
const repo = {
|
||||||
id: 'repo',
|
id: 'repo',
|
||||||
path: '/repo',
|
path: '/repo',
|
||||||
@@ -96,7 +97,7 @@ it.each([
|
|||||||
'bounds shared polling for $rows rows and $clients clients over thirty minutes',
|
'bounds shared polling for $rows rows and $clients clients over thirty minutes',
|
||||||
async ({ rows, clients }) => {
|
async ({ rows, clients }) => {
|
||||||
const { createVisibleHostedReviewRefreshScheduler } =
|
const { createVisibleHostedReviewRefreshScheduler } =
|
||||||
await import('../../../../renderer/src/store/slices/hosted-review/refresh/visible-hosted-review-refresh-scheduler')
|
await import('../../src/renderer/src/store/slices/hosted-review/refresh/visible-hosted-review-refresh-scheduler')
|
||||||
const start = Date.now()
|
const start = Date.now()
|
||||||
const spans: { branch: string; startedAt: number; completedAt: number }[] = []
|
const spans: { branch: string; startedAt: number; completedAt: number }[] = []
|
||||||
const deliveries: number[] = []
|
const deliveries: number[] = []
|
||||||
Reference in New Issue
Block a user