Add unit tests for publisher Resources operationUtils - #1406
Conversation
📝 WalkthroughWalkthroughChangesOperation utility test coverage
Estimated code review effort: 2 (Simple) | ~10 minutes Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ 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 |
|
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
portals/publisher/src/main/webapp/source/Tests/Unit/operationUtils.test.js (1)
168-174: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winRestore warning spies even when assertions fail.
mockRestore()runs after the assertions, so a thrown error can leaveconsole.warnmocked and affect later tests. Use automatic cleanup inafterEachor atry/finallyblock.Also applies to: 208-219
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@portals/publisher/src/main/webapp/source/Tests/Unit/operationUtils.test.js` around lines 168 - 174, Ensure the console.warn spy created in the getTaggedOperations tests is restored even when an assertion fails. Replace the post-assertion mockRestore calls in the affected tests with automatic afterEach cleanup or try/finally protection, covering both the shown test and the additional tests around lines 208–219.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@portals/publisher/src/main/webapp/source/Tests/Unit/operationUtils.test.js`:
- Around line 117-138: Add a regression test in the isSelectAll suite using
expected verbs such as get/post and a selected set with the same count but
different names, asserting false. Update isSelectAll to compare each selected
verb name against the corresponding operation names, not only verb counts, while
preserving the existing full and partial selection behavior.
---
Nitpick comments:
In `@portals/publisher/src/main/webapp/source/Tests/Unit/operationUtils.test.js`:
- Around line 168-174: Ensure the console.warn spy created in the
getTaggedOperations tests is restored even when an assertion fails. Replace the
post-assertion mockRestore calls in the affected tests with automatic afterEach
cleanup or try/finally protection, covering both the shown test and the
additional tests around lines 208–219.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: c041d824-cfa2-4b8f-bef5-ebb5dfb86e3d
📒 Files selected for processing (1)
portals/publisher/src/main/webapp/source/Tests/Unit/operationUtils.test.js



Purpose
operationUtils.jsis used by the Resources page to parse and group API operations, but it didn't have any unit tests.This PR adds tests for its main helper functions, with extra coverage for the different OpenAPI versions since parameter generation differs between OpenAPI 3.x and Swagger 2.0.
Changes
Adds
source/Tests/Unit/operationUtils.test.jswith 20 tests:extractPathParametersschemashape, Swagger 2.0 inlinetypeshape, no parameter targets, unrecognised versionsgetOperationScopesdefaultsecurity scheme,x-scopefallback, no scopes, unrecognised versionsmapAPIOperationsisSelectAllgetTaggedOperationsDefaultbucket, silent skip for absent operations, API product delegationgetAPIProductTaggedOperationsThis PR only adds unit tests. No production code has been changed.