test: remove 6 low-value test cases (#39925)

Co-authored-by: OrcaWin <293788423+OrcaWin@users.noreply.github.com>
This commit is contained in:
OrcaWin
2026-11-08 10:50:46 -08:00
committed by GitHub
co-authored by OrcaWin
parent f74bb65fa1
commit fcd356ad88
5 changed files with 25 additions and 166 deletions
File diff suppressed because one or more lines are too long
@@ -1,99 +0,0 @@
import { act, create, type ReactTestRenderer } from 'react-test-renderer'
import { afterEach, expect, it } from 'vitest'
import type { NativeChatMessage } from '../../../../../src/shared/native-chat/native-chat-types'
import { useMobileNativeChatProjection } from './use-mobile-native-chat-projection'
Object.assign(globalThis, { IS_REACT_ACT_ENVIRONMENT: true })
const CI_ID = 'orca:pr-event:github.com/acme/repo#3:8d5f74b:1'
let roleReads = 0
// The CI predicate reads `role` first, so a counting getter sees every row it checks.
function counted(id: string, role: NativeChatMessage['role'], text: string): NativeChatMessage {
const message = { id, blocks: [{ type: 'text', text }], source: 'transcript', timestamp: 0 }
Object.defineProperty(message, 'role', {
enumerable: true,
get: () => {
roleReads++
return role
}
})
// oxlint-disable-next-line typescript/consistent-type-assertions -- SAFETY: `role` is defined above as a getter.
return message as NativeChatMessage
}
const conversation = (turns: number) =>
Array.from({ length: turns }, (_, index) => [
counted(`u${index}`, 'user', `ask ${index}`),
counted(`a${index}`, 'assistant', `answer ${index}`)
]).flat()
const renderers: ReactTestRenderer[] = []
afterEach(() => {
act(() => renderers.forEach((renderer) => renderer.unmount()))
renderers.length = 0
})
function mount(messages: readonly NativeChatMessage[], shows: boolean) {
const view: { rows: NativeChatMessage[] } = { rows: [] }
function Probe(props: { messages: readonly NativeChatMessage[]; shows: boolean }) {
view.rows = useMobileNativeChatProjection(props.messages, 'claude', ['chat'], props.shows)
return null
}
let renderer!: ReactTestRenderer
act(() => {
renderer = create(<Probe messages={messages} shows={shows} />)
})
renderers.push(renderer)
const update = (next: readonly NativeChatMessage[], nextShows: boolean): number => {
roleReads = 0
act(() => renderer.update(<Probe messages={next} shows={nextShows} />))
return roleReads
}
return { view, update }
}
it('hides CI result lines after projection, one predicate pass per changed row array', () => {
for (const turns of [25, 250]) {
const history = conversation(turns)
const appended = [...history, counted('tail', 'assistant', 'streamed')]
const shown = mount(history, true)
const projectionReads = shown.update(appended, true)
const hidden = mount(history, false)
// Hidden adds at most one read per projected row: the filter checks each row once.
expect(hidden.update(appended, false) - projectionReads).toBeLessThanOrEqual(turns * 2 + 1)
const hiddenRows = hidden.view.rows
expect(hidden.update(appended, false)).toBe(0)
// With no CI row the filter hands back the projection itself, and a flip rebuilds nothing.
expect(hidden.update(appended, true)).toBe(0)
expect(hidden.view.rows).toBe(hiddenRows)
}
const ciLine: NativeChatMessage = {
id: CI_ID,
role: 'system',
blocks: [
{
type: 'text',
text: 'CI failing on repo#3 at 8d5f74b',
presentation: 'pull-request-event',
tone: 'failure'
}
],
timestamp: 0,
source: 'transcript'
}
const withCi = [
counted('u1', 'user', 'open a PR'),
counted('a1', 'assistant', 'Opened it'),
ciLine,
counted('a2', 'assistant', 'Pushed the fix')
]
const chat = mount(withCi, true)
const shownRows = chat.view.rows
expect(shownRows.map((row) => row.id)).toEqual(['u1', 'a1', CI_ID, 'a2'])
chat.update(withCi, false)
expect(chat.view.rows.map((row) => row.id)).toEqual(['u1', 'a1', 'a2'])
chat.update(withCi, true)
expect(chat.view.rows).toBe(shownRows)
})
@@ -70,19 +70,6 @@ describe('commit actions', () => {
expect(await git('show', 'HEAD:file.txt')).toBe('base')
expect(await git('log', '-1', '--format=%s')).toBe('base')
})
it('cherry-picks onto the current branch without opening an editor', async () => {
const result = await applyCommit(directory, 'cherry-pick', topic)
expect(result).toMatchObject({ outcome: 'landed', branch: 'main' })
expect(await git('show', 'HEAD:file.txt')).toBe('topic')
expect(await git('log', '-1', '--format=%s')).toBe('topic change')
})
it('reverts a commit without opening an editor', async () => {
await git('cherry-pick', topic)
const result = await applyCommit(directory, 'revert', await git('rev-parse', 'HEAD'))
expect(result).toMatchObject({ outcome: 'landed', branch: 'main' })
expect(await git('show', 'HEAD:file.txt')).toBe('base')
expect(await git('log', '-1', '--format=%s')).toBe('Revert "topic change"')
})
it('skips an empty graph cherry-pick while preserving unrelated unstaged edits', async () => {
await writeFile(join(directory, 'unrelated.txt'), 'original\n')
await git('add', 'unrelated.txt')
@@ -164,16 +164,6 @@ it('drops a landed-switch refresh that settles after the user selects the twin',
expect(useAppStore.getState().gitStatusByWorktree[id]).toEqual(dirty)
})
it("blocks on a twin's status read that comes back with readError", async () => {
status.mockResolvedValueOnce({
entries: [],
conflictOperation: 'unknown',
readError: 'index unreadable'
})
const seen = await readFor('local')
expect(seen.current?.statusReadError).toBe('index unreadable')
})
it("doesn't trust the twin's slot when this copy becomes the owner", async () => {
const seen = await readFor('local')
expect(seen.current).toMatchObject({ statusKnown: true, entries: [] })
@@ -144,21 +144,6 @@ describe('PTY owner colour replies after the asker exits', () => {
expect(writes).toEqual([REPLY])
})
it('settles every query held before the finish marker in one pass', () => {
vi.useFakeTimers()
const { ingress, writes, runCommand, groupReads } = createHarness()
runCommand()
for (let index = 0; index < 100; index += 1) {
ingress.accept(QUERY)
}
groupReads.count = 0
ingress.accept(PROMPT)
vi.runAllTimers()
expect(writes).toEqual([])
expect(groupReads.count).toBeLessThan(10)
})
it('sees a finish marker split across reads during the wait', () => {
vi.useFakeTimers()
const { ingress, writes, runCommand } = createHarness()
@@ -200,20 +185,6 @@ describe('PTY owner colour replies after the asker exits', () => {
}
})
it('reads no foreground group and holds nothing while no colour query arrives', () => {
const { ingress, emissions, runCommand, groupReads } = createHarness()
runCommand()
groupReads.count = 0
for (let index = 0; index < 100; index += 1) {
ingress.accept(
`\x1b[32mline ${index}\x1b[0m \x1b]8;;https://example.com\x1b\\link\x1b]8;;\x1b\\\r\n`
)
}
expect(groupReads.count).toBe(0)
expect(emissions.at(-1)?.rawEndSeq).toBe(ingress.acceptedRawSequence)
})
it('answers queries queued during a wait together, not 20 ms apart', () => {
vi.useFakeTimers()
const { ingress, writes, runCommand } = createHarness()