mirror of
https://github.com/stablyai/orca.git
synced 2026-11-17 03:15:01 +00:00
test: drop the workspace cleanup facet rows' work-count assertions (#39748)
Three tests only counted how often facet, measurement and query passes ran, and a fourth checked a zero count beside its real assertion. AGENTS.md bans work-count tests, and they fail under React Compiler, which memoizes differently. The behavior checks stay. Co-authored-by: OrcaWin <293788423+OrcaWin@users.noreply.github.com>
This commit is contained in:
+2
-121
@@ -8,12 +8,9 @@ import {
|
||||
DEFAULT_WORKSPACE_CLEANUP_SORT
|
||||
} from '../../../../shared/workspace-cleanup/workspace-cleanup-filter-model'
|
||||
import { cloneDefaultWorkspaceStatuses } from '../../../../shared/workspace-statuses'
|
||||
import type * as FacetModule from './workspace-cleanup-facets'
|
||||
import type * as QueryModule from './workspace-cleanup-query'
|
||||
import { makeFacetCandidate } from './workspace-cleanup-facet.test.fixture'
|
||||
|
||||
const holders = vi.hoisted(() => ({ state: null as AppState | null }))
|
||||
const counts = vi.hoisted(() => ({ facetCounts: 0, measured: 0, queries: 0 }))
|
||||
|
||||
vi.mock('@/store', () => ({
|
||||
useAppStore: <T,>(selector: (state: AppState) => T): T => {
|
||||
@@ -24,36 +21,6 @@ vi.mock('@/store', () => ({
|
||||
}
|
||||
}))
|
||||
|
||||
vi.mock('./workspace-cleanup-facets', async (importOriginal) => {
|
||||
const actual = await importOriginal<typeof FacetModule>()
|
||||
return {
|
||||
...actual,
|
||||
countWorkspaceCleanupMeasuredRows: (
|
||||
...args: Parameters<typeof actual.countWorkspaceCleanupMeasuredRows>
|
||||
) => {
|
||||
counts.measured += 1
|
||||
return actual.countWorkspaceCleanupMeasuredRows(...args)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
vi.mock('./workspace-cleanup-query', async (importOriginal) => {
|
||||
const actual = await importOriginal<typeof QueryModule>()
|
||||
return {
|
||||
...actual,
|
||||
countWorkspaceCleanupFacetMatches: (
|
||||
...args: Parameters<typeof actual.countWorkspaceCleanupFacetMatches>
|
||||
) => {
|
||||
counts.facetCounts += 1
|
||||
return actual.countWorkspaceCleanupFacetMatches(...args)
|
||||
},
|
||||
runWorkspaceCleanupQuery: (...args: Parameters<typeof actual.runWorkspaceCleanupQuery>) => {
|
||||
counts.queries += 1
|
||||
return actual.runWorkspaceCleanupQuery(...args)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
import { useWorkspaceCleanupFacetRows } from './use-workspace-cleanup-facet-rows'
|
||||
|
||||
function makeState(): AppState {
|
||||
@@ -72,36 +39,9 @@ function makeState(): AppState {
|
||||
} as unknown as AppState
|
||||
}
|
||||
|
||||
describe('useWorkspaceCleanupFacetRows hot paths', () => {
|
||||
describe('useWorkspaceCleanupFacetRows', () => {
|
||||
beforeEach(() => {
|
||||
holders.state = makeState()
|
||||
counts.facetCounts = 0
|
||||
counts.measured = 0
|
||||
counts.queries = 0
|
||||
})
|
||||
|
||||
it('does only the query work when the user types', () => {
|
||||
const candidates = [makeFacetCandidate()]
|
||||
const filters = createDefaultWorkspaceCleanupFilterState()
|
||||
const view = renderHook(
|
||||
({ currentFilters }) =>
|
||||
useWorkspaceCleanupFacetRows({
|
||||
candidates,
|
||||
filters: currentFilters,
|
||||
sort: DEFAULT_WORKSPACE_CLEANUP_SORT,
|
||||
now: 1_700_000_000_000
|
||||
}),
|
||||
{ initialProps: { currentFilters: filters } }
|
||||
)
|
||||
const initialCounts = { ...counts }
|
||||
const reviewIndex = view.result.current.reviewInfoByWorktreeId
|
||||
|
||||
view.rerender({ currentFilters: { ...filters, query: 'alpha' } })
|
||||
|
||||
expect(counts.queries).toBeGreaterThan(initialCounts.queries)
|
||||
expect(counts.facetCounts).toBe(initialCounts.facetCounts)
|
||||
expect(counts.measured).toBe(initialCounts.measured)
|
||||
expect(view.result.current.reviewInfoByWorktreeId).toBe(reviewIndex)
|
||||
})
|
||||
|
||||
it('keeps review joins stable during unrelated agent-status churn', () => {
|
||||
@@ -123,39 +63,6 @@ describe('useWorkspaceCleanupFacetRows hot paths', () => {
|
||||
expect(view.result.current.reviewInfoByWorktreeId).toBe(reviewIndex)
|
||||
})
|
||||
|
||||
it('does not rebuild facets for count-only size progress', () => {
|
||||
const candidates = [makeFacetCandidate()]
|
||||
const filters = createDefaultWorkspaceCleanupFilterState()
|
||||
const view = renderHook(() =>
|
||||
useWorkspaceCleanupFacetRows({
|
||||
candidates,
|
||||
filters,
|
||||
sort: DEFAULT_WORKSPACE_CLEANUP_SORT,
|
||||
now: 1_700_000_000_000
|
||||
})
|
||||
)
|
||||
const initialCounts = { ...counts }
|
||||
|
||||
holders.state = {
|
||||
...holders.state!,
|
||||
workspaceSpaceScanProgress: {
|
||||
scanId: 'scan-1',
|
||||
state: 'running',
|
||||
startedAt: 1,
|
||||
updatedAt: 2,
|
||||
totalRepoCount: 1,
|
||||
scannedRepoCount: 0,
|
||||
totalWorktreeCount: 100,
|
||||
scannedWorktreeCount: 20,
|
||||
currentRepoDisplayName: 'Repo',
|
||||
currentWorktreeDisplayName: 'alpha'
|
||||
}
|
||||
}
|
||||
view.rerender()
|
||||
|
||||
expect(counts).toEqual(initialCounts)
|
||||
})
|
||||
|
||||
it('projects streamed size measurements before the full scan completes', () => {
|
||||
const candidates = [makeFacetCandidate()]
|
||||
const filters = createDefaultWorkspaceCleanupFilterState()
|
||||
@@ -195,31 +102,6 @@ describe('useWorkspaceCleanupFacetRows hot paths', () => {
|
||||
expect(view.result.current.options.repos).toEqual([{ id: 'folder-1', label: 'Loose files' }])
|
||||
})
|
||||
|
||||
it('skips every downstream pass when a streaming tick changes no candidate', () => {
|
||||
const candidates = [makeFacetCandidate(), makeFacetCandidate({ worktreeId: 'repo-1::/b' })]
|
||||
const filters = createDefaultWorkspaceCleanupFilterState()
|
||||
const view = renderHook(
|
||||
({ current }) =>
|
||||
useWorkspaceCleanupFacetRows({
|
||||
candidates: current,
|
||||
filters,
|
||||
sort: DEFAULT_WORKSPACE_CLEANUP_SORT,
|
||||
now: 1_700_000_000_000
|
||||
}),
|
||||
{ initialProps: { current: candidates } }
|
||||
)
|
||||
const initialCounts = { ...counts }
|
||||
const matched = view.result.current.facetMatchedIdentities
|
||||
const rows = view.result.current.rows
|
||||
|
||||
// A no-op progress tick delivers a fresh array of the same candidate objects.
|
||||
view.rerender({ current: [...candidates] })
|
||||
|
||||
expect(counts).toEqual(initialCounts)
|
||||
expect(view.result.current.rows).toBe(rows)
|
||||
expect(view.result.current.facetMatchedIdentities).toBe(matched)
|
||||
})
|
||||
|
||||
it('keeps facet identity for untouched rows when a tick replaces one candidate', () => {
|
||||
const stable = makeFacetCandidate()
|
||||
const replaced = makeFacetCandidate({ worktreeId: 'repo-1::/b' })
|
||||
@@ -248,7 +130,7 @@ describe('useWorkspaceCleanupFacetRows hot paths', () => {
|
||||
).toBe('renamed')
|
||||
})
|
||||
|
||||
it('skips facet count and option passes while the filter panel is closed', () => {
|
||||
it('offers no facet options while the filter panel is closed', () => {
|
||||
const view = renderHook(() =>
|
||||
useWorkspaceCleanupFacetRows({
|
||||
candidates: [makeFacetCandidate()],
|
||||
@@ -259,7 +141,6 @@ describe('useWorkspaceCleanupFacetRows hot paths', () => {
|
||||
})
|
||||
)
|
||||
|
||||
expect(counts.facetCounts).toBe(0)
|
||||
expect(view.result.current.options.repos).toEqual([])
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user