refactor: revert HeaderList method names to PropertyList conventions#7931
Conversation
- Renamed methods in req.headerList and res.headerList from 'forEach' to 'each' for consistency with the new API. - Updated method translations in the Postman converters to reflect the new method names: 'append' to 'add', 'set' to 'upsert', and 'delete' to 'remove'. - Adjusted related tests to ensure they validate the new method names and functionality. - Removed deprecated test cases for 'append' and 'set', replacing them with tests for 'add' and 'upsert'. - Enhanced documentation to clarify the changes in method names and their usage.
|
Caution Review failedFailed to post review comments WalkthroughThe PR refactors the HeaderList API: renames iteration ChangesHeaderList API Refactor
Sequence Diagram(s)sequenceDiagram
participant Editor as CodeMirror Autocomplete
participant Translator as Postman↔Bruno Translators
participant Sandbox as QuickJS Sandbox Bridge
participant HeaderList as Bruno HeaderList (core)
Editor->>Translator: user script uses pm.request/pm.response headers
Translator->>Sandbox: emit transformed calls (req.headerList.each/add/upsert/remove)
Sandbox->>HeaderList: invoke `each` / `add` / `upsert` / `remove` (sync bridge)
HeaderList-->>Sandbox: update req.headers & __headersToDelete
HeaderList-->>Translator: (reads) header values for translation if needed
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
- Introduced tests to verify that the 'idx' property is undefined in HeaderList, ensuring compliance with the updated API. - Added tests to confirm that positional methods (prepend, insert, insertAfter) do not exist in HeaderList, reflecting the recent refactor. - Implemented a test to check that the two-argument form of the 'add' method correctly overwrites existing headers, enhancing the robustness of header management tests.
JIRA
Summary
Reverts HeaderList method names from MDN Headers naming (
append,set,delete,forEach) back to PropertyList conventions (add,upsert,remove,each) for consistency with CookieList and the rest of the PropertyList hierarchy.Method name reversions
append(item | name, value?)add(item | name, value?)set(item | name, value?)upsert(item | name, value?)delete(predicate, context?)remove(predicate, context?)forEach(fn, context?)each(fn, context?)Two-arg form support on
add()andupsert()is preserved.Test plan
npm run test --workspace=packages/bruno-js— 488 tests passnpm run test --workspace=packages/bruno-converters— 950 tests pass.bruintegration test filesContribution Checklist:
Summary by CodeRabbit
New Features
Refactor
Tests