test: remove marginal browser coverage

This commit is contained in:
OrcaWin
2026-11-08 19:27:31 -08:00
parent 88c7c19233
commit bd2dc1e7fe
5 changed files with 0 additions and 197 deletions
@@ -197,96 +197,6 @@ describe('ClientHostedBrowserPagePane', () => {
expect(screen.getByText('Client-hosted browser unavailable')).not.toBeNull()
expect(document.querySelector('webview')).toBeNull()
})
it('requests the one-time intro tour on the first active client-hosted page', async () => {
vi.useFakeTimers()
const { useAppStore } = await import('@/store')
const prior = {
persistedUIReady: useAppStore.getState().persistedUIReady,
contextualToursSeenIds: useAppStore.getState().contextualToursSeenIds,
activeContextualTourId: useAppStore.getState().activeContextualTourId
}
useAppStore.setState({
persistedUIReady: true,
contextualToursSeenIds: [],
activeContextualTourId: null
})
const { webview } = createWebview()
mocks.attach.mockReturnValue(retainedAttachment(webview))
try {
render(
<ClientHostedBrowserPagePane
browserTab={page()}
workspaceId="workspace-a"
chromeShortcutScope="focused"
runtimeEnvironmentId="environment-a"
worktreeId="worktree-a"
placement={PLACEMENT}
isActive={true}
onUpdatePageState={vi.fn()}
onSetUrl={vi.fn()}
/>
)
// Why: happy-dom rects are zero-sized and the tour gate requires a measurable target.
const target = document.querySelector<HTMLElement>(
'[data-contextual-tour-target="client-hosted-browser-controls"]'
)
expect(target).not.toBeNull()
target!.getBoundingClientRect = () => new DOMRect(0, 0, 400, 32)
await act(async () => {
await vi.advanceTimersByTimeAsync(0)
})
expect(useAppStore.getState().activeContextualTourId).toBe('client-hosted-browser')
} finally {
useAppStore.setState(prior)
vi.useRealTimers()
}
})
it('never re-requests the intro tour once it has been seen', async () => {
vi.useFakeTimers()
const { useAppStore } = await import('@/store')
const prior = {
persistedUIReady: useAppStore.getState().persistedUIReady,
contextualToursSeenIds: useAppStore.getState().contextualToursSeenIds,
activeContextualTourId: useAppStore.getState().activeContextualTourId
}
useAppStore.setState({
persistedUIReady: true,
contextualToursSeenIds: ['client-hosted-browser'],
activeContextualTourId: null
})
const { webview } = createWebview()
mocks.attach.mockReturnValue(retainedAttachment(webview))
try {
render(
<ClientHostedBrowserPagePane
browserTab={page()}
workspaceId="workspace-a"
chromeShortcutScope="focused"
runtimeEnvironmentId="environment-a"
worktreeId="worktree-a"
placement={PLACEMENT}
isActive={true}
onUpdatePageState={vi.fn()}
onSetUrl={vi.fn()}
/>
)
// Why: same measurable target as the positive case — only seenIds differs.
const target = document.querySelector<HTMLElement>(
'[data-contextual-tour-target="client-hosted-browser-controls"]'
)
expect(target).not.toBeNull()
target!.getBoundingClientRect = () => new DOMRect(0, 0, 400, 32)
await act(async () => {
await vi.advanceTimersByTimeAsync(0)
})
expect(useAppStore.getState().activeContextualTourId).toBeNull()
} finally {
useAppStore.setState(prior)
vi.useRealTimers()
}
})
})
describe('ClientHostedBrowserPagePane address bar parity', () => {
@@ -103,18 +103,6 @@ describe('formatBrowserAnnotationsAsMarkdown', () => {
expect(markdown).not.toContain('\n## injected')
})
it('heads document preview annotations with the Windows file path', () => {
const annotation = makeAnnotation()
const sanitizedUrl = 'C:\\repo\\docs\\report.html'
const markdown = formatBrowserAnnotationsAsMarkdown([
makeAnnotation({
payload: { ...annotation.payload, page: { ...annotation.payload.page, sanitizedUrl } }
})
])
expect(markdown).toContain(`## Design Feedback: ${sanitizedUrl}`)
})
it('does not split surrogate pairs at the inline annotation cap', () => {
const annotation = makeAnnotation()
const selectedText = `${'x'.repeat(BROWSER_ANNOTATION_INLINE_TEXT_MAX_LENGTH - 1)}😀tail`
@@ -287,27 +287,6 @@ describe('browser grab toast owner', () => {
expect(next.view.result.current.grabToast).toBeNull()
expect(vi.getTimerCount()).toBe(0)
})
it.each(['clipboard', 'interaction'] as const)(
'honors reentrant cleanup during %s delivery',
async (point) => {
const payload = makePayload()
extract.mockResolvedValue({ ok: true, payload })
const { view, bounds } = mount()
if (point === 'clipboard') {
writes.mockImplementationOnce(() => view.unmount())
} else {
state.recordFeatureInteraction.mockImplementationOnce(() => view.unmount())
}
await act(async () => {
view.result.current.handleGrabActionShortcut('c')
await Promise.resolve()
})
expect(writes.mock.calls).toEqual([[formatGrabPayloadAsText(payload)]])
expect(state.recordFeatureInteraction.mock.calls).toEqual([['browser-grab']])
expect(bounds).not.toHaveBeenCalled()
expect(vi.getTimerCount()).toBe(0)
}
)
it('preserves latest target reads and screenshot completion after cleanup', async () => {
const extraction = deferred<BrowserExtractHoverResult>()
const image = deferred<{ ok: true; screenshot: typeof screenshot }>()
@@ -1,23 +0,0 @@
import { describe, expect, it, vi } from 'vitest'
import { ORCA_BROWSER_BLANK_URL } from '../../../../shared/constants'
const mocks = vi.hoisted(() => ({
createWebRuntimeSessionBrowserTab: vi.fn(async (_args: Record<string, unknown>) => true)
}))
vi.mock('@/runtime/browser/creation/web-runtime-browser-creation', () => ({
createWebRuntimeSessionBrowserTab: mocks.createWebRuntimeSessionBrowserTab
}))
import { resolveBrowserReopenOnServerUrl } from './browser-reopen-on-server'
describe('resolveBrowserReopenOnServerUrl', () => {
it('reopens blank rather than replaying something the new engine cannot restore', () => {
expect(resolveBrowserReopenOnServerUrl(ORCA_BROWSER_BLANK_URL)).toBeUndefined()
expect(resolveBrowserReopenOnServerUrl('about:blank')).toBeUndefined()
expect(resolveBrowserReopenOnServerUrl('file:///etc/hosts')).toBeUndefined()
expect(resolveBrowserReopenOnServerUrl('')).toBeUndefined()
expect(resolveBrowserReopenOnServerUrl(null)).toBeUndefined()
expect(resolveBrowserReopenOnServerUrl(undefined)).toBeUndefined()
})
})
@@ -1,51 +0,0 @@
// @vitest-environment happy-dom
import { expect, it, vi } from 'vitest'
import { publishNativeChatVisualGuestTheme } from '@/components/native-chat/media/visuals/NativeChatVisualGuestThemePublisher'
vi.mock('@/components/native-chat/media/visuals/NativeChatVisualGuestThemePublisher', () => ({
publishNativeChatVisualGuestTheme: vi.fn()
}))
import { acquireWebviewsDragPassthrough } from '../host-guest/webview-drag-passthrough'
import { webviewRegistry } from '../host-guest/webview-registry'
import { attachDocPreviewWebview } from './doc-preview-webview-attach'
function attach(previewId: string, container: HTMLDivElement) {
return attachDocPreviewWebview({
previewId,
container,
url: 'orca-preview://grant/index.html',
ariaLabel: 'HTML preview',
onLoadStarted: vi.fn(),
onLoadStopped: vi.fn(),
onLoadFailed: vi.fn(),
onNavigated: vi.fn(),
onTitleUpdated: vi.fn(),
onViewportMessage: vi.fn()
})
}
it('restores pointer input when a drag ends after attaching a document preview', () => {
const container = document.createElement('div')
document.body.appendChild(container)
const append = vi.spyOn(container, 'appendChild')
append.mockImplementation((node) => {
expect(publishNativeChatVisualGuestTheme).toHaveBeenCalledTimes(1)
expect((node as HTMLElement).style.pointerEvents).toBe('none')
return Node.prototype.appendChild.call(container, node)
})
const release = acquireWebviewsDragPassthrough()
const attached = attach('preview-drag', container)
try {
expect(webviewRegistry.get('preview-drag')).toBe(attached.webview)
expect(attached.webview.style.pointerEvents).toBe('none')
release()
expect(attached.webview.style.pointerEvents).toBe('')
} finally {
release()
attached.detach()
container.remove()
append.mockRestore()
}
expect(webviewRegistry.has('preview-drag')).toBe(false)
})