Add comprehensive --rsc-pro generator tests#3098
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
WalkthroughNew test assertions were added to Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~5 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 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 |
Greptile SummaryCloses the Confidence Score: 5/5Safe to merge — test-only additions with a no-op source refactor. All changes are either new RSpec assertions (no production impact) or a semantically equivalent function-declaration refactor. The previous P1 gap around rscWebpackConfig.js assertions was resolved in commit 199d0cb before this review. No remaining findings rise above P2. No files require special attention. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A["run_generator_test_with_args(--rsc-pro)"] --> B["before(:all) – single generator run"]
B --> C["include_examples rsc_common_files"]
B --> D["include_examples rsc_hello_server_files"]
B --> E["it: pins Pro dependencies"]
B --> F["it: creates node-renderer.js NEW"]
B --> G["it: adds RSC bundle watcher to Procfile.dev NEW"]
B --> H["it: creates HelloServer instead of HelloWorld NEW"]
B --> I["it: adds HelloServer route and RSC payload route NEW"]
B --> J["it: creates rscWebpackConfig.js NEW"]
B --> K["it: serverWebpackConfig includes RSCWebpackPlugin NEW"]
B --> L["it: serverWebpackConfig has rscBundle parameter NEW"]
B --> M["it: sets DEFAULT_ROUTE to hello_server in bin/dev"]
C --> C1["Procfile.dev exists\nPro initializer content\nLayout content"]
D --> D1["HelloServer controller layout\nHelloServer view stream_react_component"]
J --> J1["serverWebpackModule require\nserverWebpackConfig(true)\nrsc-bundle / react-server"]
K --> K1["RSCWebpackPlugin import\nreact-on-rails-rsc/WebpackPlugin"]
L --> L1["configureServer=(rscBundle=false)\nif (!rscBundle) guard"]
Reviews (2): Last reviewed commit: "Add missing serverWebpackConfig.js asser..." | Re-trigger Greptile |
Review: Add comprehensive --rsc-pro generator testsGood addition — this PR closes a real coverage gap. The 5 new assertions faithfully parallel the Weak assertions on
|
Review feedback addressedAddressed:
Skipped (rationale):
All review threads resolved. Tests pass (19 examples, 0 failures). |
Review: Add comprehensive
|
There was a problem hiding this comment.
🧹 Nitpick comments (1)
react_on_rails/spec/react_on_rails/generators/install_generator_spec.rb (1)
1735-1778: Consider extracting duplicated--rsc/--rsc-proassertions into shared examples.These new examples mirror the
with --rscblock very closely; centralizing common expectations would reduce drift risk.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@react_on_rails/spec/react_on_rails/generators/install_generator_spec.rb` around lines 1735 - 1778, The tests duplicate many expectations across the `with --rsc` and `with --rsc-pro` contexts; extract the repeated assertions (the node-renderer check, Procfile.dev entries, HelloServer file/route assertions, and rscWebpackConfig checks) into a shared_examples (e.g., shared_examples "rsc generator behavior") and replace the duplicated blocks with calls to that shared example (use `it_behaves_like "rsc generator behavior"` or `include_examples` inside the contexts for `--rsc` and `--rsc-pro`); make sure the shared_examples contains the assertions referencing the same file checks and strings used now (e.g., "client/node-renderer.js", "Procfile.dev", "app/javascript/src/HelloServer", route checks for "hello_server" and "rsc_payload", and the rscWebpackConfig content expectations) so both contexts invoke the identical expectations.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@react_on_rails/spec/react_on_rails/generators/install_generator_spec.rb`:
- Around line 1735-1778: The tests duplicate many expectations across the `with
--rsc` and `with --rsc-pro` contexts; extract the repeated assertions (the
node-renderer check, Procfile.dev entries, HelloServer file/route assertions,
and rscWebpackConfig checks) into a shared_examples (e.g., shared_examples "rsc
generator behavior") and replace the duplicated blocks with calls to that shared
example (use `it_behaves_like "rsc generator behavior"` or `include_examples`
inside the contexts for `--rsc` and `--rsc-pro`); make sure the shared_examples
contains the assertions referencing the same file checks and strings used now
(e.g., "client/node-renderer.js", "Procfile.dev",
"app/javascript/src/HelloServer", route checks for "hello_server" and
"rsc_payload", and the rscWebpackConfig content expectations) so both contexts
invoke the identical expectations.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: d4b0c2eb-7646-4fbb-87f1-420d60b017fb
📒 Files selected for processing (1)
react_on_rails/spec/react_on_rails/generators/install_generator_spec.rb
ReviewThis is a solid addition — the Blocking / CorrectnessMissing Non-blocking
Overall the approach is correct and the tests themselves are well-written. Address the |
size-limit report 📦
|
Review feedback addressed (round 2)Addressed:
Skipped (rationale):
All review threads resolved. |
|
Tip For best results, initiate chat on the files or code changes.
The PR looks good — all threads resolved and tests green. Approving. [approve] 🧠 Learnings used |
ReviewOverall: This is a straightforward, low-risk addition. The missing test coverage for What looks good
One issue worth addressing before more RSC variants landSee the inline comment on lines 1735-1792. Every new Not blocking — the coverage is better than it was — but worth doing before the pattern spreads further. |
…nd configs The --rsc-pro test context was missing several important assertions that the --rsc context had. This adds tests verifying that --rsc-pro mode correctly: - Creates node-renderer.js for Pro SSR - Adds RSC bundle watcher to Procfile.dev - Replaces HelloWorld with HelloServer (controller, routes, components) - Adds hello_server and rsc_payload routes - Creates rscWebpackConfig.js Closes #2793 Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Both --rsc and --rsc-pro use the same template, so the assertions should match. Adds the 3 missing checks: require path, default unwrap, and serverWebpackConfig(true) call. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
The --rsc context had two serverWebpackConfig.js tests (RSCWebpackPlugin import and rscBundle parameter) that weren't carried over to --rsc-pro. Since both modes generate the same serverWebpackConfig.js, these assertions should be mirrored to fully close the coverage gap. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
4d143df to
1b5b1d1
Compare
Review of #3098 — Add comprehensive
|
| New test (added here) | Existing counterpart in --rsc |
|---|---|
creates node-renderer.js |
line 1552–1556 |
adds RSC bundle watcher to Procfile.dev |
line 1559–1564 |
creates rscWebpackConfig.js |
line 1577–1585 |
serverWebpackConfig includes RSCWebpackPlugin import |
line 1587–1591 |
serverWebpackConfig has rscBundle parameter |
line 1594–1598 |
The codebase already does this right via rsc_generator_examples.rb — rsc_common_files and rsc_hello_server_files are used in both contexts. These five tests are the same behavioural contract and belong in the same file, perhaps as a new shared example like rsc_webpack_configuration:
# spec/react_on_rails/support/shared_examples/rsc_generator_examples.rb
shared_examples "rsc_webpack_configuration" do
it "creates node-renderer.js" do ... end
it "adds RSC bundle watcher to Procfile.dev" do ... end
it "creates rscWebpackConfig.js" do ... end
it "serverWebpackConfig includes RSCWebpackPlugin import" do ... end
it "serverWebpackConfig has rscBundle parameter" do ... end
endThen both contexts simply call include_examples "rsc_webpack_configuration". Without this, any future template change requires updating the same assertions in two places.
Minor: route test naming inconsistency
The new "adds HelloServer route and RSC payload route" name is actually more accurate than the --rsc counterpart ("adds HelloServer route") because both assert rsc_payload too. It would be worth updating the --rsc test name to match at the same time, or consolidate it into a shared example to enforce parity going forward.
…ages * origin/main: (44 commits) Consolidate CSP nonce sanitization into shared module (#2828) Add comprehensive --rsc-pro generator tests (#3098) fix: cross-env validation and docs for renderer password (#3090) Improve package metadata and Pro upgrade CTAs (#3112) docs: standardize warning syntax to GFM alert format (#3115) docs: improve react-intl documentation for React Server Components (#3085) Fix generator CI SSR regression on main (#3110) Refocus GitHub README on docs navigation (#3113) Add manual dev environment testing checklist for coding agents (#3074) Bump version to 16.6.0 Update CHANGELOG.md for 16.6.0 (#3078) fix: node-renderer diagnostic improvements (#3086) fix: pin third-party npm deps in generator to prevent peer dep conflicts (#3083) chore(deps): bump lodash from 4.17.23 to 4.18.1 in the npm-security group across 1 directory (#2920) fix: refactor formatExceptionMessage to accept generic request context (#2877) Bump version to 16.6.0.rc.1 Update CHANGELOG.md for 16.6.0.rc.1 (#3079) Update CHANGELOG.md unreleased section (#3077) Fix Content-Length mismatch and null renderingRequest errors in node renderer (#3069) Improve memory debugging docs with simpler heap snapshot approach (#3072) ... # Conflicts: # docs/pro/home-pro.md # docs/pro/react-on-rails-pro.md # docs/sidebars.ts
## Summary #2821 introduced a dedicated `--rsc-pro` install flag. It was closed the next day with: "Closing as redundant: current generator semantics already treat --rsc as including Pro by design, so introducing --rsc-pro adds an unnecessary parallel mode." The flag then shipped anyway in #2822, which was primarily about the Pro upgrade automation (#2626 — Gemfile swap, import rewriter). The --rsc-pro bits rode along as a ~10% passenger in that larger PR and were never removed after #2821's close. #3098 was then opened to add more tests for the flag, further entrenching something that was explicitly called redundant. This PR completes the intent behind #2821's close: removes the flag and folds its useful behaviors into --rsc, where they belong. ## What moves from --rsc-pro to --rsc - Pro verification checklist now fires on any --rsc install - Prerelease installation note now fires on any --rsc install with a prerelease gem version - Exact version pin for the Pro gem now triggers on `Gem::Version.new(ReactOnRails::VERSION).prerelease?` instead of the flag — this is the real reason exact pinning matters (Bundler's `~>` doesn't match prereleases), not a flag-specific behavior Side effect: plain `--rsc` on a prerelease gem version now installs correctly where it previously would have failed against `~>` pinning. ## What is removed - `class_option :rsc_pro` - `use_rsc_pro_mode?` helper - `--rsc-pro` branches in `use_pro?`, `use_rsc?`, `pro_requirement_flag`, `recovery_install_command` - All `--rsc-pro` test contexts ## What is NOT touched `pro_generator.rb` and `pro_generator_spec.rb` (the #2626 upgrade automation — Gemfile swap, import rewriter) are independent of this flag and untouched. Bugs in that code are tracked separately in #3104. ## Closes / supersedes Supersedes #3098 (its test assertions were inside `context "with --rsc-pro"`, which no longer exists). ## Test plan - `bundle exec rubocop` on all modified files — clean - CI to run the full rspec suite 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Removed** * The Pro-specific install flag `--rsc-pro` has been removed. * **Changed** * Pro-related behaviors that previously required `--rsc-pro` now apply when using `--rsc` (post-install verification checklist, prerelease install notes, and exact Pro gem pinning for prereleases). * **Chore** * Added a URL exclusion to link-checking configuration to skip a specific domain. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Claude Opus 4.6 (1M context) <[email protected]>
Summary
--rsc-progenerator context to match the thoroughness of the--rsctestsThe
--rsc-progenerator mode implementation was completed in #2822, but the test coverage was incomplete — only version pinning and DEFAULT_ROUTE were verified. This closes the gap by adding route, component, Procfile, and webpack config assertions.Closes #2793
Test plan
bundle exec rspec react_on_rails/spec/react_on_rails/generators/install_generator_spec.rb -e "with --rsc-pro"— 12 examples, 0 failuresbundle exec rubocop— no offenses🤖 Generated with Claude Code
Note
Low Risk
Low risk: only adds RSpec assertions around generator output, with no production code changes. Main risk is increased test brittleness if templates evolve.
Overview
Strengthens test coverage for the
react_on_rails:install --rsc-propath by asserting generation ofclient/node-renderer.js, the RSC bundle watcher entry inProcfile.dev, and the switch fromHelloWorldscaffolding toHelloServer.Adds checks that
config/routes.rbincludes bothhello_serverandrsc_payload, and verifies RSC-specific webpack artifacts (config/webpack/rscWebpackConfig.jsplusRSCWebpackPluginusage and therscBundleparameter inserverWebpackConfig).Reviewed by Cursor Bugbot for commit 1b5b1d1. Bugbot is set up for automated code reviews on this repo. Configure here.
Summary by CodeRabbit