mirror of
https://github.com/stablyai/orca.git
synced 2026-11-17 03:15:01 +00:00
test: remove low-value sidebar and page preference suites
This commit is contained in:
@@ -447,7 +447,6 @@
|
||||
3 test-no-wall-clock:src/main/wsl/orcad/wsl-orcad-real-distro-lane.test.ts
|
||||
1 test-no-wall-clock:src/renderer/src/components/activity/activity-auto-mark-read-loop.react185.test.tsx
|
||||
1 test-no-wall-clock:src/renderer/src/components/browser-pane/assemble-chrome/browser-workspace-pane.adoption-chrome.test.tsx
|
||||
1 test-no-wall-clock:src/renderer/src/components/sidebar/worktree-list/listing/WorktreeList.lineage-agent-expansion-coupling.test.tsx
|
||||
2 test-no-wall-clock:src/renderer/src/components/terminal-pane/pty-connection/emulation/fish-color-scheme-child-stdin.node-pty.test.ts
|
||||
2 test-no-wall-clock:src/renderer/src/components/terminal-pane/snapshots/remote-snapshot-alt-screen-host-chain.test.ts
|
||||
1 test-no-wall-clock:src/renderer/src/components/terminal/initial-terminal-structured-launch.test.tsx
|
||||
@@ -542,7 +541,6 @@
|
||||
1 test-timeout-needs-reason:src/renderer/src/lib/source-control/checks/check-run-details-log-normalization-performance.test.ts
|
||||
1 test-timeout-needs-reason:src/shared/__tests__/process-host/windows-tree-kill-late-taskkill.win32.test.ts
|
||||
1 test-timeout-needs-reason:src/shared/shell/wsl/wsl-login-shell-command.test.ts
|
||||
1 test-timeout-needs-reason:tests/e2e/active-view-restart-restore.spec.ts
|
||||
1 test-timeout-needs-reason:tests/e2e/agent-send-picker-reveal.spec.ts
|
||||
1 test-timeout-needs-reason:tests/e2e/agent-session-log-tail-stability.spec.ts
|
||||
1 test-timeout-needs-reason:tests/e2e/browser-agent-input-focus-isolation-native.spec.ts
|
||||
|
||||
@@ -3598,7 +3598,6 @@
|
||||
"src/renderer/src/components/sidebar/Sidebar.test.tsx": 833,
|
||||
"src/renderer/src/components/sidebar/workspace-card/surface/WorktreeCard.single-reference-details.test.tsx": 2032,
|
||||
"src/renderer/src/components/sidebar/workspace-actions/context-menu/WorktreeContextMenu.closed-menu-work.test.tsx": 1753,
|
||||
"src/renderer/src/components/sidebar/worktree-list/listing/WorktreeList.lineage-agent-expansion-coupling.test.tsx": 5388,
|
||||
"src/renderer/src/components/sidebar/workspace-visibility/dialog/WorktreeVisibilityDialog.test.tsx": 2602,
|
||||
"src/renderer/src/components/sidebar/workspace-actions/deletion/delete-worktree-parallel-flow.test.ts": 938,
|
||||
"src/renderer/src/components/sidebar/workspace-creation/folder/folder-workspace-composer-submit-host-platform.test.ts": 2264,
|
||||
@@ -4835,7 +4834,6 @@
|
||||
],
|
||||
"overheadMs": 0,
|
||||
"timings": {
|
||||
"tests/e2e/active-view-restart-restore.spec.ts": 22600,
|
||||
"tests/e2e/activity-agent-pane-isolation.spec.ts": 102400,
|
||||
"tests/e2e/add-project-default-checkout.spec.ts": 41600,
|
||||
"tests/e2e/agent-dashboard-status-burst.spec.ts": 16900,
|
||||
@@ -5083,7 +5081,6 @@
|
||||
"tests/e2e/worktree-card-downward-drag.spec.ts": 60000,
|
||||
"tests/e2e/worktree-delete-shortcut.spec.ts": 20600,
|
||||
"tests/e2e/worktree-lifecycle.spec.ts": 44000,
|
||||
"tests/e2e/worktree-lineage-agent-expansion.spec.ts": 21800,
|
||||
"tests/e2e/worktree-lineage.spec.ts": 96700,
|
||||
"tests/e2e/worktree-recent-sort.spec.ts": 28400,
|
||||
"tests/e2e/worktree-scroll-to-current.spec.ts": 62400,
|
||||
|
||||
-496
@@ -1,496 +0,0 @@
|
||||
// @vitest-environment happy-dom
|
||||
import {
|
||||
acceptedAgentStatuses,
|
||||
type AcceptedAgentStatuses
|
||||
} from '@/store/slices/agent-status/accepted-agent-statuses'
|
||||
|
||||
vi.mock('@/components/confirmation-dialog-context', () => ({
|
||||
useConfirmationDialog: () => vi.fn().mockResolvedValue(false)
|
||||
}))
|
||||
|
||||
// Render real list/agents so changing lineage row keys remounts cards and exercises disclosure persistence independently of child-worktree expansion.
|
||||
|
||||
import { act, type ReactNode } from 'react'
|
||||
import { useAppStore } from '@/store'
|
||||
import { createRoot, type Root } from 'react-dom/client'
|
||||
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
import type * as ProjectHeaderDragContract from '../drag/project-header-drag-contract'
|
||||
import type {
|
||||
AgentStatusEntry,
|
||||
AgentStatusOrchestrationContext
|
||||
} from '../../../../../../shared/agent-status/contracts/agent-status-types'
|
||||
import type { Repo } from '../../../../../../shared/repository/repo-types'
|
||||
import type { TerminalTab } from '../../../../../../shared/workspace-layout/terminal-tab-types'
|
||||
import type { WorktreeCardProperty } from '../../../../../../shared/ui-chrome-types'
|
||||
import type { WorktreeLineage } from '../../../../../../shared/worktree/lineage-types'
|
||||
import type { Worktree } from '../../../../../../shared/worktree/types'
|
||||
import { clearWorktreeAgentExpansionStateForTests } from '../../workspace-card/activity/worktree-card-agents-expansion-state'
|
||||
|
||||
globalThis.IS_REACT_ACT_ENVIRONMENT = true
|
||||
|
||||
const mockStore = vi.hoisted(() => ({
|
||||
state: {} as Record<string, unknown>,
|
||||
setVisibleReviewCardWorktreeIds: vi.fn<(ids: readonly string[]) => void>(),
|
||||
activateWorktreeFromSidebar: vi.fn(),
|
||||
openModal: vi.fn()
|
||||
}))
|
||||
|
||||
type WorktreeListComponent = React.ComponentType<{
|
||||
scrollOffsetRef: React.RefObject<number>
|
||||
scrollAnchorRef: React.RefObject<unknown>
|
||||
}>
|
||||
|
||||
let WorktreeList: WorktreeListComponent
|
||||
|
||||
vi.mock('@/store', () => ({
|
||||
useAppStore: Object.assign(
|
||||
(selector: (state: Record<string, unknown>) => unknown) => selector(mockStore.state),
|
||||
{
|
||||
getState: () => mockStore.state,
|
||||
subscribe: () => () => {}
|
||||
}
|
||||
)
|
||||
}))
|
||||
|
||||
// Use the virtualizer keys when rendering the visible workspace rows.
|
||||
vi.mock('@tanstack/react-virtual', () => ({
|
||||
defaultRangeExtractor: ({ startIndex, endIndex }: { startIndex: number; endIndex: number }) =>
|
||||
Array.from({ length: endIndex - startIndex + 1 }, (_, index) => startIndex + index),
|
||||
measureElement: () => 32,
|
||||
useVirtualizer: ({
|
||||
count,
|
||||
getItemKey
|
||||
}: {
|
||||
count: number
|
||||
getItemKey?: (index: number) => string | number
|
||||
}) => ({
|
||||
elementsCache: new Map(),
|
||||
getTotalSize: () => count * 96,
|
||||
getVirtualItems: () =>
|
||||
Array.from({ length: count }, (_, index) => ({
|
||||
index,
|
||||
key: getItemKey ? getItemKey(index) : `row-${index}`,
|
||||
start: index * 96
|
||||
})),
|
||||
measureElement: vi.fn(),
|
||||
scrollToIndex: vi.fn()
|
||||
})
|
||||
}))
|
||||
|
||||
vi.mock('@/hooks/useVirtualizedScrollAnchor', () => ({
|
||||
VIRTUALIZED_SCROLL_ANCHOR_RECORD_EVENT: 'orca:test-record-scroll-anchor',
|
||||
useVirtualizedScrollAnchor: vi.fn()
|
||||
}))
|
||||
|
||||
vi.mock('../drag/project-header-drag', () => ({
|
||||
useRepoHeaderDrag: () => ({
|
||||
state: { draggingRepoId: null, dropIndicatorY: null },
|
||||
onHandlePointerDown: vi.fn()
|
||||
})
|
||||
}))
|
||||
|
||||
vi.mock('../drag/project-header-drag-contract', async (importOriginal) => ({
|
||||
...(await importOriginal<typeof ProjectHeaderDragContract>()),
|
||||
isRepoHeaderActionTarget: () => false
|
||||
}))
|
||||
|
||||
vi.mock('@/components/ui/hover-card', () => ({
|
||||
HoverCard: ({ children }: { children: ReactNode }) => <>{children}</>,
|
||||
HoverCardContent: ({ children }: { children: ReactNode }) => (
|
||||
<div data-hover-card-content="">{children}</div>
|
||||
),
|
||||
HoverCardTrigger: ({ children }: { children: ReactNode }) => <>{children}</>
|
||||
}))
|
||||
|
||||
vi.mock('@/components/ui/tooltip', () => ({
|
||||
Tooltip: ({ children }: { children: ReactNode }) => <>{children}</>,
|
||||
TooltipContent: ({ children }: { children: ReactNode }) => <>{children}</>,
|
||||
TooltipTrigger: ({ children }: { children: ReactNode }) => <>{children}</>
|
||||
}))
|
||||
|
||||
vi.mock('@/components/ui/dropdown-menu', () => ({
|
||||
DropdownMenu: ({ children }: { children: ReactNode }) => <>{children}</>,
|
||||
DropdownMenuContent: ({ children }: { children: ReactNode }) => <div>{children}</div>,
|
||||
DropdownMenuItem: ({ children, onSelect }: { children: ReactNode; onSelect?: () => void }) => (
|
||||
<button onClick={onSelect}>{children}</button>
|
||||
),
|
||||
DropdownMenuSeparator: () => <hr />,
|
||||
DropdownMenuSub: ({ children }: { children: ReactNode }) => <>{children}</>,
|
||||
DropdownMenuSubContent: ({ children }: { children: ReactNode }) => <div>{children}</div>,
|
||||
DropdownMenuSubTrigger: ({ children }: { children: ReactNode }) => <div>{children}</div>,
|
||||
DropdownMenuTrigger: ({ children }: { children: ReactNode }) => <>{children}</>
|
||||
}))
|
||||
|
||||
vi.mock('@/lib/workspace/activation/sidebar-worktree-activation', () => ({
|
||||
activateWorktreeFromSidebar: mockStore.activateWorktreeFromSidebar
|
||||
}))
|
||||
|
||||
vi.mock('@/lib/workspace/activation/worktree-activation', () => ({
|
||||
activateAndRevealWorktree: vi.fn()
|
||||
}))
|
||||
|
||||
vi.mock('@/runtime/rpc/calls/runtime-rpc-call', () => ({
|
||||
callRuntimeRpc: vi.fn()
|
||||
}))
|
||||
|
||||
vi.mock('../../workspace-card/activity/CacheTimer', () => ({
|
||||
default: () => null,
|
||||
usePromptCacheCountdownStartedAt: () => null,
|
||||
usePromptCacheCountdownForPane: () => null
|
||||
}))
|
||||
|
||||
vi.mock('../../workspace-actions/context-menu/WorktreeContextMenu', () => ({
|
||||
default: ({ children }: { children: ReactNode }) => <>{children}</>,
|
||||
WORKTREE_CONTEXT_MENU_SCOPE_ATTR: 'data-orca-context-menu-scope',
|
||||
WORKTREE_NATIVE_CONTEXT_MENU_ATTR: 'data-worktree-native-context-menu'
|
||||
}))
|
||||
|
||||
const TAB_ID = 'tabP'
|
||||
const PANE_ROOT = `${TAB_ID}:aaaaaaaa-aaaa-4aaa-8aaa-aaaaaaaaaaaa`
|
||||
const PANE_CHILD = `${TAB_ID}:bbbbbbbb-bbbb-4bbb-8bbb-bbbbbbbbbbbb`
|
||||
const PANE_ROOT_2 = `${TAB_ID}:cccccccc-cccc-4ccc-8ccc-cccccccccccc`
|
||||
|
||||
function makeRepo(): Repo {
|
||||
return {
|
||||
id: 'repo-1',
|
||||
path: '/tmp/lineage-agent-coupling',
|
||||
displayName: 'lineage-agent-coupling',
|
||||
badgeColor: '#999999',
|
||||
addedAt: 1
|
||||
}
|
||||
}
|
||||
|
||||
function makeWorktree(args: {
|
||||
id: string
|
||||
displayName: string
|
||||
branch: string
|
||||
sortOrder: number
|
||||
instanceId: string
|
||||
}): Worktree {
|
||||
return {
|
||||
id: args.id,
|
||||
instanceId: args.instanceId,
|
||||
repoId: 'repo-1',
|
||||
path: `/tmp/lineage-agent-coupling/${args.id}`,
|
||||
displayName: args.displayName,
|
||||
branch: args.branch,
|
||||
head: 'abc123',
|
||||
isBare: false,
|
||||
isMainWorktree: false,
|
||||
comment: '',
|
||||
linkedIssue: null,
|
||||
linkedPR: null,
|
||||
linkedLinearIssue: null,
|
||||
isArchived: false,
|
||||
isUnread: false,
|
||||
isPinned: false,
|
||||
sortOrder: args.sortOrder,
|
||||
lastActivityAt: args.sortOrder
|
||||
}
|
||||
}
|
||||
|
||||
function makeLineage(worktree: Worktree, parent: Worktree): WorktreeLineage {
|
||||
return {
|
||||
worktreeId: worktree.id,
|
||||
worktreeInstanceId: worktree.instanceId!,
|
||||
parentWorktreeId: parent.id,
|
||||
parentWorktreeInstanceId: parent.instanceId!,
|
||||
origin: 'orchestration',
|
||||
capture: { source: 'orchestration-context', confidence: 'explicit' },
|
||||
createdAt: 1
|
||||
}
|
||||
}
|
||||
|
||||
function makeAgentEntry(
|
||||
paneKey: string,
|
||||
prompt: string,
|
||||
orchestration?: AgentStatusOrchestrationContext
|
||||
): AgentStatusEntry {
|
||||
const now = Date.now()
|
||||
return {
|
||||
state: 'working',
|
||||
prompt,
|
||||
updatedAt: now,
|
||||
stateStartedAt: now,
|
||||
agentType: 'claude',
|
||||
paneKey,
|
||||
worktreeId: 'parent',
|
||||
stateHistory: [],
|
||||
...(orchestration ? { orchestration } : {})
|
||||
}
|
||||
}
|
||||
|
||||
function makeParentTab(): TerminalTab {
|
||||
return {
|
||||
id: TAB_ID,
|
||||
ptyId: null,
|
||||
worktreeId: 'parent',
|
||||
title: 'Parent Terminal',
|
||||
customTitle: null,
|
||||
color: null,
|
||||
sortOrder: 0,
|
||||
createdAt: 1
|
||||
}
|
||||
}
|
||||
|
||||
function setAgentLineageState(options: {
|
||||
agentActivityDisplayMode: 'compact' | 'full'
|
||||
secondRootAgent?: boolean
|
||||
collapsedGroups?: Set<string>
|
||||
}): void {
|
||||
const repo = makeRepo()
|
||||
const parent = makeWorktree({
|
||||
id: 'parent',
|
||||
instanceId: 'parent-instance',
|
||||
displayName: 'lineage parent',
|
||||
branch: 'parent-branch',
|
||||
sortOrder: 20
|
||||
})
|
||||
const child = makeWorktree({
|
||||
id: 'child',
|
||||
instanceId: 'child-instance',
|
||||
displayName: 'lineage child',
|
||||
branch: 'child-branch',
|
||||
sortOrder: 10
|
||||
})
|
||||
let agentStatusByPaneKey: AcceptedAgentStatuses = acceptedAgentStatuses(
|
||||
Object.entries({
|
||||
[PANE_ROOT]: makeAgentEntry(PANE_ROOT, 'PARENT_AGENT_PROMPT'),
|
||||
[PANE_CHILD]: makeAgentEntry(PANE_CHILD, 'CHILD_AGENT_PROMPT', {
|
||||
taskId: 't1',
|
||||
dispatchId: 'd1',
|
||||
parentPaneKey: PANE_ROOT
|
||||
})
|
||||
})
|
||||
)
|
||||
if (options.secondRootAgent) {
|
||||
agentStatusByPaneKey = agentStatusByPaneKey.replace([
|
||||
[PANE_ROOT_2, makeAgentEntry(PANE_ROOT_2, 'SECOND_ROOT_PROMPT')]
|
||||
])
|
||||
}
|
||||
|
||||
mockStore.state = {
|
||||
collapsedGroups: options.collapsedGroups ?? new Set<string>(),
|
||||
toggleCollapsedGroup: vi.fn((key: string) => {
|
||||
// Replace the Set immutably so the list’s identity-keyed memo rebuilds render rows.
|
||||
const set = new Set(mockStore.state.collapsedGroups as Set<string>)
|
||||
if (set.has(key)) {
|
||||
set.delete(key)
|
||||
} else {
|
||||
set.add(key)
|
||||
}
|
||||
mockStore.state.collapsedGroups = set
|
||||
}),
|
||||
|
||||
activeModal: '',
|
||||
activeView: 'terminal',
|
||||
activeWorktreeId: null,
|
||||
activeWorkspaceKey: null,
|
||||
activeTabId: null,
|
||||
activeTabType: null,
|
||||
agentStatusEpoch: 0,
|
||||
browserTabsByWorktree: {},
|
||||
clearPendingRevealWorktreeId: vi.fn(),
|
||||
deleteStateByWorktreeId: {},
|
||||
detectedWorktreesByRepo: {},
|
||||
fetchFolderWorkspacePathStatus: vi.fn(),
|
||||
fetchHostedReviewForBranch: vi.fn(),
|
||||
fetchIssue: vi.fn(),
|
||||
fetchLinearIssue: vi.fn(),
|
||||
filterRepoIds: [],
|
||||
folderWorkspaces: [],
|
||||
folderWorkspacePathStatuses: {},
|
||||
getFolderWorkspacePathStatusCacheKey: (request: unknown) => JSON.stringify(request),
|
||||
getFreshFolderWorkspacePathStatus: () => null,
|
||||
gitConflictOperationByWorktree: {},
|
||||
groupBy: 'none',
|
||||
hideDefaultBranchWorkspace: false,
|
||||
hostedReviewCache: {},
|
||||
issueCache: {},
|
||||
linearIssueCache: {},
|
||||
linearStatus: null,
|
||||
migrationUnsupportedByPtyId: {},
|
||||
openModal: mockStore.openModal,
|
||||
openSettingsPage: vi.fn(),
|
||||
openSettingsTarget: null,
|
||||
openTaskPage: vi.fn(),
|
||||
pendingRevealWorktree: null,
|
||||
prCache: {},
|
||||
projectGroups: [],
|
||||
ptyIdsByTabId: {},
|
||||
recordFeatureInteraction: vi.fn(),
|
||||
suppressContextualTour: vi.fn(),
|
||||
remoteBranchConflictByWorktreeId: {},
|
||||
reorderRepos: vi.fn(),
|
||||
reportVisibleGitHubPRRefreshCandidates: vi.fn(),
|
||||
setVisibleReviewCardWorktreeIds: mockStore.setVisibleReviewCardWorktreeIds,
|
||||
repos: [repo],
|
||||
|
||||
revealWorktreeInSidebar: vi.fn(),
|
||||
runtimePaneTitlesByTabId: {},
|
||||
runtimeAgentOrchestrationByPaneKey: {},
|
||||
setFilterRepoIds: vi.fn(),
|
||||
setHideDefaultBranchWorkspace: vi.fn(),
|
||||
setRenamingWorktreeId: vi.fn(),
|
||||
setShowSleepingWorkspaces: vi.fn(),
|
||||
setSortBy: vi.fn(),
|
||||
setWorktreesPinnedAndReveal: vi.fn(),
|
||||
settings: null,
|
||||
showSleepingWorkspaces: true,
|
||||
sortBy: 'manual',
|
||||
sortEpoch: 0,
|
||||
sshConnectedGeneration: 0,
|
||||
sshConnectionStates: new Map(),
|
||||
sshTargetLabels: new Map(),
|
||||
terminalLayoutsByTabId: {},
|
||||
updateRepo: vi.fn(),
|
||||
updateWorktreeMeta: vi.fn(),
|
||||
updateWorktreesMeta: vi.fn(),
|
||||
workspaceHostScope: 'all',
|
||||
workspacePortScan: null,
|
||||
workspaceStatuses: [],
|
||||
worktreeCardProperties: [
|
||||
'status',
|
||||
'pr',
|
||||
'comment',
|
||||
'inline-agents'
|
||||
] satisfies WorktreeCardProperty[],
|
||||
worktreeLineageById: { [child.id]: makeLineage(child, parent) },
|
||||
worktreesByRepo: { [repo.id]: [parent, child] },
|
||||
|
||||
agentActivityDisplayMode: options.agentActivityDisplayMode,
|
||||
agentSendPopoverTargetMode: null,
|
||||
acknowledgedAgentsByPaneKey: {},
|
||||
dropAgentStatus: vi.fn(),
|
||||
sendPromptToSidebarAgentTarget: vi.fn(),
|
||||
tabsByWorktree: { parent: [makeParentTab()] },
|
||||
unifiedTabsByWorktree: {},
|
||||
structuredChatSleptAtByPaneKey: {},
|
||||
paneForegroundAgentByPaneKey: {},
|
||||
agentStatusByPaneKey
|
||||
}
|
||||
const changes = Array.from(agentStatusByPaneKey, ([paneKey, current]) => ({
|
||||
paneKey,
|
||||
previous: undefined,
|
||||
current
|
||||
}))
|
||||
agentStatusByPaneKey.projection.prepare(useAppStore.getState(), changes)()
|
||||
agentStatusByPaneKey.prepare()()
|
||||
}
|
||||
|
||||
const mountedRoots: Root[] = []
|
||||
|
||||
async function renderWorktreeList(): Promise<{ container: HTMLDivElement; root: Root }> {
|
||||
const container = document.createElement('div')
|
||||
document.body.appendChild(container)
|
||||
const root = createRoot(container)
|
||||
mountedRoots.push(root)
|
||||
await act(async () => {
|
||||
root.render(
|
||||
<WorktreeList scrollOffsetRef={{ current: 0 }} scrollAnchorRef={{ current: null }} />
|
||||
)
|
||||
})
|
||||
return { container, root }
|
||||
}
|
||||
|
||||
// The mock store is not reactive; fresh ref props bypass memo so changed groups rebuild render keys.
|
||||
async function rerender(root: Root): Promise<void> {
|
||||
await act(async () => {
|
||||
root.render(
|
||||
<WorktreeList scrollOffsetRef={{ current: 0 }} scrollAnchorRef={{ current: null }} />
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
function findButtonByAriaLabel(container: HTMLElement, pattern: RegExp): HTMLButtonElement | null {
|
||||
return (
|
||||
[...container.querySelectorAll<HTMLButtonElement>('button[aria-expanded]')].find((button) =>
|
||||
pattern.test(button.getAttribute('aria-label') ?? '')
|
||||
) ?? null
|
||||
)
|
||||
}
|
||||
|
||||
function childWorktreeChip(container: HTMLElement): HTMLButtonElement | null {
|
||||
return findButtonByAriaLabel(container, /child workspace/i)
|
||||
}
|
||||
|
||||
function agentChildDisclosure(container: HTMLElement): HTMLButtonElement | null {
|
||||
return findButtonByAriaLabel(container, /child agent/i)
|
||||
}
|
||||
|
||||
function compactAgentSummary(container: HTMLElement): HTMLButtonElement | null {
|
||||
return (
|
||||
[...container.querySelectorAll<HTMLButtonElement>('button.compact-agent-summary-button')][0] ??
|
||||
null
|
||||
)
|
||||
}
|
||||
|
||||
function childWorktreeCardPresent(container: HTMLElement): boolean {
|
||||
return container.querySelector('[id="worktree-list-option-all%3A%7Cchild"]') !== null
|
||||
}
|
||||
|
||||
async function click(el: Element): Promise<void> {
|
||||
await act(async () => {
|
||||
el.dispatchEvent(new MouseEvent('click', { bubbles: true }))
|
||||
})
|
||||
}
|
||||
|
||||
describe('WorktreeCard agent-list <-> child-worktrees expansion coupling', () => {
|
||||
beforeAll(async () => {
|
||||
WorktreeList = (await import('./WorktreeList')).default as WorktreeListComponent
|
||||
}, 60_000)
|
||||
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks()
|
||||
// Clear module-scoped expansion between tests because it intentionally survives remounts.
|
||||
clearWorktreeAgentExpansionStateForTests()
|
||||
})
|
||||
|
||||
afterEach(async () => {
|
||||
await act(async () => {
|
||||
for (const root of mountedRoots.splice(0)) {
|
||||
root.unmount()
|
||||
}
|
||||
// Lazy markdown imports must finish before Vitest tears down the module environment.
|
||||
await vi.dynamicImportSettled()
|
||||
})
|
||||
document.body.innerHTML = ''
|
||||
clearWorktreeAgentExpansionStateForTests()
|
||||
})
|
||||
|
||||
it('[full mode] collapsing child worktrees preserves agent expansion', async () => {
|
||||
setAgentLineageState({ agentActivityDisplayMode: 'full' })
|
||||
const { container, root } = await renderWorktreeList()
|
||||
|
||||
await click(agentChildDisclosure(container)!)
|
||||
expect(agentChildDisclosure(container)!.getAttribute('aria-expanded')).toBe('true')
|
||||
|
||||
await click(childWorktreeChip(container)!)
|
||||
expect(mockStore.state.toggleCollapsedGroup).toHaveBeenCalledWith('lineage:parent')
|
||||
await rerender(root)
|
||||
|
||||
expect(childWorktreeCardPresent(container)).toBe(false)
|
||||
|
||||
expect(agentChildDisclosure(container)!.getAttribute('aria-expanded')).toBe('true')
|
||||
expect(container.textContent).toContain('CHILD_AGENT_PROMPT')
|
||||
})
|
||||
|
||||
it('[compact mode] toggling CHILD WORKTREES preserves the compact agent summary expansion (regression)', async () => {
|
||||
setAgentLineageState({ agentActivityDisplayMode: 'compact', secondRootAgent: true })
|
||||
const { container, root } = await renderWorktreeList()
|
||||
|
||||
const summary = compactAgentSummary(container)
|
||||
expect(summary).not.toBeNull()
|
||||
expect(summary!.getAttribute('aria-expanded')).toBe('false')
|
||||
|
||||
await click(summary!)
|
||||
expect(compactAgentSummary(container)!.getAttribute('aria-expanded')).toBe('true')
|
||||
|
||||
await click(childWorktreeChip(container)!)
|
||||
expect(mockStore.state.toggleCollapsedGroup).toHaveBeenCalledWith('lineage:parent')
|
||||
await rerender(root)
|
||||
|
||||
expect(childWorktreeCardPresent(container)).toBe(false)
|
||||
expect(compactAgentSummary(container)!.getAttribute('aria-expanded')).toBe('true')
|
||||
})
|
||||
})
|
||||
@@ -1,77 +0,0 @@
|
||||
// Prove active-view.json → ui.get → startup hydration across real restarts, with a workspace so terminal hydration cannot mask view restore.
|
||||
|
||||
import { existsSync, readFileSync } from 'node:fs'
|
||||
import type { ElectronApplication } from '@stablyai/playwright-test'
|
||||
import { test, expect } from './helpers/orca-app'
|
||||
import { getStoreState, waitForSessionReady } from './helpers/store'
|
||||
import { attachRepoAndOpenTerminal, createRestartSession } from './helpers/orca-restart'
|
||||
import { TEST_REPO_PATH_FILE } from './global-setup'
|
||||
|
||||
function seededRepoPathOrSkip(): string {
|
||||
const repoPath = existsSync(TEST_REPO_PATH_FILE)
|
||||
? readFileSync(TEST_REPO_PATH_FILE, 'utf-8').trim()
|
||||
: ''
|
||||
test.skip(!repoPath || !existsSync(repoPath), 'Global setup did not produce a seeded test repo')
|
||||
return repoPath
|
||||
}
|
||||
|
||||
test('restores the active top-level view (Tasks) after an app restart', async (// oxlint-disable-next-line no-empty-pattern -- Playwright's second fixture arg is testInfo; the first must be an object destructure to opt out of the default fixture set.
|
||||
{}, testInfo) => {
|
||||
test.setTimeout(300_000)
|
||||
const repoPath = seededRepoPathOrSkip()
|
||||
const session = createRestartSession(testInfo)
|
||||
let firstApp: ElectronApplication | null = null
|
||||
let secondApp: ElectronApplication | null = null
|
||||
try {
|
||||
const first = await session.launch()
|
||||
firstApp = first.app
|
||||
await waitForSessionReady(first.page)
|
||||
// Attach a workspace or Landing bypasses the view switch; settle worktree activation before navigating.
|
||||
await attachRepoAndOpenTerminal(first.page, repoPath)
|
||||
|
||||
expect(await getStoreState<string>(first.page, 'activeView')).toBe('terminal')
|
||||
|
||||
await first.page.evaluate(() => {
|
||||
const store = window.__store
|
||||
if (!store) {
|
||||
throw new Error('window.__store is not available')
|
||||
}
|
||||
store.getState().openTaskPage()
|
||||
})
|
||||
await expect
|
||||
.poll(async () => getStoreState<string>(first.page, 'activeView'), { timeout: 10_000 })
|
||||
.toBe('tasks')
|
||||
// Use locale-independent Tasks chrome; the Close tasks label is translated.
|
||||
await expect(
|
||||
first.page.locator('[data-contextual-tour-target="tasks-source-filters"]')
|
||||
).toBeVisible({ timeout: 10_000 })
|
||||
await expect(first.page.locator('.xterm')).not.toBeVisible({ timeout: 10_000 })
|
||||
|
||||
// Exercise the synchronous quit checkpoint before an asynchronous preference write can finish.
|
||||
await session.close(firstApp)
|
||||
firstApp = null
|
||||
|
||||
const second = await session.launch()
|
||||
secondApp = second.app
|
||||
await waitForSessionReady(second.page)
|
||||
|
||||
await expect
|
||||
.poll(async () => getStoreState<string>(second.page, 'activeView'), { timeout: 10_000 })
|
||||
.toBe('tasks')
|
||||
await expect(
|
||||
second.page.locator('[data-contextual-tour-target="tasks-source-filters"]')
|
||||
).toBeVisible({ timeout: 10_000 })
|
||||
await expect(second.page.locator('.xterm')).not.toBeVisible({ timeout: 10_000 })
|
||||
} finally {
|
||||
// Guard each step so a failing close still runs the remaining cleanup.
|
||||
for (const app of [secondApp, firstApp]) {
|
||||
if (!app) {
|
||||
continue
|
||||
}
|
||||
try {
|
||||
await session.close(app)
|
||||
} catch {}
|
||||
}
|
||||
await session.dispose()
|
||||
}
|
||||
})
|
||||
@@ -1,57 +0,0 @@
|
||||
import { expect, test } from './helpers/orca-app'
|
||||
|
||||
for (const theme of ['dark', 'light'] as const) {
|
||||
test(`tab drag stays cancelled after blur and a later drag still splits (${theme})`, async ({
|
||||
orcaPage
|
||||
}, testInfo) => {
|
||||
await orcaPage.setViewportSize({ width: 1200, height: 900 })
|
||||
await orcaPage.evaluate(async (theme) => {
|
||||
const state = window.__store!.getState()
|
||||
await state.updateSettingsOrThrow({ theme })
|
||||
const worktreeId = state.activeWorktreeId!
|
||||
const tabs = state.tabsByWorktree[worktreeId] ?? []
|
||||
for (let index = tabs.length; index < 2; index++) {
|
||||
state.createTab(worktreeId)
|
||||
}
|
||||
}, theme)
|
||||
|
||||
const tabs = orcaPage.locator('[data-testid="sortable-tab"]:visible')
|
||||
const panels = orcaPage.locator('[data-tab-group-body-id]:visible')
|
||||
const preview = orcaPage.getByText('New split', { exact: true })
|
||||
await expect(tabs).toHaveCount(2)
|
||||
await expect(panels).toHaveCount(1)
|
||||
const panel = (await panels.boundingBox())!
|
||||
const target = { x: panel.x + panel.width - 30, y: panel.y + panel.height / 2 }
|
||||
const startDrag = async (): Promise<void> => {
|
||||
const tab = (await tabs.first().boundingBox())!
|
||||
await orcaPage.mouse.move(tab.x + tab.width / 2, tab.y + tab.height / 2)
|
||||
await orcaPage.mouse.down()
|
||||
await orcaPage.mouse.move(target.x, target.y, { steps: 12 })
|
||||
await expect(preview).toBeVisible()
|
||||
}
|
||||
|
||||
await startDrag()
|
||||
// Exercise the window event without changing native focus on the developer's desktop.
|
||||
await orcaPage.evaluate(async () => {
|
||||
window.dispatchEvent(new Event('blur'))
|
||||
await new Promise((resolve) => window.setTimeout(resolve, 0))
|
||||
})
|
||||
await expect(preview).toHaveCount(0)
|
||||
await orcaPage.mouse.move(target.x - 10, target.y + 10, { steps: 3 })
|
||||
|
||||
const screenshot = testInfo.outputPath(`tab-drag-after-blur-${theme}.png`)
|
||||
await orcaPage.screenshot({ path: screenshot, animations: 'disabled' })
|
||||
await testInfo.attach(`tab-drag-after-blur-${theme}`, {
|
||||
path: screenshot,
|
||||
contentType: 'image/png'
|
||||
})
|
||||
await expect(preview).toHaveCount(0)
|
||||
await orcaPage.mouse.up()
|
||||
await expect(panels).toHaveCount(1)
|
||||
|
||||
await startDrag()
|
||||
await orcaPage.mouse.up()
|
||||
await expect(preview).toHaveCount(0)
|
||||
await expect(panels).toHaveCount(2)
|
||||
})
|
||||
}
|
||||
@@ -1,107 +0,0 @@
|
||||
import type { Page } from '@stablyai/playwright-test'
|
||||
import { mkdirSync } from 'node:fs'
|
||||
import { resolve } from 'node:path'
|
||||
import { test, expect } from './helpers/orca-app'
|
||||
import { waitForActiveWorktree, waitForSessionReady } from './helpers/store'
|
||||
import { seedLineageScenario } from './worktree-lineage-state'
|
||||
import { worktreeRow } from './worktree-row-locators'
|
||||
|
||||
// ORCA_CAPTURE_EVIDENCE=1 writes before/after screenshots to pr-evidence/; default CI runs behavioral assertions only.
|
||||
const CAPTURE_EVIDENCE = process.env.ORCA_CAPTURE_EVIDENCE === '1'
|
||||
const SHOT_DIR = resolve(process.cwd(), 'pr-evidence')
|
||||
|
||||
async function captureSidebar(page: Page, name: string): Promise<void> {
|
||||
if (!CAPTURE_EVIDENCE) {
|
||||
return
|
||||
}
|
||||
mkdirSync(SHOT_DIR, { recursive: true })
|
||||
await sidebar(page).screenshot({ path: resolve(SHOT_DIR, name) })
|
||||
}
|
||||
|
||||
// Seed two parent agents for the compact summary alongside the child-workspace chip.
|
||||
async function seedTwoParentAgents(page: Page, worktreeId: string): Promise<void> {
|
||||
await page.evaluate((worktreeId) => {
|
||||
const store = window.__store
|
||||
if (!store) {
|
||||
throw new Error('window.__store is not available')
|
||||
}
|
||||
const state = store.getState()
|
||||
if (!state.worktreeCardProperties.includes('inline-agents')) {
|
||||
state.setWorktreeCardProperties([...state.worktreeCardProperties, 'inline-agents'])
|
||||
}
|
||||
while ((store.getState().tabsByWorktree[worktreeId] ?? []).length < 2) {
|
||||
store.getState().createTab(worktreeId)
|
||||
}
|
||||
const tabs = (store.getState().tabsByWorktree[worktreeId] ?? []).slice(0, 2)
|
||||
const now = Date.now()
|
||||
const specs = [
|
||||
{ state: 'working' as const, prompt: 'Refactor auth middleware', agentType: 'claude' },
|
||||
{ state: 'done' as const, prompt: 'Write unit tests for parser', agentType: 'codex' }
|
||||
]
|
||||
tabs.forEach((tab, index) => {
|
||||
const spec = specs[index]!
|
||||
const leafId = crypto.randomUUID()
|
||||
store
|
||||
.getState()
|
||||
.setAgentStatus(
|
||||
`${tab.id}:${leafId}`,
|
||||
{ state: spec.state, prompt: spec.prompt, agentType: spec.agentType },
|
||||
spec.agentType,
|
||||
{ updatedAt: now, stateStartedAt: now }
|
||||
)
|
||||
})
|
||||
}, worktreeId)
|
||||
}
|
||||
|
||||
function sidebar(page: Page) {
|
||||
return page.locator('[data-worktree-sidebar]').first()
|
||||
}
|
||||
|
||||
function compactSummary(page: Page, parentId: string) {
|
||||
return worktreeRow(page, parentId).locator('button.compact-agent-summary-button').first()
|
||||
}
|
||||
|
||||
function childWorkspacesChip(page: Page, parentId: string) {
|
||||
return worktreeRow(page, parentId)
|
||||
.getByRole('button', { name: /child workspace/i })
|
||||
.first()
|
||||
}
|
||||
|
||||
test.describe('Worktree lineage agent-list expansion independence', () => {
|
||||
test.describe.configure({ mode: 'serial' })
|
||||
|
||||
test.beforeEach(async ({ orcaPage }) => {
|
||||
await waitForSessionReady(orcaPage)
|
||||
await waitForActiveWorktree(orcaPage)
|
||||
})
|
||||
|
||||
test('toggling child worktrees does not collapse the expanded agent summary', async ({
|
||||
orcaPage
|
||||
}) => {
|
||||
const { parentId, childId } = await seedLineageScenario(orcaPage)
|
||||
const parentRow = worktreeRow(orcaPage, parentId)
|
||||
const childRow = worktreeRow(orcaPage, childId)
|
||||
|
||||
await parentRow.click()
|
||||
await expect(parentRow).toHaveAttribute('aria-current', 'page')
|
||||
|
||||
await seedTwoParentAgents(orcaPage, parentId)
|
||||
|
||||
await expect(compactSummary(orcaPage, parentId)).toBeVisible({ timeout: 10_000 })
|
||||
await expect(childWorkspacesChip(orcaPage, parentId)).toBeVisible()
|
||||
await expect(childRow).toBeVisible()
|
||||
await expect(compactSummary(orcaPage, parentId)).toHaveAttribute('aria-expanded', 'false')
|
||||
await captureSidebar(orcaPage, '1-before-both-collapsed.png')
|
||||
|
||||
await compactSummary(orcaPage, parentId).click()
|
||||
await expect(compactSummary(orcaPage, parentId)).toHaveAttribute('aria-expanded', 'true')
|
||||
await captureSidebar(orcaPage, '2-agents-expanded.png')
|
||||
|
||||
// Collapse children to remount the parent card; require expanded agent summary to survive.
|
||||
await childWorkspacesChip(orcaPage, parentId).click()
|
||||
await expect(childRow).toBeHidden()
|
||||
|
||||
await expect(compactSummary(orcaPage, parentId)).toHaveAttribute('aria-expanded', 'true')
|
||||
await captureSidebar(orcaPage, '3-after-children-toggle-agents-still-expanded.png')
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user