From 43df511fadfc9cde5682ab7e0c48626c4da2bd2d Mon Sep 17 00:00:00 2001 From: OrcaWin Date: Thu, 12 Nov 2026 15:16:17 -0800 Subject: [PATCH] test: remove low-value mobile, focus, and prompt coverage (#41692) Co-authored-by: OrcaWin <293788423+OrcaWin@users.noreply.github.com> --- .../scripts/ci/sharding/ci-shard-timings.json | 1 - .../mobile-file-tap-open.test.ts | 113 ------------------ .../navigation/host-stack-navigation.test.ts | 82 ------------- .../terminal/terminal-accessory-keys.test.ts | 81 ------------- .../errors/TerminalErrorToast.test.tsx | 42 ------- .../pr-comments-resolution-prompt.test.ts | 45 ------- 6 files changed, 364 deletions(-) delete mode 100644 mobile/src/terminal/terminal-accessory-keys.test.ts delete mode 100644 src/renderer/src/components/terminal-pane/errors/TerminalErrorToast.test.tsx delete mode 100644 src/shared/source-control/review-comments/pr-comments-resolution-prompt.test.ts diff --git a/config/scripts/ci/sharding/ci-shard-timings.json b/config/scripts/ci/sharding/ci-shard-timings.json index 3e51afe4adc..cf5ff03df85 100644 --- a/config/scripts/ci/sharding/ci-shard-timings.json +++ b/config/scripts/ci/sharding/ci-shard-timings.json @@ -6354,7 +6354,6 @@ "src/shared/git/worktrees/git-worktree-admin.test.ts": 161, "src/shared/github/account-binding.test.ts": 48, "src/shared/github/api-availability.test.ts": 47, - "src/shared/source-control/review-comments/pr-comments-resolution-prompt.test.ts": 49, "src/shared/github/project-board-columns.test.ts": 64, "src/shared/github/project-identity.test.ts": 33, "src/shared/github/project-ref-input.test.ts": 40, diff --git a/mobile/src/files/session-documents/mobile-file-tap-open.test.ts b/mobile/src/files/session-documents/mobile-file-tap-open.test.ts index c436160748c..778676c0d8e 100644 --- a/mobile/src/files/session-documents/mobile-file-tap-open.test.ts +++ b/mobile/src/files/session-documents/mobile-file-tap-open.test.ts @@ -9,21 +9,6 @@ function ok(result: unknown): RpcResponse { return { id: 'rpc', ok: true, result, _meta: { runtimeId: 'runtime-1' } } } -function createClient(responses: (RpcResponse | Error)[]) { - return { - sendRequest: vi.fn(async (method) => { - const response = responses.shift() - if (!response) { - throw new Error(`no scripted response for ${method}`) - } - if (response instanceof Error) { - throw response - } - return response - }) - } -} - function activeTerminalState(activated: boolean) { return { activated, @@ -92,14 +77,6 @@ describe('openMobileFileTap', () => { .map(([, params]) => params) } - it('opens the longest terminal reading that exists, as desktop does', async () => { - const opened = await openTerminalReadings( - ['src/index.ts', 'src/index.ts.map', 'src/index.ts.map.bak'], - new Set(['src/index.ts', 'src/index.ts.map']) - ) - expect(opened).toEqual([{ worktree: 'id:wt-1', relativePath: 'src/index.ts.map' }]) - }) - it('still checks the real path behind hundreds of hard-wrap guesses', async () => { const guesses = Array.from({ length: 210 }, (_, index) => `src/file${index}.tssrc/next.ts`) const opened = await openTerminalReadings( @@ -108,94 +85,4 @@ describe('openMobileFileTap', () => { ) expect(opened).toEqual([{ worktree: 'id:wt-1', relativePath: 'src/file19.ts' }]) }) - - it('does not navigate an absolute artifact after the user leaves the source terminal', async () => { - let resolveRequest: (value: RpcResponse) => void = () => {} - const client = { - sendRequest: vi.fn( - () => - new Promise((resolve) => { - resolveRequest = resolve - }) - ) - } - let activeTerminalHandle: string | null = 'terminal-1' - const pushPreviewRoute = vi.fn() - - openMobileFileTap({ - client, - hostId: 'host-1', - worktreeId: 'wt-1', - candidates: [{ pathText: '/tmp/result.json', line: null, column: null }], - terminalHandle: 'terminal-1', - pushPreviewRoute, - openBrowser: vi.fn(), - triggerOpenFeedback: vi.fn(), - fetchSessionTabs: vi.fn(), - getSessionTabs: () => [], - getActiveSessionTabId: () => null, - getActivationState: (activated) => ({ - ...activeTerminalState(activated), - activeTerminalHandle - }), - switchSessionTab: vi.fn(), - scheduleDelayedAction: vi.fn() - }) - - activeTerminalHandle = 'terminal-2' - resolveRequest( - ok({ - worktree: 'wt-1', - relativePath: null, - absolutePath: '/tmp/result.json', - exists: true, - isDirectory: false, - openTarget: { - kind: 'absolute-file', - provider: 'local', - absolutePath: '/tmp/result.json', - grantId: 'grant-1' - } - }) - ) - await vi.advanceTimersByTimeAsync(0) - - expect(pushPreviewRoute).not.toHaveBeenCalled() - }) - - it('does not report a stale failure after a newer tap supersedes it', async () => { - const client = createClient([ - ok({ - worktree: 'wt-1', - relativePath: null, - absolutePath: null, - exists: false, - isDirectory: false - }) - ]) - const onOpenFailed = vi.fn() - - openMobileFileTap({ - client, - hostId: 'host-1', - worktreeId: 'wt-1', - candidates: [{ pathText: 'gone/missing.ts', line: null, column: null }], - pushPreviewRoute: vi.fn(), - openBrowser: vi.fn(), - triggerOpenFeedback: vi.fn(), - fetchSessionTabs: vi.fn(), - getSessionTabs: () => [], - getActiveSessionTabId: () => null, - getActivationState: (activated) => ({ - ...activeTerminalState(activated), - latestActivationSeq: 2 - }), - switchSessionTab: vi.fn(), - scheduleDelayedAction: vi.fn(), - onOpenFailed - }) - await vi.advanceTimersByTimeAsync(0) - - expect(onOpenFailed).not.toHaveBeenCalled() - }) }) diff --git a/mobile/src/navigation/host-stack-navigation.test.ts b/mobile/src/navigation/host-stack-navigation.test.ts index 64f99b4b3cc..dc0cf52af11 100644 --- a/mobile/src/navigation/host-stack-navigation.test.ts +++ b/mobile/src/navigation/host-stack-navigation.test.ts @@ -1,17 +1,9 @@ import { describe, expect, it, vi } from 'vitest' import { coordinateHostStackNavigation, - navigateToHostStackRoute, type HostStackNavigationState } from './host-stack-navigation' -const TARGET = { name: '[hostId]/tasks', params: { hostId: 'host/one' } } as const -const OTHER_TARGET = { - name: '[hostId]/session/[worktreeId]', - params: { hostId: 'host/one', worktreeId: 'repo::/tmp/wt' } -} as const - -// Remove listeners for real so teardown is tested instead of merely the active guard. function navigationHarness(initialState: HostStackNavigationState | undefined) { const stateListeners = new Set<() => void>() let state = initialState @@ -57,58 +49,6 @@ function committedHostState(hostIdParam: string): HostStackNavigationState { } describe('host stack navigation', () => { - it('stops listening and never replaces once canceled', () => { - const harness = navigationHarness({ index: 0, routes: [{ name: 'index' }] }) - - const controller = navigateToHostStackRoute( - harness.navigation, - { push: vi.fn(), replace: vi.fn() }, - 'host/one', - TARGET - ) - expect(harness.listenerCount()).toBe(1) - controller.cancel() - - expect(harness.unsubscribe).toHaveBeenCalledTimes(1) - expect(harness.listenerCount()).toBe(0) - expect(controller.isActive()).toBe(false) - - harness.setState(committedHostState('host/one')) - expect(harness.navigation.dispatch).not.toHaveBeenCalled() - }) - - it('retargets a still-pending transition to the same host instead of pushing twice', () => { - const harness = navigationHarness({ index: 0, routes: [{ name: 'index' }] }) - const push = vi.fn() - const router = { push, replace: vi.fn() } - - const pending = coordinateHostStackNavigation( - null, - harness.navigation, - router, - 'host/one', - TARGET - ) - const retargeted = coordinateHostStackNavigation( - pending, - harness.navigation, - router, - 'host/one', - OTHER_TARGET - ) - - expect(retargeted).toBe(pending) - expect(push).toHaveBeenCalledTimes(1) - expect(harness.listenerCount()).toBe(1) - - harness.setState(committedHostState('host/one')) - - expect(harness.navigation.dispatch).toHaveBeenCalledTimes(1) - expect(harness.navigation.dispatch).toHaveBeenCalledWith( - expect.objectContaining({ payload: OTHER_TARGET }) - ) - }) - describe('a session opened inside its host document', () => { const SESSION = { name: '[hostId]/session/[worktreeId]', @@ -155,27 +95,5 @@ describe('host stack navigation', () => { ] ]) }) - - it('lets another screen tapped while the push commits take the list place', () => { - const harness = navigationHarness({ index: 0, routes: [{ name: 'index' }] }) - const push = vi.fn() - const router = { push, replace: vi.fn() } - - const pending = coordinateHostStackNavigation( - null, - harness.navigation, - router, - 'host/one', - SESSION, - true - ) - coordinateHostStackNavigation(pending, harness.navigation, router, 'host/one', TARGET) - harness.setState(committedHostState('host/one')) - - expect(push).toHaveBeenCalledTimes(1) - expect(harness.navigation.dispatch.mock.calls).toEqual([ - [{ type: 'REPLACE', target: '/h', source: 'host-index', payload: TARGET }] - ]) - }) }) }) diff --git a/mobile/src/terminal/terminal-accessory-keys.test.ts b/mobile/src/terminal/terminal-accessory-keys.test.ts deleted file mode 100644 index ddf5d586082..00000000000 --- a/mobile/src/terminal/terminal-accessory-keys.test.ts +++ /dev/null @@ -1,81 +0,0 @@ -import { describe, expect, it } from 'vitest' - -import { buildTerminalShortcutKey } from './terminal-accessory-keys' - -describe('TERMINAL_ACCESSORY_KEYS', () => { - it('builds Ctrl, Alt, and Shift printable shortcut bytes', () => { - expect(buildTerminalShortcutKey({ key: 'c', modifiers: ['ctrl'] })).toEqual({ - label: 'Ctrl+C', - bytes: '\x03', - accessibilityLabel: 'Ctrl C' - }) - expect(buildTerminalShortcutKey({ key: 'k', modifiers: ['ctrl', 'alt'] })).toEqual({ - label: 'Ctrl+Alt+K', - bytes: '\x1b\x0b', - accessibilityLabel: 'Ctrl Alt K' - }) - expect(buildTerminalShortcutKey({ key: '1', modifiers: ['alt', 'shift'] })).toEqual({ - label: 'Alt+Shift+1', - bytes: '\x1b!', - accessibilityLabel: 'Alt Shift 1' - }) - }) - - it('builds custom Space shortcut bytes with terminal modifiers', () => { - expect(buildTerminalShortcutKey({ key: 'space', modifiers: [] })).toEqual({ - label: 'Space', - bytes: ' ', - accessibilityLabel: 'Space' - }) - expect(buildTerminalShortcutKey({ key: 'space', modifiers: ['ctrl'] })).toEqual({ - label: 'Ctrl+Space', - bytes: '\x00', - accessibilityLabel: 'Ctrl Space' - }) - expect(buildTerminalShortcutKey({ key: 'space', modifiers: ['alt'] })).toEqual({ - label: 'Alt+Space', - bytes: '\x1b ', - accessibilityLabel: 'Alt Space' - }) - }) - - it('builds modified special-key terminal sequences', () => { - expect(buildTerminalShortcutKey({ key: 'tab', modifiers: ['shift'] })).toEqual({ - label: 'Shift+Tab', - bytes: '\x1b[Z', - accessibilityLabel: 'Shift Tab' - }) - expect(buildTerminalShortcutKey({ key: 'enter', modifiers: [] })).toEqual({ - label: 'Enter', - bytes: '\r', - accessibilityLabel: 'Enter' - }) - expect(buildTerminalShortcutKey({ key: 'arrowRight', modifiers: ['ctrl', 'shift'] })).toEqual({ - label: 'Ctrl+Shift+→', - bytes: '\x1b[1;6C', - accessibilityLabel: 'Ctrl Shift →' - }) - expect(buildTerminalShortcutKey({ key: 'delete', modifiers: ['alt'] })).toEqual({ - label: 'Alt+Del', - bytes: '\x1b[3;3~', - accessibilityLabel: 'Alt Del' - }) - }) - - it('builds function-key terminal sequences', () => { - expect(buildTerminalShortcutKey({ key: 'f1', modifiers: [] })).toEqual({ - label: 'F1', - bytes: '\x1bOP', - accessibilityLabel: 'F1' - }) - expect(buildTerminalShortcutKey({ key: 'f5', modifiers: ['shift'] })).toEqual({ - label: 'Shift+F5', - bytes: '\x1b[15;2~', - accessibilityLabel: 'Shift F5' - }) - }) - - it('rejects control combinations that terminals cannot encode as control bytes', () => { - expect(buildTerminalShortcutKey({ key: '1', modifiers: ['ctrl'] })).toBeNull() - }) -}) diff --git a/src/renderer/src/components/terminal-pane/errors/TerminalErrorToast.test.tsx b/src/renderer/src/components/terminal-pane/errors/TerminalErrorToast.test.tsx deleted file mode 100644 index acce4df0cdc..00000000000 --- a/src/renderer/src/components/terminal-pane/errors/TerminalErrorToast.test.tsx +++ /dev/null @@ -1,42 +0,0 @@ -// @vitest-environment happy-dom -import { cleanup, render, screen, waitFor } from '@testing-library/react' -import userEvent from '@testing-library/user-event' -import { afterEach, expect, it, vi } from 'vitest' -import { TerminalErrorToast } from './TerminalErrorToast' - -vi.mock('@/i18n/use-translate', () => ({ - useTranslate: () => (_key: string, text: string) => text -})) -afterEach(cleanup) - -it('returns typing to the terminal when Retry disables its button', async () => { - const user = userEvent.setup() - let finishRetry!: (result: boolean) => void - const retry = new Promise((resolve) => { - finishRetry = resolve - }) - const terminal = document.createElement('textarea') - document.body.append(terminal) - try { - render( - {}} - onRetry={() => retry} - onRestoreTerminalFocus={() => terminal.focus()} - /> - ) - await user.click(screen.getByRole('button', { name: /^Retry$/ })) - expect(document.activeElement).toBe(terminal) - await user.keyboard('echo retry') - expect(terminal.value).toBe('echo retry') - finishRetry(true) - await waitFor(() => - expect(screen.getByRole('button', { name: /^Retry$/ }).hasAttribute('disabled')).toBe(false) - ) - expect(document.activeElement).toBe(terminal) - } finally { - terminal.remove() - } -}) diff --git a/src/shared/source-control/review-comments/pr-comments-resolution-prompt.test.ts b/src/shared/source-control/review-comments/pr-comments-resolution-prompt.test.ts deleted file mode 100644 index 03c4368e326..00000000000 --- a/src/shared/source-control/review-comments/pr-comments-resolution-prompt.test.ts +++ /dev/null @@ -1,45 +0,0 @@ -import { expect, it } from 'vitest' -import type { PRComment } from '../../github/comments/comment-types' -import { buildPRCommentsResolutionPrompt } from './pr-comments-resolution-prompt' - -it('serializes selected thread content once while preserving replies and standalone feedback', () => { - const root: PRComment = { - id: 11, - author: 'reviewer', - authorAvatarUrl: '', - body: 'Check missing workspace names', - createdAt: '', - url: '', - threadId: 'discussion-1', - isResolved: false - } - const prompt = buildPRCommentsResolutionPrompt({ - reviewKind: 'MR', - reviewNumber: 42, - reviewTitle: 'Workspace labels', - reviewUrl: 'https://gitlab.example/repo/-/merge_requests/42', - groups: [ - { - kind: 'thread', - threadId: 'discussion-1', - root, - replies: [{ ...root, id: 12, body: 'Include older remote hosts' }] - }, - { kind: 'standalone', comment: { ...root, id: 13, body: 'Check cleanup sorting' } } - ] - }) - const serialized = prompt.split('Selected comment data JSON:\n')[1]!.split('\n\nRules:')[0]! - const payload = JSON.parse(serialized) - - expect(payload).not.toHaveProperty('hostResolvableThreads') - expect(payload.selectedCommentGroups).toMatchObject([ - { - kind: 'thread', - threadId: 'discussion-1', - isHostResolvable: true, - root: { id: 11, body: 'Check missing workspace names' }, - replies: [{ id: 12, body: 'Include older remote hosts' }] - }, - { kind: 'standalone', comment: { id: 13, body: 'Check cleanup sorting' } } - ]) -})