-
-
Notifications
You must be signed in to change notification settings - Fork 8.6k
[node] Add asMap function to Header class and corresponding tests #16832
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[node] Add asMap function to Header class and corresponding tests #16832
Conversation
…without asMap error
PR Compliance Guide 🔍Below is a summary of compliance checks for this PR:
Compliance status legend🟢 - Fully Compliant🟡 - Partial Compliant 🔴 - Not Compliant ⚪ - Requires Further Human Verification 🏷️ - Compliance label |
|||||||||||||||||||||||||
PR Code Suggestions ✨Explore these optional code suggestions:
|
||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This pull request fixes issue #16339 by adding an asMap() method to the Header class in the BiDi network module, enabling proper serialization of Header objects when providing custom responses through the network interception API.
Key Changes:
- Added
asMap()method to theHeaderclass that returns a Map with 'name' and 'value' entries - Added unit test file to verify the fix prevents the "header.asMap is not a function" error
- Added integration test demonstrating the ability to provide responses with custom headers
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| javascript/selenium-webdriver/bidi/networkTypes.js | Adds the asMap() method to the Header class, enabling conversion to Map representation consistent with BytesValue.asMap() |
| javascript/selenium-webdriver/test/bidi/network_types_test.js | New test file verifying that ProvideResponseParameters can accept headers without throwing the asMap error |
| javascript/selenium-webdriver/test/bidi/network_commands_test.js | Adds integration test demonstrating end-to-end functionality of providing responses with custom headers via BiDi protocol |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
User description
🔗 Related Issues
fixes #16339
fixes review for #16340
💥 What does this PR do?
This pull request introduces improvements to the BiDi network response handling in the Selenium WebDriver JavaScript bindings, focusing on enhanced header manipulation and testing. The main changes add a utility method to the
Headerclass and introduce a new test to verify providing custom headers in responses.Enhancements to header handling:
asMap()method to theHeaderclass innetworkTypes.js, allowing easy conversion of header objects to a map representation for further processing.Testing improvements:
BytesValueandHeaderinnetwork_commands_test.jsto support new test functionality.🔧 Implementation Notes
💡 Additional Considerations
🔄 Types of changes
PR Type
Enhancement, Tests
Description
Add
asMap()method toHeaderclass for map conversionImplement comprehensive tests for header handling in responses
Fix issue where
header.asMap()was not available in BiDi network operationsValidate
ProvideResponseParameterswith custom headers integrationDiagram Walkthrough
File Walkthrough
networkTypes.js
Add asMap conversion method to Header classjavascript/selenium-webdriver/bidi/networkTypes.js
asMap()method toHeaderclass that converts header name andvalue to a Map
Object.fromEntries()for properserialization
network_commands_test.js
Add integration test for response headers handlingjavascript/selenium-webdriver/test/bidi/network_commands_test.js
BytesValueandHeaderfrom networkTypes modulecan provide response with headersthatvalidates custom header handling
response body and status code
ProvideResponseParameterscorrectly handles headers inBiDi protocol
network_types_test.js
Create unit tests for Header asMap functionalityjavascript/selenium-webdriver/test/bidi/network_types_test.js
ProvideResponseParameterswithheaders
asMap()methodavailability
errors are thrown