mirror of
https://github.com/stablyai/orca.git
synced 2026-11-19 04:23:57 +00:00
test: remove low-value preview and setup mapping coverage
This commit is contained in:
-71
@@ -43,7 +43,6 @@ vi.mock('../../popups/presentation/popup-origin-bar-window', () => ({
|
||||
|
||||
import { browserManager } from '../browser-manager'
|
||||
import { respondToBrowserPagePrompt } from '../../prompts/browser-page-prompts'
|
||||
import { handleBrowserGuestLogin } from '../../prompts/browser-http-auth-prompt'
|
||||
import {
|
||||
guestNavigationMethods,
|
||||
rendererWebContentsId,
|
||||
@@ -159,74 +158,4 @@ describe('browserManager page prompt routing', () => {
|
||||
expect(prompts().at(-1)).toMatchObject({ origin: null })
|
||||
answerLatest(false)
|
||||
})
|
||||
|
||||
it("asks for a new tab's first sign-in once its window registers the tab", async () => {
|
||||
const rendererSendMock = vi.fn()
|
||||
const guest = {
|
||||
...guestNavigationMethods(),
|
||||
id: 109,
|
||||
isDestroyed: vi.fn(() => false),
|
||||
isCurrentlyAudible: vi.fn(() => false),
|
||||
getType: vi.fn(() => 'webview'),
|
||||
getURL: vi.fn(() => ''),
|
||||
setBackgroundThrottling: guestSetBackgroundThrottlingMock,
|
||||
setWindowOpenHandler: guestSetWindowOpenHandlerMock,
|
||||
on: guestOnMock,
|
||||
prependListener: vi.fn(),
|
||||
once: vi.fn(),
|
||||
off: guestOffMock,
|
||||
openDevTools: guestOpenDevToolsMock
|
||||
}
|
||||
const renderer = {
|
||||
id: rendererWebContentsId,
|
||||
isDestroyed: () => false,
|
||||
send: rendererSendMock,
|
||||
on: vi.fn(),
|
||||
off: vi.fn()
|
||||
}
|
||||
webContentsFromIdMock.mockImplementation((id: number) =>
|
||||
id === guest.id ? guest : id === rendererWebContentsId ? renderer : null
|
||||
)
|
||||
// Guests can start loading before renderer registration.
|
||||
browserManager.attachGuestPolicies(webContentsFromIdMock(guest.id))
|
||||
const event = { preventDefault: vi.fn() }
|
||||
const callback = vi.fn()
|
||||
handleBrowserGuestLogin(
|
||||
event,
|
||||
webContentsFromIdMock(guest.id),
|
||||
{
|
||||
url: 'https://staging.acme.com/',
|
||||
pid: 1,
|
||||
isRequestForNavigation: true,
|
||||
firstAuthAttempt: true
|
||||
},
|
||||
{ isProxy: false, scheme: 'basic', host: 'staging.acme.com', port: 443, realm: 'Staging' },
|
||||
callback
|
||||
)
|
||||
// Keep the challenge pending until registration supplies a prompt window.
|
||||
expect(event.preventDefault).toHaveBeenCalled()
|
||||
expect(rendererSendMock).not.toHaveBeenCalledWith(
|
||||
'browser:page-prompt-requested',
|
||||
expect.anything()
|
||||
)
|
||||
|
||||
browserManager.registerGuest({
|
||||
browserPageId: 'browser-3',
|
||||
webContentsId: guest.id,
|
||||
rendererWebContentsId
|
||||
})
|
||||
|
||||
const request = rendererSendMock.mock.calls.find(
|
||||
([channel]) => channel === 'browser:page-prompt-requested'
|
||||
)?.[1]
|
||||
expect(request).toMatchObject({
|
||||
kind: 'http-auth',
|
||||
details: { origin: 'https://staging.acme.com' }
|
||||
})
|
||||
await respondToBrowserPagePrompt(webContentsFromIdMock(rendererWebContentsId), {
|
||||
requestId: request.requestId,
|
||||
answer: { username: 'qa', password: 'hunter2' }
|
||||
})
|
||||
expect(callback).toHaveBeenCalledWith('qa', 'hunter2')
|
||||
})
|
||||
})
|
||||
|
||||
@@ -1,48 +0,0 @@
|
||||
import { afterEach, describe, expect, it, vi } from 'vitest'
|
||||
import type { OrcaRuntimeService } from '../../runtime/orca-runtime'
|
||||
import type { RuntimeStore } from '../../runtime/construction/runtime-store-contract'
|
||||
import { getDefaultWorkspaceCleanupRules } from '../../../shared/workspace-cleanup/workspace-cleanup-policy'
|
||||
|
||||
const { collectWorkspaces } = vi.hoisted(() => ({ collectWorkspaces: vi.fn() }))
|
||||
|
||||
vi.mock('./workspace-cleanup-run-evidence', () => ({
|
||||
collectWorkspaceCleanupWorkspaces: collectWorkspaces
|
||||
}))
|
||||
vi.mock('../space-analysis/workspace-space-analysis-snapshot', () => ({
|
||||
readWorkspaceSpaceAnalysisSnapshot: () => Promise.resolve(null)
|
||||
}))
|
||||
|
||||
const { WorkspaceCleanupRunner } = await import('./workspace-cleanup-runner')
|
||||
|
||||
function createRunner(): InstanceType<typeof WorkspaceCleanupRunner> {
|
||||
const store = {
|
||||
getSettings: () => ({ workspaceCleanupPolicy: getDefaultWorkspaceCleanupRules() })
|
||||
}
|
||||
return new WorkspaceCleanupRunner({
|
||||
// SAFETY: preview only reads settings from the store and passes the runtime through to mocked evidence.
|
||||
// oxlint-disable-next-line typescript/consistent-type-assertions -- SAFETY: see above
|
||||
store: store as unknown as RuntimeStore,
|
||||
// oxlint-disable-next-line typescript/consistent-type-assertions -- SAFETY: see above
|
||||
runtime: {} as OrcaRuntimeService,
|
||||
historyDirectory: '/unused'
|
||||
})
|
||||
}
|
||||
|
||||
describe('workspace cleanup runner preview', () => {
|
||||
afterEach(() => {
|
||||
collectWorkspaces.mockReset()
|
||||
})
|
||||
|
||||
it('shares one evaluation between concurrent previews of the same rules', async () => {
|
||||
let finish: (value: []) => void = () => {}
|
||||
collectWorkspaces.mockReturnValue(new Promise<[]>((resolve) => (finish = resolve)))
|
||||
const runner = createRunner()
|
||||
|
||||
const first = runner.preview()
|
||||
const second = runner.preview(getDefaultWorkspaceCleanupRules())
|
||||
finish([])
|
||||
await Promise.all([first, second])
|
||||
|
||||
expect(collectWorkspaces).toHaveBeenCalledTimes(1)
|
||||
})
|
||||
})
|
||||
@@ -1,27 +0,0 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { setupHooksCreateSource } from './worktree-creation-hook-preparation'
|
||||
|
||||
describe('setupHooksCreateSource', () => {
|
||||
it('reads the named branch only for explicit reuse', () => {
|
||||
expect(
|
||||
setupHooksCreateSource({
|
||||
branchIntent: 'open-existing-v2',
|
||||
branchNameOverride: 'feature',
|
||||
baseBranch: 'origin/main'
|
||||
})
|
||||
).toEqual({ kind: 'branch', ref: 'feature', baseBranch: 'origin/main' })
|
||||
})
|
||||
|
||||
it('reads the base when a new branch only borrows the name', () => {
|
||||
expect(
|
||||
setupHooksCreateSource({
|
||||
branchIntent: 'create-new',
|
||||
branchNameOverride: 'feature',
|
||||
baseBranch: 'origin/main'
|
||||
})
|
||||
).toEqual({ kind: 'base', baseBranch: 'origin/main' })
|
||||
expect(
|
||||
setupHooksCreateSource({ branchNameOverride: 'pr-branch', baseBranch: 'refs/pull/7/head' })
|
||||
).toEqual({ kind: 'base', baseBranch: 'refs/pull/7/head' })
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user