@@ -2227,15 +2227,38 @@ describe('browser cookies command', () => {
22272227
22282228 await program . parseAsync ( [ 'node' , 'opencli' , 'browser' , '--session' , 'test' , 'cookies' , '--domain' , 'example.com' ] ) ;
22292229
2230- expect ( browserState . page ! . getCookies ) . toHaveBeenCalledWith ( { domain : 'example.com' , url : undefined } ) ;
2230+ expect ( browserState . page ! . getCookies ) . toHaveBeenCalledWith ( { domain : 'example.com' } ) ;
22312231 const out = lastJsonLog ( ) ;
2232- expect ( out . count ) . toBe ( 2 ) ;
2232+ expect ( out ) . toMatchObject ( {
2233+ session : 'test' ,
2234+ count : 2 ,
2235+ captured_at : expect . any ( String ) ,
2236+ } ) ;
22332237 expect ( out . cookies ) . toEqual ( expect . arrayContaining ( [
22342238 expect . objectContaining ( { name : 'session' , httpOnly : true } ) ,
22352239 expect . objectContaining ( { name : 'theme' , httpOnly : false } ) ,
22362240 ] ) ) ;
22372241 } ) ;
22382242
2243+ it ( 'passes --url through to getCookies without sending an unset --domain' , async ( ) => {
2244+ const program = createProgram ( '' , '' ) ;
2245+
2246+ await program . parseAsync ( [ 'node' , 'opencli' , 'browser' , '--session' , 'test' , 'cookies' , '--url' , 'https://example.com/login' ] ) ;
2247+
2248+ expect ( browserState . page ! . getCookies ) . toHaveBeenCalledWith ( { url : 'https://example.com/login' } ) ;
2249+ } ) ;
2250+
2251+ it ( 'emits an empty cookies envelope with count 0 when the scope matches nothing' , async ( ) => {
2252+ ( browserState . page ! . getCookies as ReturnType < typeof vi . fn > ) . mockResolvedValueOnce ( [ ] ) ;
2253+ const program = createProgram ( '' , '' ) ;
2254+
2255+ await program . parseAsync ( [ 'node' , 'opencli' , 'browser' , '--session' , 'test' , 'cookies' , '--domain' , 'nothing.example' ] ) ;
2256+
2257+ const out = lastJsonLog ( ) ;
2258+ expect ( out . count ) . toBe ( 0 ) ;
2259+ expect ( out . cookies ) . toEqual ( [ ] ) ;
2260+ } ) ;
2261+
22392262 it ( 'errors with missing_scope when neither --domain nor --url is provided' , async ( ) => {
22402263 const program = createProgram ( '' , '' ) ;
22412264
0 commit comments