test: fix hidden terminal CI fallout (#2683)

This commit is contained in:
Neil 2026-05-23 02:21:15 -07:00 committed by GitHub
parent 3adad22eca
commit a0cdbfdf57
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 74 additions and 13 deletions

View File

@ -80,11 +80,27 @@ vi.mock('../ui/toggle-group', () => ({
}))
vi.mock('./SettingsFormControls', () => ({
SettingsRow: function SettingsRow({ children }: { children?: unknown }) {
return children
},
NumberField: function NumberField() {
return null
},
FontAutocomplete: function FontAutocomplete() {
return null
},
SettingsSegmentedControl: function SettingsSegmentedControl({
options
}: {
options?: readonly { label: string }[]
}) {
return options?.map((option) => option.label) ?? null
},
SettingsSubsectionHeader: function SettingsSubsectionHeader() {
return null
},
SettingsSwitchRow: function SettingsSwitchRow() {
return null
}
}))

View File

@ -80,11 +80,35 @@ vi.mock('../ui/toggle-group', () => ({
}))
vi.mock('./SettingsFormControls', () => ({
SettingsRow: function SettingsRow({
description,
control,
children
}: {
description?: unknown
control?: unknown
children?: unknown
}) {
return [description, control, children]
},
NumberField: function NumberField() {
return null
},
FontAutocomplete: function FontAutocomplete() {
return null
},
SettingsSegmentedControl: function SettingsSegmentedControl({
options
}: {
options?: readonly { label: string }[]
}) {
return options?.map((option) => option.label) ?? null
},
SettingsSubsectionHeader: function SettingsSubsectionHeader() {
return null
},
SettingsSwitchRow: function SettingsSwitchRow() {
return null
}
}))
@ -140,6 +164,15 @@ type ReactElementLike = {
props: Record<string, unknown>
}
function getPropNodes(el: ReactElementLike): unknown[] {
const nodes = [el.props?.children, el.props?.description, el.props?.control]
const options = el.props?.options
if (Array.isArray(options)) {
nodes.push(options.map((option) => (option as { label?: unknown }).label))
}
return nodes
}
function collectText(node: unknown): string {
if (node == null) {
return ''
@ -154,7 +187,7 @@ function collectText(node: unknown): string {
return node.map(collectText).join('')
}
const el = node as ReactElementLike
return collectText(el.props?.children)
return getPropNodes(el).map(collectText).join('')
}
function findAnchorByText(node: unknown, text: string): ReactElementLike | null {
@ -178,7 +211,13 @@ function findAnchorByText(node: unknown, text: string): ReactElementLike | null
if (typeName === 'a' && collectText(el.props.children).includes(text)) {
return el
}
return findAnchorByText(el.props?.children, text)
for (const child of getPropNodes(el)) {
const found = findAnchorByText(child, text)
if (found) {
return found
}
}
return null
}
describe('TerminalPane PowerShell version setting', () => {

View File

@ -515,11 +515,13 @@ describe('createRemoteRuntimePtyTransport', () => {
'before\x1b]9999;{"state":"working","prompt":"ship it","agentType":"codex"}\x07after\x1b]0;. Claude working\x07\x07'
)
expect(onAgentStatus).toHaveBeenCalledWith({
state: 'working',
prompt: 'ship it',
agentType: 'codex'
})
await vi.waitFor(() =>
expect(onAgentStatus).toHaveBeenCalledWith({
state: 'working',
prompt: 'ship it',
agentType: 'codex'
})
)
expect(onData).toHaveBeenCalledWith('beforeafter\x1b]0;. Claude working\x07\x07')
expect(onTitleChange).toHaveBeenCalledWith('. Claude working', '. Claude working')
expect(onBell).toHaveBeenCalledTimes(1)
@ -546,11 +548,13 @@ describe('createRemoteRuntimePtyTransport', () => {
'before\x1b]9999;{"state":"working","prompt":"ship it","agentType":"codex"}\x07after'
)
expect(onAgentStatus).toHaveBeenCalledWith({
state: 'working',
prompt: 'ship it',
agentType: 'codex'
})
await vi.waitFor(() =>
expect(onAgentStatus).toHaveBeenCalledWith({
state: 'working',
prompt: 'ship it',
agentType: 'codex'
})
)
expect(onData).toHaveBeenCalledWith('beforeafter')
})
@ -852,7 +856,9 @@ describe('createRemoteRuntimePtyTransport', () => {
)
expect(onReplayData).toHaveBeenCalledWith('beforeafter\x1b]0;Remote title\x07\x07')
expect(onTitleChange).toHaveBeenCalledWith('Remote title', 'Remote title')
await vi.waitFor(() =>
expect(onTitleChange).toHaveBeenCalledWith('Remote title', 'Remote title')
)
expect(onAgentStatus).not.toHaveBeenCalled()
expect(onBell).not.toHaveBeenCalled()
})