mirror of
https://github.com/stablyai/orca.git
synced 2026-11-17 11:24:37 +00:00
test: remove low-value UI and process suites
This commit is contained in:
@@ -4150,7 +4150,6 @@
|
||||
"src/renderer/src/components/artifacts/ArtifactPublishButton.test.tsx": 706,
|
||||
"src/renderer/src/components/artifacts/ArtifactsPage.test.tsx": 2052,
|
||||
"src/renderer/src/components/artifacts/artifact-publish-flow.test.ts": 114,
|
||||
"src/renderer/src/components/automations/authoring/AutomationEditorPromptEditor.test.tsx": 396,
|
||||
"src/renderer/src/components/automations/AutomationPromptDisclosure.test.tsx": 893,
|
||||
"src/renderer/src/components/automations/AutomationRunsTable.test.tsx": 668,
|
||||
"src/renderer/src/components/automations/authoring/AutomationSchedulePicker.test.ts": 431,
|
||||
@@ -4283,7 +4282,6 @@
|
||||
"src/renderer/src/components/diff-comments/DiffCommentDraftCard.test.tsx": 1988,
|
||||
"src/renderer/src/components/diff-comments/diff-comment-draft-zone.test.tsx": 2633,
|
||||
"src/renderer/src/components/diff-comments/diff-comment-line-range.test.ts": 49,
|
||||
"src/renderer/src/components/diff-comments/diff-comment-popover-outside-click.test.tsx": 1889,
|
||||
"src/renderer/src/components/diff-comments/useDiffCommentDecorator.lifecycle.test.tsx": 2669,
|
||||
"src/renderer/src/components/diff-comments/useDiffCommentDecorator.range-selection.test.tsx": 1782,
|
||||
"src/renderer/src/components/editor/check-details/panel/CheckRunDetailsPanel.copy.test.tsx": 3108,
|
||||
@@ -4785,7 +4783,6 @@
|
||||
"src/renderer/src/components/right-sidebar/checks-panel/refresh/checks-panel-git-status-snapshot.test.ts": 61,
|
||||
"src/renderer/src/components/right-sidebar/checks-panel/review-actions/checks-panel-review-creation.test.ts": 69,
|
||||
"src/renderer/src/components/right-sidebar/checks-panel/checks-panel-review-lookup-authority.test.ts": 54,
|
||||
"src/renderer/src/components/right-sidebar/checks-panel/gitlab-review-client.test.ts": 321,
|
||||
"src/renderer/src/components/right-sidebar/checks-panel/comments/review-comment-markdown.test.tsx": 2171,
|
||||
"src/renderer/src/components/right-sidebar/checks-panel/refresh/use-checks-panel-manual-refresh-recovery.test.tsx": 2909,
|
||||
"src/renderer/src/components/right-sidebar/file-explorer/mutations/file-explorer-delete-undo-precondition.test.tsx": 2023,
|
||||
@@ -4865,7 +4862,6 @@
|
||||
"src/renderer/src/components/settings/repository/worktrees/SparsePresetSettingsSection.test.tsx": 744,
|
||||
"src/renderer/src/components/settings/ssh/server-actions/SshHostDeltaMoveDialog.test.tsx": 438,
|
||||
"src/renderer/src/components/settings/ssh/server-actions/SshHostRecoverServerAction.test.tsx": 669,
|
||||
"src/renderer/src/components/settings/ssh/targets/SshTargetForm.test.tsx": 1014,
|
||||
"src/renderer/src/components/settings/ssh/targets/SshTargetList.test.tsx": 2093,
|
||||
"src/renderer/src/components/settings/tasks/TaskSourceSimpleSetup.test.tsx": 527,
|
||||
"src/renderer/src/components/settings/TerminalAppearanceSection.ghostty.test.ts": 549,
|
||||
|
||||
@@ -24,7 +24,6 @@ vi.mock('./agent-launch-terminal-prompt', () => ({
|
||||
}))
|
||||
const { AGENT_LAUNCH_METHODS } = await import('./agent-launch')
|
||||
const AGENT_LAUNCH_REPLAY = methodNamed(AGENT_LAUNCH_METHODS, 'agent.launchReplay')
|
||||
const AGENT_LAUNCH = methodNamed(AGENT_LAUNCH_METHODS, 'agent.launch')
|
||||
|
||||
const TAB_ID = '9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d'
|
||||
const LEAF_ID = '3f2504e0-4f89-41d3-9a0c-0305e82c3301'
|
||||
@@ -77,14 +76,3 @@ describe('a replayed launch', () => {
|
||||
expect(replay.selectCreatedMobileSessionTabForClient).not.toHaveBeenCalled()
|
||||
})
|
||||
})
|
||||
|
||||
describe('a focused chat launch from the local CLI', () => {
|
||||
it('asks the host window to select the chat', async () => {
|
||||
const runtime = Object.assign(runtimeStub({}), { focusLaunchedChatInHostWindow: vi.fn() })
|
||||
const params = AGENT_LAUNCH.params.parse({ ...EXISTING_LAUNCH, presentation: 'focused' })
|
||||
|
||||
await AGENT_LAUNCH.handler(params, rpcContext(runtime, {}))
|
||||
|
||||
expect(runtime.focusLaunchedChatInHostWindow).toHaveBeenCalledWith('wt-7', 'sess-1')
|
||||
})
|
||||
})
|
||||
|
||||
@@ -46,35 +46,4 @@ describe('browser Find subscriptions', () => {
|
||||
expect(samePageCallback).toHaveBeenCalledOnce()
|
||||
expect(sameWorkspaceCallback).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('dispatches an explicitly undefined workspace as page-only, not as a miss', () => {
|
||||
const subscriptions = createBrowserFindSubscriptions()
|
||||
const callback = vi.fn()
|
||||
subscriptions.subscribe(FIRST_SOURCE, callback)
|
||||
|
||||
// Structured-clone IPC preserves explicitly undefined properties.
|
||||
subscriptions.dispatch({
|
||||
browserPageId: FIRST_SOURCE.browserPageId,
|
||||
browserWorkspaceId: undefined
|
||||
})
|
||||
|
||||
expect(callback).toHaveBeenCalledOnce()
|
||||
})
|
||||
|
||||
it('rejects malformed identities and blank ids', () => {
|
||||
const subscriptions = createBrowserFindSubscriptions()
|
||||
const callback = vi.fn()
|
||||
subscriptions.subscribe(FIRST_SOURCE, callback)
|
||||
|
||||
subscriptions.dispatch(undefined)
|
||||
subscriptions.dispatch(['page-1'])
|
||||
subscriptions.dispatch({ browserWorkspaceId: FIRST_SOURCE.browserWorkspaceId })
|
||||
subscriptions.dispatch({ browserPageId: '' })
|
||||
subscriptions.dispatch({
|
||||
browserPageId: FIRST_SOURCE.browserPageId,
|
||||
browserWorkspaceId: ''
|
||||
})
|
||||
|
||||
expect(callback).not.toHaveBeenCalled()
|
||||
})
|
||||
})
|
||||
|
||||
-73
@@ -1,73 +0,0 @@
|
||||
// @vitest-environment happy-dom
|
||||
import { cleanup, render } from '@testing-library/react'
|
||||
import { afterEach, describe, expect, it, vi } from 'vitest'
|
||||
|
||||
const editorProps = vi.hoisted(() => ({ current: null as Record<string, unknown> | null }))
|
||||
const installFindShortcut = vi.hoisted(() => vi.fn(() => vi.fn()))
|
||||
const syncContentOnMount = vi.hoisted(() => vi.fn(() => false))
|
||||
const syncContentUpdate = vi.hoisted(() => vi.fn())
|
||||
|
||||
vi.mock('@monaco-editor/react', () => ({
|
||||
default: (props: Record<string, unknown>) => {
|
||||
editorProps.current = props
|
||||
return <div data-testid="monaco-editor-stub" />
|
||||
},
|
||||
loader: { config: vi.fn() }
|
||||
}))
|
||||
vi.mock('@/lib/editor/monaco/monaco-setup', () => ({ monaco: {} }))
|
||||
vi.mock('@/store/index', () => ({
|
||||
useAppStore: (selector: (state: Record<string, unknown>) => unknown) =>
|
||||
selector({
|
||||
settings: { theme: 'dark', terminalFontSize: 13, terminalFontFamily: 'monospace' },
|
||||
editorFontZoomLevel: 0
|
||||
})
|
||||
}))
|
||||
vi.mock('@/components/editor/editor-shortcuts', () => ({
|
||||
installMonacoEditorFindShortcut: installFindShortcut
|
||||
}))
|
||||
vi.mock('@/components/editor/monaco-content-sync', () => ({
|
||||
syncContentOnMount,
|
||||
syncContentUpdate
|
||||
}))
|
||||
|
||||
import { AutomationEditorPromptEditor } from './AutomationEditorPromptEditor'
|
||||
|
||||
afterEach(() => {
|
||||
cleanup()
|
||||
editorProps.current = null
|
||||
installFindShortcut.mockClear()
|
||||
syncContentOnMount.mockClear()
|
||||
syncContentUpdate.mockClear()
|
||||
})
|
||||
|
||||
describe('AutomationEditorPromptEditor', () => {
|
||||
it('dismisses on Escape only when find is closed', () => {
|
||||
const onDismiss = vi.fn()
|
||||
const editorDom = document.createElement('div')
|
||||
const editorInstance = {
|
||||
getContainerDomNode: () => editorDom,
|
||||
onDidDispose: vi.fn()
|
||||
}
|
||||
render(
|
||||
<AutomationEditorPromptEditor
|
||||
value="prompt"
|
||||
placeholder="Prompt placeholder"
|
||||
ariaLabel="Prompt"
|
||||
onChange={vi.fn()}
|
||||
onDismiss={onDismiss}
|
||||
/>
|
||||
)
|
||||
const onMount = editorProps.current?.onMount as (editor: typeof editorInstance) => void
|
||||
onMount(editorInstance)
|
||||
|
||||
const findWidget = document.createElement('div')
|
||||
findWidget.className = 'find-widget'
|
||||
editorDom.append(findWidget)
|
||||
editorDom.dispatchEvent(new KeyboardEvent('keydown', { key: 'Escape', bubbles: true }))
|
||||
expect(onDismiss).not.toHaveBeenCalled()
|
||||
|
||||
findWidget.setAttribute('aria-hidden', 'true')
|
||||
editorDom.dispatchEvent(new KeyboardEvent('keydown', { key: 'Escape', bubbles: true }))
|
||||
expect(onDismiss).toHaveBeenCalledTimes(1)
|
||||
})
|
||||
})
|
||||
@@ -1,87 +0,0 @@
|
||||
// @vitest-environment happy-dom
|
||||
|
||||
import { act } from 'react'
|
||||
import { createRoot, type Root } from 'react-dom/client'
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
import { COMMENT_BODY_NONBLANK_SCAN_MAX_BYTES } from '@/lib/source-control/review/comments/comment-body-submit-state'
|
||||
import { DiffCommentPopover } from './DiffCommentPopover'
|
||||
|
||||
const roots: Root[] = []
|
||||
|
||||
async function renderPopover(args: {
|
||||
onCancel: () => void
|
||||
onSubmit?: (body: string) => Promise<void>
|
||||
}): Promise<HTMLDivElement> {
|
||||
const container = document.createElement('div')
|
||||
document.body.appendChild(container)
|
||||
const root = createRoot(container)
|
||||
roots.push(root)
|
||||
|
||||
await act(async () => {
|
||||
root.render(
|
||||
<DiffCommentPopover
|
||||
lineNumber={3}
|
||||
top={10}
|
||||
onCancel={args.onCancel}
|
||||
onSubmit={args.onSubmit ?? (async () => {})}
|
||||
/>
|
||||
)
|
||||
})
|
||||
|
||||
return container
|
||||
}
|
||||
|
||||
// Use the native value setter and input event so React observes the controlled textarea change.
|
||||
function typeInDraft(container: HTMLElement, value: string): void {
|
||||
const textarea = container.querySelector('textarea')
|
||||
if (!textarea) {
|
||||
throw new Error('textarea not found')
|
||||
}
|
||||
const setter = Object.getOwnPropertyDescriptor(HTMLTextAreaElement.prototype, 'value')?.set
|
||||
setter?.call(textarea, value)
|
||||
textarea.dispatchEvent(new Event('input', { bubbles: true }))
|
||||
}
|
||||
|
||||
async function clickOutside(): Promise<void> {
|
||||
await act(async () => {
|
||||
document.body.dispatchEvent(new MouseEvent('mousedown', { bubbles: true }))
|
||||
})
|
||||
}
|
||||
|
||||
describe('DiffCommentPopover outside-click draft preservation', () => {
|
||||
beforeEach(() => {
|
||||
globalThis.IS_REACT_ACT_ENVIRONMENT = true
|
||||
})
|
||||
|
||||
afterEach(() => {
|
||||
roots.splice(0).forEach((root) => {
|
||||
act(() => root.unmount())
|
||||
})
|
||||
document.body.replaceChildren()
|
||||
vi.clearAllMocks()
|
||||
})
|
||||
|
||||
it('keeps the popover open on outside-click when the draft has content', async () => {
|
||||
const onCancel = vi.fn()
|
||||
const container = await renderPopover({ onCancel })
|
||||
|
||||
await act(async () => {
|
||||
typeInDraft(container, 'unsaved note')
|
||||
})
|
||||
await clickOutside()
|
||||
|
||||
expect(onCancel).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('keeps the popover open when non-whitespace text follows large leading whitespace', async () => {
|
||||
const onCancel = vi.fn()
|
||||
const container = await renderPopover({ onCancel })
|
||||
|
||||
await act(async () => {
|
||||
typeInDraft(container, `${' '.repeat(COMMENT_BODY_NONBLANK_SCAN_MAX_BYTES + 1)}note`)
|
||||
})
|
||||
await clickOutside()
|
||||
|
||||
expect(onCancel).not.toHaveBeenCalled()
|
||||
})
|
||||
})
|
||||
@@ -1,77 +0,0 @@
|
||||
import { beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
|
||||
const runtime = vi.hoisted(() => ({ call: vi.fn() }))
|
||||
|
||||
vi.mock('@/runtime/rpc/calls/runtime-rpc-call', () => ({
|
||||
callRuntimeRpc: runtime.call
|
||||
}))
|
||||
vi.mock('@/runtime/rpc/compatibility/runtime-capability-proof', () => ({
|
||||
runtimeEnvironmentSupportsCapability: vi.fn()
|
||||
}))
|
||||
|
||||
import {
|
||||
fetchGitLabMRDetailsForChecks,
|
||||
resolveGitLabMRDiscussionForChecks
|
||||
} from './gitlab-review-client'
|
||||
|
||||
const gl = { workItemDetails: vi.fn(), resolveMRDiscussion: vi.fn() }
|
||||
|
||||
beforeEach(() => {
|
||||
runtime.call.mockReset()
|
||||
runtime.call.mockResolvedValue(null)
|
||||
gl.workItemDetails.mockReset().mockResolvedValue(null)
|
||||
gl.resolveMRDiscussion.mockReset().mockResolvedValue({ ok: true })
|
||||
vi.stubGlobal('window', { api: { gl } })
|
||||
})
|
||||
|
||||
describe('GitLab checks-panel provider adapter', () => {
|
||||
it('reads an SSH workspace MR on this computer, never the focused server (#24264)', async () => {
|
||||
await fetchGitLabMRDetailsForChecks({
|
||||
repoPath: '/workspace/repo',
|
||||
repoId: 'repo-1',
|
||||
iid: 17,
|
||||
repoOwnerExecutionHostId: 'ssh:devbox'
|
||||
})
|
||||
await resolveGitLabMRDiscussionForChecks({
|
||||
repoPath: '/workspace/repo',
|
||||
repoId: 'repo-1',
|
||||
iid: 17,
|
||||
discussionId: 'discussion-4',
|
||||
resolved: true,
|
||||
repoOwnerExecutionHostId: 'ssh:devbox'
|
||||
})
|
||||
|
||||
expect(runtime.call).not.toHaveBeenCalled()
|
||||
expect(gl.workItemDetails).toHaveBeenCalledWith({
|
||||
repoPath: '/workspace/repo',
|
||||
repoId: 'repo-1',
|
||||
repoOwnerExecutionHostId: 'ssh:devbox',
|
||||
iid: 17,
|
||||
type: 'mr',
|
||||
includeReviewDetails: false
|
||||
})
|
||||
expect(gl.resolveMRDiscussion).toHaveBeenCalledOnce()
|
||||
})
|
||||
|
||||
it('reads a server-owned workspace MR on its owner with the 30 second timeout', async () => {
|
||||
await fetchGitLabMRDetailsForChecks({
|
||||
repoPath: '/workspace/repo',
|
||||
repoId: 'repo-1',
|
||||
iid: 17,
|
||||
repoOwnerExecutionHostId: 'runtime:owner-runtime'
|
||||
})
|
||||
|
||||
expect(gl.workItemDetails).not.toHaveBeenCalled()
|
||||
expect(runtime.call).toHaveBeenCalledWith(
|
||||
{ kind: 'environment', environmentId: 'owner-runtime' },
|
||||
'gitlab.workItemDetails',
|
||||
expect.objectContaining({
|
||||
repo: 'id:repo-1',
|
||||
iid: 17,
|
||||
type: 'mr',
|
||||
includeReviewDetails: false
|
||||
}),
|
||||
{ timeoutMs: 30_000 }
|
||||
)
|
||||
})
|
||||
})
|
||||
@@ -1,95 +0,0 @@
|
||||
// @vitest-environment happy-dom
|
||||
|
||||
// @vitest-environment happy-dom
|
||||
import { act } from 'react'
|
||||
import { createRoot, type Root } from 'react-dom/client'
|
||||
import { afterEach, describe, expect, it, vi } from 'vitest'
|
||||
import { EMPTY_FORM, type EditingTarget } from '../../../ssh-host-form/ssh-target-draft'
|
||||
import { SshTargetForm } from './SshTargetForm'
|
||||
|
||||
afterEach(() => {
|
||||
document.body.innerHTML = ''
|
||||
})
|
||||
|
||||
type RenderProps = {
|
||||
open?: boolean
|
||||
editingId?: string | null
|
||||
form?: EditingTarget
|
||||
saving?: boolean
|
||||
onSave?: () => void
|
||||
onOpenChange?: (open: boolean) => void
|
||||
onFormChange?: (updater: (prev: EditingTarget) => EditingTarget) => void
|
||||
}
|
||||
|
||||
async function renderForm(props: RenderProps, root?: Root): Promise<Root> {
|
||||
const container = root ? null : document.createElement('div')
|
||||
if (container) {
|
||||
document.body.appendChild(container)
|
||||
}
|
||||
const nextRoot = root ?? createRoot(container!)
|
||||
await act(async () => {
|
||||
nextRoot.render(
|
||||
<SshTargetForm
|
||||
open={props.open ?? true}
|
||||
editingId={props.editingId ?? null}
|
||||
form={props.form ?? EMPTY_FORM}
|
||||
saving={props.saving ?? false}
|
||||
onFormChange={props.onFormChange ?? vi.fn()}
|
||||
onSave={props.onSave ?? vi.fn()}
|
||||
onOpenChange={props.onOpenChange ?? vi.fn()}
|
||||
/>
|
||||
)
|
||||
})
|
||||
return nextRoot
|
||||
}
|
||||
|
||||
describe('SshTargetForm', () => {
|
||||
it('treats a freshly opened edit session as clean', async () => {
|
||||
const editTarget: EditingTarget = { ...EMPTY_FORM, label: 'dev-box', host: 'dev-box.lan' }
|
||||
const onOpenChange = vi.fn()
|
||||
// Start closed so the previous baseline (EMPTY_FORM) differs from the edit draft.
|
||||
const root = await renderForm({ open: false, onOpenChange })
|
||||
await renderForm({ open: true, editingId: 'target-1', form: editTarget, onOpenChange }, root)
|
||||
|
||||
// Session effects update baseline without rerender; dismissal must read current refs.
|
||||
await act(async () => {
|
||||
await new Promise((resolve) => setTimeout(resolve, 0))
|
||||
})
|
||||
await act(async () => {
|
||||
document.body.dispatchEvent(
|
||||
new MouseEvent('pointerdown', { bubbles: true, cancelable: true })
|
||||
)
|
||||
document.body.dispatchEvent(new MouseEvent('click', { bubbles: true, cancelable: true }))
|
||||
})
|
||||
expect(onOpenChange).toHaveBeenCalledWith(false)
|
||||
act(() => root.unmount())
|
||||
})
|
||||
|
||||
it('blocks a backdrop dismissal while the draft differs from the baseline', async () => {
|
||||
const editTarget: EditingTarget = { ...EMPTY_FORM, label: 'dev-box', host: 'dev-box.lan' }
|
||||
const onOpenChange = vi.fn()
|
||||
const root = await renderForm({ open: false, onOpenChange })
|
||||
await renderForm({ open: true, editingId: 'target-1', form: editTarget, onOpenChange }, root)
|
||||
await renderForm(
|
||||
{
|
||||
open: true,
|
||||
editingId: 'target-1',
|
||||
form: { ...editTarget, host: 'other.lan' },
|
||||
onOpenChange
|
||||
},
|
||||
root
|
||||
)
|
||||
|
||||
await act(async () => {
|
||||
await new Promise((resolve) => setTimeout(resolve, 0))
|
||||
})
|
||||
await act(async () => {
|
||||
document.body.dispatchEvent(
|
||||
new MouseEvent('pointerdown', { bubbles: true, cancelable: true })
|
||||
)
|
||||
document.body.dispatchEvent(new MouseEvent('click', { bubbles: true, cancelable: true }))
|
||||
})
|
||||
expect(onOpenChange).not.toHaveBeenCalled()
|
||||
act(() => root.unmount())
|
||||
})
|
||||
})
|
||||
-84
@@ -1,84 +0,0 @@
|
||||
// @vitest-environment happy-dom
|
||||
|
||||
import { cleanup, renderHook } from '@testing-library/react'
|
||||
import { afterEach, beforeEach, expect, it, vi } from 'vitest'
|
||||
import { useAppStore } from '@/store'
|
||||
|
||||
import { useProjectsCollapseShortcut } from './use-projects-collapse-shortcut'
|
||||
|
||||
const initialState = useAppStore.getInitialState()
|
||||
let target: HTMLElement
|
||||
let guestShortcut: (() => void) | undefined
|
||||
|
||||
beforeEach(() => {
|
||||
vi.useFakeTimers()
|
||||
useAppStore.setState(
|
||||
{
|
||||
...initialState,
|
||||
persistedUIReady: true,
|
||||
contextualToursAutoEligible: false
|
||||
},
|
||||
true
|
||||
)
|
||||
Object.assign(window, {
|
||||
api: {
|
||||
ui: {
|
||||
set: () => Promise.resolve(),
|
||||
onToggleProjectsCollapse: (callback: () => void) => {
|
||||
guestShortcut = callback
|
||||
return () => {
|
||||
guestShortcut = undefined
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
vi.spyOn(navigator, 'userAgent', 'get').mockReturnValue('Windows')
|
||||
target = document.createElement('div')
|
||||
target.setAttribute('data-contextual-tour-target', 'projects-collapse-all')
|
||||
target.innerHTML = '<span data-projects-collapse-toggle><button>Toggle</button></span>'
|
||||
target.getBoundingClientRect = () => new DOMRect(100, 100, 150, 24)
|
||||
document.body.append(target)
|
||||
})
|
||||
|
||||
afterEach(() => {
|
||||
cleanup()
|
||||
target.remove()
|
||||
useAppStore.setState(initialState, true)
|
||||
vi.restoreAllMocks()
|
||||
vi.useRealTimers()
|
||||
})
|
||||
|
||||
it('keeps the shortcut usable during its own announcement and respects other dialogs', () => {
|
||||
const toggle = vi.fn()
|
||||
renderHook(() => useProjectsCollapseShortcut(true, toggle))
|
||||
const panel = document.createElement('section')
|
||||
panel.setAttribute('role', 'dialog')
|
||||
panel.setAttribute('data-contextual-tour-panel', 'projects-collapse-all')
|
||||
const rects = [new DOMRect(100, 140, 320, 180)]
|
||||
panel.getClientRects = () =>
|
||||
Object.assign(rects, { item: (index: number) => rects[index] ?? null })
|
||||
document.body.append(panel)
|
||||
const press = () =>
|
||||
window.dispatchEvent(
|
||||
new KeyboardEvent('keydown', {
|
||||
key: 'р',
|
||||
code: 'KeyH',
|
||||
ctrlKey: true,
|
||||
shiftKey: true,
|
||||
bubbles: true,
|
||||
cancelable: true
|
||||
})
|
||||
)
|
||||
press()
|
||||
expect(toggle).toHaveBeenCalledOnce()
|
||||
toggle.mockClear()
|
||||
guestShortcut?.()
|
||||
expect(toggle).toHaveBeenCalledOnce()
|
||||
panel.removeAttribute('data-contextual-tour-panel')
|
||||
toggle.mockClear()
|
||||
press()
|
||||
guestShortcut?.()
|
||||
expect(toggle).not.toHaveBeenCalled()
|
||||
panel.remove()
|
||||
})
|
||||
@@ -36,12 +36,6 @@ function setup() {
|
||||
|
||||
// Enter executes a terminal command, so exercise the actual guarded search field.
|
||||
describe('quick command search IME ownership', () => {
|
||||
it('navigates hosted commands by the caller-provided composite key', () => {
|
||||
const { input, onCommandValueChange } = setup()
|
||||
fireEvent.keyDown(input, { key: 'ArrowDown', keyCode: 40 })
|
||||
expect(onCommandValueChange).toHaveBeenCalledWith(commands[1].id)
|
||||
})
|
||||
|
||||
it('does not run a command on the bare redispatch after a confirmation', () => {
|
||||
const { input, onRun } = setup()
|
||||
fireEvent.compositionStart(input)
|
||||
|
||||
@@ -159,10 +159,6 @@ export async function readFreshNativeTable(
|
||||
}
|
||||
}
|
||||
|
||||
export function nativeReadWaitersForTests(): number {
|
||||
return slotWaiters.size
|
||||
}
|
||||
|
||||
export function resetNativeReadsForTests(): void {
|
||||
sharedReads.clear()
|
||||
slotWaiters.clear()
|
||||
|
||||
@@ -13,7 +13,7 @@ import {
|
||||
type LibprocProcessRow,
|
||||
type LibprocQuery
|
||||
} from './libproc-addon'
|
||||
import { nativeReadWaitersForTests, resetNativeReadsForTests } from './libproc-native-reads'
|
||||
import { resetNativeReadsForTests } from './libproc-native-reads'
|
||||
import { runPsInProcess } from './libproc-process-table'
|
||||
import { resetPsFallbackForTests } from './libproc-ps-fallback'
|
||||
import { createProcessTableSnapshotReader } from './process-table-snapshot-reader'
|
||||
@@ -225,107 +225,6 @@ describe('runPsInProcess', () => {
|
||||
)
|
||||
})
|
||||
|
||||
it('never joins a read submitted before the request, so stale rows never reach a caller', async () => {
|
||||
type Rows = LibprocProcessRow[] | null
|
||||
let finishStale: (rows: Rows) => void = () => {}
|
||||
const stale = new Promise<Rows>((resolve) => {
|
||||
finishStale = resolve
|
||||
})
|
||||
const readProcessTable = vi
|
||||
.fn<(query: LibprocQuery) => Promise<Rows>>()
|
||||
.mockReturnValueOnce(stale)
|
||||
.mockImplementation(async (query) => tableFor(query))
|
||||
installAddon({ readProcessTable })
|
||||
const args = ['-axo', 'pid=,ppid=']
|
||||
|
||||
expect(await runPsInProcess(args, { timeoutMs: 10 })).toMatchObject({ timedOut: true })
|
||||
const fresh = runPsInProcess(args, BUDGET)
|
||||
finishStale([row({ pid: 9999, ppid: 4242 })])
|
||||
expect((await fresh)?.stdout).not.toContain('9999')
|
||||
expect(readProcessTable).toHaveBeenCalledTimes(2)
|
||||
})
|
||||
|
||||
it('queues past the read cap without retaining timed-out waiters, then hands a stalled pool to budgeted ps', async () => {
|
||||
vi.useFakeTimers()
|
||||
const addon = installAddon({ readProcessTable: vi.fn(() => new Promise<never>(() => {})) })
|
||||
runProcess.mockResolvedValue(PS_RESULT)
|
||||
const read = (pid: number, timeoutMs = 50) =>
|
||||
runPsInProcess(['-p', String(pid), '-o', 'pid='], { timeoutMs })
|
||||
|
||||
// Eight distinct reads fill the cap and stall; overflow callers wait on one slot notifier.
|
||||
const capped = Array.from({ length: 8 }, (_, index) => read(5000 + index, 10_000))
|
||||
const overflow = Array.from({ length: 300 }, (_, index) => read(6000 + index))
|
||||
expect(nativeReadWaitersForTests()).toBe(300)
|
||||
await vi.advanceTimersByTimeAsync(50)
|
||||
expect(nativeReadWaitersForTests()).toBe(0)
|
||||
// The stalled burst costs the fork budget, not one ps per caller; the rest time out like a killed ps.
|
||||
await vi.advanceTimersByTimeAsync(50)
|
||||
const results = await Promise.all(overflow)
|
||||
expect(results.filter((result) => result?.timedOut === false)).toHaveLength(4)
|
||||
expect(results.filter((result) => result?.timedOut === true)).toHaveLength(296)
|
||||
expect(runProcess).toHaveBeenCalledTimes(4)
|
||||
|
||||
// The breaker stays open for its cool-down: callers go to ps without queueing on the pool.
|
||||
await vi.advanceTimersByTimeAsync(1_000)
|
||||
expect(await read(7000)).toEqual(PS_RESULT)
|
||||
expect(nativeReadWaitersForTests()).toBe(0)
|
||||
expect(addon.readProcessTable).toHaveBeenCalledTimes(8)
|
||||
await vi.advanceTimersByTimeAsync(10_000)
|
||||
expect(await Promise.all(capped)).toEqual(
|
||||
Array(8).fill(expect.objectContaining({ timedOut: true }))
|
||||
)
|
||||
|
||||
// Past the cool-down with the cap still held, callers learn it at once instead of after their timeout.
|
||||
await vi.advanceTimersByTimeAsync(30_000)
|
||||
let settled: unknown = 'pending'
|
||||
void read(8000, 5_000).then((result) => {
|
||||
settled = result
|
||||
})
|
||||
await vi.advanceTimersByTimeAsync(0)
|
||||
expect(settled).toEqual(PS_RESULT)
|
||||
})
|
||||
|
||||
it('recovers argv for a sudo use_pty tree on its own pty, but not for root daemons or GUI helpers', async () => {
|
||||
const TTYS005 = (16 << 24) | 5
|
||||
const root = { commandIncomplete: true, flags: 0x2 }
|
||||
const table = [
|
||||
...TABLE,
|
||||
row({
|
||||
...root,
|
||||
pid: 4600,
|
||||
ppid: 4242,
|
||||
tdev: TTYS004,
|
||||
comm: 'sudo',
|
||||
command: '/usr/bin/sudo'
|
||||
}),
|
||||
row({
|
||||
...root,
|
||||
pid: 4601,
|
||||
ppid: 4600,
|
||||
tdev: TTYS005,
|
||||
comm: 'sudo',
|
||||
command: '/usr/bin/sudo'
|
||||
}),
|
||||
row({ ...root, pid: 4602, ppid: 4601, tdev: TTYS005, comm: 'zsh', command: '/bin/zsh' }),
|
||||
row({ ...root, pid: 4603, ppid: 4602, tdev: TTYS005, comm: 'node', command: '/opt/node' }),
|
||||
row({ pid: 300, ppid: 1, comm: 'syslogd', command: '/usr/sbin/syslogd' }),
|
||||
row({
|
||||
pid: 700,
|
||||
ppid: 1,
|
||||
comm: 'Orca',
|
||||
command: '/Applications/Orca',
|
||||
commandIncomplete: false
|
||||
}),
|
||||
row({ pid: 701, ppid: 700, comm: 'helper', command: '/usr/libexec/helper' })
|
||||
]
|
||||
installAddon({ readProcessTable: vi.fn(async (query: LibprocQuery) => tableFor(query, table)) })
|
||||
runProcess.mockResolvedValue({ code: 0, signal: null, stdout: '', stderr: '', timedOut: false })
|
||||
|
||||
await runPsInProcess(['-axo', 'pid=,command='], { env: { LC_ALL: 'C' }, timeoutMs: 1000 })
|
||||
const pids = runProcess.mock.calls[0]?.[0].args.at(-1).split(',').map(Number).sort()
|
||||
expect(pids).toEqual([4600, 4601, 4602, 4603])
|
||||
})
|
||||
|
||||
it('asks ps again once exec changes the program behind a cached pid and start time', async () => {
|
||||
const shell = row({ pid: 4700, ppid: 4242, tdev: TTYS004, comm: 'zsh', command: '/bin/zsh' })
|
||||
let current = shell
|
||||
@@ -375,35 +274,6 @@ describe('runPsInProcess', () => {
|
||||
expect(runProcess.mock.calls[0]?.[0].args.at(-1)).toBe('4803')
|
||||
})
|
||||
|
||||
it('shares one argv ps among concurrent readers and waits out a failed recovery before asking again', async () => {
|
||||
vi.useFakeTimers({ toFake: ['setTimeout', 'clearTimeout', 'performance'] })
|
||||
const sudo = row({
|
||||
pid: 4900,
|
||||
ppid: 4242,
|
||||
tdev: TTYS004,
|
||||
uid: OTHER_UID,
|
||||
comm: 'node',
|
||||
command: '(node)'
|
||||
})
|
||||
installAddon({
|
||||
readProcessTable: vi.fn(async (query: LibprocQuery) => tableFor(query, [...TABLE, sudo]))
|
||||
})
|
||||
// ps omits a process that exited, or one it cannot read either.
|
||||
runProcess.mockResolvedValue({ code: 1, signal: null, stdout: '', stderr: '', timedOut: false })
|
||||
const read = (): Promise<unknown> =>
|
||||
runPsInProcess(['-o', 'pid=,command=', '-t', 'ttys004'], BUDGET)
|
||||
|
||||
const concurrent = await Promise.all(Array.from({ length: 24 }, read))
|
||||
expect(concurrent).toEqual(Array(24).fill(expect.objectContaining({ timedOut: false })))
|
||||
expect(runProcess).toHaveBeenCalledTimes(1)
|
||||
|
||||
await read()
|
||||
expect(runProcess).toHaveBeenCalledTimes(1)
|
||||
await vi.advanceTimersByTimeAsync(5_000)
|
||||
await read()
|
||||
expect(runProcess).toHaveBeenCalledTimes(2)
|
||||
})
|
||||
|
||||
it('reuses recovered argv for at most 1.5s, so a same-comm re-exec is seen', async () => {
|
||||
vi.useFakeTimers({ toFake: ['setTimeout', 'clearTimeout', 'performance'] })
|
||||
const sudo = row({
|
||||
@@ -436,37 +306,6 @@ describe('runPsInProcess', () => {
|
||||
expect(runProcess).toHaveBeenCalledTimes(2)
|
||||
})
|
||||
|
||||
it('waits out a failed recovery from when ps gave up, however long it ran', async () => {
|
||||
vi.useFakeTimers({ toFake: ['setTimeout', 'clearTimeout', 'performance'] })
|
||||
const sudo = row({
|
||||
pid: 5200,
|
||||
ppid: 4242,
|
||||
tdev: TTYS004,
|
||||
uid: OTHER_UID,
|
||||
comm: 'su',
|
||||
command: '(su)'
|
||||
})
|
||||
installAddon({
|
||||
readProcessTable: vi.fn(async (query: LibprocQuery) => tableFor(query, [...TABLE, sudo]))
|
||||
})
|
||||
// A loaded host: ps takes 6s, then omits the process.
|
||||
let finish: () => void = () => {}
|
||||
runProcess.mockImplementation(
|
||||
() =>
|
||||
new Promise((resolve) => {
|
||||
finish = () => resolve({ code: 1, signal: null, stdout: '', stderr: '', timedOut: false })
|
||||
})
|
||||
)
|
||||
const read = () => runPsInProcess(['-p', '5200', '-o', 'command='], { timeoutMs: 10_000 })
|
||||
|
||||
const slow = read()
|
||||
await vi.advanceTimersByTimeAsync(6_000)
|
||||
finish()
|
||||
await slow
|
||||
await read()
|
||||
expect(runProcess).toHaveBeenCalledTimes(1)
|
||||
})
|
||||
|
||||
it('recovers a su pane’s argv within the recovery budget however often it is read', async () => {
|
||||
vi.useFakeTimers({ toFake: ['setTimeout', 'clearTimeout', 'performance'] })
|
||||
const su = row({
|
||||
|
||||
Reference in New Issue
Block a user