Earlier commit 9a09c4d7 swapped the CDPClient construction in
browser_use/browser/session.py from the raw cdp_use.CDPClient to our
TimeoutWrappedCDPClient subclass. test_cdp_headers.py patches the
CDPClient symbol in session.py's namespace to assert headers/User-Agent
propagate — but since the code now instantiates TimeoutWrappedCDPClient,
the patch no longer intercepts the call and the mock.assert_called_once
check fails with 'Called 0 times'.
Point the patches at session.TimeoutWrappedCDPClient instead so the
assertions match what the code actually constructs. Header propagation
still works end-to-end because TimeoutWrappedCDPClient forwards
*args/**kwargs to super().__init__.
- Updated the assertion for the User-Agent header in the /json/version endpoint test to improve readability by using a multi-line format.
- This change enhances the clarity of the test's intent while maintaining the existing validation logic.
These modifications contribute to better maintainability of the test code.
- Improved assertions in tests to ensure all user-provided headers are present in the additional_headers.
- Added checks to confirm that the User-Agent header is injected for remote connections, ensuring consistent behavior across tests.
- Updated the test for the /json/version endpoint to validate the presence and format of the User-Agent header.
These changes enhance the reliability of header handling in the CDP client tests.