Add tests for validation of user input - #709
Conversation
Part of flipcomputing#701 AI use: Claude was used to create an example test for a generator and to write code to detect blocks with text fields
|
Warning Review limit reached
Next review available in: 45 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe PR adds security tests for Blockly color and free-text JavaScript generator fields, covering valid output, invalid input fallback, injection payload handling, unsupported blocks, and automatic discovery of free-text fields. The tests are registered as a selectable ChangesSecurity generator validation
Estimated code review effort: 3 (Moderate) | ~20 minutes 🚥 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)
tests/security/free-text-validation.test.js (1)
8-8: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winRemove unused constant.
The
allBlockTypesarray is never referenced and can be safely removed.♻️ Proposed refactor
-const allBlockTypes = Object.keys(Blockly.Blocks).sort();🤖 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 `@tests/security/free-text-validation.test.js` at line 8, Remove the unused allBlockTypes constant declaration from the test file, leaving the surrounding security validation setup unchanged.
🤖 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 `@tests/security/free-text-validation.test.js`:
- Around line 54-62: Update the test workspace lifecycle around the shared
workspace declaration and test suite hooks so each test starts with a clean
Blockly workspace and the workspace is disposed after the suite completes,
preventing retained blocks and global leaks. Revise the comment above generate
to describe unwrapping blockToCode results generally, without referencing
colour_from_string or a specific block type.
---
Nitpick comments:
In `@tests/security/free-text-validation.test.js`:
- Line 8: Remove the unused allBlockTypes constant declaration from the test
file, leaving the surrounding security validation setup unchanged.
🪄 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: defaults
Review profile: CHILL
Plan: Pro
Run ID: 6e697f82-3448-4578-9a6d-50ed7827d225
📒 Files selected for processing (4)
tests/security/color-validation.test.jstests/security/free-text-validation.test.jstests/security/index.test.jstests/tests.html
Part of flipcomputing#701 AI use: CodeRabbit pointed out the issues
Additionally adds tests that check that all blocks accepting user input are covered
Part of #701
Summary by CodeRabbit