mirror of
https://github.com/stablyai/orca.git
synced 2026-11-04 19:17:28 +00:00
fix(browser): accept an empty --value in fill and select commands (#16030)
`orca fill --value ""` and `orca select --value ""` were rejected client-side with "Missing required --value" even though the browser.fill/browser.select RPC schemas already accept an empty string. Read --value with the existing getRequiredStringFlagAllowingEmpty helper so an empty value clears a field or picks the blank option, while an absent --value is still rejected. Co-authored-by: Neil <4138956+nwparker@users.noreply.github.com>
This commit is contained in:
@@ -208,3 +208,34 @@ describe('orca cli cookie set and set credentials preserve an empty value', () =
|
||||
process.exitCode = priorExitCode
|
||||
})
|
||||
})
|
||||
|
||||
describe('orca cli fill and select preserve an empty value', () => {
|
||||
beforeEach(() => {
|
||||
callMock.mockReset()
|
||||
process.exitCode = undefined
|
||||
})
|
||||
|
||||
afterEach(() => {
|
||||
vi.restoreAllMocks()
|
||||
})
|
||||
|
||||
it.each([
|
||||
['fill', 'browser.fill', { filled: 'ref_1' }],
|
||||
['select', 'browser.select', { selected: 'ref_1' }]
|
||||
])('passes an empty --value through %s to %s', async (command, method, result) => {
|
||||
queueFixtures(callMock, okFixture(`req_${command}`, result))
|
||||
vi.spyOn(console, 'log').mockImplementation(() => {})
|
||||
|
||||
await main(
|
||||
[command, '--element', 'ref_1', '--value', '', '--worktree', 'all', '--json'],
|
||||
'/tmp/not-an-orca-worktree'
|
||||
)
|
||||
|
||||
expect(callMock).toHaveBeenCalledTimes(1)
|
||||
expect(callMock).toHaveBeenCalledWith(method, {
|
||||
element: 'ref_1',
|
||||
value: '',
|
||||
worktree: undefined
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
@@ -18,7 +18,8 @@ import {
|
||||
getOptionalNumberFlag,
|
||||
getOptionalStringFlag,
|
||||
getRequiredFiniteNumber,
|
||||
getRequiredStringFlag
|
||||
getRequiredStringFlag,
|
||||
getRequiredStringFlagAllowingEmpty
|
||||
} from '../flags'
|
||||
import { getBrowserCommandTarget } from '../selectors'
|
||||
|
||||
@@ -50,7 +51,7 @@ export const BROWSER_INTERACT_HANDLERS: Record<string, CommandHandler> = {
|
||||
},
|
||||
fill: async ({ flags, client, cwd, json }) => {
|
||||
const element = getRequiredStringFlag(flags, 'element')
|
||||
const value = getRequiredStringFlag(flags, 'value')
|
||||
const value = getRequiredStringFlagAllowingEmpty(flags, 'value')
|
||||
const target = await getBrowserCommandTarget(flags, cwd, client)
|
||||
const result = await client.call<BrowserFillResult>('browser.fill', {
|
||||
element,
|
||||
@@ -67,7 +68,7 @@ export const BROWSER_INTERACT_HANDLERS: Record<string, CommandHandler> = {
|
||||
},
|
||||
select: async ({ flags, client, cwd, json }) => {
|
||||
const element = getRequiredStringFlag(flags, 'element')
|
||||
const value = getRequiredStringFlag(flags, 'value')
|
||||
const value = getRequiredStringFlagAllowingEmpty(flags, 'value')
|
||||
const target = await getBrowserCommandTarget(flags, cwd, client)
|
||||
const result = await client.call<BrowserSelectResult>('browser.select', {
|
||||
element,
|
||||
|
||||
Reference in New Issue
Block a user